Imported from libpng-1.0.6.tar

This commit is contained in:
Glenn Randers-Pehrson 2000-03-21 05:13:06 -06:00
parent a77ef625a6
commit 520a764cd7
74 changed files with 2298 additions and 1436 deletions

140
ANNOUNCE
View File

@ -1,169 +1,85 @@
Libpng 1.0.5s - February 18, 2000
Libpng 1.0.6 - March 21, 2000
This is not intended to be a public release. It will be replaced
within a few weeks by a public version or by another test version.
This is a public release of libpng, intended for use in production codes.
Changes since the last public release (1.0.5):
version libpng-1.0.5a October 23, 1999
Added contrib/pngsuite and contrib/pngminus (Willem van Schaik)
Fixed a typo in the png_set_sRGB() function call in example.c (Jan Nijtmans)
Further optimization and bugfix of pngvcrd.c
Revised pngset.c so that it does not allocate or free memory in the user's
text_ptr structure. Instead, it makes its own copy.
Created separate write_end_info_struct in pngtest.c for a more severe test.
Added code in pngwrite.c to free info_ptr->text[i].key to stop a memory leak.
version libpng-1.0.5b November 23, 1999
Created separate write_end_info_struct in pngtest.c for a more severe test.
Moved PNG_FLAG_HAVE_CHUNK_HEADER, PNG_FLAG_BACKGROUND_IS_GRAY and
PNG_FLAG_WROTE_tIME from flags to mode.
Added png_write_info_before_PLTE() function.
Fixed some typecasting in contrib/gregbook/*.c
Updated scripts/makevms.com and added makevms.com to contrib/gregbook
and contrib/pngminus (Martin Zinser)
version libpng-1.0.5c November 26, 1999
Updated scripts/makevms.com (Martin Zinser)
Moved png_get_header_version from png.h to png.c, to accomodate ansi2knr.
Removed all global arrays (according to PNG_NO_GLOBAL_ARRAYS macro), to
accomodate making DLL's: Moved usr_png_ver from global variable to function
png_get_header_ver() in png.c. Moved png_sig to png_sig_bytes in png.c and
eliminated use of png_sig in pngwutil.c. Moved the various png_CHNK arrays
into pngtypes.h. Eliminated use of global png_pass arrays. Declared the
into local arrays. Eliminated use of global png_pass arrays. Declared the
png_CHNK and png_pass arrays to be "const". Made the global arrays
available to applications (although none are used in libpng itself) when
PNG_NO_GLOBAL_ARRAYS is not defined or when PNG_GLOBAL_ARRAYS is defined.
Removed some extraneous "-I" from contrib/pngminus/makefile.std
available to applications when PNG_NO_GLOBAL_ARRAYS is not defined or
when PNG_USE_GLOBAL_ARRAYS is defined. Made available to applications a
macro "PNG_USE_LOCAL_ARRAYS".
Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2.
Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3
version libpng-1.0.5d November 29, 1999
Add type cast (png_const_charp) two places in png.c
Eliminated pngtypes.h; use macros instead to declare PNG_CHNK arrays.
Renamed "PNG_GLOBAL_ARRAYS" to "PNG_USE_GLOBAL_ARRAYS" and made available
to applications a macro "PNG_USE_LOCAL_ARRAYS".
#ifdef out all the new declarations when PNG_USE_GLOBAL_ARRAYS is defined.
Added PNG_EXPORT_VAR macro to accommodate making DLL's.
version libpng-1.0.5e November 30, 1999
Added iCCP, iTXt, and sPLT support; added "lang" member to the png_text
structure; refactored the inflate/deflate support to make adding new chunks
with trailing compressed parts easier in the future, and added new functions
png_free_iCCP, png_free_pCAL, png_free_sPLT, png_free_text, png_get_iCCP,
png_get_spalettes, png_set_iCCP, png_set_spalettes (Eric S. Raymond).
NOTE: Applications that write text chunks MUST define png_text->lang. Before
calling png_set_text(). It must be set to NULL if you want to write tEXt or
zTXt chunks. If you want your application to be able to run with older
versions of libpng, use
#ifdef PNG_iTXt_SUPPORTED
png_text[i].lang = NULL;
#endif
Refactored the inflate/deflate support to make adding new chunks with
trailing compressed parts easier in the future (Eric S. Raymond).
Added iCCP, iTXt, sCAL, and sPLT support; added "lang", "lang_key", and
itxt_length" members to the png_text structure (Eric S. Raymond, Glenn R-P)
Changed png_get_oFFs() and png_set_oFFs() to use signed rather than unsigned
offsets (Eric S. Raymond).
Combined PNG_READ_cHNK_SUPPORTED and PNG_WRITE_cHNK_SUPPORTED macros into
PNG_cHNK_SUPPORTED and combined the three types of PNG_text_SUPPORTED
macros, leaving the separate macros also available.
Removed comments on #endifs at the end of many short, non-nested #if-blocks.
version libpng-1.0.5f December 6, 1999
Changed makefile.solaris to issue a warning about potential problems when
the ucb "ld" is in the path ahead of the ccs "ld".
Removed "- [date]" from the "synopsis" line in libpng.3 and libpngpf.3.
Added sCAL chunk support (Eric S. Raymond).
version libpng-1.0.5g December 7, 1999
Fixed "png_free_spallettes" typo in png.h
Added code to handle new chunks in pngpread.c
Moved PNG_CHNK string macro definitions outside of PNG_NO_EXTERN block
Added "translated_key" to png_text structure and png_write_iTXt().
Added code in pngwrite.c to work around a newly discovered zlib bug.
version libpng-1.0.5h December 10, 1999
NOTE: regarding the note for version 1.0.5e, the following must also
be included in your code:
png_text[i].translated_key = NULL;
Unknown chunk handling is now supported.
Unknown chunk handling is now supported (Eric S. Raymond).
Option to eliminate all floating point support was added. Some new
fixed-point functions such as png_set_gAMA_fixed() were added.
version libpng-1.0.5i December 13, 1999
Added some type casts to silence compiler warnings.
Renamed "png_free_spalette" to "png_free_spalettes" for consistency.
Removed leading blanks from a #define in pngvcrd.c
Added some parameters to the new png_set_keep_unknown_chunks() function,
and relocated it in pngset.c
Added a test for up->location != 0 in the first instance of writing
unknown chunks in pngwrite.c
Changed "num" to "i" in png_free_spalettes() and png_free_unknowns() to
prevent recursion.
Added png_free_hIST() function.
Various patches to fix bugs in the sCAL and integer cHRM processing,
and to add some convenience macros for use with sCAL.
version libpng-1.0.5j December 21, 1999
Changed "unit" parameter of png_write_sCAL from png_byte to int, to work
around buggy compilers.
Added new type "png_fixed_point" for integers that hold float*100000 values
Restored backward compatibility of tEXt/zTXt chunk processing:
Added members "lang_key" and "itxt_length" to png_text struct. Set
text_length=0 when "text" contains iTXt data. Use the "compression"
member to distinguish among tEXt/zTXt/iTXt types. Restored the first
four members of png_text to the same order as v.1.0.5d. The "Note" above,
about backward incompatibility of libpng-1.0.5e, no longer applies.
Added PNG_ITXT_COMPRESSION_NONE (1) and PNG_ITXT_COMPRESSION_zTXt(2) macros.
Fixed png_read|write_iTXt() to read|write parameters in the right order.
and to write the iTXt chunk after IDAT if it appears in the end_ptr.
Added pnggccrd.c, version of pngvcrd.c Intel assembler for gcc (Greg Roelofs)
Reversed the order of trying to write floating-point and fixed-point gAMA.
version libpng-1.0.5k December 27, 1999
Added many parentheses, e.g., "if (a && b & c)" becomes "if (a && (b & c))"
Added png_handle_as_unknown()
Added png_free_chunk_list() function and chunk_list and num_chunk_list members
of png_ptr.
Eliminated erroneous warnings about multiple sPLT chunks and sPLT-after-PLTE.
Fixed a libpng-1.0.5h bug in pngrutil.c that was issuing erroneous warnings
about ignoring incorrect gAMA with sRGB (gAMA was in fact not ignored)
Added png_free_tRNS(); png_set_tRNS() now malloc's its own trans array (ESR).
Added chunk_list and num_chunk_list members of png_ptr.
Define png_get_int_32 when oFFs chunk is supported as well as when pCAL is.
Changed type of proflen from png_int_32 to png_uint_32 in png_get_iCCP().
version libpng-1.0.5l January 1, 2000
Added functions png_set_read_user_chunk_fn() and png_get_user_chunk_ptr()
for setting a callback function to handle unknown chunks and for
retrieving the associated user pointer (Glenn).
version 1.0.5m [January 7, 2000]
Added high-level functions png_read_png(), png_write_png(), png_free_pixels().
version 1.0.5n [January 9, 2000]
Added png_free_PLTE() function, and modified png_set_PLTE() to malloc its
own memory for info_ptr->palette. This makes it safe for the calling
application to free its copy of the palette any time after it calls
png_set_PLTE().
version 1.0.5o [January 20, 2000]
Cosmetic changes only (removed some trailing blanks and TABs)
version 1.0.5p [January 31, 2000]
Added png_free_data() function.
Added high-level functions png_read_png() and png_write_png() (ESR).
Renamed pngdll.mak to makefile.bd32
Cosmetic changes in pngtest.c
version 1.0.5q [February 5, 2000]
Relocated the makefile.solaris warning about PATH problems.
Fixed pngvcrd.c bug by pushing/popping registers in mmxsupport (Bruce Oberg)
Revised makefile.gcmmx
Added PNG_SETJMP_SUPPORTED, PNG_SETJMP_NOT_SUPPORTED, and PNG_ABORT() macros
version 1.0.5r [February 7, 2000]
Removed superfluous prototype for png_get_itxt from png.h
Fixed a bug in pngrtran.c that improperly expanded the background color.
Return *num_text=0 from png_get_text() when appropriate, and fix documentation
of png_get_text() in libpng.txt/libpng.3.
version 1.0.5s [February 18, 2000]
Added "png_jmpbuf()" macro to pngconf.h, to help people migrate to the
new error handler that's planned for the next libpng release, and changed
example.c, pngtest.c, and contrib programs to use this macro.
Added PNG_SETJMP_SUPPORTED, PNG_SETJMP_NOT_SUPPORTED, and PNG_ABORT() and
"png_jmpbuf()" macros to pngconf.h, to help people migrate to the new error
handler that's planned for the next libpng release, and changed example.c,
pngtest.c, and contrib programs to use this macro.
Revised some of the DLL-export macros in pngconf.h (Greg Roelofs)
Fixed a bug in png_read_png() that caused it to fail to expand some images
that it should have expanded.
Fixed some mistakes in the unused and undocumented INCH_CONVERSIONS functions
in pngget.c
Changed the allocation of palette, history, and trans arrays back to
the version 1.0.5 method (linking instead of copying) which restores
backward compatibility with version 1.0.5. Added some remarks about
that in example.c
Updated makefile.linux and makefile.gccmmx to make directories conditionally.
Made cosmetic changes to pngasmrd.h
Added png_set_rows() and png_get_rows(), for use with png_read|write_png().
Modified png_read_png() to allocate info_ptr->row_pointers only if it
hasn't already been allocated.
Increased precision of rgb_to_gray calculations from 8 to 15 bits and
added png_set_rgb_to_gray_fixed() function.
Added makefile.bc32 (32-bit Borland C++, C mode)
Updated references to the zlib home page, which has moved to freesoftware.com.
Corrected bugs in documentation regarding png_read_row() and png_write_row().
Renamed makefile.borland,turboc3 back to makefile.bor,tc3 as in version 1.0.3,
revised borland makefiles; added makefile.ibmvac3 and makefile.gcc (Cosmin)
Added makefile.sggcc (SGI IRIX with gcc)
Send comments/corrections/commendations to
png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu

28
CHANGES
View File

@ -628,9 +628,35 @@ version 1.0.5s [February 18, 2000]
Changed the allocation of palette, history, and trans arrays back to
the version 1.0.5 method (linking instead of copying) which restores
backward compatibility with version 1.0.5. Added some remarks about
that in example.c. Added "free_me" member to info_ptr and png_ptr.
that in example.c. Added "free_me" member to info_ptr and png_ptr
and added png_free_data() function.
Updated makefile.linux and makefile.gccmmx to make directories conditionally.
Made cosmetic changes to pngasmrd.h
Added png_set_rows() and png_get_rows(), for use with png_read|write_png().
Modified png_read_png() to allocate info_ptr->row_pointers only if it
hasn't already been allocated.
version 1.0.5t [March 4, 2000]
Changed png_jmp_env() migration aiding macro to png_jmpbuf().
Fixed "interlace" typo (should be "interlaced") in contrib/gregbook/read2-x.c
Fixed bug with use of PNG_BEFORE_IHDR bit in png_ptr->mode, introduced when
PNG_FLAG_HAVE_CHUNK_HEADER was moved into png_ptr->mode in version 1.0.5b
Files in contrib/gregbook were revised to use png_jmpbuf() and to select
a 24-bit visual if one is available, and to allow abbreviated options.
Files in contrib/pngminus were revised to use the png_jmpbuf() macro.
Removed spaces in makefile.linux and makefile.gcmmx, introduced in 1.0.5s
version 1.0.5u [March 5, 2000]
Simplified the code that detects old png.h in png.c and pngtest.c
Renamed png_spalette (_p, _pp) to png_sPLT_t (_tp, _tpp)
Increased precision of rgb_to_gray calculations from 8 to 15 bits and
added png_set_rgb_to_gray_fixed() function.
Added makefile.bc32 (32-bit Borland C++, C mode)
version 1.0.5v [March 11, 2000]
Added some parentheses to the png_jmpbuf macro definition.
Updated references to the zlib home page, which has moved to freesoftware.com.
Corrected bugs in documentation regarding png_read_row() and png_write_row().
Updated documentation of png_rgb_to_gray calculations in libpng.3/libpng.txt.
Renamed makefile.borland,turboc3 back to makefile.bor,tc3 as in version 1.0.3,
revised borland makefiles; added makefile.ibmvac3 and makefile.gcc (Cosmin)
version 1.0.6 [March 21, 2000]
Minor revisions of makefile.bor, libpng.txt, and gregbook/rpng2-win.c
Added makefile.sggcc (SGI IRIX with gcc)

33
INSTALL
View File

@ -1,5 +1,5 @@
Installing libpng version 1.0.5s - February 18, 2000
Installing libpng version 1.0.6 - March 21, 2000
Before installing libpng, you must first install zlib. zlib
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.
You can rename the directories that you downloaded (they
might be called "libpng-1.0.5s" or "lpng103" and "zlib-1.1.3"
might be called "libpng-1.0.6" or "lpng106" and "zlib-1.1.3"
or "zlib113") so that you have directories called "zlib" and "libpng".
Your directory structure should look like this:
@ -40,25 +40,27 @@ If the line endings in the files look funny, you may wish to get the other
distribution of libpng. It is available in both tar.gz (UNIX style line
endings) and zip (DOS style line endings) formats.
First enter the zlib directory and follow the instructions
in zlib/README. Then come back here and choose the
appropriate makefile.sys in the scripts directory.
First enter the zlib directory and follow the instructions in zlib/README.
Then come back here and choose the appropriate makefile.sys in the scripts
directory.
The files that are presently available in the scripts directory
include
descrip.mms => VMS makefile for MMS or MMK
makefile.std => Generic UNIX makefile
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
makefile.linux => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.6)
makefile.gcmmx => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.6,
uses assembler code tuned for Intel MMX platform)
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
makefile.knr => Archaic UNIX Makefile that converts files with
ansi2knr (Requires ansi2knr.c from
ftp://ftp.cs.wisc.edu/ghost)
makefile.dec => DEC Alpha UNIX makefile
makefile.hpux => HPUX (10.20 and 11.00) makefile
makefile.sgi => Silicon Graphics IRIX makefile
makefile.ibmvac3 => IBM VisualAge/C++ version 3.x for Win32 and OS/2 (static)
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
makefile.sggcc => Silicon Graphics (gcc, creates libpng.so.2.1.0.6)
makefile.sunos => Sun makefile
makefile.solaris => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.5s)
makefile.linux => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.5s)
makefile.gcmmx => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.5s,
uses assembler code tuned for Intel MMX platform)
makefile.solaris => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.6)
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
makefile.mips => MIPS makefile
makefile.acorn => Acorn makefile
@ -67,10 +69,10 @@ include
(Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc)
makefile.atari => Atari makefile
makefile.beos => BEOS makefile for X86
makefile.borland => Borland makefile (uses bcc)
makefile.bor => Borland makefile (uses bcc)
makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode)
makefile.bd32 => To make a png32bd.dll with Borland C++ 4.5
makefile.turboc3 => Turbo C 3.0 makefile
build.bat => MS-DOS batch file for Borland compiler
makefile.tc3 => Turbo C 3.0 makefile
makefile.dj2 => DJGPP 2 makefile
makefile.msc => Microsoft C makefile
makefile.vcawin32 => makefile for Microsoft Visual C++ 5.0 and later (uses
@ -81,6 +83,7 @@ include
pngos2.def => OS/2 module definition file used by makefile.os2
makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model
makevms.com => VMS build script
descrip.mms => VMS makefile for MMS or MMK
pngdef.pas => Defines for a png32bd.dll with Borland C++ 4.5
SCOPTIONS.ppc => Used with smakefile.ppc

View File

@ -1,5 +1,5 @@
Known bugs and suggested enhancements in libpng-1.0.5
Known bugs and suggested enhancements in libpng-1.0.6
1. March 15, 1998 -- OPTIMIZATION -- Kevin Bracey
@ -41,43 +41,3 @@ Known bugs and suggested enhancements in libpng-1.0.5
Much of this was completed in libpng-1.0.5h, but gamma compensation
is not yet done in fixed-point arithmetic.
4. October 1999 -- BUG
pngvcrd.c is failing for interlaced PNGs that have empty passes.
STATUS: A check for "width != 0" is required in several places.
Fixed in libpng-1.0.5a/1.1.0
5. October 1999 -- BUG
Under MSVC++6.0 with debugging enabled, heap corruption was detected
while destroying the png_write_ptr.
STATUS: This was fixed by modifying png_set_text (in pngset.c) to
refrain from writing into the user's text_ptr. With this fix, however,
pngwrite.c, while destroying the info_ptr, was failing to free the
text->key strings. Fix for the latter problem is to duplicate code
from png.c.
Fixed in libpng-1.0.5a/1.1.0
6. December 1999 -- new BUG
The png_text structure was modified in libpng-1.0.5e in a manner that
is not backward compatible (the lang member was added, and the
translated_key member was added to libpng-1.0.5g)
STATUS: Fixed in libpng-1.0.5j/1.1.0
7. December 1999 -- BUG
The new pnggccrd.c has syntax errors when compiled with gcc.
STATUS: Under investigation.
8. February 2000 -- BUG
When an RGBA file is expanded, only 24 or 48 bits per pixel are reserved
in rowbytes.
STATUS: Fixed in libpng-1.0.5s

View File

@ -5,7 +5,7 @@ Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
Copyright (c) 1996, 1997 Andreas Dilger
(libpng versions 0.90, December 1996, through 0.96, May 1997)
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
(libpng versions 0.97, January 1998, through 1.0.5s, February 18, 2000)
(libpng versions 0.97, January 1998, through 1.0.6, March 21, 2000)
For the purposes of this copyright and license, "Contributing Authors"
is defined as the following set of individuals:
@ -68,4 +68,4 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
randeg@alum.rpi.edu
February 18, 2000
March 21, 2000

37
README
View File

@ -1,4 +1,4 @@
README for libpng 1.0.5s - February 18, 2000 (shared library 2.1)
README for libpng 1.0.6 - March 21, 2000 (shared library 2.1)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.
@ -129,22 +129,26 @@ gladly listen. Even if your suggestion is not used for version
Files in this distribution:
ANNOUNCE => Announcement of this version, with recent changes
CHANGES => Description of changes between libpng versions
KNOWNBUG => List of known bugs and deficiencies
LICENSE => License to use and redistribute libpng
README => This file
TODO => Things not implemented in the current library
build.bat => MS-DOS batch file for Borland compiler
descrip.mms => VMS project file
Y2KINFO => Statement of Y2K compliance
example.c => Example code for using libpng functions
libpng.3 => manual page for libpng
libpng.3 => manual page for libpng (includes libpng.txt)
libpng.txt => Description of libpng and its functions
libpngpf.3 => manual page for libpng's private functions
png.5 => manual page for the PNG format
png.c => Basic interface functions common to library
png.h => Library function and interface declarations
pngconf.h => System specific library configuration
pngasmrd.h => Header file for assembler-coded functions
pngerror.c => Error/warning message I/O functions
pngget.c => Functions for retrieving info from struct
pngmem.c => Memory handling functions
pngnow.png => PNG logo
pngpread.c => Progressive reading functions
pngread.c => Read data/helper high-level functions
pngrio.c => Lowest-level data read I/O functions
@ -166,21 +170,24 @@ Files in this distribution:
pngsuite => Test images
scripts => Directory containing scripts for building libpng:
descrip.mms => VMS makefile for MMS or MMK
makefile.std => Generic UNIX makefile
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
makefile.linux => Linux/ELF makefile
(gcc, creates libpng.so.2.1.0.6)
makefile.gcmmx => Linux/ELF makefile (gcc, creates
libpng.so.2.1.0.6, uses assembler code
tuned for Intel MMX platform)
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
makefile.knr => Archaic UNIX Makefile that converts files with
ansi2knr (Requires ansi2knr.c from
ftp://ftp.cs.wisc.edu/ghost)
makefile.dec => DEC Alpha UNIX makefile
makefile.hpux => HPUX (10.20 and 11.00) makefile
makefile.sgi => Silicon Graphics IRIX makefile
makefile.ibmvac3 => IBM VisualAge/C++ ver 3.x for Win32, OS/2 (static)
makefile.sgi => Silicon Graphics IRIX (cc, creates static lib)
makefile.sggcc => Silicon Graphics (gcc, creates libpng.so.2.1.0.6)
makefile.sunos => Sun makefile
makefile.solaris => Solaris 2.X makefile
(gcc, creates libpng.so.2.1.0.5s)
makefile.linux => Linux/ELF makefile
(gcc, creates libpng.so.2.1.0.5s)
makefile.gcmmx => Linux/ELF makefile (gcc, creates
libpng.so.2.1.0.5s, uses assembler code
tuned for Intel MMX platform)
(gcc, creates libpng.so.2.1.0.6)
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
makefile.mips => MIPS makefile
makefile.acorn => Acorn makefile
@ -190,10 +197,10 @@ Files in this distribution:
scripts/SCOPTIONS.ppc)
makefile.atari => Atari makefile
makefile.beos => BEOS makefile for X86
makefile.borland => Borland makefile (uses bcc)
makefile.bor => Borland makefile (uses bcc)
makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode)
makefile.bd32 => To make a png32bd.dll with Borland C++ 4.5
makefile.turboc3 => Turbo C 3.0 makefile
build.bat => MS-DOS batch file for Borland compiler
makefile.tc3 => Turbo C 3.0 makefile
makefile.dj2 => DJGPP 2 makefile
makefile.msc => Microsoft C makefile
makefile.vcawin32 => makefile for Microsoft Visual C++ 5.0 and

View File

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

6
configure vendored Executable file
View File

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

26
contrib/gregbook/LICENSE Normal file
View File

@ -0,0 +1,26 @@
---------------------------------------------------------------------------
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors
be held liable for any damages arising in any way from the use of
this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions:
1. Redistributions of source code must retain the above copyright
notice, disclaimer, and this list of conditions.
2. Redistributions in binary form must reproduce the above copyright
notice, disclaimer, and this list of conditions in the documenta-
tion and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this
software must display the following acknowledgment:
This product includes software developed by Greg Roelofs
and contributors for the book, "PNG: The Definitive Guide,"
published by O'Reilly and Associates.
---------------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
# Sample makefile for rpng-x / rpng2-x / wpng using gcc and make.
# Greg Roelofs
# Last modified: 16 February 1999
# Last modified: 28 February 2000
#
# The programs built by this makefile are described in the book,
# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and
@ -9,11 +9,12 @@
#
# Invoke this makefile from a shell prompt in the usual way; for example:
#
# make -f makefile.unx
# make -f Makefile.unx
#
# This makefile assumes libpng and zlib have already been built or downloaded
# and are both installed in /usr/local/{include,lib} (as indicated by the
# PNGPATH and ZPATH macros below). Edit as appropriate.
# PNG* and Z* macros below). Edit as appropriate--choose only ONE each of
# the PNGINC, PNGLIB, ZINC and ZLIB lines.
#
# This makefile builds statically linked executables (against libpng and zlib,
# that is), but that can be changed by uncommenting the appropriate PNGLIB and
@ -22,30 +23,38 @@
# macros --------------------------------------------------------------------
PNGPATH = /usr/local
PNGINC = -I$(PNGPATH)/include
#PNGLIB = -L$(PNGPATH)/lib -lpng
PNGLIB = $(PNGPATH)/lib/libpng.a
PNGINC = -I/usr/local/include
#PNGLIB = -L/usr/local/lib -lpng # dynamically linked against libpng
PNGLIB = /usr/local/lib/libpng.a # statically linked against libpng
# or:
#PNGINC = -I../..
#PNGLIB = -L../.. -lpng
#PNGLIB = ../../libpng.a
ZPATH = /usr/local
ZINC = -I$(ZPATH)/include
#ZLIB = -L$(ZPATH)/lib -lz
ZLIB = $(ZPATH)/lib/libz.a
ZINC = -I/usr/local/include
#ZLIB = -L/usr/local/lib -lz # dynamically linked against zlib
ZLIB = /usr/local/lib/libz.a # statically linked against zlib
#ZINC = -I../zlib
#ZLIB = -L../zlib -lz
#ZLIB = ../../../zlib/libz.a
#XPATH = /usr/X11
XPATH = /usr/X11R6
XINC = -I$(XPATH)/include
XLIB = -L$(XPATH)/lib -lX11
#XINC = -I/usr/include/X11 # old-style, stock X distributions
#XLIB = -L/usr/lib/X11 -lX11
#XINC = -I/usr/openwin/include/X11 # Sun workstations (OpenWindows)
#XLIB = -L/usr/openwin/lib -lX11
XINC = -I/usr/X11R6/include # new X distributions (XFree86, etc.)
XLIB = -L/usr/X11R6/lib -lX11
INCS = $(PNGINC) $(ZINC) $(XINC)
RLIBS = $(PNGLIB) $(ZLIB) $(XLIB) -lm
WLIBS = $(PNGLIB) $(ZLIB) -lm
WLIBS = $(PNGLIB) $(ZLIB)
CC = gcc
LD = gcc
RM = rm -f
CFLAGS = -O -Wall $(INCS)
# [note that -Wall is a gcc-specific compilation flag ("all warnings on")]
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
# [-ansi, -pedantic and -W can also be used]
LDFLAGS =
O = .o
E =

View File

@ -10,14 +10,14 @@
# Invoke this makefile from a DOS prompt window via:
#
# %devstudio%\vc\bin\vcvars32.bat
# nmake -nologo -f makefile.w32
# nmake -nologo -f Makefile.w32
#
# where %devstudio% is the installation directory for MSVC / DevStudio. If
# you get "environment out of space" errors, create a desktop shortcut with
# "c:\windows\command.com /e:4096" as the program command line and set the
# working directory to this directory. Then double-click to open the new
# DOS-prompt window with a bigger environment and retry the commands above.
#
#
# This makefile assumes libpng and zlib have already been built or downloaded
# and are in subdirectories at the same level as the current subdirectory
# (as indicated by the PNGPATH and ZPATH macros below). Edit as appropriate.
@ -32,12 +32,12 @@
# macros --------------------------------------------------------------------
PNGPATH = ../libpng
PNGPATH = ../..
PNGINC = -I$(PNGPATH)
#PNGLIB = $(PNGPATH)/pngdll.lib
PNGLIB = $(PNGPATH)/libpng.lib
ZPATH = ../zlib
ZPATH = ../../../zlib
ZINC = -I$(ZPATH)
#ZLIB = $(ZPATH)/zlibdll.lib
ZLIB = $(ZPATH)/zlibstat.lib

View File

@ -1,52 +1,183 @@
PNG: The Definitive Guide: Source Code
===========================
PNG: The Definitive Guide
===========================
Chapters 13, 14 and 15 of PNG: The Definitive Guide discuss three
Source Code
Chapters 13, 14 and 15 of "PNG: The Definitive Guide" discuss three free,
cross-platform demo programs that show how to use the libpng reference
library: rpng, rpng2 and wpng. rpng and rpng2 are viewers; the first is a
very simple example that that shows how a standard file-viewer might use
libpng, while the second is designed to process streaming data and shows how
a web browser might be written. wpng is a simple command-line program that
reads binary PPM files (the ``raw'' RGB subset of NetPBM) and converts them
to PNG.
library: rpng, rpng2 and wpng. rpng and rpng2 are viewers; the first is
a very simple example that that shows how a standard file-viewer might use
libpng, while the second is designed to process streaming data and shows
how a web browser might be written. wpng is a simple command-line program
that reads binary PGM and PPM files (the ``raw'' grayscale and RGB subsets
of PBMPLUS/NetPBM) and converts them to PNG.
The source code for all three demo programs currently compiles only under
Unix and 32-bit Windows. It has been tested with gcc 2.7.2.3 under Linux and
Solaris and with Microsoft Visual C++ 5.0 under Windows 95. Brief
instructions for compiling the programs are included at the top of the
makefiles; makefile.unx is the Unix version, and makefile.w32 is (you
guessed it!) the version for 32-bit Windows. libpng and zlib are required.
The source code for all three demo programs currently compiles under
Unix, OpenVMS, and 32-bit Windows. (Special thanks to Martin Zinser,
zinser@decus.de, for making the necessary changes for OpenVMS and for
providing an appropriate build script.) Build instructions can be
found below.
----------------------------------------------------------------------------
Files:
License
README this file
README.w32 additional Windows-specific information
LICENSE terms of distribution and reuse (BSD-like)
The source code to the demo programs may be used and distributed freely
(even if you didn't buy the book--but feel free to do so at any time),
subject to the terms of the following BSD-like license:
Makefile.unx Unix makefile
Makefile.w32 Windows (MSVC) makefile
makevms.com OpenVMS build script
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
rpng-win.c Windows front end for the basic viewer
rpng-x.c X Window System (Unix, OpenVMS) front end
readpng.c generic back end for the basic viewer
readpng.h header file for the basic viewer
This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors
be held liable for any damages arising in any way from the use of
this software.
rpng2-win.c Windows front end for the progressive viewer
rpng2-x.c X front end for the progressive viewer
readpng2.c generic back end for the progressive viewer
readpng2.h header file for the progressive viewer
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
wpng.c generic (text) front end for the converter
writepng.c generic back end for the converter
writepng.h header file for the converter
1. Redistributions of source code must retain the above
copyright notice, disclaimer, and this list of conditions.
2. Redistributions in binary form must reproduce the above
copyright notice, disclaimer, and this list of conditions in
the documentation and/or other materials provided with the
distribution.
3. All advertising materials mentioning features or use of this
software must display the following acknowledgment:
toucan.png transparent PNG for testing (by Stefan Schneider)
This product includes software developed by Greg Roelofs
and contributors for the book, "PNG: The Definitive
Guide," published by O'Reilly and Associates.
Note that the programs are designed to be functional, but their primary
purpose is to demonstrate how to use libpng to add PNG support to other
programs. As such, their user interfaces are crude and definitely not
intended for everyday use.
----------------------------------------------------------
http://www.cdrom.com/pub/png/book/sources.html
Please see http://www.cdrom.com/pub/png/pngbook.html for further infor-
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.
Greg Roelofs
19 March 2000
BUILD INSTRUCTIONS
- Prerequisites:
- zlib ftp://ftp.cdrom.com/pub/infozip/zlib/zlib.html
- libpng http://www.cdrom.com/pub/png/pngcode.html
- pngbook http://www.cdrom.com/pub/png/book/sources.html
The pngbook demo programs are explicitly designed to demonstrate proper
coding techniques for using the libpng reference library. As a result,
you need to download and build both zlib (on which libpng depends) and
libpng. A common build setup is to place the zlib, libpng and pngbook
subdirectory trees ("folders") in the same parent directory. Then the
libpng build can refer to files in ../zlib (or ..\zlib or [-.zlib]),
and similarly for the pngbook build.
Note that all three packages are designed to be built from a command
line by default; those who wish to use a graphical or other integrated
development environments are on their own.
- Unix:
Unpack the latest pngbook sources (which should correspond to this
README file) into a directory and change into that directory.
Copy Makefile.unx to Makefile and edit the PNG* and Z* variables
appropriately (possibly also the X* variables if necessary).
make
There is no "install" target, so copy the three executables somewhere
in your path or run them from the current directory. All three will
print a basic usage screen when run without any command-line arguments;
see the book for more details.
- Windows:
Unpack the latest pngbook sources (which should correspond to this
README file) into a folder, open a "DOS shell" or "command prompt"
or equivalent command-line window, and cd into the folder where you
unpacked the source code.
For MSVC, set up the necessary environment variables by invoking
%devstudio%\vc\bin\vcvars32.bat
where where %devstudio% is the installation directory for MSVC /
DevStudio. If you get "environment out of space" errors under 95/98,
create a desktop shortcut with "c:\windows\command.com /e:4096" as
the program command line and set the working directory to the pngbook
directory. Then double-click to open the new DOS-prompt window with
a bigger environment and retry the commands above.
Copy Makefile.w32 to Makefile and edit the PNGPATH and ZPATH variables
appropriately (possibly also the "INC" and "LIB" variables if needed).
Note that the names of the dynamic and static libpng and zlib libraries
used in the makefile may change in later releases of the libraries.
Also note that, as of libpng version 1.0.5, MSVC DLL builds do not work.
This makefile therefore builds statically linked executables, but if
the DLL problems ever get fixed, uncommenting the appropriate PNGLIB
and ZLIB lines will build dynamically linked executables instead.
Do the build by typing
nmake
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
current folder. Unlike the Unix versions, the two windowed programs
(rpng and rpng2) do not display a usage screen when invoked without
command-line arguments; see README.w32 for brief help or the book for
details. Note that the programs use the Unix-style "-" character to
specify options, instead of the more common DOS/Windows "/" character.
- OpenVMS:
Unpack the pngbook sources into a subdirectory and change into that
subdirectory.
Edit makevms.com appropriately, specifically the zpath and pngpath
variables.
@makevms
To run the programs, they probably first need to be set up as "foreign
symbols," with "disk" and "dir" set appropriately:
$ rpng == "$disk:[dir]rpng-x.exe"
$ rpng2 == "$disk:[dir]rpng2-x.exe"
$ wpng == "$disk:[dir]wpng.exe"
All three will print a basic usage screen when run without any command-
line arguments; see the book for more details. Note that the options
style is Unix-like, i.e., preceded by "-" rather than "/".
RUNNING THE PROGRAMS: (VERY) BRIEF INTRO
rpng is a simple PNG viewer that can display transparent PNGs with a
specified background color; for example,
rpng -bgcolor #ff0000 toucan.png
would display the image with a red background. rpng2 is a progressive
viewer that simulates a web browser in some respects; it can display
images against either a background color or a dynamically generated
background image. For example:
rpng2 -bgpat 16 toucan.png
wpng is a purely command-line image converter from binary PBMPLUS/NetPBM
format (.pgm or .ppm) to PNG; for example,
wpng -time < toucan.ppm > toucan.png
would convert the specified PPM file (using redirection) to PNG, auto-
matically setting the PNG modification-time chunk.
All options can be abbreviated to the shortest unique value; for example,
"-bgc" for -bgcolor (versus "-bgp" for -bgpat), or "-g" for -gamma.

View File

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

@ -1,11 +1,22 @@
$!------------------------------------------------------------------------------
$! make Contrib programs of libpng under OpenVMS
$! make "PNG: The Definitive Guide" demo programs (for X) under OpenVMS
$!
$! Script created by Martin Zinser for libpng; modified by Greg Roelofs
$! for standalone pngbook source distribution.
$!
$!
$! Look for the compiler used
$! Set locations where zlib and libpng sources live.
$!
$ zlibsrc = "[---.zlib]"
$ ccopt="/include=(''zlibsrc',[--])"
$ zpath = "[-.zlib]"
$ pngpath = "[-.libpng]"
$!
$! USE THESE INSTEAD if building from libpng's [.contrib.gregbook] directory:
$! zpath = "[---.zlib]"
$! pngpath = "[--]"
$!
$! Look for the compiler used.
$!
$ ccopt="/include=(''zpath',''pngpath')"
$ if f$getsyi("HW_MODEL").ge.1024
$ then
$ ccopt = "/prefix=all"+ccopt
@ -29,13 +40,16 @@ $ comp = "__decc__=1"
$ endif
$ endif
$ open/write lopt lib.opt
$ write lopt "[--]libpng.olb/lib"
$ write lopt "''zlibsrc'libz.olb/lib"
$ write lopt "''pngpath'libpng.olb/lib"
$ write lopt "''zpath'libz.olb/lib"
$ close lopt
$ open/write xopt x11.opt
$ write xopt "sys$library:decw$xlibshr.exe/share"
$ close xopt
$ write sys$output "Compiling PNG contrib programs ..."
$!
$! Build 'em.
$!
$ write sys$output "Compiling PNG book programs ..."
$ CALL MAKE readpng.OBJ "cc ''CCOPT' readpng" -
readpng.c readpng.h
$ CALL MAKE readpng2.OBJ "cc ''CCOPT' readpng2" -

View File

@ -4,7 +4,7 @@
---------------------------------------------------------------------------
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors
@ -32,8 +32,13 @@
#include <stdio.h>
#include <stdlib.h>
#include "png.h" /* libpng header; includes zlib.h */
#include "readpng.h" /* typedefs, common macros, public prototypes */
#include "png.h" /* libpng header; includes zlib.h */
#include "readpng.h" /* typedefs, common macros, public prototypes */
/* future versions of libpng will provide this macro: */
#ifndef png_jmpbuf
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
#endif
static png_structp png_ptr = NULL;
@ -44,7 +49,7 @@ int bit_depth, color_type;
uch *image_data = NULL;
void readpng_version_info()
void readpng_version_info(void)
{
fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n",
PNG_LIBPNG_VER_STRING, png_libpng_ver);
@ -55,7 +60,7 @@ void readpng_version_info()
/* return value = 0 for success, 1 for bad sig, 2 for bad IHDR, 4 for no mem */
int readpng_init(FILE *infile, long *pWidth, long *pHeight)
int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight)
{
uch sig[8];
@ -89,7 +94,7 @@ int readpng_init(FILE *infile, long *pWidth, long *pHeight)
/* setjmp() must be called in every function that calls a PNG-reading
* libpng function */
if (setjmp(png_jmp_env(png_ptr))) {
if (setjmp(png_jmpbuf(png_ptr))) {
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return 2;
}
@ -130,7 +135,7 @@ int readpng_get_bgcolor(uch *red, uch *green, uch *blue)
/* setjmp() must be called in every function that calls a PNG-reading
* libpng function */
if (setjmp(png_jmp_env(png_ptr))) {
if (setjmp(png_jmpbuf(png_ptr))) {
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return 2;
}
@ -184,7 +189,7 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
/* setjmp() must be called in every function that calls a PNG-reading
* libpng function */
if (setjmp(png_jmp_env(png_ptr))) {
if (setjmp(png_jmpbuf(png_ptr))) {
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return NULL;
}

View File

@ -4,7 +4,7 @@
---------------------------------------------------------------------------
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors
@ -54,7 +54,7 @@ typedef unsigned long ulg;
void readpng_version_info(void);
int readpng_init(FILE *infile, long *pWidth, long *pHeight);
int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight);
int readpng_get_bgcolor(uch *bg_red, uch *bg_green, uch *bg_blue);

View File

@ -4,7 +4,7 @@
---------------------------------------------------------------------------
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors
@ -30,10 +30,10 @@
---------------------------------------------------------------------------*/
#include <stdlib.h> /* for exit() prototype */
#include <stdlib.h> /* for exit() prototype */
#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
#include "readpng2.h" /* typedefs, common macros, public prototypes */
#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
#include "readpng2.h" /* typedefs, common macros, public prototypes */
/* local prototypes */
@ -47,7 +47,7 @@ static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg);
void readpng2_version_info()
void readpng2_version_info(void)
{
fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n",
PNG_LIBPNG_VER_STRING, png_libpng_ver);
@ -70,7 +70,7 @@ int readpng2_check_sig(uch *sig, int num)
int readpng2_init(mainprog_info *mainprog_ptr)
{
png_structp png_ptr; /* note: temporary variables! */
png_structp png_ptr; /* note: temporary variables! */
png_infop info_ptr;
@ -98,7 +98,7 @@ int readpng2_init(mainprog_info *mainprog_ptr)
* but compatible error handlers must either use longjmp() themselves
* (as in this program) or exit immediately, so here we are: */
if (setjmp(png_jmp_env(mainprog_ptr))) {
if (setjmp(mainprog_ptr->jmpbuf)) {
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return 2;
}
@ -136,7 +136,7 @@ int readpng2_decode_data(mainprog_info *mainprog_ptr, uch *rawbuf, ulg length)
/* setjmp() must be called in every function that calls a PNG-reading
* libpng function */
if (setjmp(png_jmp_env(mainprog_ptr))) {
if (setjmp(mainprog_ptr->jmpbuf)) {
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
mainprog_ptr->png_ptr = NULL;
mainprog_ptr->info_ptr = NULL;
@ -176,7 +176,7 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
mainprog_ptr = png_get_progressive_ptr(png_ptr);
if (mainprog_ptr == NULL) { /* we be hosed */
if (mainprog_ptr == NULL) { /* we be hosed */
fprintf(stderr,
"readpng2 error: main struct not recoverable in info_callback.\n");
fflush(stderr);
@ -283,7 +283,7 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
png_read_update_info(png_ptr, info_ptr);
mainprog_ptr->rowbytes = png_get_rowbytes(png_ptr, info_ptr);
mainprog_ptr->rowbytes = (int)png_get_rowbytes(png_ptr, info_ptr);
mainprog_ptr->channels = png_get_channels(png_ptr, info_ptr);
@ -323,6 +323,11 @@ static void readpng2_row_callback(png_structp png_ptr, png_bytep new_row,
mainprog_ptr = png_get_progressive_ptr(png_ptr);
/* save the pass number for optional use by the front end */
mainprog_ptr->pass = pass;
/* have libpng either combine the new row data with the existing row data
* from previous passes (if interlaced) or else just copy the new row
* into the main program's image buffer */
@ -408,7 +413,7 @@ static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg)
fflush(stderr);
mainprog_ptr = png_get_error_ptr(png_ptr);
if (mainprog_ptr == NULL) { /* we are completely hosed now */
if (mainprog_ptr == NULL) { /* we are completely hosed now */
fprintf(stderr,
"readpng2 severe error: jmpbuf not recoverable; terminating.\n");
fflush(stderr);

View File

@ -4,7 +4,7 @@
---------------------------------------------------------------------------
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors
@ -61,7 +61,8 @@ typedef struct _mainprog_info {
uch *image_data;
uch **row_pointers;
jmp_buf jmpbuf;
int passes; /* not used */
int passes; /* not used */
int pass;
int rowbytes;
int channels;
int need_bgcolor;

View File

@ -16,7 +16,16 @@
---------------------------------------------------------------------------
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
Changelog:
- 1.00: initial public release
- 1.01: modified to allow abbreviated options; fixed long/ulong mis-
match; switched to png_jmpbuf() macro
- 1.02: added extra set of parentheses to png_jmpbuf() macro; fixed
command-line parsing bug
---------------------------------------------------------------------------
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors
@ -43,7 +52,7 @@
#define PROGNAME "rpng-win"
#define LONGNAME "Simple PNG Viewer for Windows"
#define VERSION "1.0 of 20 February 1999"
#define VERSION "1.02 of 19 March 2000"
#include <stdio.h>
#include <stdlib.h>
@ -53,7 +62,7 @@
/* #define DEBUG : this enables the Trace() macros */
#include "readpng.h" /* typedefs, common macros, readpng prototypes */
#include "readpng.h" /* typedefs, common macros, readpng prototypes */
/* could just include png.h, but this macro is the only thing we need
@ -61,10 +70,10 @@
* only happen with alpha (which could easily be avoided with
* "ush acopy = (alpha);") */
#define alpha_composite(composite, fg, alpha, bg) { \
ush temp = ((ush)(fg)*(ush)(alpha) + \
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
#define alpha_composite(composite, fg, alpha, bg) { \
ush temp = ((ush)(fg)*(ush)(alpha) + \
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
}
@ -78,7 +87,7 @@ LRESULT CALLBACK rpng_win_wndproc(HWND, UINT, WPARAM, LPARAM);
static char titlebar[1024], *window_name = titlebar;
static char *progname = PROGNAME;
static char *appname = LONGNAME;
static char *icon_name = PROGNAME; /* GRR: not (yet) used */
static char *icon_name = PROGNAME; /* GRR: not (yet) used */
static char *filename;
static FILE *infile;
@ -104,15 +113,15 @@ static HWND global_hwnd;
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
{
char *args[1024]; /* arbitrary limit, but should suffice */
char *args[1024]; /* arbitrary limit, but should suffice */
char *p, *q, **argv = args;
int argc = 0;
int rc, alen, flen;
int error = 0;
int have_bg = FALSE;
double LUT_exponent; /* just the lookup table */
double CRT_exponent = 2.2; /* just the monitor */
double default_display_exponent; /* whole display system */
double LUT_exponent; /* just the lookup table */
double CRT_exponent = 2.2; /* just the monitor */
double default_display_exponent; /* whole display system */
MSG msg;
@ -199,20 +208,24 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
/* Now parse the command line for options and the PNG filename. */
while (*++argv && !error) {
if (!strcmp(*argv, "-gamma")) {
if (!strncmp(*argv, "-gamma", 2)) {
if (!*++argv)
++error;
display_exponent = atof(*argv);
if (display_exponent <= 0.0)
++error;
} else if (!strcmp(*argv, "-bgcolor")) {
else {
display_exponent = atof(*argv);
if (display_exponent <= 0.0)
++error;
}
} else if (!strncmp(*argv, "-bgcolor", 2)) {
if (!*++argv)
++error;
bgstr = *argv;
if (strlen(bgstr) != 7 || bgstr[0] != '#')
++error;
else
have_bg = TRUE;
else {
bgstr = *argv;
if (strlen(bgstr) != 7 || bgstr[0] != '#')
++error;
else
have_bg = TRUE;
}
} else {
if (**argv != '-') {
filename = *argv;
@ -255,6 +268,9 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
fclose(infile);
}
/* usage screen */
if (error) {
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
readpng_version_info();
@ -265,7 +281,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
"\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"
" bg \tdesired background color in 7-character hex RGB format\n"
"\t\t (e.g., ``#ff7f00'' 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"
"\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n"
"\n", PROGNAME, default_display_exponent);
@ -336,6 +352,10 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
/* wait for the user to tell us when to quit */
printf(
"Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n");
fflush(stdout);
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
@ -371,7 +391,7 @@ static int rpng_win_create_window(HINSTANCE hInst, int showmode)
if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) +
wimage_rowbytes*image_height)))
{
return 4; /* fail */
return 4; /* fail */
}
/*---------------------------------------------------------------------------
@ -477,7 +497,7 @@ static int rpng_win_display_image()
g = *src++;
b = *src++;
*dest++ = b;
*dest++ = g; /* note reverse order */
*dest++ = g; /* note reverse order */
*dest++ = r;
}
} else /* if (image_channels == 4) */ {
@ -582,15 +602,15 @@ LRESULT CALLBACK rpng_win_wndproc(HWND hwnd, UINT iMsg, WPARAM wP, LPARAM lP)
/* wait for the user to tell us when to quit */
case WM_CHAR:
switch (wP) { /* only need one, so ignore repeat count */
switch (wP) { /* only need one, so ignore repeat count */
case 'q':
case 'Q':
case 0x1B: /* Esc key */
case 0x1B: /* Esc key */
PostQuitMessage(0);
}
return 0;
case WM_LBUTTONDOWN: /* another way of quitting */
case WM_LBUTTONDOWN: /* another way of quitting */
case WM_DESTROY:
PostQuitMessage(0);
return 0;

View File

@ -5,8 +5,8 @@
This program decodes and displays PNG images, with gamma correction and
optionally with a user-specified background color (in case the image has
transparency). It is very nearly the most basic PNG viewer possible.
This version is for the X Window System (tested under Unix, but may work
under VMS or OS/2 with a little tweaking).
This version is for the X Window System (tested by author under Unix and
by Martin Zinser under OpenVMS; may work under OS/2 with some tweaking).
to do:
- 8-bit support
@ -14,7 +14,17 @@
---------------------------------------------------------------------------
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
Changelog:
- 1.01: initial public release
- 1.02: modified to allow abbreviated options; fixed long/ulong mis-
match; switched to png_jmpbuf() macro
- 1.10: added support for non-default visuals; fixed X pixel-conversion
- 1.11: added extra set of parentheses to png_jmpbuf() macro; fixed
command-line parsing bug
---------------------------------------------------------------------------
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind,