Imported from libpng-1.0.6.tar
This commit is contained in:
parent
a77ef625a6
commit
520a764cd7
140
ANNOUNCE
140
ANNOUNCE
@ -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
|
This is a public release of libpng, intended for use in production codes.
|
||||||
within a few weeks by a public version or by another test version.
|
|
||||||
|
|
||||||
Changes since the last public release (1.0.5):
|
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)
|
Added contrib/pngsuite and contrib/pngminus (Willem van Schaik)
|
||||||
Fixed a typo in the png_set_sRGB() function call in example.c (Jan Nijtmans)
|
Fixed a typo in the png_set_sRGB() function call in example.c (Jan Nijtmans)
|
||||||
Further optimization and bugfix of pngvcrd.c
|
Further optimization and bugfix of pngvcrd.c
|
||||||
Revised pngset.c so that it does not allocate or free memory in the user's
|
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.
|
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.
|
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
|
Moved PNG_FLAG_HAVE_CHUNK_HEADER, PNG_FLAG_BACKGROUND_IS_GRAY and
|
||||||
PNG_FLAG_WROTE_tIME from flags to mode.
|
PNG_FLAG_WROTE_tIME from flags to mode.
|
||||||
Added png_write_info_before_PLTE() function.
|
Added png_write_info_before_PLTE() function.
|
||||||
Fixed some typecasting in contrib/gregbook/*.c
|
Fixed some typecasting in contrib/gregbook/*.c
|
||||||
Updated scripts/makevms.com and added makevms.com to contrib/gregbook
|
Updated scripts/makevms.com (Martin Zinser)
|
||||||
and contrib/pngminus (Martin Zinser)
|
|
||||||
version libpng-1.0.5c November 26, 1999
|
|
||||||
Moved png_get_header_version from png.h to png.c, to accomodate ansi2knr.
|
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
|
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
|
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
|
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
|
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
|
png_CHNK and png_pass arrays to be "const". Made the global arrays
|
||||||
available to applications (although none are used in libpng itself) when
|
available to applications when PNG_NO_GLOBAL_ARRAYS is not defined or
|
||||||
PNG_NO_GLOBAL_ARRAYS is not defined or when PNG_GLOBAL_ARRAYS is defined.
|
when PNG_USE_GLOBAL_ARRAYS is defined. Made available to applications a
|
||||||
Removed some extraneous "-I" from contrib/pngminus/makefile.std
|
macro "PNG_USE_LOCAL_ARRAYS".
|
||||||
Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2.
|
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
|
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.
|
Added PNG_EXPORT_VAR macro to accommodate making DLL's.
|
||||||
version libpng-1.0.5e November 30, 1999
|
Refactored the inflate/deflate support to make adding new chunks with
|
||||||
Added iCCP, iTXt, and sPLT support; added "lang" member to the png_text
|
trailing compressed parts easier in the future (Eric S. Raymond).
|
||||||
structure; refactored the inflate/deflate support to make adding new chunks
|
Added iCCP, iTXt, sCAL, and sPLT support; added "lang", "lang_key", and
|
||||||
with trailing compressed parts easier in the future, and added new functions
|
itxt_length" members to the png_text structure (Eric S. Raymond, Glenn R-P)
|
||||||
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
|
|
||||||
|
|
||||||
Changed png_get_oFFs() and png_set_oFFs() to use signed rather than unsigned
|
Changed png_get_oFFs() and png_set_oFFs() to use signed rather than unsigned
|
||||||
offsets (Eric S. Raymond).
|
offsets (Eric S. Raymond).
|
||||||
Combined PNG_READ_cHNK_SUPPORTED and PNG_WRITE_cHNK_SUPPORTED macros into
|
Combined PNG_READ_cHNK_SUPPORTED and PNG_WRITE_cHNK_SUPPORTED macros into
|
||||||
PNG_cHNK_SUPPORTED and combined the three types of PNG_text_SUPPORTED
|
PNG_cHNK_SUPPORTED and combined the three types of PNG_text_SUPPORTED
|
||||||
macros, leaving the separate macros also available.
|
macros, leaving the separate macros also available.
|
||||||
Removed comments on #endifs at the end of many short, non-nested #if-blocks.
|
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
|
Changed makefile.solaris to issue a warning about potential problems when
|
||||||
the ucb "ld" is in the path ahead of the ccs "ld".
|
the ucb "ld" is in the path ahead of the ccs "ld".
|
||||||
Removed "- [date]" from the "synopsis" line in libpng.3 and libpngpf.3.
|
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.
|
Added code in pngwrite.c to work around a newly discovered zlib bug.
|
||||||
version libpng-1.0.5h December 10, 1999
|
Unknown chunk handling is now supported (Eric S. Raymond).
|
||||||
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.
|
|
||||||
Option to eliminate all floating point support was added. Some new
|
Option to eliminate all floating point support was added. Some new
|
||||||
fixed-point functions such as png_set_gAMA_fixed() were added.
|
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
|
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 many parentheses, e.g., "if (a && b & c)" becomes "if (a && (b & c))"
|
||||||
Added png_handle_as_unknown()
|
Added png_handle_as_unknown()
|
||||||
Added png_free_chunk_list() function and chunk_list and num_chunk_list members
|
Added chunk_list and num_chunk_list members of png_ptr.
|
||||||
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).
|
|
||||||
Define png_get_int_32 when oFFs chunk is supported as well as when pCAL is.
|
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()
|
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
|
for setting a callback function to handle unknown chunks and for
|
||||||
retrieving the associated user pointer (Glenn).
|
retrieving the associated user pointer (Glenn).
|
||||||
version 1.0.5m [January 7, 2000]
|
Added png_free_data() function.
|
||||||
Added high-level functions png_read_png(), png_write_png(), png_free_pixels().
|
Added high-level functions png_read_png() and png_write_png() (ESR).
|
||||||
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]
|
|
||||||
Renamed pngdll.mak to makefile.bd32
|
Renamed pngdll.mak to makefile.bd32
|
||||||
Cosmetic changes in pngtest.c
|
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)
|
Fixed pngvcrd.c bug by pushing/popping registers in mmxsupport (Bruce Oberg)
|
||||||
Revised makefile.gcmmx
|
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.
|
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
|
Return *num_text=0 from png_get_text() when appropriate, and fix documentation
|
||||||
of png_get_text() in libpng.txt/libpng.3.
|
of png_get_text() in libpng.txt/libpng.3.
|
||||||
version 1.0.5s [February 18, 2000]
|
Added PNG_SETJMP_SUPPORTED, PNG_SETJMP_NOT_SUPPORTED, and PNG_ABORT() and
|
||||||
Added "png_jmpbuf()" macro to pngconf.h, to help people migrate to the
|
"png_jmpbuf()" macros to pngconf.h, to help people migrate to the new error
|
||||||
new error handler that's planned for the next libpng release, and changed
|
handler that's planned for the next libpng release, and changed example.c,
|
||||||
example.c, pngtest.c, and contrib programs to use this macro.
|
pngtest.c, and contrib programs to use this macro.
|
||||||
Revised some of the DLL-export macros in pngconf.h (Greg Roelofs)
|
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
|
Fixed some mistakes in the unused and undocumented INCH_CONVERSIONS functions
|
||||||
in pngget.c
|
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.
|
Updated makefile.linux and makefile.gccmmx to make directories conditionally.
|
||||||
Made cosmetic changes to pngasmrd.h
|
Increased precision of rgb_to_gray calculations from 8 to 15 bits and
|
||||||
Added png_set_rows() and png_get_rows(), for use with png_read|write_png().
|
added png_set_rgb_to_gray_fixed() function.
|
||||||
Modified png_read_png() to allocate info_ptr->row_pointers only if it
|
Added makefile.bc32 (32-bit Borland C++, C mode)
|
||||||
hasn't already been allocated.
|
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
|
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
|
||||||
|
28
CHANGES
28
CHANGES
@ -628,9 +628,35 @@ version 1.0.5s [February 18, 2000]
|
|||||||
Changed the allocation of palette, history, and trans arrays back to
|
Changed the allocation of palette, history, and trans arrays back to
|
||||||
the version 1.0.5 method (linking instead of copying) which restores
|
the version 1.0.5 method (linking instead of copying) which restores
|
||||||
backward compatibility with version 1.0.5. Added some remarks about
|
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.
|
Updated makefile.linux and makefile.gccmmx to make directories conditionally.
|
||||||
Made cosmetic changes to pngasmrd.h
|
Made cosmetic changes to pngasmrd.h
|
||||||
Added png_set_rows() and png_get_rows(), for use with png_read|write_png().
|
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
|
Modified png_read_png() to allocate info_ptr->row_pointers only if it
|
||||||
hasn't already been allocated.
|
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
33
INSTALL
@ -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
|
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.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".
|
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:
|
||||||
@ -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
|
distribution of libpng. It is available in both tar.gz (UNIX style line
|
||||||
endings) and zip (DOS style line endings) formats.
|
endings) and zip (DOS style line endings) formats.
|
||||||
|
|
||||||
First enter the zlib directory and follow the instructions
|
First enter the zlib directory and follow the instructions in zlib/README.
|
||||||
in zlib/README. Then come back here and choose the
|
Then come back here and choose the appropriate makefile.sys in the scripts
|
||||||
appropriate makefile.sys in the scripts directory.
|
directory.
|
||||||
The files that are presently available in the scripts directory
|
The files that are presently available in the scripts directory
|
||||||
include
|
include
|
||||||
|
|
||||||
descrip.mms => VMS makefile for MMS or MMK
|
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
|
||||||
makefile.std => Generic UNIX makefile
|
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
|
makefile.knr => Archaic UNIX Makefile that converts files with
|
||||||
ansi2knr (Requires ansi2knr.c from
|
ansi2knr (Requires ansi2knr.c from
|
||||||
ftp://ftp.cs.wisc.edu/ghost)
|
ftp://ftp.cs.wisc.edu/ghost)
|
||||||
makefile.dec => DEC Alpha UNIX makefile
|
makefile.dec => DEC Alpha UNIX makefile
|
||||||
makefile.hpux => HPUX (10.20 and 11.00) makefile
|
makefile.hpux => HPUX (10.20 and 11.00) makefile
|
||||||
makefile.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.sunos => Sun makefile
|
||||||
makefile.solaris => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.5s)
|
makefile.solaris => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.6)
|
||||||
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.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
|
||||||
@ -67,10 +69,10 @@ include
|
|||||||
(Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc)
|
(Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc)
|
||||||
makefile.atari => Atari makefile
|
makefile.atari => Atari makefile
|
||||||
makefile.beos => BEOS makefile for X86
|
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.bd32 => To make a png32bd.dll with Borland C++ 4.5
|
||||||
makefile.turboc3 => Turbo C 3.0 makefile
|
makefile.tc3 => Turbo C 3.0 makefile
|
||||||
build.bat => MS-DOS batch file for Borland compiler
|
|
||||||
makefile.dj2 => DJGPP 2 makefile
|
makefile.dj2 => DJGPP 2 makefile
|
||||||
makefile.msc => Microsoft C makefile
|
makefile.msc => Microsoft C makefile
|
||||||
makefile.vcawin32 => makefile for Microsoft Visual C++ 5.0 and later (uses
|
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
|
pngos2.def => OS/2 module definition file used by makefile.os2
|
||||||
makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model
|
makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model
|
||||||
makevms.com => VMS build script
|
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
|
pngdef.pas => Defines for a png32bd.dll with Borland C++ 4.5
|
||||||
SCOPTIONS.ppc => Used with smakefile.ppc
|
SCOPTIONS.ppc => Used with smakefile.ppc
|
||||||
|
|
||||||
|
42
KNOWNBUG
42
KNOWNBUG
@ -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
|
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
|
Much of this was completed in libpng-1.0.5h, but gamma compensation
|
||||||
is not yet done in fixed-point arithmetic.
|
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
|
|
||||||
|
4
LICENSE
4
LICENSE
@ -5,7 +5,7 @@ Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
|||||||
Copyright (c) 1996, 1997 Andreas Dilger
|
Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
(libpng versions 0.90, December 1996, through 0.96, May 1997)
|
(libpng versions 0.90, December 1996, through 0.96, May 1997)
|
||||||
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
(libpng versions 0.97, January 1998, through 1.0.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"
|
For the purposes of this copyright and license, "Contributing Authors"
|
||||||
is defined as the following set of individuals:
|
is defined as the following set of individuals:
|
||||||
@ -68,4 +68,4 @@ certification mark of the Open Source Initiative.
|
|||||||
|
|
||||||
Glenn Randers-Pehrson
|
Glenn Randers-Pehrson
|
||||||
randeg@alum.rpi.edu
|
randeg@alum.rpi.edu
|
||||||
February 18, 2000
|
March 21, 2000
|
||||||
|
37
README
37
README
@ -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 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.
|
||||||
@ -129,22 +129,26 @@ gladly listen. Even if your suggestion is not used for version
|
|||||||
|
|
||||||
Files in this distribution:
|
Files in this distribution:
|
||||||
|
|
||||||
|
ANNOUNCE => Announcement of this version, with recent changes
|
||||||
CHANGES => Description of changes between libpng versions
|
CHANGES => Description of changes between libpng versions
|
||||||
|
KNOWNBUG => List of known bugs and deficiencies
|
||||||
|
LICENSE => License to use and redistribute libpng
|
||||||
README => This file
|
README => This file
|
||||||
TODO => Things not implemented in the current library
|
TODO => Things not implemented in the current library
|
||||||
build.bat => MS-DOS batch file for Borland compiler
|
Y2KINFO => Statement of Y2K compliance
|
||||||
descrip.mms => VMS project file
|
|
||||||
example.c => Example code for using libpng functions
|
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
|
libpng.txt => Description of libpng and its functions
|
||||||
libpngpf.3 => manual page for libpng's private functions
|
libpngpf.3 => manual page for libpng's private functions
|
||||||
png.5 => manual page for the PNG format
|
png.5 => manual page for the PNG format
|
||||||
png.c => Basic interface functions common to library
|
png.c => Basic interface functions common to library
|
||||||
png.h => Library function and interface declarations
|
png.h => Library function and interface declarations
|
||||||
pngconf.h => System specific library configuration
|
pngconf.h => System specific library configuration
|
||||||
|
pngasmrd.h => Header file for assembler-coded functions
|
||||||
pngerror.c => Error/warning message I/O functions
|
pngerror.c => Error/warning message I/O functions
|
||||||
pngget.c => Functions for retrieving info from struct
|
pngget.c => Functions for retrieving info from struct
|
||||||
pngmem.c => Memory handling functions
|
pngmem.c => Memory handling functions
|
||||||
|
pngnow.png => PNG logo
|
||||||
pngpread.c => Progressive reading functions
|
pngpread.c => Progressive reading functions
|
||||||
pngread.c => Read data/helper high-level functions
|
pngread.c => Read data/helper high-level functions
|
||||||
pngrio.c => Lowest-level data read I/O functions
|
pngrio.c => Lowest-level data read I/O functions
|
||||||
@ -166,21 +170,24 @@ Files in this distribution:
|
|||||||
pngsuite => Test images
|
pngsuite => Test images
|
||||||
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
|
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
|
makefile.knr => Archaic UNIX Makefile that converts files with
|
||||||
ansi2knr (Requires ansi2knr.c from
|
ansi2knr (Requires ansi2knr.c from
|
||||||
ftp://ftp.cs.wisc.edu/ghost)
|
ftp://ftp.cs.wisc.edu/ghost)
|
||||||
makefile.dec => DEC Alpha UNIX makefile
|
makefile.dec => DEC Alpha UNIX makefile
|
||||||
makefile.hpux => HPUX (10.20 and 11.00) makefile
|
makefile.hpux => HPUX (10.20 and 11.00) makefile
|
||||||
makefile.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.sunos => Sun makefile
|
||||||
makefile.solaris => Solaris 2.X makefile
|
makefile.solaris => Solaris 2.X makefile
|
||||||
(gcc, creates libpng.so.2.1.0.5s)
|
(gcc, creates libpng.so.2.1.0.6)
|
||||||
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.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
|
||||||
@ -190,10 +197,10 @@ Files in this distribution:
|
|||||||
scripts/SCOPTIONS.ppc)
|
scripts/SCOPTIONS.ppc)
|
||||||
makefile.atari => Atari makefile
|
makefile.atari => Atari makefile
|
||||||
makefile.beos => BEOS makefile for X86
|
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.bd32 => To make a png32bd.dll with Borland C++ 4.5
|
||||||
makefile.turboc3 => Turbo C 3.0 makefile
|
makefile.tc3 => Turbo C 3.0 makefile
|
||||||
build.bat => MS-DOS batch file for Borland compiler
|
|
||||||
makefile.dj2 => DJGPP 2 makefile
|
makefile.dj2 => DJGPP 2 makefile
|
||||||
makefile.msc => Microsoft C makefile
|
makefile.msc => Microsoft C makefile
|
||||||
makefile.vcawin32 => makefile for Microsoft Visual C++ 5.0 and
|
makefile.vcawin32 => makefile for Microsoft Visual C++ 5.0 and
|
||||||
|
4
Y2KINFO
4
Y2KINFO
@ -1,13 +1,13 @@
|
|||||||
Y2K compliance in libpng:
|
Y2K compliance in libpng:
|
||||||
=========================
|
=========================
|
||||||
|
|
||||||
February 18, 2000
|
March 21, 2000
|
||||||
|
|
||||||
Since the PNG Development group is an ad-hoc body, we can't make
|
Since the PNG Development group is an ad-hoc body, we can't make
|
||||||
an official declaration.
|
an official declaration.
|
||||||
|
|
||||||
This is your unofficial assurance that libpng from version 0.71 and
|
This is your unofficial assurance that libpng from version 0.71 and
|
||||||
upward through 1.0.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.
|
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
|
||||||
|
6
configure
vendored
Executable file
6
configure
vendored
Executable 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
26
contrib/gregbook/LICENSE
Normal 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.
|
||||||
|
|
||||||
|
---------------------------------------------------------------------------
|
@ -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: 16 February 1999
|
# Last modified: 28 February 2000
|
||||||
#
|
#
|
||||||
# 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
|
||||||
@ -9,11 +9,12 @@
|
|||||||
#
|
#
|
||||||
# Invoke this makefile from a shell prompt in the usual way; for example:
|
# 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
|
# 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
|
# 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,
|
# This makefile builds statically linked executables (against libpng and zlib,
|
||||||
# that is), but that can be changed by uncommenting the appropriate PNGLIB and
|
# that is), but that can be changed by uncommenting the appropriate PNGLIB and
|
||||||
@ -22,30 +23,38 @@
|
|||||||
|
|
||||||
# macros --------------------------------------------------------------------
|
# macros --------------------------------------------------------------------
|
||||||
|
|
||||||
PNGPATH = /usr/local
|
PNGINC = -I/usr/local/include
|
||||||
PNGINC = -I$(PNGPATH)/include
|
#PNGLIB = -L/usr/local/lib -lpng # dynamically linked against libpng
|
||||||
#PNGLIB = -L$(PNGPATH)/lib -lpng
|
PNGLIB = /usr/local/lib/libpng.a # statically linked against libpng
|
||||||
PNGLIB = $(PNGPATH)/lib/libpng.a
|
# or:
|
||||||
|
#PNGINC = -I../..
|
||||||
|
#PNGLIB = -L../.. -lpng
|
||||||
|
#PNGLIB = ../../libpng.a
|
||||||
|
|
||||||
ZPATH = /usr/local
|
ZINC = -I/usr/local/include
|
||||||
ZINC = -I$(ZPATH)/include
|
#ZLIB = -L/usr/local/lib -lz # dynamically linked against zlib
|
||||||
#ZLIB = -L$(ZPATH)/lib -lz
|
ZLIB = /usr/local/lib/libz.a # statically linked against zlib
|
||||||
ZLIB = $(ZPATH)/lib/libz.a
|
#ZINC = -I../zlib
|
||||||
|
#ZLIB = -L../zlib -lz
|
||||||
|
#ZLIB = ../../../zlib/libz.a
|
||||||
|
|
||||||
#XPATH = /usr/X11
|
#XINC = -I/usr/include/X11 # old-style, stock X distributions
|
||||||
XPATH = /usr/X11R6
|
#XLIB = -L/usr/lib/X11 -lX11
|
||||||
XINC = -I$(XPATH)/include
|
#XINC = -I/usr/openwin/include/X11 # Sun workstations (OpenWindows)
|
||||||
XLIB = -L$(XPATH)/lib -lX11
|
#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)
|
INCS = $(PNGINC) $(ZINC) $(XINC)
|
||||||
RLIBS = $(PNGLIB) $(ZLIB) $(XLIB) -lm
|
RLIBS = $(PNGLIB) $(ZLIB) $(XLIB) -lm
|
||||||
WLIBS = $(PNGLIB) $(ZLIB) -lm
|
WLIBS = $(PNGLIB) $(ZLIB)
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
LD = gcc
|
LD = gcc
|
||||||
RM = rm -f
|
RM = rm -f
|
||||||
CFLAGS = -O -Wall $(INCS)
|
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 =
|
LDFLAGS =
|
||||||
O = .o
|
O = .o
|
||||||
E =
|
E =
|
@ -10,7 +10,7 @@
|
|||||||
# Invoke this makefile from a DOS prompt window via:
|
# Invoke this makefile from a DOS prompt window via:
|
||||||
#
|
#
|
||||||
# %devstudio%\vc\bin\vcvars32.bat
|
# %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
|
# where %devstudio% is the installation directory for MSVC / DevStudio. If
|
||||||
# you get "environment out of space" errors, create a desktop shortcut with
|
# you get "environment out of space" errors, create a desktop shortcut with
|
||||||
@ -32,12 +32,12 @@
|
|||||||
|
|
||||||
# macros --------------------------------------------------------------------
|
# macros --------------------------------------------------------------------
|
||||||
|
|
||||||
PNGPATH = ../libpng
|
PNGPATH = ../..
|
||||||
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
|
@ -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
|
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
|
library: rpng, rpng2 and wpng. rpng and rpng2 are viewers; the first is
|
||||||
very simple example that that shows how a standard file-viewer might use
|
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
|
libpng, while the second is designed to process streaming data and shows
|
||||||
a web browser might be written. wpng is a simple command-line program that
|
how a web browser might be written. wpng is a simple command-line program
|
||||||
reads binary PPM files (the ``raw'' RGB subset of NetPBM) and converts them
|
that reads binary PGM and PPM files (the ``raw'' grayscale and RGB subsets
|
||||||
to PNG.
|
of PBMPLUS/NetPBM) and converts them to PNG.
|
||||||
|
|
||||||
The source code for all three demo programs currently compiles only under
|
The source code for all three demo programs currently compiles under
|
||||||
Unix and 32-bit Windows. It has been tested with gcc 2.7.2.3 under Linux and
|
Unix, OpenVMS, and 32-bit Windows. (Special thanks to Martin Zinser,
|
||||||
Solaris and with Microsoft Visual C++ 5.0 under Windows 95. Brief
|
zinser@decus.de, for making the necessary changes for OpenVMS and for
|
||||||
instructions for compiling the programs are included at the top of the
|
providing an appropriate build script.) Build instructions can be
|
||||||
makefiles; makefile.unx is the Unix version, and makefile.w32 is (you
|
found below.
|
||||||
guessed it!) the version for 32-bit Windows. libpng and zlib are required.
|
|
||||||
|
|
||||||
----------------------------------------------------------------------------
|
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
|
Makefile.unx Unix makefile
|
||||||
(even if you didn't buy the book--but feel free to do so at any time),
|
Makefile.w32 Windows (MSVC) makefile
|
||||||
subject to the terms of the following BSD-like license:
|
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,
|
rpng2-win.c Windows front end for the progressive viewer
|
||||||
express or implied. In no event shall the author or contributors
|
rpng2-x.c X front end for the progressive viewer
|
||||||
be held liable for any damages arising in any way from the use of
|
readpng2.c generic back end for the progressive viewer
|
||||||
this software.
|
readpng2.h header file for the progressive viewer
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any
|
wpng.c generic (text) front end for the converter
|
||||||
purpose, including commercial applications, and to alter it and
|
writepng.c generic back end for the converter
|
||||||
redistribute it freely, subject to the following restrictions:
|
writepng.h header file for the converter
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above
|
toucan.png transparent PNG for testing (by Stefan Schneider)
|
||||||
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:
|
|
||||||
|
|
||||||
This product includes software developed by Greg Roelofs
|
Note that the programs are designed to be functional, but their primary
|
||||||
and contributors for the book, "PNG: The Definitive
|
purpose is to demonstrate how to use libpng to add PNG support to other
|
||||||
Guide," published by O'Reilly and Associates.
|
programs. As such, their user interfaces are crude and definitely not
|
||||||
|
intended for everyday use.
|
||||||
|
|
||||||
----------------------------------------------------------
|
Please see http://www.cdrom.com/pub/png/pngbook.html for further infor-
|
||||||
http://www.cdrom.com/pub/png/book/sources.html
|
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.
|
||||||
|
53
contrib/gregbook/README.w32
Normal file
53
contrib/gregbook/README.w32
Normal 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
|
@ -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]"
|
$ zpath = "[-.zlib]"
|
||||||
$ ccopt="/include=(''zlibsrc',[--])"
|
$ 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
|
$ if f$getsyi("HW_MODEL").ge.1024
|
||||||
$ then
|
$ then
|
||||||
$ ccopt = "/prefix=all"+ccopt
|
$ ccopt = "/prefix=all"+ccopt
|
||||||
@ -29,13 +40,16 @@ $ comp = "__decc__=1"
|
|||||||
$ endif
|
$ endif
|
||||||
$ endif
|
$ endif
|
||||||
$ open/write lopt lib.opt
|
$ open/write lopt lib.opt
|
||||||
$ write lopt "[--]libpng.olb/lib"
|
$ write lopt "''pngpath'libpng.olb/lib"
|
||||||
$ write lopt "''zlibsrc'libz.olb/lib"
|
$ write lopt "''zpath'libz.olb/lib"
|
||||||
$ close lopt
|
$ close lopt
|
||||||
$ open/write xopt x11.opt
|
$ open/write xopt x11.opt
|
||||||
$ write xopt "sys$library:decw$xlibshr.exe/share"
|
$ write xopt "sys$library:decw$xlibshr.exe/share"
|
||||||
$ close xopt
|
$ 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" -
|
$ CALL MAKE readpng.OBJ "cc ''CCOPT' readpng" -
|
||||||
readpng.c readpng.h
|
readpng.c readpng.h
|
||||||
$ CALL MAKE readpng2.OBJ "cc ''CCOPT' readpng2" -
|
$ CALL MAKE readpng2.OBJ "cc ''CCOPT' readpng2" -
|
||||||
|
@ -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,
|
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
|
||||||
@ -35,6 +35,11 @@
|
|||||||
#include "png.h" /* libpng header; includes zlib.h */
|
#include "png.h" /* libpng header; includes zlib.h */
|
||||||
#include "readpng.h" /* typedefs, common macros, public prototypes */
|
#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;
|
static png_structp png_ptr = NULL;
|
||||||
static png_infop info_ptr = NULL;
|
static png_infop info_ptr = NULL;
|
||||||
@ -44,7 +49,7 @@ int bit_depth, color_type;
|
|||||||
uch *image_data = NULL;
|
uch *image_data = NULL;
|
||||||
|
|
||||||
|
|
||||||
void readpng_version_info()
|
void readpng_version_info(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n",
|
fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n",
|
||||||
PNG_LIBPNG_VER_STRING, png_libpng_ver);
|
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 */
|
/* 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];
|
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
|
/* setjmp() must be called in every function that calls a PNG-reading
|
||||||
* libpng function */
|
* libpng function */
|
||||||
|
|
||||||
if (setjmp(png_jmp_env(png_ptr))) {
|
if (setjmp(png_jmpbuf(png_ptr))) {
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
return 2;
|
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
|
/* setjmp() must be called in every function that calls a PNG-reading
|
||||||
* libpng function */
|
* libpng function */
|
||||||
|
|
||||||
if (setjmp(png_jmp_env(png_ptr))) {
|
if (setjmp(png_jmpbuf(png_ptr))) {
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
return 2;
|
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
|
/* setjmp() must be called in every function that calls a PNG-reading
|
||||||
* libpng function */
|
* libpng function */
|
||||||
|
|
||||||
if (setjmp(png_jmp_env(png_ptr))) {
|
if (setjmp(png_jmpbuf(png_ptr))) {
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -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,
|
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
|
||||||
@ -54,7 +54,7 @@ typedef unsigned long ulg;
|
|||||||
|
|
||||||
void readpng_version_info(void);
|
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);
|
int readpng_get_bgcolor(uch *bg_red, uch *bg_green, uch *bg_blue);
|
||||||
|
|
||||||
|
@ -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,
|
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
|
||||||
@ -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",
|
fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n",
|
||||||
PNG_LIBPNG_VER_STRING, png_libpng_ver);
|
PNG_LIBPNG_VER_STRING, png_libpng_ver);
|
||||||
@ -98,7 +98,7 @@ int readpng2_init(mainprog_info *mainprog_ptr)
|
|||||||
* but compatible error handlers must either use longjmp() themselves
|
* but compatible error handlers must either use longjmp() themselves
|
||||||
* (as in this program) or exit immediately, so here we are: */
|
* (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);
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
return 2;
|
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
|
/* setjmp() must be called in every function that calls a PNG-reading
|
||||||
* libpng function */
|
* libpng function */
|
||||||
|
|
||||||
if (setjmp(png_jmp_env(mainprog_ptr))) {
|
if (setjmp(mainprog_ptr->jmpbuf)) {
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
mainprog_ptr->png_ptr = NULL;
|
mainprog_ptr->png_ptr = NULL;
|
||||||
mainprog_ptr->info_ptr = NULL;
|
mainprog_ptr->info_ptr = NULL;
|
||||||
@ -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);
|
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);
|
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);
|
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
|
/* 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
|
* from previous passes (if interlaced) or else just copy the new row
|
||||||
* into the main program's image buffer */
|
* into the main program's image buffer */
|
||||||
|
@ -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,
|
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
|
||||||
@ -62,6 +62,7 @@ typedef struct _mainprog_info {
|
|||||||
uch **row_pointers;
|
uch **row_pointers;
|
||||||
jmp_buf jmpbuf;
|
jmp_buf jmpbuf;
|
||||||
int passes; /* not used */
|
int passes; /* not used */
|
||||||
|
int pass;
|
||||||
int rowbytes;
|
int rowbytes;
|
||||||
int channels;
|
int channels;
|
||||||
int need_bgcolor;
|
int need_bgcolor;
|
||||||
|
@ -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,
|
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
|
||||||
@ -43,7 +52,7 @@
|
|||||||
|
|
||||||
#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.0 of 20 February 1999"
|
#define VERSION "1.02 of 19 March 2000"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -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. */
|
/* Now parse the command line for options and the PNG filename. */
|
||||||
|
|
||||||
while (*++argv && !error) {
|
while (*++argv && !error) {
|
||||||
if (!strcmp(*argv, "-gamma")) {
|
if (!strncmp(*argv, "-gamma", 2)) {
|
||||||
if (!*++argv)
|
if (!*++argv)
|
||||||
++error;
|
++error;
|
||||||
|
else {
|
||||||
display_exponent = atof(*argv);
|
display_exponent = atof(*argv);
|
||||||
if (display_exponent <= 0.0)
|
if (display_exponent <= 0.0)
|
||||||
++error;
|
++error;
|
||||||
} else if (!strcmp(*argv, "-bgcolor")) {
|
}
|
||||||
|
} else if (!strncmp(*argv, "-bgcolor", 2)) {
|
||||||
if (!*++argv)
|
if (!*++argv)
|
||||||
++error;
|
++error;
|
||||||
|
else {
|
||||||
bgstr = *argv;
|
bgstr = *argv;
|
||||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||||
++error;
|
++error;
|
||||||
else
|
else
|
||||||
have_bg = TRUE;
|
have_bg = TRUE;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (**argv != '-') {
|
if (**argv != '-') {
|
||||||
filename = *argv;
|
filename = *argv;
|
||||||
@ -255,6 +268,9 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
|||||||
fclose(infile);
|
fclose(infile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* usage screen */
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
||||||
readpng_version_info();
|
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 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., ``#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"
|
"\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);
|
"\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 */
|
/* 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)) {
|
while (GetMessage(&msg, NULL, 0, 0)) {
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
This program decodes and displays PNG images, with gamma correction and
|
This program decodes and displays PNG images, with gamma correction and
|
||||||
optionally with a user-specified background color (in case the image has
|
optionally with a user-specified background color (in case the image has
|
||||||
transparency). It is very nearly the most basic PNG viewer possible.
|
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
|
This version is for the X Window System (tested by author under Unix and
|
||||||
under VMS or OS/2 with a little tweaking).
|
by Martin Zinser under OpenVMS; may work under OS/2 with some tweaking).
|
||||||
|
|
||||||
to do:
|
to do:
|
||||||
- 8-bit support
|
- 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,
|
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
|
||||||
@ -41,7 +51,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.01 of 31 March 1999"
|
#define VERSION "1.11 of 19 March 2000"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -95,15 +105,16 @@ static uch *image_data;
|
|||||||
static char *displayname;
|
static char *displayname;
|
||||||
static XImage *ximage;
|
static XImage *ximage;
|
||||||
static Display *display;
|
static Display *display;
|
||||||
static int bitmap_order;
|
|
||||||
static int depth;
|
static int depth;
|
||||||
static Visual *visual;
|
static Visual *visual;
|
||||||
static int RPixelShift, GPixelShift, BPixelShift;
|
static XVisualInfo *visual_list;
|
||||||
static ulg RedMask, GreenMask, BlueMask;
|
static int RShift, GShift, BShift;
|
||||||
|
static ulg RMask, GMask, BMask;
|
||||||
static Window window;
|
static Window window;
|
||||||
static GC gc;
|
static GC gc;
|
||||||
static Colormap colormap;
|
static Colormap colormap;
|
||||||
|
|
||||||
|
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;
|
||||||
/*
|
/*
|
||||||
@ -188,24 +199,29 @@ int main(int argc, char **argv)
|
|||||||
/* Now parse the command line for options and the PNG filename. */
|
/* Now parse the command line for options and the PNG filename. */
|
||||||
|
|
||||||
while (*++argv && !error) {
|
while (*++argv && !error) {
|
||||||
if (!strcmp(*argv, "-display")) {
|
if (!strncmp(*argv, "-display", 2)) {
|
||||||
if (!*++argv)
|
if (!*++argv)
|
||||||
++error;
|
++error;
|
||||||
|
else
|
||||||
displayname = *argv;
|
displayname = *argv;
|
||||||
} else if (!strcmp(*argv, "-gamma")) {
|
} else if (!strncmp(*argv, "-gamma", 2)) {
|
||||||
if (!*++argv)
|
if (!*++argv)
|
||||||
++error;
|
++error;
|
||||||
|
else {
|
||||||
display_exponent = atof(*argv);
|
display_exponent = atof(*argv);
|
||||||
if (display_exponent <= 0.0)
|
if (display_exponent <= 0.0)
|
||||||
++error;
|
++error;
|
||||||
} else if (!strcmp(*argv, "-bgcolor")) {
|
}
|
||||||
|
} else if (!strncmp(*argv, "-bgcolor", 2)) {
|
||||||
if (!*++argv)
|
if (!*++argv)
|
||||||
++error;
|
++error;
|
||||||
|
else {
|
||||||
bgstr = *argv;
|
bgstr = *argv;
|
||||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||||
++error;
|
++error;
|
||||||
else
|
else
|
||||||
have_bg = TRUE;
|
have_bg = TRUE;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (**argv != '-') {
|
if (**argv != '-') {
|
||||||
filename = *argv;
|
filename = *argv;
|
||||||
@ -222,8 +238,7 @@ int main(int argc, char **argv)
|
|||||||
fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename);
|
fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename);
|
||||||
++error;
|
++error;
|
||||||
} else {
|
} else {
|
||||||
if ((rc = readpng_init(infile, (long *)(&image_width),
|
if ((rc = readpng_init(infile, &image_width, &image_height)) != 0) {
|
||||||
(long *)(&image_height))) != 0) {
|
|
||||||
switch (rc) {
|
switch (rc) {
|
||||||
case 1:
|
case 1:
|
||||||
fprintf(stderr, PROGNAME
|
fprintf(stderr, PROGNAME
|
||||||
@ -257,6 +272,9 @@ int main(int argc, char **argv)
|
|||||||
fclose(infile);
|
fclose(infile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* usage screen */
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
||||||
readpng_version_info();
|
readpng_version_info();
|
||||||
@ -268,9 +286,10 @@ int main(int argc, char **argv)
|
|||||||
"\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., ``#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"
|
"\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 (within image window, after image\n"
|
||||||
|
"is displayed) to quit.\n"
|
||||||
"\n", PROGNAME, default_display_exponent);
|
"\n", PROGNAME, default_display_exponent);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -344,6 +363,10 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
/* wait for the user to tell us when to quit */
|
/* 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);
|
||||||
|
|
||||||
do
|
do
|
||||||
XNextEvent(display, &e);
|
XNextEvent(display, &e);
|
||||||
while (!(e.type == ButtonPress && e.xbutton.button == Button1) &&
|
while (!(e.type == ButtonPress && e.xbutton.button == Button1) &&
|
||||||
@ -362,11 +385,13 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int rpng_x_create_window()
|
static int rpng_x_create_window(void)
|
||||||
{
|
{
|
||||||
uch *xdata;
|
uch *xdata;
|
||||||
|
int need_colormap = FALSE;
|
||||||
int screen, pad;
|
int screen, pad;
|
||||||
ulg bg_pixel = 0L;
|
ulg bg_pixel = 0L;
|
||||||
|
ulg attrmask;
|
||||||
Window root;
|
Window root;
|
||||||
XEvent e;
|
XEvent e;
|
||||||
XGCValues gcvalues;
|
XGCValues gcvalues;
|
||||||
@ -378,11 +403,15 @@ static int rpng_x_create_window()
|
|||||||
XWMHints *wm_hints;
|
XWMHints *wm_hints;
|
||||||
|
|
||||||
|
|
||||||
bitmap_order = BitmapBitOrder(display);
|
|
||||||
screen = DefaultScreen(display);
|
screen = DefaultScreen(display);
|
||||||
depth = DisplayPlanes(display, screen);
|
depth = DisplayPlanes(display, screen);
|
||||||
root = RootWindow(display, screen);
|
root = RootWindow(display, screen);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
XSynchronize(display, True);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* GRR: add 8-bit support */
|
/* GRR: add 8-bit support */
|
||||||
if (/* depth != 8 && */ depth != 16 && depth != 24 && depth != 32) {
|
if (/* depth != 8 && */ depth != 16 && depth != 24 && depth != 32) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@ -394,27 +423,73 @@ static int rpng_x_create_window()
|
|||||||
XMatchVisualInfo(display, screen, depth,
|
XMatchVisualInfo(display, screen, depth,
|
||||||
(depth == 8)? PseudoColor : TrueColor, &visual_info);
|
(depth == 8)? PseudoColor : TrueColor, &visual_info);
|
||||||
visual = visual_info.visual;
|
visual = visual_info.visual;
|
||||||
|
#else
|
||||||
|
if (depth != 16 && depth != 24 && depth != 32) {
|
||||||
|
int visuals_matched = 0;
|
||||||
|
|
||||||
RedMask = visual->red_mask;
|
Trace((stderr, "default depth is %d: checking other visuals\n",
|
||||||
GreenMask = visual->green_mask;
|
depth))
|
||||||
BlueMask = visual->blue_mask;
|
|
||||||
|
/* 24-bit first */
|
||||||
|
visual_info.screen = screen;
|
||||||
|
visual_info.depth = 24;
|
||||||
|
visual_list = XGetVisualInfo(display,
|
||||||
|
VisualScreenMask | VisualDepthMask, &visual_info, &visuals_matched);
|
||||||
|
if (visuals_matched == 0) {
|
||||||
|
/* GRR: add 15-, 16- and 32-bit TrueColor visuals (also DirectColor?) */
|
||||||
|
fprintf(stderr, "default screen depth %d not supported, and no"
|
||||||
|
" 24-bit visuals found\n", depth);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
Trace((stderr, "XGetVisualInfo() returned %d 24-bit visuals\n",
|
||||||
|
visuals_matched))
|
||||||
|
visual = visual_list[0].visual;
|
||||||
|
depth = visual_list[0].depth;
|
||||||
|
/*
|
||||||
|
colormap_size = visual_list[0].colormap_size;
|
||||||
|
visual_class = visual->class;
|
||||||
|
visualID = XVisualIDFromVisual(visual);
|
||||||
|
*/
|
||||||
|
have_nondefault_visual = TRUE;
|
||||||
|
need_colormap = TRUE;
|
||||||
|
} else {
|
||||||
|
XMatchVisualInfo(display, screen, depth, TrueColor, &visual_info);
|
||||||
|
visual = visual_info.visual;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
RMask = visual->red_mask;
|
||||||
|
GMask = visual->green_mask;
|
||||||
|
BMask = visual->blue_mask;
|
||||||
|
|
||||||
/* GRR: add/check 8-bit support */
|
/* GRR: add/check 8-bit support */
|
||||||
if (depth == 8) {
|
if (depth == 8 || need_colormap) {
|
||||||
colormap = XCreateColormap(display, root, visual, AllocNone);
|
colormap = XCreateColormap(display, root, visual, AllocNone);
|
||||||
if (!colormap) {
|
if (!colormap) {
|
||||||
fprintf(stderr, "XCreateColormap() failed\n");
|
fprintf(stderr, "XCreateColormap() failed\n");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
have_colormap = TRUE;
|
have_colormap = TRUE;
|
||||||
} else if (depth == 16) {
|
}
|
||||||
RPixelShift = 15 - rpng_x_msb(RedMask); /* these are right-shifts */
|
if (depth == 15 || depth == 16) {
|
||||||
GPixelShift = 15 - rpng_x_msb(GreenMask);
|
RShift = 15 - rpng_x_msb(RMask); /* these are right-shifts */
|
||||||
BPixelShift = 15 - rpng_x_msb(BlueMask);
|
GShift = 15 - rpng_x_msb(GMask);
|
||||||
} else /* if (depth > 16) */ {
|
BShift = 15 - rpng_x_msb(BMask);
|
||||||
RPixelShift = rpng_x_msb(RedMask) - 7; /* these are left-shifts */
|
} else if (depth > 16) {
|
||||||
GPixelShift = rpng_x_msb(GreenMask) - 7;
|
#define NO_24BIT_MASKS
|
||||||
BPixelShift = rpng_x_msb(BlueMask) - 7;
|
#ifdef NO_24BIT_MASKS
|
||||||
|
RShift = rpng_x_msb(RMask) - 7; /* these are left-shifts */
|
||||||
|
GShift = rpng_x_msb(GMask) - 7;
|
||||||
|
BShift = rpng_x_msb(BMask) - 7;
|
||||||
|
#else
|
||||||
|
RShift = 7 - rpng_x_msb(RMask); /* these are right-shifts, too */
|
||||||
|
GShift = 7 - rpng_x_msb(GMask);
|
||||||
|
BShift = 7 - rpng_x_msb(BMask);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (depth >= 15 && (RShift < 0 || GShift < 0 || BShift < 0)) {
|
||||||
|
fprintf(stderr, "rpng internal logic error: negative X shift(s)!\n");
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------
|
/*---------------------------------------------------------------------------
|
||||||
@ -423,9 +498,16 @@ static int rpng_x_create_window()
|
|||||||
|
|
||||||
attr.backing_store = Always;
|
attr.backing_store = Always;
|
||||||
attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask;
|
attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask;
|
||||||
|
attrmask = CWBackingStore | CWEventMask;
|
||||||
|
if (have_nondefault_visual) {
|
||||||
|
attr.colormap = colormap;
|
||||||
|
attr.background_pixel = 0;
|
||||||
|
attr.border_pixel = 1;
|
||||||
|
attrmask |= CWColormap | CWBackPixel | CWBorderPixel;
|
||||||
|
}
|
||||||
|
|
||||||
window = XCreateWindow(display, root, 0, 0, image_width, image_height,
|
window = XCreateWindow(display, root, 0, 0, image_width, image_height, 0,
|
||||||
0, depth, InputOutput, visual, CWBackingStore | CWEventMask, &attr);
|
depth, InputOutput, visual, attrmask, &attr);
|
||||||
|
|
||||||
if (window == None) {
|
if (window == None) {
|
||||||
fprintf(stderr, "XCreateWindow() failed\n");
|
fprintf(stderr, "XCreateWindow() failed\n");
|
||||||
@ -446,8 +528,8 @@ static int rpng_x_create_window()
|
|||||||
if ((size_hints = XAllocSizeHints()) != NULL) {
|
if ((size_hints = XAllocSizeHints()) != NULL) {
|
||||||
/* window will not be resizable */
|
/* window will not be resizable */
|
||||||
size_hints->flags = PMinSize | PMaxSize;
|
size_hints->flags = PMinSize | PMaxSize;
|
||||||
size_hints->min_width = size_hints->max_width = image_width;
|
size_hints->min_width = size_hints->max_width = (int)image_width;
|
||||||
size_hints->min_height = size_hints->max_height = image_height;
|
size_hints->min_height = size_hints->max_height = (int)image_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((wm_hints = XAllocWMHints()) != NULL) {
|
if ((wm_hints = XAllocWMHints()) != NULL) {
|
||||||
@ -469,13 +551,13 @@ static int rpng_x_create_window()
|
|||||||
---------------------------------------------------------------------------*/
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
if (depth == 24 || depth == 32) {
|
if (depth == 24 || depth == 32) {
|
||||||
bg_pixel = ((ulg)bg_red << RPixelShift) |
|
bg_pixel = ((ulg)bg_red << RShift) |
|
||||||
((ulg)bg_green << GPixelShift) |
|
((ulg)bg_green << GShift) |
|
||||||
((ulg)bg_blue << BPixelShift);
|
((ulg)bg_blue << BShift);
|
||||||
} else if (depth == 16) {
|
} else if (depth == 16) {
|
||||||
bg_pixel = ((((ulg)bg_red << 8) >> RPixelShift) & RedMask) |
|
bg_pixel = ((((ulg)bg_red << 8) >> RShift) & RMask) |
|
||||||
((((ulg)bg_green << 8) >> GPixelShift) & GreenMask) |
|
((((ulg)bg_green << 8) >> GShift) & GMask) |
|
||||||
((((ulg)bg_blue << 8) >> BPixelShift) & BlueMask);
|
((((ulg)bg_blue << 8) >> BShift) & BMask);
|
||||||
} else /* depth == 8 */ {
|
} else /* depth == 8 */ {
|
||||||
|
|
||||||
/* GRR: add 8-bit support */
|
/* GRR: add 8-bit support */
|
||||||
@ -524,7 +606,7 @@ static int rpng_x_create_window()
|
|||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* to avoid testing the bitmap_order every pixel (or doubling the size of
|
/* to avoid testing the byte order every pixel (or doubling the size of
|
||||||
* the drawing routine with a giant if-test), we arbitrarily set the byte
|
* the drawing routine with a giant if-test), we arbitrarily set the byte
|
||||||
* order to MSBFirst and let Xlib worry about inverting things on little-
|
* order to MSBFirst and let Xlib worry about inverting things on little-
|
||||||
* endian machines (like Linux/x86, old VAXen, etc.)--this is not the most
|
* endian machines (like Linux/x86, old VAXen, etc.)--this is not the most
|
||||||
@ -541,20 +623,24 @@ static int rpng_x_create_window()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int rpng_x_display_image()
|
static int rpng_x_display_image(void)
|
||||||
{
|
{
|
||||||
uch *src;
|
uch *src;
|
||||||
char *dest;
|
char *dest;
|
||||||
uch r, g, b, a;
|
uch r, g, b, a;
|
||||||
int ximage_rowbytes = ximage->bytes_per_line;
|
|
||||||
ulg i, row, lastrow = 0;
|
ulg i, row, lastrow = 0;
|
||||||
ulg pixel;
|
ulg pixel;
|
||||||
|
int ximage_rowbytes = ximage->bytes_per_line;
|
||||||
|
/* int bpp = ximage->bits_per_pixel; */
|
||||||
|
|
||||||
|
|
||||||
Trace((stderr, "beginning display loop (image_channels == %d)\n",
|
Trace((stderr, "beginning display loop (image_channels == %d)\n",
|
||||||
image_channels))
|
image_channels))
|
||||||
Trace((stderr, "(width = %ld, rowbytes = %ld, ximage_rowbytes = %d)\n",
|
Trace((stderr, " (width = %ld, rowbytes = %ld, ximage_rowbytes = %d)\n",
|
||||||
image_width, image_rowbytes, ximage_rowbytes))
|
image_width, image_rowbytes, ximage_rowbytes))
|
||||||
|
Trace((stderr, " (bpp = %d)\n", ximage->bits_per_pixel))
|
||||||
|
Trace((stderr, " (byte_order = %s)\n", ximage->byte_order == MSBFirst?
|
||||||
|
"MSBFirst" : (ximage->byte_order == LSBFirst? "LSBFirst" : "unknown")))
|
||||||
|
|
||||||
if (depth == 24 || depth == 32) {
|
if (depth == 24 || depth == 32) {
|
||||||
ulg red, green, blue;
|
ulg red, green, blue;
|
||||||
@ -567,14 +653,27 @@ static int rpng_x_display_image()
|
|||||||
red = *src++;
|
red = *src++;
|
||||||
green = *src++;
|
green = *src++;
|
||||||
blue = *src++;
|
blue = *src++;
|
||||||
pixel = (red << RPixelShift) |
|
#ifdef NO_24BIT_MASKS
|
||||||
(green << GPixelShift) |
|
pixel = (red << RShift) |
|
||||||
(blue << BPixelShift);
|
(green << GShift) |
|
||||||
|
(blue << BShift);
|
||||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||||
*dest++ = ((uch *)&pixel)[3];
|
/* GRR BUG: this assumes bpp == 32, but may be 24: */
|
||||||
*dest++ = ((uch *)&pixel)[2];
|
*dest++ = (char)((pixel >> 24) & 0xff);
|
||||||
*dest++ = ((uch *)&pixel)[1];
|
*dest++ = (char)((pixel >> 16) & 0xff);
|
||||||
*dest++ = ((uch *)&pixel)[0];
|
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||||
|
*dest++ = (char)( pixel & 0xff);
|
||||||
|
#else
|
||||||
|
red = (RShift < 0)? red << (-RShift) : red >> RShift;
|
||||||
|
green = (GShift < 0)? green << (-GShift) : green >> GShift;
|
||||||
|
blue = (BShift < 0)? blue << (-BShift) : blue >> BShift;
|
||||||
|
pixel = (red & RMask) | (green & GMask) | (blue & BMask);
|
||||||
|
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||||
|
*dest++ = (char)((pixel >> 24) & 0xff);
|
||||||
|
*dest++ = (char)((pixel >> 16) & 0xff);
|
||||||
|
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||||
|
*dest++ = (char)( pixel & 0xff);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} else /* if (image_channels == 4) */ {
|
} else /* if (image_channels == 4) */ {
|
||||||
for (i = image_width; i > 0; --i) {
|
for (i = image_width; i > 0; --i) {
|
||||||
@ -598,20 +697,20 @@ static int rpng_x_display_image()
|
|||||||
alpha_composite(green, g, a, bg_green);
|
alpha_composite(green, g, a, bg_green);
|
||||||
alpha_composite(blue, b, a, bg_blue);
|
alpha_composite(blue, b, a, bg_blue);
|
||||||
}
|
}
|
||||||
pixel = (red << RPixelShift) |
|
pixel = (red << RShift) |
|
||||||
(green << GPixelShift) |
|
(green << GShift) |
|
||||||
(blue << BPixelShift);
|
(blue << BShift);
|
||||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||||
*dest++ = ((uch *)&pixel)[3];
|
*dest++ = (char)((pixel >> 24) & 0xff);
|
||||||
*dest++ = ((uch *)&pixel)[2];
|
*dest++ = (char)((pixel >> 16) & 0xff);
|
||||||
*dest++ = ((uch *)&pixel)[1];
|
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||||
*dest++ = ((uch *)&pixel)[0];
|
*dest++ = (char)( pixel & 0xff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* display after every 16 lines */
|
/* display after every 16 lines */
|
||||||
if (((row+1) & 0xf) == 0) {
|
if (((row+1) & 0xf) == 0) {
|
||||||
XPutImage(display, window, gc, ximage, 0, lastrow, 0, lastrow,
|
XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0,
|
||||||
image_width, 16);
|
(int)lastrow, image_width, 16);
|
||||||
XFlush(display);
|
XFlush(display);
|
||||||
lastrow = row + 1;
|
lastrow = row + 1;
|
||||||
}
|
}
|
||||||
@ -631,12 +730,12 @@ static int rpng_x_display_image()
|
|||||||
++src;
|
++src;
|
||||||
blue = ((ush)(*src) << 8);
|
blue = ((ush)(*src) << 8);
|
||||||
++src;
|
++src;
|
||||||
pixel = ((red >> RPixelShift) & RedMask) |
|
pixel = ((red >> RShift) & RMask) |
|
||||||
((green >> GPixelShift) & GreenMask) |
|
((green >> GShift) & GMask) |
|
||||||
((blue >> BPixelShift) & BlueMask);
|
((blue >> BShift) & BMask);
|
||||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||||
*dest++ = ((uch *)&pixel)[1];
|
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||||
*dest++ = ((uch *)&pixel)[0];
|
*dest++ = (char)( pixel & 0xff);
|
||||||
}
|
}
|
||||||
} else /* if (image_channels == 4) */ {
|
} else /* if (image_channels == 4) */ {
|
||||||
for (i = image_width; i > 0; --i) {
|
for (i = image_width; i > 0; --i) {
|
||||||
@ -663,18 +762,18 @@ static int rpng_x_display_image()
|
|||||||
green = ((ush)g << 8);
|
green = ((ush)g << 8);
|
||||||
blue = ((ush)b << 8);
|
blue = ((ush)b << 8);
|
||||||
}
|
}
|
||||||
pixel = ((red >> RPixelShift) & RedMask) |
|
pixel = ((red >> RShift) & RMask) |
|
||||||
((green >> GPixelShift) & GreenMask) |
|
((green >> GShift) & GMask) |
|
||||||
((blue >> BPixelShift) & BlueMask);
|
((blue >> BShift) & BMask);
|
||||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||||
*dest++ = ((uch *)&pixel)[1];
|
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||||
*dest++ = ((uch *)&pixel)[0];
|
*dest++ = (char)( pixel & 0xff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* display after every 16 lines */
|
/* display after every 16 lines */
|
||||||
if (((row+1) & 0xf) == 0) {
|
if (((row+1) & 0xf) == 0) {
|
||||||
XPutImage(display, window, gc, ximage, 0, lastrow, 0, lastrow,
|
XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0,
|
||||||
image_width, 16);
|
(int)lastrow, image_width, 16);
|
||||||
XFlush(display);
|
XFlush(display);
|
||||||
lastrow = row + 1;
|
lastrow = row + 1;
|
||||||
}
|
}
|
||||||
@ -688,8 +787,8 @@ static int rpng_x_display_image()
|
|||||||
|
|
||||||
Trace((stderr, "calling final XPutImage()\n"))
|
Trace((stderr, "calling final XPutImage()\n"))
|
||||||
if (lastrow < image_height) {
|
if (lastrow < image_height) {
|
||||||
XPutImage(display, window, gc, ximage, 0, lastrow, 0, lastrow,
|
XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0,
|
||||||
image_width, image_height-lastrow);
|
(int)lastrow, image_width, image_height-lastrow);
|
||||||
XFlush(display);
|
XFlush(display);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -699,7 +798,7 @@ static int rpng_x_display_image()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void rpng_x_cleanup()
|
static void rpng_x_cleanup(void)
|
||||||
{
|
{
|
||||||
if (image_data) {
|
if (image_data) {
|
||||||
free(image_data);
|
free(image_data);
|
||||||
@ -722,6 +821,9 @@ static void rpng_x_cleanup()
|
|||||||
|
|
||||||
if (have_colormap)
|
if (have_colormap)
|
||||||
XFreeColormap(display, colormap);
|
XFreeColormap(display, colormap);
|
||||||
|
|
||||||
|
if (have_nondefault_visual)
|
||||||
|
XFree(visual_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,10 +22,13 @@
|
|||||||
Changelog:
|
Changelog:
|
||||||
- 1.01: initial public release
|
- 1.01: initial public release
|
||||||
- 1.02: fixed cut-and-paste error in usage screen (oops...)
|
- 1.02: fixed cut-and-paste error in usage screen (oops...)
|
||||||
|
- 1.03: modified to allow abbreviated options
|
||||||
|
- 1.04: removed bogus extra argument from usage fprintf() [Glenn R-P?];
|
||||||
|
fixed command-line parsing bug
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
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,
|
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,7 +55,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.02 of 22 September 1999"
|
#define VERSION "1.04 of 19 March 2000"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -213,7 +216,8 @@ static int global_showmode;
|
|||||||
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
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, *bgstr = NULL, **argv = args;
|
char **argv = args;
|
||||||
|
char *p, *q, *bgstr = NULL;
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
int rc, alen, flen;
|
int rc, alen, flen;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
@ -316,15 +320,18 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
|||||||
/* Now parse the command line for options and the PNG filename. */
|
/* Now parse the command line for options and the PNG filename. */
|
||||||
|
|
||||||
while (*++argv && !error) {
|
while (*++argv && !error) {
|
||||||
if (!strcmp(*argv, "-gamma")) {
|
if (!strncmp(*argv, "-gamma", 2)) {
|
||||||
if (!*++argv)
|
if (!*++argv)
|
||||||
++error;
|
++error;
|
||||||
|
else {
|
||||||
rpng2_info.display_exponent = atof(*argv);
|
rpng2_info.display_exponent = atof(*argv);
|
||||||
if (rpng2_info.display_exponent <= 0.0)
|
if (rpng2_info.display_exponent <= 0.0)
|
||||||
++error;
|
++error;
|
||||||
} else if (!strcmp(*argv, "-bgcolor")) {
|
}
|
||||||
|
} else if (!strncmp(*argv, "-bgcolor", 4)) {
|
||||||
if (!*++argv)
|
if (!*++argv)
|
||||||
++error;
|
++error;
|
||||||
|
else {
|
||||||
bgstr = *argv;
|
bgstr = *argv;
|
||||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||||
++error;
|
++error;
|
||||||
@ -332,9 +339,11 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
|||||||
have_bg = TRUE;
|
have_bg = TRUE;
|
||||||
bg_image = FALSE;
|
bg_image = FALSE;
|
||||||
}
|
}
|
||||||
} else if (!strcmp(*argv, "-bgpat")) {
|
}
|
||||||
|
} else if (!strncmp(*argv, "-bgpat", 4)) {
|
||||||
if (!*++argv)
|
if (!*++argv)
|
||||||
++error;
|
++error;
|
||||||
|
else {
|
||||||
pat = atoi(*argv) - 1;
|
pat = atoi(*argv) - 1;
|
||||||
if (pat < 0 || pat >= num_bgpat)
|
if (pat < 0 || pat >= num_bgpat)
|
||||||
++error;
|
++error;
|
||||||
@ -342,7 +351,8 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
|||||||
bg_image = TRUE;
|
bg_image = TRUE;
|
||||||
have_bg = FALSE;
|
have_bg = FALSE;
|
||||||
}
|
}
|
||||||
} else if (!strcmp(*argv, "-timing")) {
|
}
|
||||||
|
} else if (!strncmp(*argv, "-timing", 2)) {
|
||||||
timing = TRUE;
|
timing = TRUE;
|
||||||
} else {
|
} else {
|
||||||
if (**argv != '-') {
|
if (**argv != '-') {
|
||||||
@ -387,6 +397,9 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
|||||||
fclose(infile);
|
fclose(infile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* usage screen */
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
||||||
readpng2_version_info();
|
readpng2_version_info();
|
||||||
@ -398,14 +411,14 @@ 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 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., ``#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; overrides -bgpat\n"
|
"\t\t used with transparent images; overrides -bgpat\n"
|
||||||
" pat \tdesired background pattern number (1-%d); used with\n"
|
" pat \tdesired background pattern number (1-%d); used with\n"
|
||||||
"\t\t transparent images; overrides -bgcolor\n"
|
"\t\t transparent images; overrides -bgcolor\n"
|
||||||
" -timing\tenables delay for every block read, to simulate modem\n"
|
" -timing\tenables delay for every block read, to simulate modem\n"
|
||||||
"\t\t download of image (~36 Kbps)\n"
|
"\t\t download of image (~36 Kbps)\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, num_bgpat);
|
"\n", PROGNAME, default_display_exponent, num_bgpat);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1028,7 +1041,9 @@ static void rpng2_win_finish_display()
|
|||||||
* that the image is done */
|
* that the image is done */
|
||||||
|
|
||||||
rpng2_info.done = TRUE;
|
rpng2_info.done = TRUE;
|
||||||
printf("Done. Press Q, Esc or mouse button 1 to quit.\n");
|
printf(
|
||||||
|
"Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n");
|
||||||
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,9 +6,11 @@
|
|||||||
a web browser (though the front end is only set up to read from files).
|
a web browser (though the front end is only set up to read from files).
|
||||||
It supports gamma correction, user-specified background colors, and user-
|
It supports gamma correction, user-specified background colors, and user-
|
||||||
specified background patterns (for transparent images). This version is
|
specified background patterns (for transparent images). This version is
|
||||||
for the X Window System (tested under Unix, but may work under VMS or OS/2
|
for the X Window System (tested by the author under Unix and by Martin
|
||||||
with a little tweaking). Thanks to Adam Costello and Pieter S. van der
|
Zinser under OpenVMS; may work under OS/2 with a little tweaking).
|
||||||
Meulen for the "diamond" and "radial waves" patterns, respectively.
|
|
||||||
|
Thanks to Adam Costello and Pieter S. van der Meulen for the "diamond"
|
||||||
|
and "radial waves" patterns, respectively.
|
||||||
|
|
||||||
to do:
|
to do:
|
||||||
- 8-bit support
|
- 8-bit support
|
||||||
@ -17,7 +19,16 @@
|
|||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
Changelog:
|
||||||
|
- 1.01: initial public release
|
||||||
|
- 1.02: modified to allow abbreviated options; fixed char/uchar mismatch
|
||||||
|
- 1.10: added support for non-default visuals; fixed X pixel-conversion
|
||||||
|
- 1.11: added -usleep option for demos; fixed command-line parsing bug
|
||||||
|
- 1.12: added -pause option for demos and testing
|
||||||
|
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 1998-2000 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
|
||||||
@ -44,7 +55,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.01 of 31 March 1999"
|
#define VERSION "1.12 of 19 March 2000"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -58,7 +69,7 @@
|
|||||||
#include <X11/keysym.h> /* defines XK_* macros */
|
#include <X11/keysym.h> /* defines XK_* macros */
|
||||||
|
|
||||||
#ifdef VMS
|
#ifdef VMS
|
||||||
#include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* all for PvdM background code: */
|
/* all for PvdM background code: */
|
||||||
@ -129,6 +140,10 @@ static int bgscale = 16;
|
|||||||
static ulg bg_rowbytes;
|
static ulg bg_rowbytes;
|
||||||
static uch *bg_data;
|
static uch *bg_data;
|
||||||
|
|
||||||
|
int pause_after_pass = FALSE;
|
||||||
|
int demo_timing = FALSE;
|
||||||
|
ulg usleep_duration = 0L;
|
||||||
|
|
||||||
static struct rgb_color {
|
static struct rgb_color {
|
||||||
uch r, g, b;
|
uch r, g, b;
|
||||||
} rgb[] = {
|
} rgb[] = {
|
||||||
@ -201,12 +216,14 @@ static XImage *ximage;
|
|||||||
static Display *display;
|
static Display *display;
|
||||||
static int depth;
|
static int depth;
|
||||||
static Visual *visual;
|
static Visual *visual;
|
||||||
static int RPixelShift, GPixelShift, BPixelShift;
|
static XVisualInfo *visual_list;
|
||||||
static ulg RedMask, GreenMask, BlueMask;
|
static int RShift, GShift, BShift;
|
||||||
|
static ulg RMask, GMask, BMask;
|
||||||
static Window window;
|
static Window window;
|
||||||
static GC gc;
|
static GC gc;
|
||||||
static Colormap colormap;
|
static Colormap colormap;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
@ -294,19 +311,23 @@ int main(int argc, char **argv)
|
|||||||
/* Now parse the command line for options and the PNG filename. */
|
/* Now parse the command line for options and the PNG filename. */
|
||||||
|
|
||||||
while (*++argv && !error) {
|
while (*++argv && !error) {
|
||||||
if (!strcmp(*argv, "-display")) {
|
if (!strncmp(*argv, "-display", 2)) {
|
||||||
if (!*++argv)
|
if (!*++argv)
|
||||||
++error;
|
++error;
|
||||||
|
else
|
||||||
displayname = *argv;
|
displayname = *argv;
|
||||||
} else if (!strcmp(*argv, "-gamma")) {
|
} else if (!strncmp(*argv, "-gamma", 2)) {
|
||||||
if (!*++argv)
|
if (!*++argv)
|
||||||
++error;
|
++error;
|
||||||
|
else {
|
||||||
rpng2_info.display_exponent = atof(*argv);
|
rpng2_info.display_exponent = atof(*argv);
|
||||||
if (rpng2_info.display_exponent <= 0.0)
|
if (rpng2_info.display_exponent <= 0.0)
|
||||||
++error;
|
++error;
|
||||||
} else if (!strcmp(*argv, "-bgcolor")) {
|
}
|
||||||
|
} else if (!strncmp(*argv, "-bgcolor", 4)) {
|
||||||
if (!*++argv)
|
if (!*++argv)
|
||||||
++error;
|
++error;
|
||||||
|
else {
|
||||||
bgstr = *argv;
|
bgstr = *argv;
|
||||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||||
++error;
|
++error;
|
||||||
@ -314,9 +335,11 @@ int main(int argc, char **argv)
|
|||||||
have_bg = TRUE;
|
have_bg = TRUE;
|
||||||
bg_image = FALSE;
|
bg_image = FALSE;
|
||||||
}
|
}
|
||||||
} else if (!strcmp(*argv, "-bgpat")) {
|
}
|
||||||
|
} else if (!strncmp(*argv, "-bgpat", 4)) {
|
||||||
if (!*++argv)
|
if (!*++argv)
|
||||||
++error;
|
++error;
|
||||||
|
else {
|
||||||
pat = atoi(*argv) - 1;
|
pat = atoi(*argv) - 1;
|
||||||
if (pat < 0 || pat >= num_bgpat)
|
if (pat < 0 || pat >= num_bgpat)
|
||||||
++error;
|
++error;
|
||||||
@ -324,7 +347,17 @@ int main(int argc, char **argv)
|
|||||||
bg_image = TRUE;
|
bg_image = TRUE;
|
||||||
have_bg = FALSE;
|
have_bg = FALSE;
|
||||||
}
|
}
|
||||||
} else if (!strcmp(*argv, "-timing")) {
|
}
|
||||||
|
} else if (!strncmp(*argv, "-usleep", 2)) {
|
||||||
|
if (!*++argv)
|
||||||
|
++error;
|
||||||
|
else {
|
||||||
|
usleep_duration = (ulg)atol(*argv);
|
||||||
|
demo_timing = TRUE;
|
||||||
|
}
|
||||||
|
} else if (!strncmp(*argv, "-pause", 2)) {
|
||||||
|
pause_after_pass = TRUE;
|
||||||
|
} else if (!strncmp(*argv, "-timing", 2)) {
|
||||||
timing = TRUE;
|
timing = TRUE;
|
||||||
} else {
|
} else {
|
||||||
if (**argv != '-') {
|
if (**argv != '-') {
|
||||||
@ -377,25 +410,32 @@ int main(int argc, char **argv)
|
|||||||
fclose(infile);
|
fclose(infile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* usage screen */
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
||||||
readpng2_version_info();
|
readpng2_version_info();
|
||||||
fprintf(stderr, "\n"
|
fprintf(stderr, "\n"
|
||||||
"Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg | -bgpat pat]\n"
|
"Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg | -bgpat pat]\n"
|
||||||
" %*s [-timing] file.png\n\n"
|
" %*s [-usleep dur | -timing] [-pause] file.png\n\n"
|
||||||
" xdpy\tname of the target X display (e.g., ``hostname:0'')\n"
|
" xdpy\tname of the target X display (e.g., ``hostname:0'')\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., ``#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; overrides -bgpat\n"
|
"\t\t used with transparent images; overrides -bgpat\n"
|
||||||
" pat \tdesired background pattern number (1-%d); used with\n"
|
" pat \tdesired background pattern number (1-%d); used with\n"
|
||||||
"\t\t transparent images; overrides -bgcolor\n"
|
"\t\t transparent images; overrides -bgcolor\n"
|
||||||
|
" dur \tduration in microseconds to wait after displaying each\n"
|
||||||
|
"\t\t row (for demo purposes)\n"
|
||||||
" -timing\tenables delay for every block read, to simulate modem\n"
|
" -timing\tenables delay for every block read, to simulate modem\n"
|
||||||
"\t\t download of image (~36 Kbps)\n"
|
"\t\t download of image (~36 Kbps)\n"
|
||||||
"\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n"
|
" -pause\tpauses after displaying each pass until key pressed\n"
|
||||||
|
"\nPress Q, Esc or mouse button 1 (within image window, after image\n"
|
||||||
|
"is displayed) to quit.\n"
|
||||||
"\n", PROGNAME, strlen(PROGNAME), " ", default_display_exponent,
|
"\n", PROGNAME, strlen(PROGNAME), " ", default_display_exponent,
|
||||||
num_bgpat);
|
num_bgpat);
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -489,7 +529,7 @@ int main(int argc, char **argv)
|
|||||||
* in turn is called by libpng after all of the pre-IDAT chunks have been
|
* in turn is called by libpng after all of the pre-IDAT chunks have been
|
||||||
* read and processed--i.e., we now have enough info to finish initializing */
|
* read and processed--i.e., we now have enough info to finish initializing */
|
||||||
|
|
||||||
static void rpng2_x_init()
|
static void rpng2_x_init(void)
|
||||||
{
|
{
|
||||||
ulg i;
|
ulg i;
|
||||||
ulg rowbytes = rpng2_info.rowbytes;
|
ulg rowbytes = rpng2_info.rowbytes;
|
||||||
@ -531,12 +571,14 @@ static void rpng2_x_init()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int rpng2_x_create_window()
|
static int rpng2_x_create_window(void)
|
||||||
{
|
{
|
||||||
ulg bg_red = rpng2_info.bg_red;
|
ulg bg_red = rpng2_info.bg_red;
|
||||||
ulg bg_green = rpng2_info.bg_green;
|
ulg bg_green = rpng2_info.bg_green;
|
||||||
ulg bg_blue = rpng2_info.bg_blue;
|
ulg bg_blue = rpng2_info.bg_blue;
|
||||||
ulg bg_pixel = 0L;
|
ulg bg_pixel = 0L;
|
||||||
|
ulg attrmask;
|
||||||
|
int need_colormap = FALSE;
|
||||||
int screen, pad;
|
int screen, pad;
|
||||||
uch *xdata;
|
uch *xdata;
|
||||||
Window root;
|
Window root;
|
||||||
@ -556,39 +598,70 @@ static int rpng2_x_create_window()
|
|||||||
depth = DisplayPlanes(display, screen);
|
depth = DisplayPlanes(display, screen);
|
||||||
root = RootWindow(display, screen);
|
root = RootWindow(display, screen);
|
||||||
|
|
||||||
/* GRR: add 8-bit support */
|
#ifdef DEBUG
|
||||||
if (/* depth != 8 && */ depth != 16 && depth != 24 && depth != 32) {
|
XSynchronize(display, True);
|
||||||
fprintf(stderr,
|
#endif
|
||||||
"screen depth %d not supported (only 16-, 24- or 32-bit TrueColor)\n",
|
|
||||||
depth);
|
if (depth != 16 && depth != 24 && depth != 32) {
|
||||||
|
int visuals_matched = 0;
|
||||||
|
|
||||||
|
Trace((stderr, "default depth is %d: checking other visuals\n",
|
||||||
|
depth))
|
||||||
|
|
||||||
|
/* 24-bit first */
|
||||||
|
visual_info.screen = screen;
|
||||||
|
visual_info.depth = 24;
|
||||||
|
visual_list = XGetVisualInfo(display,
|
||||||
|
VisualScreenMask | VisualDepthMask, &visual_info, &visuals_matched);
|
||||||
|
if (visuals_matched == 0) {
|
||||||
|
/* GRR: add 15-, 16- and 32-bit TrueColor visuals (also DirectColor?) */
|
||||||
|
fprintf(stderr, "default screen depth %d not supported, and no"
|
||||||
|
" 24-bit visuals found\n", depth);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
Trace((stderr, "XGetVisualInfo() returned %d 24-bit visuals\n",
|
||||||
XMatchVisualInfo(display, screen, depth,
|
visuals_matched))
|
||||||
(depth == 8)? PseudoColor : TrueColor, &visual_info);
|
visual = visual_list[0].visual;
|
||||||
|
depth = visual_list[0].depth;
|
||||||
|
/*
|
||||||
|
colormap_size = visual_list[0].colormap_size;
|
||||||
|
visual_class = visual->class;
|
||||||
|
visualID = XVisualIDFromVisual(visual);
|
||||||
|
*/
|
||||||
|
have_nondefault_visual = TRUE;
|
||||||
|
need_colormap = TRUE;
|
||||||
|
} else {
|
||||||
|
XMatchVisualInfo(display, screen, depth, TrueColor, &visual_info);
|
||||||
visual = visual_info.visual;
|
visual = visual_info.visual;
|
||||||
|
}
|
||||||
|
|
||||||
RedMask = visual->red_mask;
|
RMask = visual->red_mask;
|
||||||
GreenMask = visual->green_mask;
|
GMask = visual->green_mask;
|
||||||
BlueMask = visual->blue_mask;
|
BMask = visual->blue_mask;
|
||||||
|
|
||||||
/* GRR: add/check 8-bit support */
|
/* GRR: add/check 8-bit support */
|
||||||
if (depth == 8) {
|
if (depth == 8 || need_colormap) {
|
||||||
colormap = XCreateColormap(display, root, visual, AllocNone);
|
colormap = XCreateColormap(display, root, visual, AllocNone);
|
||||||
if (!colormap) {
|
if (!colormap) {
|
||||||
fprintf(stderr, "XCreateColormap() failed\n");
|
fprintf(stderr, "XCreateColormap() failed\n");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
have_colormap = TRUE;
|
have_colormap = TRUE;
|
||||||
|
if (depth == 8)
|
||||||
bg_image = FALSE; /* gradient just wastes palette entries */
|
bg_image = FALSE; /* gradient just wastes palette entries */
|
||||||
} else if (depth == 16) {
|
}
|
||||||
RPixelShift = 15 - rpng2_x_msb(RedMask); /* these are right-shifts */
|
if (depth == 15 || depth == 16) {
|
||||||
GPixelShift = 15 - rpng2_x_msb(GreenMask);
|
RShift = 15 - rpng2_x_msb(RMask); /* these are right-shifts */
|
||||||
BPixelShift = 15 - rpng2_x_msb(BlueMask);
|
GShift = 15 - rpng2_x_msb(GMask);
|
||||||
} else /* if (depth > 16) */ {
|
BShift = 15 - rpng2_x_msb(BMask);
|
||||||
RPixelShift = rpng2_x_msb(RedMask) - 7; /* these are left-shifts */
|
} else if (depth > 16) {
|
||||||
GPixelShift = rpng2_x_msb(GreenMask) - 7;
|
RShift = rpng2_x_msb(RMask) - 7; /* these are left-shifts */
|
||||||
BPixelShift = rpng2_x_msb(BlueMask) - 7;
|
GShift = rpng2_x_msb(GMask) - 7;
|
||||||
|
BShift = rpng2_x_msb(BMask) - 7;
|
||||||
|
}
|
||||||
|
if (depth >= 15 && (RShift < 0 || GShift < 0 || BShift < 0)) {
|
||||||
|
fprintf(stderr, "rpng2 internal logic error: negative X shift(s)!\n");
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------
|
/*---------------------------------------------------------------------------
|
||||||
@ -597,10 +670,16 @@ static int rpng2_x_create_window()
|
|||||||
|
|
||||||
attr.backing_store = Always;
|
attr.backing_store = Always;
|
||||||
attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask;
|
attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask;
|
||||||
|
attrmask = CWBackingStore | CWEventMask;
|
||||||
|
if (have_nondefault_visual) {
|
||||||
|
attr.colormap = colormap;
|
||||||
|
attr.background_pixel = 0;
|
||||||
|
attr.border_pixel = 1;
|
||||||
|
attrmask |= CWColormap | CWBackPixel | CWBorderPixel;
|
||||||
|
}
|
||||||
|
|
||||||
window = XCreateWindow(display, root, 0, 0, rpng2_info.width,
|
window = XCreateWindow(display, root, 0, 0, rpng2_info.width,
|
||||||
rpng2_info.height, 0, depth, InputOutput, visual,
|
rpng2_info.height, 0, depth, InputOutput, visual, attrmask, &attr);
|
||||||
CWBackingStore | CWEventMask, &attr);
|
|
||||||
|
|
||||||
if (window == None) {
|
if (window == None) {
|
||||||
fprintf(stderr, "XCreateWindow() failed\n");
|
fprintf(stderr, "XCreateWindow() failed\n");
|
||||||
@ -621,8 +700,9 @@ static int rpng2_x_create_window()
|
|||||||
if ((size_hints = XAllocSizeHints()) != NULL) {
|
if ((size_hints = XAllocSizeHints()) != NULL) {
|
||||||
/* window will not be resizable */
|
/* window will not be resizable */
|
||||||
size_hints->flags = PMinSize | PMaxSize;
|
size_hints->flags = PMinSize | PMaxSize;
|
||||||
size_hints->min_width = size_hints->max_width = rpng2_info.width;
|
size_hints->min_width = size_hints->max_width = (int)rpng2_info.width;
|
||||||
size_hints->min_height = size_hints->max_height = rpng2_info.height;
|
size_hints->min_height = size_hints->max_height =
|
||||||
|
(int)rpng2_info.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((wm_hints = XAllocWMHints()) != NULL) {
|
if ((wm_hints = XAllocWMHints()) != NULL) {
|
||||||
@ -668,7 +748,7 @@ static int rpng2_x_create_window()
|
|||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* to avoid testing the bitmap order every pixel (or doubling the size of
|
/* to avoid testing the byte order every pixel (or doubling the size of
|
||||||
* the drawing routine with a giant if-test), we arbitrarily set the byte
|
* the drawing routine with a giant if-test), we arbitrarily set the byte
|
||||||
* order to MSBFirst and let Xlib worry about inverting things on little-
|
* order to MSBFirst and let Xlib worry about inverting things on little-
|
||||||
* endian machines (e.g., Linux/x86, old VAXen, etc.)--this is not the
|
* endian machines (e.g., Linux/x86, old VAXen, etc.)--this is not the
|
||||||
@ -688,13 +768,13 @@ static int rpng2_x_create_window()
|
|||||||
|
|
||||||
if (!bg_image) {
|
if (!bg_image) {
|
||||||
if (depth == 24 || depth == 32) {
|
if (depth == 24 || depth == 32) {
|
||||||
bg_pixel = (bg_red << RPixelShift) |
|
bg_pixel = (bg_red << RShift) |
|
||||||
(bg_green << GPixelShift) |
|
(bg_green << GShift) |
|
||||||
(bg_blue << BPixelShift);
|
(bg_blue << BShift);
|
||||||
} else if (depth == 16) {
|
} else if (depth == 16) {
|
||||||
bg_pixel = (((bg_red << 8) >> RPixelShift) & RedMask) |
|
bg_pixel = (((bg_red << 8) >> RShift) & RMask) |
|
||||||
(((bg_green << 8) >> GPixelShift) & GreenMask) |
|
(((bg_green << 8) >> GShift) & GMask) |
|
||||||
(((bg_blue << 8) >> BPixelShift) & BlueMask);
|
(((bg_blue << 8) >> BShift) & BMask);
|
||||||
} else /* depth == 8 */ {
|
} else /* depth == 8 */ {
|
||||||
|
|
||||||
/* GRR: add 8-bit support */
|
/* GRR: add 8-bit support */
|
||||||
@ -723,7 +803,7 @@ static int rpng2_x_create_window()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int rpng2_x_load_bg_image()
|
static int rpng2_x_load_bg_image(void)
|
||||||
{
|
{
|
||||||
uch *src;
|
uch *src;
|
||||||
char *dest;
|
char *dest;
|
||||||
@ -772,8 +852,8 @@ static int rpng2_x_load_bg_image()
|
|||||||
int b2_diff = rgb[bg[pat].rgb2_max].b - b2_min;
|
int b2_diff = rgb[bg[pat].rgb2_max].b - b2_min;
|
||||||
|
|
||||||
for (row = 0; row < rpng2_info.height; ++row) {
|
for (row = 0; row < rpng2_info.height; ++row) {
|
||||||
yidx = row % bgscale;
|
yidx = (int)(row % bgscale);
|
||||||
even_odd_vert = (row / bgscale) & 1;
|
even_odd_vert = (int)((row / bgscale) & 1);
|
||||||
|
|
||||||
r1 = r1_min + (r1_diff * yidx) / yidx_max;
|
r1 = r1_min + (r1_diff * yidx) / yidx_max;
|
||||||
g1 = g1_min + (g1_diff * yidx) / yidx_max;
|
g1 = g1_min + (g1_diff * yidx) / yidx_max;
|
||||||
@ -789,9 +869,9 @@ static int rpng2_x_load_bg_image()
|
|||||||
g2_inv = g2_min + (g2_diff * (yidx_max-yidx)) / yidx_max;
|
g2_inv = g2_min + (g2_diff * (yidx_max-yidx)) / yidx_max;
|
||||||
b2_inv = b2_min + (b2_diff * (yidx_max-yidx)) / yidx_max;
|
b2_inv = b2_min + (b2_diff * (yidx_max-yidx)) / yidx_max;
|
||||||
|
|
||||||
dest = (char *)(bg_data + row*bg_rowbytes);
|
dest = (char *)bg_data + row*bg_rowbytes;
|
||||||
for (i = 0; i < rpng2_info.width; ++i) {
|
for (i = 0; i < rpng2_info.width; ++i) {
|
||||||
even_odd_horiz = (i / bgscale) & 1;
|
even_odd_horiz = (int)((i / bgscale) & 1);
|
||||||
even_odd = even_odd_vert ^ even_odd_horiz;
|
even_odd = even_odd_vert ^ even_odd_horiz;
|
||||||
invert_column =
|
invert_column =
|
||||||
(even_odd_horiz && (bg[pat].type & 0x10));
|
(even_odd_horiz && (bg[pat].type & 0x10));
|
||||||
@ -839,12 +919,12 @@ static int rpng2_x_load_bg_image()
|
|||||||
b2 = rgb[bg[pat].rgb2_max].b;
|
b2 = rgb[bg[pat].rgb2_max].b;
|
||||||
|
|
||||||
for (row = 0; row < rpng2_info.height; ++row) {
|
for (row = 0; row < rpng2_info.height; ++row) {
|
||||||
yidx = row % bgscale;
|
yidx = (int)(row % bgscale);
|
||||||
if (yidx > hmax)
|
if (yidx > hmax)
|
||||||
yidx = bgscale-1 - yidx;
|
yidx = bgscale-1 - yidx;
|
||||||
dest = (char *)(bg_data + row*bg_rowbytes);
|
dest = (char *)bg_data + row*bg_rowbytes;
|
||||||
for (i = 0; i < rpng2_info.width; ++i) {
|
for (i = 0; i < rpng2_info.width; ++i) {
|
||||||
xidx = i % bgscale;
|
xidx = (int)(i % bgscale);
|
||||||
if (xidx > hmax)
|
if (xidx > hmax)
|
||||||
xidx = bgscale-1 - xidx;
|
xidx = bgscale-1 - xidx;
|
||||||
k = xidx + yidx;
|
k = xidx + yidx;
|
||||||
@ -871,8 +951,8 @@ static int rpng2_x_load_bg_image()
|
|||||||
PROGNAME);
|
PROGNAME);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
|
||||||
hh = rpng2_info.height / 2;
|
hh = (int)(rpng2_info.height / 2);
|
||||||
hw = rpng2_info.width / 2;
|
hw = (int)(rpng2_info.width / 2);
|
||||||
|
|
||||||
/* variables for radial waves:
|
/* variables for radial waves:
|
||||||
* aoffset: number of degrees to rotate hue [CURRENTLY NOT USED]
|
* aoffset: number of degrees to rotate hue [CURRENTLY NOT USED]
|
||||||
@ -891,10 +971,10 @@ static int rpng2_x_load_bg_image()
|
|||||||
maxDist = (double)((hw*hw) + (hh*hh));
|
maxDist = (double)((hw*hw) + (hh*hh));
|
||||||
|
|
||||||
for (row = 0; row < rpng2_info.height; ++row) {
|
for (row = 0; row < rpng2_info.height; ++row) {
|
||||||
y = row - hh;
|
y = (int)(row - hh);
|
||||||
dest = (char *)(bg_data + row*bg_rowbytes);
|
dest = (char *)bg_data + row*bg_rowbytes;
|
||||||
for (i = 0; i < rpng2_info.width; ++i) {
|
for (i = 0; i < rpng2_info.width; ++i) {
|
||||||
x = i - hw;
|
x = (int)(i - hw);
|
||||||
angle = (x == 0)? PI_2 : atan((double)y / (double)x);
|
angle = (x == 0)? PI_2 : atan((double)y / (double)x);
|
||||||
gray = (double)MAX(ABS(y), ABS(x)) / grayspot;
|
gray = (double)MAX(ABS(y), ABS(x)) / grayspot;
|
||||||
gray = MIN(1.0, gray);
|
gray = MIN(1.0, gray);
|
||||||
@ -951,14 +1031,15 @@ static int rpng2_x_load_bg_image()
|
|||||||
red = *src++;
|
red = *src++;
|
||||||
green = *src++;
|
green = *src++;
|
||||||
blue = *src++;
|
blue = *src++;
|
||||||
pixel = (red << RPixelShift) |
|
pixel = (red << RShift) |
|
||||||
(green << GPixelShift) |
|
(green << GShift) |
|
||||||
(blue << BPixelShift);
|
(blue << BShift);
|
||||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||||
*dest++ = ((uch *)&pixel)[3];
|
/* GRR BUG: this assumes bpp == 32, but may be 24: */
|
||||||
*dest++ = ((uch *)&pixel)[2];
|
*dest++ = (char)((pixel >> 24) & 0xff);
|
||||||
*dest++ = ((uch *)&pixel)[1];
|
*dest++ = (char)((pixel >> 16) & 0xff);
|
||||||
*dest++ = ((uch *)&pixel)[0];
|
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||||
|
*dest++ = (char)( pixel & 0xff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -969,18 +1050,15 @@ static int rpng2_x_load_bg_image()
|
|||||||
src = bg_data + row*bg_rowbytes;
|
src = bg_data + row*bg_rowbytes;
|
||||||
dest = ximage->data + row*ximage_rowbytes;
|
dest = ximage->data + row*ximage_rowbytes;
|
||||||
for (i = rpng2_info.width; i > 0; --i) {
|
for (i = rpng2_info.width; i > 0; --i) {
|
||||||
red = ((ush)(*src) << 8);
|
red = ((ush)(*src) << 8); ++src;
|
||||||
++src;
|
green = ((ush)(*src) << 8); ++src;
|
||||||
green = ((ush)(*src) << 8);
|
blue = ((ush)(*src) << 8); ++src;
|
||||||
++src;
|
pixel = ((red >> RShift) & RMask) |
|
||||||
blue = ((ush)(*src) << 8);
|
((green >> GShift) & GMask) |
|
||||||
++src;
|
((blue >> BShift) & BMask);
|
||||||
pixel = ((red >> RPixelShift) & RedMask) |
|
|
||||||
((green >> GPixelShift) & GreenMask) |
|
|
||||||
((blue >> BPixelShift) & BlueMask);
|
|
||||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||||
*dest++ = ((uch *)&pixel)[1];
|
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||||
*dest++ = ((uch *)&pixel)[0];
|
*dest++ = (char)( pixel & 0xff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1011,7 +1089,7 @@ static void rpng2_x_display_row(ulg row)
|
|||||||
uch r, g, b, a;
|
uch r, g, b, a;
|
||||||
int ximage_rowbytes = ximage->bytes_per_line;
|
int ximage_rowbytes = ximage->bytes_per_line;
|
||||||
ulg i, pixel;
|
ulg i, pixel;
|
||||||
static int rows=0;
|
static int rows=0, prevpass=(-1);
|
||||||
static ulg firstrow;
|
static ulg firstrow;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------
|
/*---------------------------------------------------------------------------
|
||||||
@ -1022,8 +1100,28 @@ static void rpng2_x_display_row(ulg row)
|
|||||||
|
|
||||||
Trace((stderr, "beginning rpng2_x_display_row()\n"))
|
Trace((stderr, "beginning rpng2_x_display_row()\n"))
|
||||||
|
|
||||||
|
if (rpng2_info.pass != prevpass) {
|
||||||
|
if (pause_after_pass && rpng2_info.pass > 0) {
|
||||||
|
XEvent e;
|
||||||
|
KeySym k;
|
||||||
|
|
||||||
|
fprintf(stderr,
|
||||||
|
"%s: end of pass %d of 7; click in image window to continue\n",
|
||||||
|
PROGNAME, prevpass + 1);
|
||||||
|
do
|
||||||
|
XNextEvent(display, &e);
|
||||||
|
while (!(e.type == ButtonPress && e.xbutton.button == Button1)
|
||||||
|
&& !(e.type == KeyPress &&
|
||||||
|
((k = XLookupKeysym(&e.xkey, 0)) == XK_q
|
||||||
|
|| k == XK_Escape) )) ;
|
||||||
|
}
|
||||||
|
fprintf(stderr, "%s: pass %d of 7\r", PROGNAME, rpng2_info.pass + 1);
|
||||||
|
fflush(stderr);
|
||||||
|
prevpass = rpng2_info.pass;
|
||||||
|
}
|
||||||
|
|
||||||
if (rows == 0)
|
if (rows == 0)
|
||||||
firstrow = row; /* first row not yet displayed */
|
firstrow = row; /* first row that is not yet displayed */
|
||||||
|
|
||||||
++rows; /* count of rows received but not yet displayed */
|
++rows; /* count of rows received but not yet displayed */
|
||||||
|
|
||||||
@ -1046,14 +1144,15 @@ static void rpng2_x_display_row(ulg row)
|
|||||||
red = *src++;
|
red = *src++;
|
||||||
green = *src++;
|
green = *src++;
|
||||||
blue = *src++;
|
blue = *src++;
|
||||||
pixel = (red << RPixelShift) |
|
pixel = (red << RShift) |
|
||||||
(green << GPixelShift) |
|
(green << GShift) |
|
||||||
(blue << BPixelShift);
|
(blue << BShift);
|
||||||
/* recall that we set ximage->byte_order = MSBFirst */
|
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||||
*dest++ = ((uch *)&pixel)[3];
|
/* GRR BUG: this assumes bpp == 32, but may be 24: */
|
||||||
*dest++ = ((uch *)&pixel)[2];
|
*dest++ = (char)((pixel >> 24) & 0xff);
|
||||||
*dest++ = ((uch *)&pixel)[1];
|
*dest++ = (char)((pixel >> 16) & 0xff);
|
||||||
*dest++ = ((uch *)&pixel)[0];
|
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||||
|
*dest++ = (char)( pixel & 0xff);
|
||||||
}
|
}
|
||||||
} else /* if (rpng2_info.channels == 4) */ {
|
} else /* if (rpng2_info.channels == 4) */ {
|
||||||
for (i = rpng2_info.width; i > 0; --i) {
|
for (i = rpng2_info.width; i > 0; --i) {
|
||||||
@ -1082,14 +1181,15 @@ static void rpng2_x_display_row(ulg row)
|
|||||||
alpha_composite(green, g, a, bg_green);
|
alpha_composite(green, g, a, bg_green);
|
||||||
alpha_composite(blue, b, a, bg_blue);
|
alpha_composite(blue, b, a, bg_blue);
|
||||||
}
|
}
|
||||||
pixel = (red << RPixelShift) |
|
pixel = (red << RShift) |
|
||||||
(green << GPixelShift) |
|
(green << GShift) |
|
||||||
(blue << BPixelShift);
|
(blue << BShift);
|
||||||
/* recall that we set ximage->byte_order = MSBFirst */
|
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||||
*dest++ = ((uch *)&pixel)[3];
|
/* GRR BUG: this assumes bpp == 32, but may be 24: */
|
||||||
*dest++ = ((uch *)&pixel)[2];
|
*dest++ = (char)((pixel >> 24) & 0xff);
|
||||||
*dest++ = ((uch *)&pixel)[1];
|
*dest++ = (char)((pixel >> 16) & 0xff);
|
||||||
*dest++ = ((uch *)&pixel)[0];
|
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||||
|
*dest++ = (char)( pixel & 0xff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1108,12 +1208,12 @@ static void rpng2_x_display_row(ulg row)
|
|||||||
++src;
|
++src;
|
||||||
blue = ((ush)(*src) << 8);
|
blue = ((ush)(*src) << 8);
|
||||||
++src;
|
++src;
|
||||||
pixel = ((red >> RPixelShift) & RedMask) |
|
pixel = ((red >> RShift) & RMask) |
|
||||||
((green >> GPixelShift) & GreenMask) |
|
((green >> GShift) & GMask) |
|
||||||
((blue >> BPixelShift) & BlueMask);
|
((blue >> BShift) & BMask);
|
||||||
/* recall that we set ximage->byte_order = MSBFirst */
|
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||||
*dest++ = ((uch *)&pixel)[1];
|
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||||
*dest++ = ((uch *)&pixel)[0];
|
*dest++ = (char)( pixel & 0xff);
|
||||||
}
|
}
|
||||||
} else /* if (rpng2_info.channels == 4) */ {
|
} else /* if (rpng2_info.channels == 4) */ {
|
||||||
for (i = rpng2_info.width; i > 0; --i) {
|
for (i = rpng2_info.width; i > 0; --i) {
|
||||||
@ -1145,12 +1245,12 @@ static void rpng2_x_display_row(ulg row)
|
|||||||
green = ((ush)g << 8);
|
green = ((ush)g << 8);
|
||||||
blue = ((ush)b << 8);
|
blue = ((ush)b << 8);
|
||||||
}
|
}
|
||||||
pixel = ((red >> RPixelShift) & RedMask) |
|
pixel = ((red >> RShift) & RMask) |
|
||||||
((green >> GPixelShift) & GreenMask) |
|
((green >> GShift) & GMask) |
|
||||||
((blue >> BPixelShift) & BlueMask);
|
((blue >> BShift) & BMask);
|
||||||
/* recall that we set ximage->byte_order = MSBFirst */
|
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||||
*dest++ = ((uch *)&pixel)[1];
|
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||||
*dest++ = ((uch *)&pixel)[0];
|
*dest++ = (char)( pixel & 0xff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1162,13 +1262,23 @@ static void rpng2_x_display_row(ulg row)
|
|||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------
|
/*---------------------------------------------------------------------------
|
||||||
Display after every 16 rows or when on last row. (Region may include
|
Display after every 16 rows or when on one of last two rows. (Region
|
||||||
previously displayed lines due to interlacing--i.e., not contiguous.)
|
may include previously displayed lines due to interlacing--i.e., not
|
||||||
|
contiguous. Also, second-to-last row is final one in interlaced images
|
||||||
|
with odd number of rows.) For demos, flush (and delay) after every 16th
|
||||||
|
row so "sparse" passes don't go twice as fast.
|
||||||
---------------------------------------------------------------------------*/
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
if ((rows & 0xf) == 0 || row == rpng2_info.height-1) {
|
if (demo_timing && (row - firstrow >= 16 || row >= rpng2_info.height-2)) {
|
||||||
XPutImage(display, window, gc, ximage, 0, firstrow, 0, firstrow,
|
XPutImage(display, window, gc, ximage, 0, (int)firstrow, 0,
|
||||||
rpng2_info.width, row - firstrow + 1);
|
(int)firstrow, rpng2_info.width, row - firstrow + 1);
|
||||||
|
XFlush(display);
|
||||||
|
rows = 0;
|
||||||
|
usleep(usleep_duration);
|
||||||
|
} else
|
||||||
|
if (!demo_timing && ((rows & 0xf) == 0 || row >= rpng2_info.height-2)) {
|
||||||
|
XPutImage(display, window, gc, ximage, 0, (int)firstrow, 0,
|
||||||
|
(int)firstrow, rpng2_info.width, row - firstrow + 1);
|
||||||
XFlush(display);
|
XFlush(display);
|
||||||
rows = 0;
|
rows = 0;
|
||||||
}
|
}
|
||||||
@ -1179,7 +1289,7 @@ static void rpng2_x_display_row(ulg row)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void rpng2_x_finish_display()
|
static void rpng2_x_finish_display(void)
|
||||||
{
|
{
|
||||||
Trace((stderr, "beginning rpng2_x_finish_display()\n"))
|
Trace((stderr, "beginning rpng2_x_finish_display()\n"))
|
||||||
|
|
||||||
@ -1188,14 +1298,16 @@ static void rpng2_x_finish_display()
|
|||||||
* the image is done */
|
* the image is done */
|
||||||
|
|
||||||
rpng2_info.done = TRUE;
|
rpng2_info.done = TRUE;
|
||||||
printf("Done. Press Q, Esc or mouse button 1 to quit.\n");
|
printf(
|
||||||
|
"Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n");
|
||||||
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void rpng2_x_cleanup()
|
static void rpng2_x_cleanup(void)
|
||||||
{
|
{
|
||||||
if (bg_image && bg_data) {
|
if (bg_image && bg_data) {
|
||||||
free(bg_data);
|
free(bg_data);
|
||||||
@ -1228,6 +1340,9 @@ static void rpng2_x_cleanup()
|
|||||||
|
|
||||||
if (have_colormap)
|
if (have_colormap)
|
||||||
XFreeColormap(display, colormap);
|
XFreeColormap(display, colormap);
|
||||||
|
|
||||||
|
if (have_nondefault_visual)
|
||||||
|
XFree(visual_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BIN
contrib/gregbook/toucan.png
Normal file
BIN
contrib/gregbook/toucan.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
@ -19,7 +19,15 @@
|
|||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
Changelog:
|
||||||
|
- 1.01: initial public release
|
||||||
|
- 1.02: modified to allow abbreviated options
|
||||||
|
- 1.03: removed extraneous character from usage screen; fixed bug in
|
||||||
|
command-line parsing
|
||||||
|
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 1998-2000 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
|
||||||
@ -45,7 +53,7 @@
|
|||||||
---------------------------------------------------------------------------*/
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#define PROGNAME "wpng"
|
#define PROGNAME "wpng"
|
||||||
#define VERSION "1.01 of 31 March 1999"
|
#define VERSION "1.03 of 19 March 2000"
|
||||||
#define APPNAME "Simple PGM/PPM/PAM to PNG Converter"
|
#define APPNAME "Simple PGM/PPM/PAM to PNG Converter"
|
||||||
|
|
||||||
#if defined(__MSDOS__) || defined(__OS2__)
|
#if defined(__MSDOS__) || defined(__OS2__)
|
||||||
@ -204,30 +212,33 @@ int main(int argc, char **argv)
|
|||||||
/* Now parse the command line for options and the PNM filename. */
|
/* Now parse the command line for options and the PNM filename. */
|
||||||
|
|
||||||
while (*++argv && !error) {
|
while (*++argv && !error) {
|
||||||
if (!strcmp(*argv, "-interlaced")) {
|
if (!strncmp(*argv, "-i", 2)) {
|
||||||
wpng_info.interlaced = TRUE;
|
wpng_info.interlaced = TRUE;
|
||||||
} else if (!strcmp(*argv, "-time")) {
|
} else if (!strncmp(*argv, "-time", 3)) {
|
||||||
wpng_info.modtime = time(NULL);
|
wpng_info.modtime = time(NULL);
|
||||||
wpng_info.have_time = TRUE;
|
wpng_info.have_time = TRUE;
|
||||||
} else if (!strcmp(*argv, "-text")) {
|
} else if (!strncmp(*argv, "-text", 3)) {
|
||||||
text = TRUE;
|
text = TRUE;
|
||||||
} else if (!strcmp(*argv, "-gamma")) {
|
} else if (!strncmp(*argv, "-gamma", 2)) {
|
||||||
if (!*++argv)
|
if (!*++argv)
|
||||||
++error;
|
++error;
|
||||||
|
else {
|
||||||
wpng_info.gamma = atof(*argv);
|
wpng_info.gamma = atof(*argv);
|
||||||
if (wpng_info.gamma <= 0.0)
|
if (wpng_info.gamma <= 0.0)
|
||||||
++error;
|
++error;
|
||||||
else if (wpng_info.gamma > 1.01)
|
else if (wpng_info.gamma > 1.01)
|
||||||
fprintf(stderr, PROGNAME
|
fprintf(stderr, PROGNAME
|
||||||
" warning: file gammas are usually less than 1.0\n");
|
" warning: file gammas are usually less than 1.0\n");
|
||||||
} else if (!strcmp(*argv, "-bgcolor")) {
|
}
|
||||||
|
} else if (!strncmp(*argv, "-bgcolor", 4)) {
|
||||||
if (!*++argv)
|
if (!*++argv)
|
||||||
++error;
|
++error;
|
||||||
|
else {
|
||||||
bgstr = *argv;
|
bgstr = *argv;
|
||||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||||
++error;
|
++error;
|
||||||
else {
|
else {
|
||||||
unsigned r, g, b; /* this approach quiets compiler warnings */
|
unsigned r, g, b; /* this way quiets compiler warnings */
|
||||||
|
|
||||||
sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b);
|
sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b);
|
||||||
wpng_info.bg_red = (uch)r;
|
wpng_info.bg_red = (uch)r;
|
||||||
@ -235,6 +246,7 @@ int main(int argc, char **argv)
|
|||||||
wpng_info.bg_blue = (uch)b;
|
wpng_info.bg_blue = (uch)b;
|
||||||
wpng_info.have_bg = TRUE;
|
wpng_info.have_bg = TRUE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (**argv != '-') {
|
if (**argv != '-') {
|
||||||
inname = *argv;
|
inname = *argv;
|
||||||
@ -362,7 +374,7 @@ int main(int argc, char **argv)
|
|||||||
"\t\t (where LUT = lookup-table exponent and CRT = CRT exponent;\n"
|
"\t\t (where LUT = lookup-table exponent and CRT = CRT exponent;\n"
|
||||||
"\t\t first varies, second is usually 2.2, all are positive)\n"
|
"\t\t first varies, second is usually 2.2, all are positive)\n"
|
||||||
" bg \tdesired background color for alpha-channel images, in\n"
|
" bg \tdesired background color for alpha-channel images, in\n"
|
||||||
"\t\t 7-character hex RGB format (e.g., ``#ff7f00'' for orange:\n"
|
"\t\t 7-character hex RGB format (e.g., ``#ff7700'' for orange:\n"
|
||||||
"\t\t same as HTML colors)\n"
|
"\t\t same as HTML colors)\n"
|
||||||
" -text\tprompt interactively for text info (tEXt chunks)\n"
|
" -text\tprompt interactively for text info (tEXt chunks)\n"
|
||||||
" -time\tinclude a tIME chunk (last modification time)\n"
|
" -time\tinclude a tIME chunk (last modification time)\n"
|
||||||
@ -755,7 +767,7 @@ static int wpng_isvalid_latin1(uch *p, int len)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void wpng_cleanup()
|
static void wpng_cleanup(void)
|
||||||
{
|
{
|
||||||
if (wpng_info.outfile) {
|
if (wpng_info.outfile) {
|
||||||
fclose(wpng_info.outfile);
|
fclose(wpng_info.outfile);
|
||||||
|
@ -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,
|
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
|
||||||
@ -42,7 +42,7 @@ static void writepng_error_handler(png_structp png_ptr, png_const_charp msg);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void writepng_version_info()
|
void writepng_version_info(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n",
|
fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n",
|
||||||
PNG_LIBPNG_VER_STRING, png_libpng_ver);
|
PNG_LIBPNG_VER_STRING, png_libpng_ver);
|
||||||
@ -82,7 +82,7 @@ int writepng_init(mainprog_info *mainprog_ptr)
|
|||||||
* but compatible error handlers must either use longjmp() themselves
|
* but compatible error handlers must either use longjmp() themselves
|
||||||
* (as in this program) or exit immediately, so here we go: */
|
* (as in this program) or exit immediately, so here we go: */
|
||||||
|
|
||||||
if (setjmp(png_jmp_env(mainprog_ptr))) {
|
if (setjmp(mainprog_ptr->jmpbuf)) {
|
||||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
@ -239,7 +239,7 @@ int writepng_encode_image(mainprog_info *mainprog_ptr)
|
|||||||
/* as always, setjmp() must be called in every function that calls a
|
/* as always, setjmp() must be called in every function that calls a
|
||||||
* PNG-writing libpng function */
|
* PNG-writing libpng function */
|
||||||
|
|
||||||
if (setjmp(png_jmp_env(mainprog_ptr))) {
|
if (setjmp(mainprog_ptr->jmpbuf)) {
|
||||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||||
mainprog_ptr->png_ptr = NULL;
|
mainprog_ptr->png_ptr = NULL;
|
||||||
mainprog_ptr->info_ptr = NULL;
|
mainprog_ptr->info_ptr = NULL;
|
||||||
@ -277,7 +277,7 @@ int writepng_encode_row(mainprog_info *mainprog_ptr) /* NON-interlaced only! */
|
|||||||
/* as always, setjmp() must be called in every function that calls a
|
/* as always, setjmp() must be called in every function that calls a
|
||||||
* PNG-writing libpng function */
|
* PNG-writing libpng function */
|
||||||
|
|
||||||
if (setjmp(png_jmp_env(mainprog_ptr))) {
|
if (setjmp(mainprog_ptr->jmpbuf)) {
|
||||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||||
mainprog_ptr->png_ptr = NULL;
|
mainprog_ptr->png_ptr = NULL;
|
||||||
mainprog_ptr->info_ptr = NULL;
|
mainprog_ptr->info_ptr = NULL;
|
||||||
@ -307,7 +307,7 @@ int writepng_encode_finish(mainprog_info *mainprog_ptr) /* NON-interlaced! */
|
|||||||
/* as always, setjmp() must be called in every function that calls a
|
/* as always, setjmp() must be called in every function that calls a
|
||||||
* PNG-writing libpng function */
|
* PNG-writing libpng function */
|
||||||
|
|
||||||
if (setjmp(png_jmp_env(mainprog_ptr))) {
|
if (setjmp(mainprog_ptr->jmpbuf)) {
|
||||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||||
mainprog_ptr->png_ptr = NULL;
|
mainprog_ptr->png_ptr = NULL;
|
||||||
mainprog_ptr->info_ptr = NULL;
|
mainprog_ptr->info_ptr = NULL;
|
||||||
|
@ -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,
|
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
|
||||||
|
@ -42,6 +42,11 @@
|
|||||||
|
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
|
||||||
|
/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
|
||||||
|
#ifndef png_jmpbuf
|
||||||
|
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* function prototypes */
|
/* function prototypes */
|
||||||
|
|
||||||
int main (int argc, char *argv[]);
|
int main (int argc, char *argv[]);
|
||||||
@ -223,7 +228,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
|
|||||||
return FALSE; /* out of memory */
|
return FALSE; /* out of memory */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setjmp (png_jmp_env(png_ptr)))
|
if (setjmp (png_jmpbuf(png_ptr)))
|
||||||
{
|
{
|
||||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -40,6 +40,11 @@
|
|||||||
|
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
|
||||||
|
/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
|
||||||
|
#ifndef png_jmpbuf
|
||||||
|
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* function prototypes */
|
/* function prototypes */
|
||||||
|
|
||||||
int main (int argc, char *argv[]);
|
int main (int argc, char *argv[]);
|
||||||
@ -386,7 +391,7 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* setjmp() must be called in every function that calls a PNG-reading libpng function */
|
/* 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_write_struct (&png_ptr, (png_infopp) NULL);
|
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
32
example.c
32
example.c
@ -6,17 +6,28 @@
|
|||||||
/* This is an example of how to use libpng to read and write PNG files.
|
/* This is an example of how to use libpng to read and write PNG files.
|
||||||
* The file libpng.txt is much more verbose then this. If you have not
|
* The file libpng.txt is much more verbose then this. If you have not
|
||||||
* read it, do so first. This was designed to be a starting point of an
|
* read it, do so first. This was designed to be a starting point of an
|
||||||
* implementation. This is not officially part of libpng, and therefore
|
* implementation. This is not officially part of libpng, is hereby placed
|
||||||
* does not require a copyright notice.
|
* in the public domain, and therefore does not require a copyright notice.
|
||||||
*
|
*
|
||||||
* This file does not currently compile, because it is missing certain
|
* This file does not currently compile, because it is missing certain
|
||||||
* parts, like allocating memory to hold an image. You will have to
|
* parts, like allocating memory to hold an image. You will have to
|
||||||
* supply these parts to get it to compile. For an example of a minimal
|
* supply these parts to get it to compile. For an example of a minimal
|
||||||
* working PNG reader/writer, see pngtest.c, included in this distribution.
|
* working PNG reader/writer, see pngtest.c, included in this distribution;
|
||||||
|
* see also the programs in the contrib directory.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
|
||||||
|
/* The png_jmpbuf() macro, used in error handling, became available in
|
||||||
|
* libpng version 1.0.6. If you want to be able to run your code with older
|
||||||
|
* versions of libpng, you must define the macro yourself (but only if it
|
||||||
|
* is not already defined by libpng!).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef png_jmpbuf
|
||||||
|
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp()
|
/* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp()
|
||||||
* returns zero if the image is a PNG and nonzero if it isn't a PNG.
|
* returns zero if the image is a PNG and nonzero if it isn't a PNG.
|
||||||
*
|
*
|
||||||
@ -111,7 +122,8 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
|||||||
* the normal method of doing things with libpng). REQUIRED unless you
|
* the normal method of doing things with libpng). REQUIRED unless you
|
||||||
* set up your own error handlers in the png_create_read_struct() earlier.
|
* set up your own error handlers in the png_create_read_struct() earlier.
|
||||||
*/
|
*/
|
||||||
if (setjmp(png_jmp_env(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);
|
||||||
@ -231,7 +243,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
|||||||
screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */
|
screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tell libpng to handle the gamma conversion for you. The second call
|
/* Tell libpng to handle the gamma conversion for you. The final call
|
||||||
* is a good guess for PC generated images, but it should be configurable
|
* is a good guess for PC generated images, but it should be configurable
|
||||||
* by the user at run time by the user. It is strongly suggested that
|
* by the user at run time by the user. It is strongly suggested that
|
||||||
* your application support gamma correction.
|
* your application support gamma correction.
|
||||||
@ -240,7 +252,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
|||||||
int intent;
|
int intent;
|
||||||
|
|
||||||
if (png_get_sRGB(png_ptr, info_ptr, &intent))
|
if (png_get_sRGB(png_ptr, info_ptr, &intent))
|
||||||
png_set_sRGB(png_ptr, info_ptr, intent);
|
png_set_gamma(png_ptr, screen_gamma, 0.45455);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double image_gamma;
|
double image_gamma;
|
||||||
@ -405,7 +417,7 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
|
|||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setjmp(png_jmp_env((*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;
|
||||||
@ -433,7 +445,7 @@ int
|
|||||||
process_data(png_structp *png_ptr, png_infop *info_ptr,
|
process_data(png_structp *png_ptr, png_infop *info_ptr,
|
||||||
png_bytep buffer, png_uint_32 length)
|
png_bytep buffer, png_uint_32 length)
|
||||||
{
|
{
|
||||||
if (setjmp(png_jmp_env((*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);
|
||||||
@ -549,7 +561,7 @@ void write_png(char *file_name /* , ... other image information ... */)
|
|||||||
/* Set error handling. REQUIRED if you aren't supplying your own
|
/* Set error handling. REQUIRED if you aren't supplying your own
|
||||||
* error handling functions in the png_create_write_struct() call.
|
* error handling functions in the png_create_write_struct() call.
|
||||||
*/
|
*/
|
||||||
if (setjmp(png_ptr->jmpbuf))
|
if (setjmp(png_jmpbuf(png_ptr)))
|
||||||
{
|
{
|
||||||
/* If we get here, we had a problem reading the file */
|
/* If we get here, we had a problem reading the file */
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
@ -632,7 +644,7 @@ void write_png(char *file_name /* , ... other image information ... */)
|
|||||||
png_set_text(png_ptr, info_ptr, text_ptr, 3);
|
png_set_text(png_ptr, info_ptr, text_ptr, 3);
|
||||||
|
|
||||||
/* other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs, */
|
/* other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs, */
|
||||||
/* note that if sRGB is present the cHRM chunk must be ignored
|
/* note that if sRGB is present the gAMA and cHRM chunks must be ignored
|
||||||
* on read and must be written in accordance with the sRGB profile */
|
* on read and must be written in accordance with the sRGB profile */
|
||||||
|
|
||||||
/* Write the file header information. REQUIRED */
|
/* Write the file header information. REQUIRED */
|
||||||
|
194
libpng.3
194
libpng.3
@ -1,6 +1,6 @@
|
|||||||
.TH LIBPNG 3 "February 18, 2000"
|
.TH LIBPNG 3 "March 21, 2000"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5s
|
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.6
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
\fI\fB
|
\fI\fB
|
||||||
|
|
||||||
@ -538,7 +538,11 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5s
|
|||||||
|
|
||||||
\fI\fB
|
\fI\fB
|
||||||
|
|
||||||
\fBvoid png_set_rgb_to_gray (png_structp \fP\fIpng_ptr\fP\fB, int \fIerror_action\fP\fB);\fP
|
\fBvoid png_set_rgb_to_gray (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIerror_action\fP\fB, double \fP\fIred\fP\fB, double \fIgreen\fP\fB);\fP
|
||||||
|
|
||||||
|
\fI\fB
|
||||||
|
|
||||||
|
\fBvoid png_set_rgb_to_gray_fixed (png_structp \fP\fIpng_ptr\fP\fB, int error_action png_fixed_point \fP\fIred\fP\fB, png_fixed_point \fIgreen\fP\fB);\fP
|
||||||
|
|
||||||
\fI\fB
|
\fI\fB
|
||||||
|
|
||||||
@ -709,7 +713,7 @@ 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.5s - February 18, 2000
|
libpng version 1.0.6 - March 21, 2000
|
||||||
Updated and distributed by Glenn Randers-Pehrson
|
Updated and distributed by Glenn Randers-Pehrson
|
||||||
<randeg@alum.rpi.edu>
|
<randeg@alum.rpi.edu>
|
||||||
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
@ -746,7 +750,9 @@ Libpng was written as a companion to the PNG specification, as a way
|
|||||||
of reducing the amount of time and effort it takes to support the PNG
|
of reducing the amount of time and effort it takes to support the PNG
|
||||||
file format in application programs.
|
file format in application programs.
|
||||||
|
|
||||||
The PNG-1.2 specification is available at <http://www.cdrom.com/png>.
|
The PNG-1.2 specification is available at <http://www.cdrom.com/pub/png>
|
||||||
|
(will be moving to <http://www.libpng.org>)
|
||||||
|
and at <ftp://ftp.uu.net/graphics/png/documents/>.
|
||||||
|
|
||||||
The PNG-1.0 specification is available
|
The PNG-1.0 specification is available
|
||||||
as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/> and as a
|
as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/> and as a
|
||||||
@ -756,7 +762,9 @@ documents at <ftp://ftp.uu.net/graphics/png/documents/>.
|
|||||||
|
|
||||||
Other information
|
Other information
|
||||||
about PNG, and the latest version of libpng, can be found at the PNG home
|
about PNG, and the latest version of libpng, can be found at the PNG home
|
||||||
page, <http://www.cdrom.com/pub/png/>.
|
page, <http://www.cdrom.com/pub/png/> (will be moving to
|
||||||
|
<http://www.libpng.org>)
|
||||||
|
and at <ftp://ftp.uu.net/graphics/png/>.
|
||||||
|
|
||||||
Most users will not have to modify the library significantly; advanced
|
Most users will not have to modify the library significantly; advanced
|
||||||
users may want to modify it more. All attempts were made to make it as
|
users may want to modify it more. All attempts were made to make it as
|
||||||
@ -774,7 +782,7 @@ majority of the needs of its users.
|
|||||||
|
|
||||||
Libpng uses zlib for its compression and decompression of PNG files.
|
Libpng uses zlib for its compression and decompression of PNG files.
|
||||||
Further information about zlib, and the latest version of zlib, can
|
Further information about zlib, and the latest version of zlib, can
|
||||||
be found at the zlib home page, <http://www.cdrom.com/pub/infozip/zlib/>.
|
be found at the zlib home page, <ftp://ftp.freesoftware.com/pub/infozip/zlib/>.
|
||||||
The zlib compression utility is a general purpose utility that is
|
The zlib compression utility is a general purpose utility that is
|
||||||
useful for more than PNG files, and can be used without libpng.
|
useful for more than PNG files, and can be used without libpng.
|
||||||
See the documentation delivered with zlib for more details.
|
See the documentation delivered with zlib for more details.
|
||||||
@ -899,9 +907,9 @@ handling and memory alloc/free functions.
|
|||||||
|
|
||||||
When libpng encounters an error, it expects to longjmp back
|
When libpng encounters an error, it expects to longjmp back
|
||||||
to your routine. Therefore, you will need to call setjmp and pass
|
to your routine. Therefore, you will need to call setjmp and pass
|
||||||
your png_jmp_env(png_ptr). If you read the file from different
|
your png_jmpbuf(png_ptr). If you read the file from different
|
||||||
routines, you will need to update the jmpbuf field every time you enter
|
routines, you will need to update the jmpbuf field every time you enter
|
||||||
a new routine that will call a png_ function.
|
a new routine that will call a png_*() function.
|
||||||
|
|
||||||
See your documentation of setjmp/longjmp for your compiler for more
|
See your documentation of setjmp/longjmp for your compiler for more
|
||||||
information on setjmp/longjmp. See the discussion on libpng error
|
information on setjmp/longjmp. See the discussion on libpng error
|
||||||
@ -910,7 +918,7 @@ on the libpng error handling. If an error occurs, and libpng longjmp's
|
|||||||
back to your setjmp, you will want to call png_destroy_read_struct() to
|
back to your setjmp, you will want to call png_destroy_read_struct() to
|
||||||
free any memory.
|
free any memory.
|
||||||
|
|
||||||
if (setjmp(png_jmp_env(png_ptr)))
|
if (setjmp(png_jmpbuf(png_ptr)))
|
||||||
{
|
{
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr,
|
png_destroy_read_struct(&png_ptr, &info_ptr,
|
||||||
&end_info);
|
&end_info);
|
||||||
@ -990,38 +998,6 @@ To inform libpng about your function, use
|
|||||||
|
|
||||||
png_set_read_status_fn(png_ptr, read_row_callback);
|
png_set_read_status_fn(png_ptr, read_row_callback);
|
||||||
|
|
||||||
Finally, you can write your own transformation function if none of
|
|
||||||
the existing ones meets your needs. This is done by setting a callback
|
|
||||||
with
|
|
||||||
|
|
||||||
png_set_read_user_transform_fn(png_ptr,
|
|
||||||
read_transform_fn);
|
|
||||||
|
|
||||||
You must supply the function
|
|
||||||
|
|
||||||
void read_transform_fn(png_ptr ptr, row_info_ptr
|
|
||||||
row_info, png_bytep data)
|
|
||||||
|
|
||||||
See pngtest.c for a working example. Your function will be called
|
|
||||||
after all of the other transformations have been processed.
|
|
||||||
|
|
||||||
You can also set up a pointer to a user structure for use by your
|
|
||||||
callback function, and you can inform libpng that your transform
|
|
||||||
function will change the number of channels or bit depth with the
|
|
||||||
function
|
|
||||||
|
|
||||||
png_set_user_transform_info(png_ptr, user_ptr,
|
|
||||||
user_depth, user_channels);
|
|
||||||
|
|
||||||
The user's application, not libpng, is responsible for allocating and
|
|
||||||
freeing any memory required for the user structure.
|
|
||||||
|
|
||||||
You can retrieve the pointer via the function
|
|
||||||
png_get_user_transform_ptr(). For example:
|
|
||||||
|
|
||||||
voidp read_user_transform_ptr =
|
|
||||||
png_get_user_transform_ptr(png_ptr);
|
|
||||||
|
|
||||||
.SS Unknown-chunk handling
|
.SS Unknown-chunk handling
|
||||||
|
|
||||||
Now you get to set the way the library processes unknown chunks in the
|
Now you get to set the way the library processes unknown chunks in the
|
||||||
@ -1093,24 +1069,6 @@ call to png_read_info().
|
|||||||
|
|
||||||
This will process all chunks up to but not including the image data.
|
This will process all chunks up to but not including the image data.
|
||||||
|
|
||||||
There is one transformation you may need to set up before doing
|
|
||||||
png_read_info(), however. In PNG files, the alpha channel in an image
|
|
||||||
is the level of opacity. If you need the alpha channel in an image to
|
|
||||||
be the level of transparency instead of opacity, you can invert the
|
|
||||||
alpha channel (or the tRNS chunk data) after it's read, so that 0 is
|
|
||||||
fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit
|
|
||||||
images) is fully transparent, with
|
|
||||||
|
|
||||||
png_set_invert_alpha(png_ptr);
|
|
||||||
|
|
||||||
This must appear before png_write_info() instead of later with the
|
|
||||||
other transformations because in the case of paletted images the tRNS
|
|
||||||
chunk data has to be inverted before the tRNS chunk is written.
|
|
||||||
If your image is not a paletted image, the tRNS data (which in such cases
|
|
||||||
represents a single color to be rendered as transparent) won't need to
|
|
||||||
be changed, and you can safely do this transformation after your
|
|
||||||
png_read_info() call.
|
|
||||||
|
|
||||||
.SS Querying the info structure
|
.SS Querying the info structure
|
||||||
|
|
||||||
Functions are used to get the information from the info_ptr once it
|
Functions are used to get the information from the info_ptr once it
|
||||||
@ -1437,6 +1395,15 @@ it with the background, so that's what you should probably do):
|
|||||||
if (color_type & PNG_COLOR_MASK_ALPHA)
|
if (color_type & PNG_COLOR_MASK_ALPHA)
|
||||||
png_set_strip_alpha(png_ptr);
|
png_set_strip_alpha(png_ptr);
|
||||||
|
|
||||||
|
In PNG files, the alpha channel in an image
|
||||||
|
is the level of opacity. If you need the alpha channel in an image to
|
||||||
|
be the level of transparency instead of opacity, you can invert the
|
||||||
|
alpha channel (or the tRNS chunk data) after it's read, so that 0 is
|
||||||
|
fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit
|
||||||
|
images) is fully transparent, with
|
||||||
|
|
||||||
|
png_set_invert_alpha(png_ptr);
|
||||||
|
|
||||||
PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
|
PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
|
||||||
they can, resulting in, for example, 8 pixels per byte for 1 bit
|
they can, resulting in, for example, 8 pixels per byte for 1 bit
|
||||||
files. This code expands to 1 pixel per byte without changing the
|
files. This code expands to 1 pixel per byte without changing the
|
||||||
@ -1490,14 +1457,12 @@ RGB. This code will do that conversion:
|
|||||||
png_set_gray_to_rgb(png_ptr);
|
png_set_gray_to_rgb(png_ptr);
|
||||||
|
|
||||||
Conversely, you can convert an RGB or RGBA image to grayscale or grayscale
|
Conversely, you can convert an RGB or RGBA image to grayscale or grayscale
|
||||||
with alpha. This is intended for conversion of images that really are
|
with alpha.
|
||||||
gray (red == green == blue), so the function simply strips out the red
|
|
||||||
and blue channels, leaving the green channel in the gray position.
|
|
||||||
|
|
||||||
if (color_type == PNG_COLOR_TYPE_RGB ||
|
if (color_type == PNG_COLOR_TYPE_RGB ||
|
||||||
color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||||
png_set_rgb_to_gray(png_ptr, error_action,
|
png_set_rgb_to_gray_fixed(png_ptr, error_action,
|
||||||
double red_weight, double green_weight);
|
int red_weight, int green_weight);
|
||||||
|
|
||||||
error_action = 1: silently do the conversion
|
error_action = 1: silently do the conversion
|
||||||
error_action = 2: issue a warning if the original
|
error_action = 2: issue a warning if the original
|
||||||
@ -1508,10 +1473,10 @@ and blue channels, leaving the green channel in the gray position.
|
|||||||
image has any pixel where
|
image has any pixel where
|
||||||
red != green or red != blue
|
red != green or red != blue
|
||||||
|
|
||||||
red_weight: weight of red component
|
red_weight: weight of red component times 100000
|
||||||
(NULL -> default 54/256)
|
green_weight: weight of green component times 100000
|
||||||
green_weight: weight of green component
|
If either weight is negative, default
|
||||||
(NULL -> default 183/256)
|
weights (21268, 71514) are used.
|
||||||
|
|
||||||
If you have set error_action = 1 or 2, you can
|
If you have set error_action = 1 or 2, you can
|
||||||
later check whether the image really was gray, after processing
|
later check whether the image really was gray, after processing
|
||||||
@ -1521,13 +1486,13 @@ It will return a png_byte that is zero if the image was gray or
|
|||||||
will be silently converted to grayscale, using the green channel
|
will be silently converted to grayscale, using the green channel
|
||||||
data, regardless of the error_action setting.
|
data, regardless of the error_action setting.
|
||||||
|
|
||||||
With 0.0<=red_weight+green_weight<=1.0,
|
With red_weight+green_weight<=100000,
|
||||||
the normalized graylevel is computed:
|
the normalized graylevel is computed:
|
||||||
|
|
||||||
int rw = red_weight * 256;
|
int rw = red_weight * 65536;
|
||||||
int gw = green_weight * 256;
|
int gw = green_weight * 65536;
|
||||||
int bw = 256 - (rw + gw);
|
int bw = 65536 - (rw + gw);
|
||||||
gray = (rw*red + gw*green + bw*blue)/256;
|
gray = (rw*red + gw*green + bw*blue)/65536;
|
||||||
|
|
||||||
The default values approximate those recommended in the Charles
|
The default values approximate those recommended in the Charles
|
||||||
Poynton's Color FAQ, <http://www.inforamp.net/~poynton/>
|
Poynton's Color FAQ, <http://www.inforamp.net/~poynton/>
|
||||||
@ -1537,11 +1502,11 @@ Copyright (c) 1998-01-04 Charles Poynton poynton@inforamp.net
|
|||||||
|
|
||||||
Libpng approximates this with
|
Libpng approximates this with
|
||||||
|
|
||||||
Y = 0.211 * R + 0.715 * G + 0.074 * B
|
Y = 0.21268 * R + 0.7151 * G + 0.07217 * B
|
||||||
|
|
||||||
which can be expressed with integers as
|
which can be expressed with integers as
|
||||||
|
|
||||||
Y = (54 * R + 183 * G + 19 * B)/256
|
Y = (6969 * R + 23434 * G + 2365 * B)/32768
|
||||||
|
|
||||||
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.
|
||||||
@ -1672,6 +1637,38 @@ need to change the order the pixels are packed into bytes, you can use:
|
|||||||
if (bit_depth < 8)
|
if (bit_depth < 8)
|
||||||
png_set_packswap(png_ptr);
|
png_set_packswap(png_ptr);
|
||||||
|
|
||||||
|
Finally, you can write your own transformation function if none of
|
||||||
|
the existing ones meets your needs. This is done by setting a callback
|
||||||
|
with
|
||||||
|
|
||||||
|
png_set_read_user_transform_fn(png_ptr,
|
||||||
|
read_transform_fn);
|
||||||
|
|
||||||
|
You must supply the function
|
||||||
|
|
||||||
|
void read_transform_fn(png_ptr ptr, row_info_ptr
|
||||||
|
row_info, png_bytep data)
|
||||||
|
|
||||||
|
See pngtest.c for a working example. Your function will be called
|
||||||
|
after all of the other transformations have been processed.
|
||||||
|
|
||||||
|
You can also set up a pointer to a user structure for use by your
|
||||||
|
callback function, and you can inform libpng that your transform
|
||||||
|
function will change the number of channels or bit depth with the
|
||||||
|
function
|
||||||
|
|
||||||
|
png_set_user_transform_info(png_ptr, user_ptr,
|
||||||
|
user_depth, user_channels);
|
||||||
|
|
||||||
|
The user's application, not libpng, is responsible for allocating and
|
||||||
|
freeing any memory required for the user structure.
|
||||||
|
|
||||||
|
You can retrieve the pointer via the function
|
||||||
|
png_get_user_transform_ptr(). For example:
|
||||||
|
|
||||||
|
voidp read_user_transform_ptr =
|
||||||
|
png_get_user_transform_ptr(png_ptr);
|
||||||
|
|
||||||
The last thing to handle is interlacing; this is covered in detail below,
|
The last thing to handle is interlacing; this is covered in detail below,
|
||||||
but you must call the function here if you want libpng to handle expansion
|
but you must call the function here if you want libpng to handle expansion
|
||||||
of the interlaced image.
|
of the interlaced image.
|
||||||
@ -1726,10 +1723,10 @@ interlace_type == PNG_INTERLACE_NONE), this is simple:
|
|||||||
where row_pointers is the same as in the png_read_image() call.
|
where row_pointers is the same as in the png_read_image() call.
|
||||||
|
|
||||||
If you are doing this just one row at a time, you can do this with
|
If you are doing this just one row at a time, you can do this with
|
||||||
row_pointers:
|
a single row_pointer instead of an array of row_pointers:
|
||||||
|
|
||||||
png_bytep row_pointers = row;
|
png_bytep row_pointer = row;
|
||||||
png_read_row(png_ptr, &row_pointers, NULL);
|
png_read_row(png_ptr, row_pointers, NULL);
|
||||||
|
|
||||||
If the file is interlaced (info_ptr->interlace_type != 0), things get
|
If the file is interlaced (info_ptr->interlace_type != 0), things get
|
||||||
somewhat harder. The only current (PNG Specification version 1.2)
|
somewhat harder. The only current (PNG Specification version 1.2)
|
||||||
@ -1880,7 +1877,7 @@ png_infop info_ptr;
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setjmp(png_jmp_env(png_ptr)))
|
if (setjmp(png_jmpbuf(png_ptr)))
|
||||||
{
|
{
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr,
|
png_destroy_read_struct(&png_ptr, &info_ptr,
|
||||||
(png_infopp)NULL);
|
(png_infopp)NULL);
|
||||||
@ -1914,7 +1911,7 @@ png_infop info_ptr;
|
|||||||
int
|
int
|
||||||
process_data(png_bytep buffer, png_uint_32 length)
|
process_data(png_bytep buffer, png_uint_32 length)
|
||||||
{
|
{
|
||||||
if (setjmp(png_jmp_env(png_ptr)))
|
if (setjmp(png_jmpbuf(png_ptr)))
|
||||||
{
|
{
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr,
|
png_destroy_read_struct(&png_ptr, &info_ptr,
|
||||||
(png_infopp)NULL);
|
(png_infopp)NULL);
|
||||||
@ -2069,15 +2066,15 @@ png_create_write_struct_2() instead of png_create_read_struct():
|
|||||||
After you have these structures, you will need to set up the
|
After you have these structures, you will need to set up the
|
||||||
error handling. When libpng encounters an error, it expects to
|
error handling. When libpng encounters an error, it expects to
|
||||||
longjmp() back to your routine. Therefore, you will need to call
|
longjmp() back to your routine. Therefore, you will need to call
|
||||||
setjmp() and pass the png_jmp_env(png_ptr). If you
|
setjmp() and pass the png_jmpbuf(png_ptr). If you
|
||||||
write the file from different routines, you will need to update
|
write the file from different routines, you will need to update
|
||||||
the png_jmp_env(png_ptr) every time you enter a new routine that will
|
the png_jmpbuf(png_ptr) every time you enter a new routine that will
|
||||||
call a png_ function. See your documentation of setjmp/longjmp
|
call a png_*() function. See your documentation of setjmp/longjmp
|
||||||
for your compiler for more information on setjmp/longjmp. See
|
for your compiler for more information on setjmp/longjmp. See
|
||||||
the discussion on libpng error handling in the Customizing Libpng
|
the discussion on libpng error handling in the Customizing Libpng
|
||||||
section below for more information on the libpng error handling.
|
section below for more information on the libpng error handling.
|
||||||
|
|
||||||
if (setjmp(png_jmp_env(png_ptr)))
|
if (setjmp(png_jmpbuf(png_ptr)))
|
||||||
{
|
{
|
||||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
@ -2512,14 +2509,15 @@ make sure to only enable a transformation if it will be valid for the
|
|||||||
data. For example, don't swap red and blue on grayscale data.
|
data. For example, don't swap red and blue on grayscale data.
|
||||||
|
|
||||||
PNG files store RGB pixels packed into 3 or 6 bytes. This code tells
|
PNG files store RGB pixels packed into 3 or 6 bytes. This code tells
|
||||||
the library to expand the input data to 4 or 8 bytes per pixel
|
the library to trip input data that has 4 or 8 bytes per pixel down
|
||||||
(or expand 1 or 2-byte grayscale data to 2 or 4 bytes per pixel).
|
to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2
|
||||||
|
bytes per pixel).
|
||||||
|
|
||||||
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
|
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
|
||||||
|
|
||||||
where the 0 is the value that will be put in the 4th byte, and the
|
where the 0 is unused, and the location is either PNG_FILLER_BEFORE or
|
||||||
location is either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending
|
PNG_FILLER_AFTER, depending upon whether the filler byte in the is stored
|
||||||
upon whether the filler byte is stored XRGB or RGBX.
|
XRGB or RGBX.
|
||||||
|
|
||||||
PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
|
PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
|
||||||
they can, resulting in, for example, 8 pixels per byte for 1 bit files.
|
they can, resulting in, for example, 8 pixels per byte for 1 bit files.
|
||||||
@ -2636,7 +2634,7 @@ that do not use flushing.
|
|||||||
.SS Writing the image data
|
.SS Writing the image data
|
||||||
|
|
||||||
That's it for the transformations. Now you can write the image data.
|
That's it for the transformations. Now you can write the image data.
|
||||||
The simplest way to do this is in one function call. If have the
|
The simplest way to do this is in one function call. If you have the
|
||||||
whole image in memory, you can just call png_write_image() and libpng
|
whole image in memory, you can just call png_write_image() and libpng
|
||||||
will write the image. You will need to pass in an array of pointers to
|
will write the image. You will need to pass in an array of pointers to
|
||||||
each row. This function automatically handles interlacing, so you don't
|
each row. This function automatically handles interlacing, so you don't
|
||||||
@ -2661,11 +2659,11 @@ this is simple:
|
|||||||
row_pointers is the same as in the png_write_image() call.
|
row_pointers is the same as in the png_write_image() call.
|
||||||
|
|
||||||
If you are just writing one row at a time, you can do this with
|
If you are just writing one row at a time, you can do this with
|
||||||
row_pointers:
|
a single row_pointer instead of an array of row_pointers:
|
||||||
|
|
||||||
png_bytep row_pointer = row;
|
png_bytep row_pointer = row;
|
||||||
|
|
||||||
png_write_row(png_ptr, &row_pointer);
|
png_write_row(png_ptr, row_pointer);
|
||||||
|
|
||||||
When the file is interlaced, things can get a good deal more
|
When the file is interlaced, things can get a good deal more
|
||||||
complicated. The only currently (as of January 2000 -- PNG Specification
|
complicated. The only currently (as of January 2000 -- PNG Specification
|
||||||
@ -3115,13 +3113,13 @@ the old method.
|
|||||||
|
|
||||||
.SH VII. Y2K Compliance in libpng
|
.SH VII. Y2K Compliance in libpng
|
||||||
|
|
||||||
February 18, 2000
|
March 21, 2000
|
||||||
|
|
||||||
Since the PNG Development group is an ad-hoc body, we can't make
|
Since the PNG Development group is an ad-hoc body, we can't make
|
||||||
an official declaration.
|
an official declaration.
|
||||||
|
|
||||||
This is your unofficial assurance that libpng from version 0.71 and
|
This is your unofficial assurance that libpng from version 0.71 and
|
||||||
upward through 1.0.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.
|
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
|
||||||
@ -3218,7 +3216,7 @@ or at
|
|||||||
.br
|
.br
|
||||||
ftp://ftp.uu.net/pub/archiving/zip/zlib
|
ftp://ftp.uu.net/pub/archiving/zip/zlib
|
||||||
.br
|
.br
|
||||||
http://www.cdrom.com/pub/infozip/zlib
|
ftp://ftp.freesoftware.com/pub/infozip/zlib
|
||||||
|
|
||||||
.LP
|
.LP
|
||||||
.IR PNG specification: RFC 2083
|
.IR PNG specification: RFC 2083
|
||||||
@ -3247,7 +3245,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.5s - February 18, 2000:
|
Libpng version 1.0.6 - March 21, 2000:
|
||||||
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).
|
||||||
|
|
||||||
@ -3262,7 +3260,7 @@ Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
|||||||
Copyright (c) 1996, 1997 Andreas Dilger
|
Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
(libpng versions 0.90, December 1996, through 0.96, May 1997)
|
(libpng versions 0.90, December 1996, through 0.96, May 1997)
|
||||||
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
(libpng versions 0.97, January 1998, through 1.0.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"
|
For the purposes of this copyright and license, "Contributing Authors"
|
||||||
is defined as the following set of individuals:
|
is defined as the following set of individuals:
|
||||||
|
178
libpng.txt
178
libpng.txt
@ -1,6 +1,6 @@
|
|||||||
libpng.txt - A description on how to use and modify libpng
|
libpng.txt - A description on how to use and modify libpng
|
||||||
|
|
||||||
libpng version 1.0.5s - February 18, 2000
|
libpng version 1.0.6 - March 21, 2000
|
||||||
Updated and distributed by Glenn Randers-Pehrson
|
Updated and distributed by Glenn Randers-Pehrson
|
||||||
<randeg@alum.rpi.edu>
|
<randeg@alum.rpi.edu>
|
||||||
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
@ -37,7 +37,9 @@ Libpng was written as a companion to the PNG specification, as a way
|
|||||||
of reducing the amount of time and effort it takes to support the PNG
|
of reducing the amount of time and effort it takes to support the PNG
|
||||||
file format in application programs.
|
file format in application programs.
|
||||||
|
|
||||||
The PNG-1.2 specification is available at <http://www.cdrom.com/png>.
|
The PNG-1.2 specification is available at <http://www.cdrom.com/pub/png>
|
||||||
|
(will be moving to <http://www.libpng.org>)
|
||||||
|
and at <ftp://ftp.uu.net/graphics/png/documents/>.
|
||||||
|
|
||||||
The PNG-1.0 specification is available
|
The PNG-1.0 specification is available
|
||||||
as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/> and as a
|
as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/> and as a
|
||||||
@ -47,7 +49,9 @@ documents at <ftp://ftp.uu.net/graphics/png/documents/>.
|
|||||||
|
|
||||||
Other information
|
Other information
|
||||||
about PNG, and the latest version of libpng, can be found at the PNG home
|
about PNG, and the latest version of libpng, can be found at the PNG home
|
||||||
page, <http://www.cdrom.com/pub/png/>.
|
page, <http://www.cdrom.com/pub/png/> (will be moving to
|
||||||
|
<http://www.libpng.org>)
|
||||||
|
and at <ftp://ftp.uu.net/graphics/png/>.
|
||||||
|
|
||||||
Most users will not have to modify the library significantly; advanced
|
Most users will not have to modify the library significantly; advanced
|
||||||
users may want to modify it more. All attempts were made to make it as
|
users may want to modify it more. All attempts were made to make it as
|
||||||
@ -65,7 +69,7 @@ majority of the needs of its users.
|
|||||||
|
|
||||||
Libpng uses zlib for its compression and decompression of PNG files.
|
Libpng uses zlib for its compression and decompression of PNG files.
|
||||||
Further information about zlib, and the latest version of zlib, can
|
Further information about zlib, and the latest version of zlib, can
|
||||||
be found at the zlib home page, <http://www.cdrom.com/pub/infozip/zlib/>.
|
be found at the zlib home page, <ftp://ftp.freesoftware.com/pub/infozip/zlib/>.
|
||||||
The zlib compression utility is a general purpose utility that is
|
The zlib compression utility is a general purpose utility that is
|
||||||
useful for more than PNG files, and can be used without libpng.
|
useful for more than PNG files, and can be used without libpng.
|
||||||
See the documentation delivered with zlib for more details.
|
See the documentation delivered with zlib for more details.
|
||||||
@ -190,9 +194,9 @@ handling and memory alloc/free functions.
|
|||||||
|
|
||||||
When libpng encounters an error, it expects to longjmp back
|
When libpng encounters an error, it expects to longjmp back
|
||||||
to your routine. Therefore, you will need to call setjmp and pass
|
to your routine. Therefore, you will need to call setjmp and pass
|
||||||
your png_jmp_env(png_ptr). If you read the file from different
|
your png_jmpbuf(png_ptr). If you read the file from different
|
||||||
routines, you will need to update the jmpbuf field every time you enter
|
routines, you will need to update the jmpbuf field every time you enter
|
||||||
a new routine that will call a png_ function.
|
a new routine that will call a png_*() function.
|
||||||
|
|
||||||
See your documentation of setjmp/longjmp for your compiler for more
|
See your documentation of setjmp/longjmp for your compiler for more
|
||||||
information on setjmp/longjmp. See the discussion on libpng error
|
information on setjmp/longjmp. See the discussion on libpng error
|
||||||
@ -201,7 +205,7 @@ on the libpng error handling. If an error occurs, and libpng longjmp's
|
|||||||
back to your setjmp, you will want to call png_destroy_read_struct() to
|
back to your setjmp, you will want to call png_destroy_read_struct() to
|
||||||
free any memory.
|
free any memory.
|
||||||
|
|
||||||
if (setjmp(png_jmp_env(png_ptr)))
|
if (setjmp(png_jmpbuf(png_ptr)))
|
||||||
{
|
{
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr,
|
png_destroy_read_struct(&png_ptr, &info_ptr,
|
||||||
&end_info);
|
&end_info);
|
||||||
@ -281,38 +285,6 @@ To inform libpng about your function, use
|
|||||||
|
|
||||||
png_set_read_status_fn(png_ptr, read_row_callback);
|
png_set_read_status_fn(png_ptr, read_row_callback);
|
||||||
|
|
||||||
Finally, you can write your own transformation function if none of
|
|
||||||
the existing ones meets your needs. This is done by setting a callback
|
|
||||||
with
|
|
||||||
|
|
||||||
png_set_read_user_transform_fn(png_ptr,
|
|
||||||
read_transform_fn);
|
|
||||||
|
|
||||||
You must supply the function
|
|
||||||
|
|
||||||
void read_transform_fn(png_ptr ptr, row_info_ptr
|
|
||||||
row_info, png_bytep data)
|
|
||||||
|
|
||||||
See pngtest.c for a working example. Your function will be called
|
|
||||||
after all of the other transformations have been processed.
|
|
||||||
|
|
||||||
You can also set up a pointer to a user structure for use by your
|
|
||||||
callback function, and you can inform libpng that your transform
|
|
||||||
function will change the number of channels or bit depth with the
|
|
||||||
function
|
|
||||||
|
|
||||||
png_set_user_transform_info(png_ptr, user_ptr,
|
|
||||||
user_depth, user_channels);
|
|
||||||
|
|
||||||
The user's application, not libpng, is responsible for allocating and
|
|
||||||
freeing any memory required for the user structure.
|
|
||||||
|
|
||||||
You can retrieve the pointer via the function
|
|
||||||
png_get_user_transform_ptr(). For example:
|
|
||||||
|
|
||||||
voidp read_user_transform_ptr =
|
|
||||||
png_get_user_transform_ptr(png_ptr);
|
|
||||||
|
|
||||||
Unknown-chunk handling
|
Unknown-chunk handling
|
||||||
|
|
||||||
Now you get to set the way the library processes unknown chunks in the
|
Now you get to set the way the library processes unknown chunks in the
|
||||||
@ -384,24 +356,6 @@ call to png_read_info().
|
|||||||
|
|
||||||
This will process all chunks up to but not including the image data.
|
This will process all chunks up to but not including the image data.
|
||||||
|
|
||||||
There is one transformation you may need to set up before doing
|
|
||||||
png_read_info(), however. In PNG files, the alpha channel in an image
|
|
||||||
is the level of opacity. If you need the alpha channel in an image to
|
|
||||||
be the level of transparency instead of opacity, you can invert the
|
|
||||||
alpha channel (or the tRNS chunk data) after it's read, so that 0 is
|
|
||||||
fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit
|
|
||||||
images) is fully transparent, with
|
|
||||||
|
|
||||||
png_set_invert_alpha(png_ptr);
|
|
||||||
|
|
||||||
This must appear before png_write_info() instead of later with the
|
|
||||||
other transformations because in the case of paletted images the tRNS
|
|
||||||
chunk data has to be inverted before the tRNS chunk is written.
|
|
||||||
If your image is not a paletted image, the tRNS data (which in such cases
|
|
||||||
represents a single color to be rendered as transparent) won't need to
|
|
||||||
be changed, and you can safely do this transformation after your
|
|
||||||
png_read_info() call.
|
|
||||||
|
|
||||||
Querying the info structure
|
Querying the info structure
|
||||||
|
|
||||||
Functions are used to get the information from the info_ptr once it
|
Functions are used to get the information from the info_ptr once it
|
||||||
@ -728,6 +682,15 @@ it with the background, so that's what you should probably do):
|
|||||||
if (color_type & PNG_COLOR_MASK_ALPHA)
|
if (color_type & PNG_COLOR_MASK_ALPHA)
|
||||||
png_set_strip_alpha(png_ptr);
|
png_set_strip_alpha(png_ptr);
|
||||||
|
|
||||||
|
In PNG files, the alpha channel in an image
|
||||||
|
is the level of opacity. If you need the alpha channel in an image to
|
||||||
|
be the level of transparency instead of opacity, you can invert the
|
||||||
|
alpha channel (or the tRNS chunk data) after it's read, so that 0 is
|
||||||
|
fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit
|
||||||
|
images) is fully transparent, with
|
||||||
|
|
||||||
|
png_set_invert_alpha(png_ptr);
|
||||||
|
|
||||||
PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
|
PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
|
||||||
they can, resulting in, for example, 8 pixels per byte for 1 bit
|
they can, resulting in, for example, 8 pixels per byte for 1 bit
|
||||||
files. This code expands to 1 pixel per byte without changing the
|
files. This code expands to 1 pixel per byte without changing the
|
||||||
@ -781,14 +744,12 @@ RGB. This code will do that conversion:
|
|||||||
png_set_gray_to_rgb(png_ptr);
|
png_set_gray_to_rgb(png_ptr);
|
||||||
|
|
||||||
Conversely, you can convert an RGB or RGBA image to grayscale or grayscale
|
Conversely, you can convert an RGB or RGBA image to grayscale or grayscale
|
||||||
with alpha. This is intended for conversion of images that really are
|
with alpha.
|
||||||
gray (red == green == blue), so the function simply strips out the red
|
|
||||||
and blue channels, leaving the green channel in the gray position.
|
|
||||||
|
|
||||||
if (color_type == PNG_COLOR_TYPE_RGB ||
|
if (color_type == PNG_COLOR_TYPE_RGB ||
|
||||||
color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||||
png_set_rgb_to_gray(png_ptr, error_action,
|
png_set_rgb_to_gray_fixed(png_ptr, error_action,
|
||||||
double red_weight, double green_weight);
|
int red_weight, int green_weight);
|
||||||
|
|
||||||
error_action = 1: silently do the conversion
|
error_action = 1: silently do the conversion
|
||||||
error_action = 2: issue a warning if the original
|
error_action = 2: issue a warning if the original
|
||||||
@ -799,10 +760,10 @@ and blue channels, leaving the green channel in the gray position.
|
|||||||
image has any pixel where
|
image has any pixel where
|
||||||
red != green or red != blue
|
red != green or red != blue
|
||||||
|
|
||||||
red_weight: weight of red component
|
red_weight: weight of red component times 100000
|
||||||
(NULL -> default 54/256)
|
green_weight: weight of green component times 100000
|
||||||
green_weight: weight of green component
|
If either weight is negative, default
|
||||||
(NULL -> default 183/256)
|
weights (21268, 71514) are used.
|
||||||
|
|
||||||
If you have set error_action = 1 or 2, you can
|
If you have set error_action = 1 or 2, you can
|
||||||
later check whether the image really was gray, after processing
|
later check whether the image really was gray, after processing
|
||||||
@ -812,13 +773,13 @@ It will return a png_byte that is zero if the image was gray or
|
|||||||
will be silently converted to grayscale, using the green channel
|
will be silently converted to grayscale, using the green channel
|
||||||
data, regardless of the error_action setting.
|
data, regardless of the error_action setting.
|
||||||
|
|
||||||
With 0.0<=red_weight+green_weight<=1.0,
|
With red_weight+green_weight<=100000,
|
||||||
the normalized graylevel is computed:
|
the normalized graylevel is computed:
|
||||||
|
|
||||||
int rw = red_weight * 256;
|
int rw = red_weight * 65536;
|
||||||
int gw = green_weight * 256;
|
int gw = green_weight * 65536;
|
||||||
int bw = 256 - (rw + gw);
|
int bw = 65536 - (rw + gw);
|
||||||
gray = (rw*red + gw*green + bw*blue)/256;
|
gray = (rw*red + gw*green + bw*blue)/65536;
|
||||||
|
|
||||||
The default values approximate those recommended in the Charles
|
The default values approximate those recommended in the Charles
|
||||||
Poynton's Color FAQ, <http://www.inforamp.net/~poynton/>
|
Poynton's Color FAQ, <http://www.inforamp.net/~poynton/>
|
||||||
@ -828,11 +789,11 @@ Copyright (c) 1998-01-04 Charles Poynton poynton@inforamp.net
|
|||||||
|
|
||||||
Libpng approximates this with
|
Libpng approximates this with
|
||||||
|
|
||||||
Y = 0.211 * R + 0.715 * G + 0.074 * B
|
Y = 0.21268 * R + 0.7151 * G + 0.07217 * B
|
||||||
|
|
||||||
which can be expressed with integers as
|
which can be expressed with integers as
|
||||||
|
|
||||||
Y = (54 * R + 183 * G + 19 * B)/256
|
Y = (6969 * R + 23434 * G + 2365 * B)/32768
|
||||||
|
|
||||||
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.
|
||||||
@ -963,6 +924,38 @@ need to change the order the pixels are packed into bytes, you can use:
|
|||||||
if (bit_depth < 8)
|
if (bit_depth < 8)
|
||||||
png_set_packswap(png_ptr);
|
png_set_packswap(png_ptr);
|
||||||
|
|
||||||
|
Finally, you can write your own transformation function if none of
|
||||||
|
the existing ones meets your needs. This is done by setting a callback
|
||||||
|
with
|
||||||
|
|
||||||
|
png_set_read_user_transform_fn(png_ptr,
|
||||||
|
read_transform_fn);
|
||||||
|
|
||||||
|
You must supply the function
|
||||||
|
|
||||||
|
void read_transform_fn(png_ptr ptr, row_info_ptr
|
||||||
|
row_info, png_bytep data)
|
||||||
|
|
||||||
|
See pngtest.c for a working example. Your function will be called
|
||||||
|
after all of the other transformations have been processed.
|
||||||
|
|
||||||
|
You can also set up a pointer to a user structure for use by your
|
||||||
|
callback function, and you can inform libpng that your transform
|
||||||
|
function will change the number of channels or bit depth with the
|
||||||
|
function
|
||||||
|
|
||||||
|
png_set_user_transform_info(png_ptr, user_ptr,
|
||||||
|
user_depth, user_channels);
|
||||||
|
|
||||||
|
The user's application, not libpng, is responsible for allocating and
|
||||||
|
freeing any memory required for the user structure.
|
||||||
|
|
||||||
|
You can retrieve the pointer via the function
|
||||||
|
png_get_user_transform_ptr(). For example:
|
||||||
|
|
||||||
|
voidp read_user_transform_ptr =
|
||||||
|
png_get_user_transform_ptr(png_ptr);
|
||||||
|
|
||||||
The last thing to handle is interlacing; this is covered in detail below,
|
The last thing to handle is interlacing; this is covered in detail below,
|
||||||
but you must call the function here if you want libpng to handle expansion
|
but you must call the function here if you want libpng to handle expansion
|
||||||
of the interlaced image.
|
of the interlaced image.
|
||||||
@ -1017,10 +1010,10 @@ interlace_type == PNG_INTERLACE_NONE), this is simple:
|
|||||||
where row_pointers is the same as in the png_read_image() call.
|
where row_pointers is the same as in the png_read_image() call.
|
||||||
|
|
||||||
If you are doing this just one row at a time, you can do this with
|
If you are doing this just one row at a time, you can do this with
|
||||||
row_pointers:
|
a single row_pointer instead of an array of row_pointers:
|
||||||
|
|
||||||
png_bytep row_pointers = row;
|
png_bytep row_pointer = row;
|
||||||
png_read_row(png_ptr, &row_pointers, NULL);
|
png_read_row(png_ptr, row_pointers, NULL);
|
||||||
|
|
||||||
If the file is interlaced (info_ptr->interlace_type != 0), things get
|
If the file is interlaced (info_ptr->interlace_type != 0), things get
|
||||||
somewhat harder. The only current (PNG Specification version 1.2)
|
somewhat harder. The only current (PNG Specification version 1.2)
|
||||||
@ -1171,7 +1164,7 @@ png_infop info_ptr;
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setjmp(png_jmp_env(png_ptr)))
|
if (setjmp(png_jmpbuf(png_ptr)))
|
||||||
{
|
{
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr,
|
png_destroy_read_struct(&png_ptr, &info_ptr,
|
||||||
(png_infopp)NULL);
|
(png_infopp)NULL);
|
||||||
@ -1205,7 +1198,7 @@ png_infop info_ptr;
|
|||||||
int
|
int
|
||||||
process_data(png_bytep buffer, png_uint_32 length)
|
process_data(png_bytep buffer, png_uint_32 length)
|
||||||
{
|
{
|
||||||
if (setjmp(png_jmp_env(png_ptr)))
|
if (setjmp(png_jmpbuf(png_ptr)))
|
||||||
{
|
{
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr,
|
png_destroy_read_struct(&png_ptr, &info_ptr,
|
||||||
(png_infopp)NULL);
|
(png_infopp)NULL);
|
||||||
@ -1360,15 +1353,15 @@ png_create_write_struct_2() instead of png_create_read_struct():
|
|||||||
After you have these structures, you will need to set up the
|
After you have these structures, you will need to set up the
|
||||||
error handling. When libpng encounters an error, it expects to
|
error handling. When libpng encounters an error, it expects to
|
||||||
longjmp() back to your routine. Therefore, you will need to call
|
longjmp() back to your routine. Therefore, you will need to call
|
||||||
setjmp() and pass the png_jmp_env(png_ptr). If you
|
setjmp() and pass the png_jmpbuf(png_ptr). If you
|
||||||
write the file from different routines, you will need to update
|
write the file from different routines, you will need to update
|
||||||
the png_jmp_env(png_ptr) every time you enter a new routine that will
|
the png_jmpbuf(png_ptr) every time you enter a new routine that will
|
||||||
call a png_ function. See your documentation of setjmp/longjmp
|
call a png_*() function. See your documentation of setjmp/longjmp
|
||||||
for your compiler for more information on setjmp/longjmp. See
|
for your compiler for more information on setjmp/longjmp. See
|
||||||
the discussion on libpng error handling in the Customizing Libpng
|
the discussion on libpng error handling in the Customizing Libpng
|
||||||
section below for more information on the libpng error handling.
|
section below for more information on the libpng error handling.
|
||||||
|
|
||||||
if (setjmp(png_jmp_env(png_ptr)))
|
if (setjmp(png_jmpbuf(png_ptr)))
|
||||||
{
|
{
|
||||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
@ -1803,14 +1796,15 @@ make sure to only enable a transformation if it will be valid for the
|
|||||||
data. For example, don't swap red and blue on grayscale data.
|
data. For example, don't swap red and blue on grayscale data.
|
||||||
|
|
||||||
PNG files store RGB pixels packed into 3 or 6 bytes. This code tells
|
PNG files store RGB pixels packed into 3 or 6 bytes. This code tells
|
||||||
the library to expand the input data to 4 or 8 bytes per pixel
|
the library to trip input data that has 4 or 8 bytes per pixel down
|
||||||
(or expand 1 or 2-byte grayscale data to 2 or 4 bytes per pixel).
|
to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2
|
||||||
|
bytes per pixel).
|
||||||
|
|
||||||
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
|
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
|
||||||
|
|
||||||
where the 0 is the value that will be put in the 4th byte, and the
|
where the 0 is unused, and the location is either PNG_FILLER_BEFORE or
|
||||||
location is either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending
|
PNG_FILLER_AFTER, depending upon whether the filler byte in the is stored
|
||||||
upon whether the filler byte is stored XRGB or RGBX.
|
XRGB or RGBX.
|
||||||
|
|
||||||
PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
|
PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
|
||||||
they can, resulting in, for example, 8 pixels per byte for 1 bit files.
|
they can, resulting in, for example, 8 pixels per byte for 1 bit files.
|
||||||
@ -1927,7 +1921,7 @@ that do not use flushing.
|
|||||||
Writing the image data
|
Writing the image data
|
||||||
|
|
||||||
That's it for the transformations. Now you can write the image data.
|
That's it for the transformations. Now you can write the image data.
|
||||||
The simplest way to do this is in one function call. If have the
|
The simplest way to do this is in one function call. If you have the
|
||||||
whole image in memory, you can just call png_write_image() and libpng
|
whole image in memory, you can just call png_write_image() and libpng
|
||||||
will write the image. You will need to pass in an array of pointers to
|
will write the image. You will need to pass in an array of pointers to
|
||||||
each row. This function automatically handles interlacing, so you don't
|
each row. This function automatically handles interlacing, so you don't
|
||||||
@ -1952,11 +1946,11 @@ this is simple:
|
|||||||
row_pointers is the same as in the png_write_image() call.
|
row_pointers is the same as in the png_write_image() call.
|
||||||
|
|
||||||
If you are just writing one row at a time, you can do this with
|
If you are just writing one row at a time, you can do this with
|
||||||
row_pointers:
|
a single row_pointer instead of an array of row_pointers:
|
||||||
|
|
||||||
png_bytep row_pointer = row;
|
png_bytep row_pointer = row;
|
||||||
|
|
||||||
png_write_row(png_ptr, &row_pointer);
|
png_write_row(png_ptr, row_pointer);
|
||||||
|
|
||||||
When the file is interlaced, things can get a good deal more
|
When the file is interlaced, things can get a good deal more
|
||||||
complicated. The only currently (as of January 2000 -- PNG Specification
|
complicated. The only currently (as of January 2000 -- PNG Specification
|
||||||
@ -2406,13 +2400,13 @@ the old method.
|
|||||||
|
|
||||||
VII. Y2K Compliance in libpng
|
VII. Y2K Compliance in libpng
|
||||||
|
|
||||||
February 18, 2000
|
March 21, 2000
|
||||||
|
|
||||||
Since the PNG Development group is an ad-hoc body, we can't make
|
Since the PNG Development group is an ad-hoc body, we can't make
|
||||||
an official declaration.
|
an official declaration.
|
||||||
|
|
||||||
This is your unofficial assurance that libpng from version 0.71 and
|
This is your unofficial assurance that libpng from version 0.71 and
|
||||||
upward through 1.0.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.
|
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
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
.TH LIBPNGPF 3 February 18, 2000
|
.TH LIBPNGPF 3 March 21, 2000
|
||||||
.SH NAME
|
.SH NAME
|
||||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5s
|
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.6
|
||||||
(private functions)
|
(private functions)
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
\fB#include <png.h>\fP
|
\fB#include <png.h>\fP
|
||||||
|
6
png.5
6
png.5
@ -1,4 +1,4 @@
|
|||||||
.TH PNG 5 "February 18, 2000"
|
.TH PNG 5 "March 21, 2000"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
png \- Portable Network Graphics (PNG) format
|
png \- Portable Network Graphics (PNG) format
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
@ -23,7 +23,9 @@ platforms.
|
|||||||
PNG 1.2 specification, July 1999:
|
PNG 1.2 specification, July 1999:
|
||||||
.IP
|
.IP
|
||||||
.br
|
.br
|
||||||
http://www.cdrom.com/pub/png
|
http://www.cdrom.com/pub/png (moving to http://www.libpng.org)
|
||||||
|
.br
|
||||||
|
or ftp://ftp.uu.net/graphics/png/documents
|
||||||
.LP
|
.LP
|
||||||
PNG 1.0 specification, October 1996:
|
PNG 1.0 specification, October 1996:
|
||||||
.IP
|
.IP
|
||||||
|
25
png.c
25
png.c
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* png.c - location for general purpose libpng functions
|
/* png.c - location for general purpose libpng functions
|
||||||
*
|
*
|
||||||
* libpng version 1.0.5s - February 18, 2000
|
* libpng version 1.0.6 - March 21, 2000
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
@ -13,13 +13,15 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
|
||||||
|
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||||
|
typedef version_1_0_6 Your_png_h_is_not_version_1_0_6;
|
||||||
|
|
||||||
/* Version information for C files. This had better match the version
|
/* Version information for C files. This had better match the version
|
||||||
* string defined in png.h.
|
* string defined in png.h. */
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef PNG_USE_GLOBAL_ARRAYS
|
#ifdef PNG_USE_GLOBAL_ARRAYS
|
||||||
/* png_libpng_ver was changed to a function in version 1.0.5c */
|
/* png_libpng_ver was changed to a function in version 1.0.5c */
|
||||||
char png_libpng_ver[12] = "1.0.5s";
|
char png_libpng_ver[12] = "1.0.6";
|
||||||
|
|
||||||
/* 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. */
|
||||||
@ -543,7 +545,7 @@ png_charp
|
|||||||
png_get_copyright(png_structp png_ptr)
|
png_get_copyright(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */
|
if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */
|
||||||
return ("\n libpng version 1.0.5s - February 18, 2000\n\
|
return ("\n libpng version 1.0.6 - March 21, 2000\n\
|
||||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n\
|
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n\
|
||||||
Copyright (c) 1996, 1997 Andreas Dilger\n\
|
Copyright (c) 1996, 1997 Andreas Dilger\n\
|
||||||
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson\n");
|
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson\n");
|
||||||
@ -561,8 +563,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("1.0.5s");
|
return("1.0.6");
|
||||||
return("1.0.5s");
|
return("1.0.6");
|
||||||
}
|
}
|
||||||
|
|
||||||
png_charp
|
png_charp
|
||||||
@ -583,15 +585,6 @@ png_get_header_version(png_structp png_ptr)
|
|||||||
return(PNG_HEADER_VERSION_STRING);
|
return(PNG_HEADER_VERSION_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
|
||||||
void
|
|
||||||
png_check_version
|
|
||||||
(version_1_0_5s png_h_is_not_version_1_0_5s)
|
|
||||||
{
|
|
||||||
if(png_h_is_not_version_1_0_5s == NULL)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||||
int
|
int
|
||||||
png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
|
png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
|
||||||
|
313
png.h
313
png.h
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* png.h - header file for PNG reference library
|
/* png.h - header file for PNG reference library
|
||||||
*
|
*
|
||||||
* libpng version 1.0.5s - February 18, 2000
|
* libpng version 1.0.6 - March 21, 2000
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
@ -9,19 +9,150 @@
|
|||||||
* Authors and maintainers:
|
* Authors and maintainers:
|
||||||
* libpng versions 0.71, May 1995, through 0.89c, May 1996: Guy Schalnat
|
* libpng versions 0.71, May 1995, through 0.89c, May 1996: Guy Schalnat
|
||||||
* libpng versions 0.90, December 1996, through 0.96, May 1997: Andreas Dilger
|
* libpng versions 0.90, December 1996, through 0.96, May 1997: Andreas Dilger
|
||||||
* libpng versions 0.97, January 1998, through 1.0.5s - February 18, 2000: Glenn
|
* libpng versions 0.97, January 1998, through 1.0.6 - March 21, 2000: Glenn
|
||||||
* See also "Contributing Authors", below.
|
* See also "Contributing Authors", below.
|
||||||
*
|
*
|
||||||
|
* Note about libpng version numbers:
|
||||||
|
*
|
||||||
|
* Due to various miscommunications, unforeseen code incompatibilities
|
||||||
|
* and occasional factors outside the authors' control, version numbering
|
||||||
|
* on the library has not always been consistent and straightforward.
|
||||||
|
* The following table summarizes matters since version 0.89c, which was
|
||||||
|
* the first widely used release:
|
||||||
|
*
|
||||||
|
* source png.h png.h shared-lib
|
||||||
|
* version string int version
|
||||||
|
* ------- ------ ----- ----------
|
||||||
|
* 0.89c ("1.0 beta 3") 0.89 89 1.0.89
|
||||||
|
* 0.90 ("1.0 beta 4") 0.90 90 0.90 [should have been 2.0.90]
|
||||||
|
* 0.95 ("1.0 beta 5") 0.95 95 0.95 [should have been 2.0.95]
|
||||||
|
* 0.96 ("1.0 beta 6") 0.96 96 0.96 [should have been 2.0.96]
|
||||||
|
* 0.97b ("1.00.97 beta 7") 1.00.97 97 1.0.1 [should have been 2.0.97]
|
||||||
|
* 0.97c 0.97 97 2.0.97
|
||||||
|
* 0.98 0.98 98 2.0.98
|
||||||
|
* 0.99 0.99 98 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.0.0 1.0.0 100 2.1.0 [100 should be 10000]
|
||||||
|
* 1.0.1 1.0.1 10001 2.1.0
|
||||||
|
* 1.0.1a-e 1.0.1a-e 10002 2.1.0.1a-e
|
||||||
|
* 1.0.2 1.0.2 10002 2.1.0.2
|
||||||
|
* 1.0.2a-b 1.0.2a-b 10003 2.1.0.2a-b
|
||||||
|
* 1.0.3 1.0.3 10003 2.1.0.3
|
||||||
|
* 1.0.3a-d 1.0.3a-d 10004 2.1.0.3a-d
|
||||||
|
* 1.0.4 1.0.4 10004 2.1.0.4
|
||||||
|
* 1.0.4a-f 1.0.4a-f 10005 2.1.0.4a-f
|
||||||
|
* 1.0.5 1.0.5 10005 2.1.0.5
|
||||||
|
* 1.0.5a-d 1.0.5a-d 10006 2.1.0.5a-d
|
||||||
|
* 1.0.5e-r 1.0.5e-r 10100 2.1.0.5e-r (not compatible)
|
||||||
|
* 1.0.5s-v 1.0.5s-v 10006 2.1.0.5s-w (compatible)
|
||||||
|
* 1.0.6 1.0.6 10006 2.1.0.6
|
||||||
|
* 1.3.0 1.3.0 10300 3.1.3.0
|
||||||
|
*
|
||||||
|
* Henceforth the source version will match the shared-library minor
|
||||||
|
* and patch numbers; the shared-library major version number will be
|
||||||
|
* used for changes in backward compatibility, as it is intended. The
|
||||||
|
* PNG_PNGLIB_VER macro, which is not used within libpng but is available
|
||||||
|
* for applications, is an unsigned integer of the form xyyzz corresponding
|
||||||
|
* to the source version x.y.z (leading zeros in y and z). Internal
|
||||||
|
* png-group beta versions (x.y.z[a-z]) will be given the next higher
|
||||||
|
* number.
|
||||||
|
*
|
||||||
|
* See libpng.txt or libpng.3 for more information. The PNG specification
|
||||||
|
* is available as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/>
|
||||||
|
* and as a W3C Recommendation <http://www.w3.org/TR/REC.png.html>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* COPYRIGHT NOTICE:
|
||||||
|
*
|
||||||
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
|
* (libpng versions 0.5, May 1995, through 0.89c, May 1996)
|
||||||
|
* 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.6, March 21, 2000)
|
||||||
|
*
|
||||||
|
* For the purposes of this copyright and license, "Contributing Authors"
|
||||||
|
* is defined as the following set of individuals:
|
||||||
|
*
|
||||||
|
* John Bowler
|
||||||
|
* Kevin Bracey
|
||||||
|
* Sam Bushell
|
||||||
|
* Andreas Dilger
|
||||||
|
* Magnus Holmgren
|
||||||
|
* Tom Lane
|
||||||
|
* Dave Martindale
|
||||||
|
* Glenn Randers-Pehrson
|
||||||
|
* Eric S. Raymond
|
||||||
|
* Greg Roelofs
|
||||||
|
* Guy Eric Schalnat
|
||||||
|
* Paul Schmidt
|
||||||
|
* Tom Tanner
|
||||||
|
* Willem van Schaik
|
||||||
|
* Tim Wegner
|
||||||
|
*
|
||||||
|
* The PNG Reference Library is supplied "AS IS". The Contributing Authors
|
||||||
|
* and Group 42, Inc. disclaim all warranties, expressed or implied,
|
||||||
|
* including, without limitation, the warranties of merchantability and of
|
||||||
|
* fitness for any purpose. The Contributing Authors and Group 42, Inc.
|
||||||
|
* assume no liability for direct, indirect, incidental, special, exemplary,
|
||||||
|
* or consequential damages, which may result from the use of the PNG
|
||||||
|
* Reference Library, even if advised of the possibility of such damage.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted to use, copy, modify, and distribute this
|
||||||
|
* source code, or portions hereof, for any purpose, without fee, subject
|
||||||
|
* to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this source code must not be misrepresented.
|
||||||
|
*
|
||||||
|
* 2. Altered versions must be plainly marked as such and must not
|
||||||
|
* be misrepresented as being the original source.
|
||||||
|
*
|
||||||
|
* 3. This Copyright notice may not be removed or altered from any
|
||||||
|
* source or altered source distribution.
|
||||||
|
*
|
||||||
|
* The Contributing Authors and Group 42, Inc. specifically permit, without
|
||||||
|
* fee, and encourage the use of this source code as a component to
|
||||||
|
* supporting the PNG file format in commercial products. If you use this
|
||||||
|
* source code in a product, acknowledgment is not required but would be
|
||||||
|
* appreciated.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A "png_get_copyright" function is available, for convenient use in "about"
|
||||||
|
* boxes and the like:
|
||||||
|
*
|
||||||
|
* printf("%s",png_get_copyright(NULL));
|
||||||
|
*
|
||||||
|
* Also, the PNG logo (in PNG format, of course) is supplied in the
|
||||||
|
* file "pngnow.png".
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Libpng is OSI Certified Open Source Software. OSI Certified is a
|
||||||
|
* certification mark of the Open Source Initiative.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The contributing authors would like to thank all those who helped
|
||||||
|
* with testing, bug fixes, and patience. This wouldn't have been
|
||||||
|
* possible without all of you.
|
||||||
|
*
|
||||||
|
* Thanks to Frank J. T. Wojcik for helping with the documentation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
* Y2K compliance in libpng:
|
* Y2K compliance in libpng:
|
||||||
* =========================
|
* =========================
|
||||||
*
|
*
|
||||||
* February 18, 2000
|
* March 21, 2000
|
||||||
*
|
*
|
||||||
* Since the PNG Development group is an ad-hoc body, we can't make
|
* Since the PNG Development group is an ad-hoc body, we can't make
|
||||||
* an official declaration.
|
* an official declaration.
|
||||||
*
|
*
|
||||||
* This is your unofficial assurance that libpng from version 0.71 and
|
* This is your unofficial assurance that libpng from version 0.71 and
|
||||||
* upward through 1.0.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.
|
* 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
|
||||||
@ -65,137 +196,6 @@
|
|||||||
* Glenn Randers-Pehrson
|
* Glenn Randers-Pehrson
|
||||||
* libpng maintainer
|
* libpng maintainer
|
||||||
* PNG Development Group
|
* PNG Development Group
|
||||||
*
|
|
||||||
* Note about libpng version numbers:
|
|
||||||
*
|
|
||||||
* Due to various miscommunications, unforeseen code incompatibilities
|
|
||||||
* and occasional factors outside the authors' control, version numbering
|
|
||||||
* on the library has not always been consistent and straightforward.
|
|
||||||
* The following table summarizes matters since version 0.89c, which was
|
|
||||||
* the first widely used release:
|
|
||||||
*
|
|
||||||
* source png.h png.h shared-lib
|
|
||||||
* version string int version
|
|
||||||
* ------- ------ ----- ----------
|
|
||||||
* 0.89c ("1.0 beta 3") 0.89 89 1.0.89
|
|
||||||
* 0.90 ("1.0 beta 4") 0.90 90 0.90 [should have been 2.0.90]
|
|
||||||
* 0.95 ("1.0 beta 5") 0.95 95 0.95 [should have been 2.0.95]
|
|
||||||
* 0.96 ("1.0 beta 6") 0.96 96 0.96 [should have been 2.0.96]
|
|
||||||
* 0.97b ("1.00.97 beta 7") 1.00.97 97 1.0.1 [should have been 2.0.97]
|
|
||||||
* 0.97c 0.97 97 2.0.97
|
|
||||||
* 0.98 0.98 98 2.0.98
|
|
||||||
* 0.99 0.99 98 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.0.0 1.0.0 100 2.1.0 [100 should be 10000]
|
|
||||||
* 1.0.1 1.0.1 10001 2.1.0
|
|
||||||
* 1.0.1a-e 1.0.1a-e 10002 2.1.0.1a-e
|
|
||||||
* 1.0.2 1.0.2 10002 2.1.0.2
|
|
||||||
* 1.0.2a-b 1.0.2a-b 10003 2.1.0.2a-b
|
|
||||||
* 1.0.3 1.0.3 10003 2.1.0.3
|
|
||||||
* 1.0.3a-d 1.0.3a-d 10004 2.1.0.3a-d
|
|
||||||
* 1.0.4 1.0.4 10004 2.1.0.4
|
|
||||||
* 1.0.4a-f 1.0.4a-f 10005 2.1.0.4a-f
|
|
||||||
* 1.0.5 1.0.5 10005 2.1.0.5
|
|
||||||
* 1.0.5a-d 1.0.5a-d 10006 2.1.0.5a-d
|
|
||||||
* 1.0.5e-r 1.0.5e-r 10100 2.1.0.5e-r (not compatible)
|
|
||||||
* 1.0.5s 1.0.5s 10006 2.1.0.5s (compatible)
|
|
||||||
* 1.3.0 1.3.0 10300 3.1.3.0
|
|
||||||
*
|
|
||||||
* Henceforth the source version will match the shared-library minor
|
|
||||||
* and patch numbers; the shared-library major version number will be
|
|
||||||
* used for changes in backward compatibility, as it is intended. The
|
|
||||||
* PNG_PNGLIB_VER macro, which is not used within libpng but is available
|
|
||||||
* for applications, is an unsigned integer of the form xyyzz corresponding
|
|
||||||
* to the source version x.y.z (leading zeros in y and z). Internal
|
|
||||||
* png-group beta versions (x.y.z[a-z]) will be given the next higher
|
|
||||||
* number.
|
|
||||||
*
|
|
||||||
* See libpng.txt or libpng.3 for more information. The PNG specification
|
|
||||||
* is available as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/>
|
|
||||||
* and as a W3C Recommendation <http://www.w3.org/TR/REC.png.html>
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* COPYRIGHT NOTICE:
|
|
||||||
*
|
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
|
||||||
* (libpng versions 0.5, May 1995, through 0.89c, May 1996)
|
|
||||||
* 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)
|
|
||||||
*
|
|
||||||
* For the purposes of this copyright and license, "Contributing Authors"
|
|
||||||
* is defined as the following set of individuals:
|
|
||||||
*
|
|
||||||
* John Bowler
|
|
||||||
* Kevin Bracey
|
|
||||||
* Sam Bushell
|
|
||||||
* Andreas Dilger
|
|
||||||
* Magnus Holmgren
|
|
||||||
* Tom Lane
|
|
||||||
* Dave Martindale
|
|
||||||
* Glenn Randers-Pehrson
|
|
||||||
* Eric S. Raymond
|
|
||||||
* Greg Roelofs
|
|
||||||
* Guy Eric Schalnat
|
|
||||||
* Paul Schmidt
|
|
||||||
* Tom Tanner
|
|
||||||
* Willem van Schaik
|
|
||||||
* Tim Wegner
|
|
||||||
*
|
|
||||||
* The PNG Reference Library is supplied "AS IS". The Contributing Authors
|
|
||||||
* and Group 42, Inc. disclaim all warranties, expressed or implied,
|
|
||||||
* including, without limitation, the warranties of merchantability and of
|
|
||||||
* fitness for any purpose. The Contributing Authors and Group 42, Inc.
|
|
||||||
* assume no liability for direct, indirect, incidental, special, exemplary,
|
|
||||||
* or consequential damages, which may result from the use of the PNG
|
|
||||||
* Reference Library, even if advised of the possibility of such damage.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted to use, copy, modify, and distribute this
|
|
||||||
* source code, or portions hereof, for any purpose, without fee, subject
|
|
||||||
* to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this source code must not be
|
|
||||||
* misrepresented.
|
|
||||||
*
|
|
||||||
* 2. Altered versions must be plainly marked as such
|
|
||||||
* and must not be misrepresented as being the
|
|
||||||
* original source.
|
|
||||||
*
|
|
||||||
* 3. This Copyright notice may not be removed or
|
|
||||||
* altered from any source or altered source
|
|
||||||
* distribution.
|
|
||||||
*
|
|
||||||
* The Contributing Authors and Group 42, Inc. specifically permit, without
|
|
||||||
* fee, and encourage the use of this source code as a component to
|
|
||||||
* supporting the PNG file format in commercial products. If you use this
|
|
||||||
* source code in a product, acknowledgment is not required but would be
|
|
||||||
* appreciated.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* A "png_get_copyright" function is available, for convenient use in "about"
|
|
||||||
* boxes and the like:
|
|
||||||
*
|
|
||||||
* printf("%s",png_get_copyright(NULL));
|
|
||||||
*
|
|
||||||
* Also, the PNG logo (in PNG format, of course) is supplied in the
|
|
||||||
* file "pngnow.png".
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Libpng is OSI Certified Open Source Software. OSI Certified is a
|
|
||||||
* certification mark of the Open Source Initiative.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The contributing authors would like to thank all those who helped
|
|
||||||
* with testing, bug fixes, and patience. This wouldn't have been
|
|
||||||
* possible without all of you.
|
|
||||||
*
|
|
||||||
* Thanks to Frank J. T. Wojcik for helping with the documentation.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _PNG_H
|
#ifndef _PNG_H
|
||||||
@ -230,7 +230,7 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* 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.5s"
|
#define PNG_LIBPNG_VER_STRING "1.0.6"
|
||||||
|
|
||||||
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
|
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
|
||||||
* We must not include leading zeros.
|
* We must not include leading zeros.
|
||||||
@ -310,26 +310,26 @@ typedef png_color_8 FAR * FAR * png_color_8pp;
|
|||||||
* The following two structures are used for the in-core representation
|
* The following two structures are used for the in-core representation
|
||||||
* of sPLT chunks.
|
* of sPLT chunks.
|
||||||
*/
|
*/
|
||||||
typedef struct png_spalette_entry_struct
|
typedef struct png_sPLT_entry_struct
|
||||||
{
|
{
|
||||||
png_uint_16 red;
|
png_uint_16 red;
|
||||||
png_uint_16 green;
|
png_uint_16 green;
|
||||||
png_uint_16 blue;
|
png_uint_16 blue;
|
||||||
png_uint_16 alpha;
|
png_uint_16 alpha;
|
||||||
png_uint_16 frequency;
|
png_uint_16 frequency;
|
||||||
} png_spalette_entry;
|
} png_sPLT_entry;
|
||||||
typedef png_spalette_entry FAR * png_spalette_entryp;
|
typedef png_sPLT_entry FAR * png_sPLT_entryp;
|
||||||
typedef png_spalette_entry FAR * FAR * png_spalette_entrypp;
|
typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp;
|
||||||
|
|
||||||
typedef struct png_spalette_struct
|
typedef struct png_sPLT_struct
|
||||||
{
|
{
|
||||||
png_charp name; /* palette name */
|
png_charp name; /* palette name */
|
||||||
png_byte depth; /* depth of palette samples */
|
png_byte depth; /* depth of palette samples */
|
||||||
png_spalette_entryp entries; /* palette entries */
|
png_sPLT_entryp entries; /* palette entries */
|
||||||
png_int_32 nentries; /* number of palette entries */
|
png_int_32 nentries; /* number of palette entries */
|
||||||
} png_spalette;
|
} png_sPLT_t;
|
||||||
typedef png_spalette FAR * png_spalette_p;
|
typedef png_sPLT_t FAR * png_sPLT_tp;
|
||||||
typedef png_spalette FAR * FAR * png_spalette_pp;
|
typedef png_sPLT_t FAR * FAR * png_sPLT_tpp;
|
||||||
|
|
||||||
#ifdef PNG_TEXT_SUPPORTED
|
#ifdef PNG_TEXT_SUPPORTED
|
||||||
/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,
|
/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,
|
||||||
@ -635,7 +635,7 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
|||||||
|
|
||||||
#if defined(PNG_sPLT_SUPPORTED)
|
#if defined(PNG_sPLT_SUPPORTED)
|
||||||
/* data on sPLT chunks (there may be more than one). */
|
/* data on sPLT chunks (there may be more than one). */
|
||||||
png_spalette_p splt_palettes;
|
png_sPLT_tp splt_palettes;
|
||||||
png_uint_32 splt_palettes_num;
|
png_uint_32 splt_palettes_num;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1039,9 +1039,9 @@ struct png_struct_def
|
|||||||
|
|
||||||
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||||
png_byte rgb_to_gray_status;
|
png_byte rgb_to_gray_status;
|
||||||
png_byte rgb_to_gray_red_coeff;
|
png_uint_16 rgb_to_gray_red_coeff;
|
||||||
png_byte rgb_to_gray_green_coeff;
|
png_uint_16 rgb_to_gray_green_coeff;
|
||||||
png_byte rgb_to_gray_blue_coeff;
|
png_uint_16 rgb_to_gray_blue_coeff;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
|
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
|
||||||
@ -1056,9 +1056,9 @@ struct png_struct_def
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* This prevents a compiler error in png_get_copyright() in png.c if png.c
|
/* This prevents a compiler error in png_get_copyright() in png.c if png.c
|
||||||
and png.h are both at * version 1.0.5s
|
and png.h are both at * version 1.0.6
|
||||||
*/
|
*/
|
||||||
typedef png_structp version_1_0_5s;
|
typedef png_structp version_1_0_6;
|
||||||
|
|
||||||
typedef png_struct FAR * FAR * png_structpp;
|
typedef png_struct FAR * FAR * png_structpp;
|
||||||
|
|
||||||
@ -1179,6 +1179,8 @@ extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr));
|
|||||||
extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr,
|
extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr,
|
||||||
int error_action, double red, double green ));
|
int error_action, double red, double green ));
|
||||||
#endif
|
#endif
|
||||||
|
extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr,
|
||||||
|
int error_action, png_fixed_point red, png_fixed_point green ));
|
||||||
extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp
|
extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp
|
||||||
png_ptr));
|
png_ptr));
|
||||||
#endif
|
#endif
|
||||||
@ -1887,12 +1889,12 @@ extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr,
|
|||||||
|
|
||||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
#if defined(PNG_READ_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_spalette_pp entries));
|
png_infop info_ptr, png_sPLT_tpp entries));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_sPLT_SUPPORTED)
|
#if defined(PNG_sPLT_SUPPORTED)
|
||||||
extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr,
|
extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr,
|
||||||
png_infop info_ptr, png_spalette_p entries, int nentries));
|
png_infop info_ptr, png_sPLT_tp entries, int nentries));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_TEXT_SUPPORTED)
|
#if defined(PNG_TEXT_SUPPORTED)
|
||||||
@ -2029,7 +2031,7 @@ extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr)
|
|||||||
extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
|
extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
|
||||||
|
|
||||||
#define PNG_HEADER_VERSION_STRING \
|
#define PNG_HEADER_VERSION_STRING \
|
||||||
" libpng version 1.0.5s - February 18, 2000 (header)\n"
|
" libpng version 1.0.6 - March 21, 2000 (header)\n"
|
||||||
|
|
||||||
#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
|
#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
|
||||||
/* With these routines we avoid an integer divide, which will be slower on
|
/* With these routines we avoid an integer divide, which will be slower on
|
||||||
@ -2083,7 +2085,6 @@ extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
|
|||||||
/* Various modes of operation. Note that after an init, mode is set to
|
/* Various modes of operation. Note that after an init, mode is set to
|
||||||
* zero automatically when the structure is created.
|
* zero automatically when the structure is created.
|
||||||
*/
|
*/
|
||||||
#define PNG_BEFORE_IHDR 0x00
|
|
||||||
#define PNG_HAVE_IHDR 0x01
|
#define PNG_HAVE_IHDR 0x01
|
||||||
#define PNG_HAVE_PLTE 0x02
|
#define PNG_HAVE_PLTE 0x02
|
||||||
#define PNG_HAVE_IDAT 0x04
|
#define PNG_HAVE_IDAT 0x04
|
||||||
@ -2404,7 +2405,7 @@ PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr,
|
|||||||
|
|
||||||
#if defined(PNG_WRITE_sPLT_SUPPORTED)
|
#if defined(PNG_WRITE_sPLT_SUPPORTED)
|
||||||
PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr,
|
PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr,
|
||||||
png_spalette_p palette));
|
png_sPLT_tp palette));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_WRITE_tRNS_SUPPORTED)
|
#if defined(PNG_WRITE_tRNS_SUPPORTED)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* 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.5s - February 18, 2000
|
* libpng 1.0.6 - March 21, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1999, 2000 Glenn Randers-Pehrson
|
||||||
*
|
*
|
||||||
|
16
pngconf.h
16
pngconf.h
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngconf.h - machine configurable file for libpng
|
/* pngconf.h - machine configurable file for libpng
|
||||||
*
|
*
|
||||||
* libpng 1.0.5s - February 18, 2000
|
* libpng 1.0.6 - March 21, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
@ -441,9 +441,14 @@
|
|||||||
* but might be required for some pre-1.0.5c applications.
|
* but might be required for some pre-1.0.5c applications.
|
||||||
*/
|
*/
|
||||||
#ifdef PNG_NO_GLOBAL_ARRAYS
|
#ifdef PNG_NO_GLOBAL_ARRAYS
|
||||||
#define PNG_USE_LOCAL_ARRAYS
|
# define PNG_USE_LOCAL_ARRAYS
|
||||||
#else
|
#else
|
||||||
#define PNG_USE_GLOBAL_ARRAYS
|
# if defined(__GNUC__) && defined(WIN32)
|
||||||
|
# define PNG_NO_GLOBAL_ARRAYS
|
||||||
|
# define PNG_USE_LOCAL_ARRAYS
|
||||||
|
# else
|
||||||
|
# define PNG_USE_GLOBAL_ARRAYS
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* These are currently experimental features, define them if you want */
|
/* These are currently experimental features, define them if you want */
|
||||||
@ -913,7 +918,10 @@ typedef z_stream FAR * png_zstreamp;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_SETJMP_SUPPORTED
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
# define png_jmp_env(png_ptr) png_ptr->jmpbuf
|
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
|
||||||
|
#else
|
||||||
|
# define png_jmpbuf(png_ptr) \
|
||||||
|
(LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(USE_FAR_KEYWORD) /* memory model independent fns */
|
#if defined(USE_FAR_KEYWORD) /* memory model independent fns */
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngerror.c - stub functions for i/o and memory allocation
|
/* pngerror.c - stub functions for i/o and memory allocation
|
||||||
*
|
*
|
||||||
* libpng 1.0.5s - February 18, 2000
|
* libpng 1.0.6 - March 21, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
|
179
pnggccrd.c
179
pnggccrd.c
@ -6,7 +6,7 @@
|
|||||||
* and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm
|
* and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm
|
||||||
* for Intel's performance analysis of the MMX vs. non-MMX code.
|
* for Intel's performance analysis of the MMX vs. non-MMX code.
|
||||||
*
|
*
|
||||||
* libpng 1.0.5s - February 18, 2000
|
* libpng 1.0.6 - March 21, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998, Intel Corporation
|
* Copyright (c) 1998, Intel Corporation
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
@ -25,14 +25,15 @@
|
|||||||
* is required to assemble the newer MMX instructions such as movq.
|
* is required to assemble the newer MMX instructions such as movq.
|
||||||
* For djgpp, see
|
* For djgpp, see
|
||||||
*
|
*
|
||||||
* ftp://ftp.cdrom.com/pub/simtelnet/gnu/djgpp/v2gnu/bnu281b.zip
|
* ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bnu281b.zip
|
||||||
*
|
*
|
||||||
* (or a later version in the same directory). For Linux, check your
|
* (or a later version in the same directory). For Linux, check your
|
||||||
* distribution's web site(s) or try these links:
|
* distribution's web site(s) or try these links:
|
||||||
*
|
*
|
||||||
* http://rufus.w3.org/linux/RPM/binutils.html
|
* http://rufus.w3.org/linux/RPM/binutils.html
|
||||||
* http://www.debian.org/Packages/stable/devel/binutils.html
|
* http://www.debian.org/Packages/stable/devel/binutils.html
|
||||||
* ftp://ftp.cdrom.com/pub/linux/slackware/slakware/d1/binutils.tgz
|
* ftp://ftp.slackware.com/pub/linux/slackware/slackware/slakware/d1/
|
||||||
|
* binutils.tgz
|
||||||
*
|
*
|
||||||
* For other platforms, see the main GNU site:
|
* For other platforms, see the main GNU site:
|
||||||
*
|
*
|
||||||
@ -40,85 +41,92 @@
|
|||||||
*
|
*
|
||||||
* Version 2.5.2l.15 is definitely too old...
|
* Version 2.5.2l.15 is definitely too old...
|
||||||
*/
|
*/
|
||||||
#if 0
|
|
||||||
// GRR NOTES
|
/*
|
||||||
//
|
* GRR NOTES
|
||||||
// 19991006:
|
* =========
|
||||||
// - fixed sign error in post-MMX cleanup code (16- & 32-bit cases)
|
*
|
||||||
//
|
* 19991006:
|
||||||
// 19991007:
|
* - fixed sign error in post-MMX cleanup code (16- & 32-bit cases)
|
||||||
// - additional optimizations (possible or definite):
|
*
|
||||||
// x [DONE] write MMX code for 64-bit case (pixel_bytes == 8) [not tested]
|
* 19991007:
|
||||||
// - write MMX code for 48-bit case (pixel_bytes == 6)
|
* - additional optimizations (possible or definite):
|
||||||
// - figure out what's up with 24-bit case (pixel_bytes == 3):
|
* x [DONE] write MMX code for 64-bit case (pixel_bytes == 8) [not tested]
|
||||||
// why subtract 8 from width_mmx in the pass 4/5 case?
|
* - write MMX code for 48-bit case (pixel_bytes == 6)
|
||||||
// (only width_mmx case)
|
* - figure out what's up with 24-bit case (pixel_bytes == 3):
|
||||||
// x [DONE] replace pixel_bytes within each block with the true
|
* why subtract 8 from width_mmx in the pass 4/5 case?
|
||||||
// constant value (or are compilers smart enough to do that?)
|
* (only width_mmx case)
|
||||||
// - rewrite all MMX interlacing code so it's aligned with
|
* x [DONE] replace pixel_bytes within each block with the true
|
||||||
// the *beginning* of the row buffer, not the end. This
|
* constant value (or are compilers smart enough to do that?)
|
||||||
// would not only allow one to eliminate half of the memory
|
* - rewrite all MMX interlacing code so it's aligned with
|
||||||
// writes for odd passes (i.e., pass == odd), it may also
|
* the *beginning* of the row buffer, not the end. This
|
||||||
// eliminate some unaligned-data-access exceptions (assuming
|
* would not only allow one to eliminate half of the memory
|
||||||
// there's a penalty for not aligning 64-bit accesses on
|
* writes for odd passes (i.e., pass == odd), it may also
|
||||||
// 64-bit boundaries). The only catch is that the "leftover"
|
* eliminate some unaligned-data-access exceptions (assuming
|
||||||
// pixel(s) at the end of the row would have to be saved,
|
* there's a penalty for not aligning 64-bit accesses on
|
||||||
// but there are enough unused MMX registers in every case,
|
* 64-bit boundaries). The only catch is that the "leftover"
|
||||||
// so this is not a problem. A further benefit is that the
|
* pixel(s) at the end of the row would have to be saved,
|
||||||
// post-MMX cleanup code (C code) in at least some of the
|
* but there are enough unused MMX registers in every case,
|
||||||
// cases could be done within the assembler block.
|
* so this is not a problem. A further benefit is that the
|
||||||
// x [DONE] the "v3 v2 v1 v0 v7 v6 v5 v4" comments are confusing,
|
* post-MMX cleanup code (C code) in at least some of the
|
||||||
// inconsistent, and don't match the MMX Programmer's Reference
|
* cases could be done within the assembler block.
|
||||||
// Manual conventions anyway. They should be changed to
|
* x [DONE] the "v3 v2 v1 v0 v7 v6 v5 v4" comments are confusing,
|
||||||
// "b7 b6 b5 b4 b3 b2 b1 b0," where b0 indicates the byte that
|
* inconsistent, and don't match the MMX Programmer's Reference
|
||||||
// was lowest in memory (e.g., corresponding to a left pixel)
|
* Manual conventions anyway. They should be changed to
|
||||||
// and b7 is the byte that was highest (e.g., a right pixel).
|
* "b7 b6 b5 b4 b3 b2 b1 b0," where b0 indicates the byte that
|
||||||
//
|
* was lowest in memory (e.g., corresponding to a left pixel)
|
||||||
// 19991016:
|
* and b7 is the byte that was highest (e.g., a right pixel).
|
||||||
// - Brennan's Guide notwithstanding, gcc under Linux does *not*
|
*
|
||||||
// want globals prefixed by underscores when referencing them--
|
* 19991016:
|
||||||
// i.e., if the variable is const4, then refer to it as const4,
|
* - Brennan's Guide notwithstanding, gcc under Linux does *not*
|
||||||
// not _const4. This seems to be a djgpp-specific requirement.
|
* want globals prefixed by underscores when referencing them--
|
||||||
// Also, such variables apparently *must* be declared outside
|
* i.e., if the variable is const4, then refer to it as const4,
|
||||||
// of functions; neither static nor automatic variables work if
|
* not _const4. This seems to be a djgpp-specific requirement.
|
||||||
// defined within the scope of a single function, but both
|
* Also, such variables apparently *must* be declared outside
|
||||||
// static and truly global (multi-module) variables work fine.
|
* of functions; neither static nor automatic variables work if
|
||||||
//
|
* defined within the scope of a single function, but both
|
||||||
// 19991023:
|
* static and truly global (multi-module) variables work fine.
|
||||||
// - fixed png_combine_row() non-MMX replication bug (odd passes only?)
|
*
|
||||||
// - switched from string-concatenation-with-macros to cleaner method of
|
* 19991023:
|
||||||
// renaming global variables for djgpp--i.e., always use prefixes in
|
* - fixed png_combine_row() non-MMX replication bug (odd passes only?)
|
||||||
// inlined assembler code (== strings) and conditionally rename the
|
* - switched from string-concatenation-with-macros to cleaner method of
|
||||||
// variables, not the other way around. Hence _const4, _mask8_0, etc.
|
* renaming global variables for djgpp--i.e., always use prefixes in
|
||||||
//
|
* inlined assembler code (== strings) and conditionally rename the
|
||||||
// 19991024:
|
* variables, not the other way around. Hence _const4, _mask8_0, etc.
|
||||||
// - fixed mmxsupport()/png_do_interlace() first-row bug
|
*
|
||||||
// This one was severely weird: even though mmxsupport() doesn't touch
|
* 19991024:
|
||||||
// ebx (where "row" pointer was stored), it nevertheless managed to zero
|
* - fixed mmxsupport()/png_do_interlace() first-row bug
|
||||||
// the register (even in static/non-fPIC code--see below), which in turn
|
* This one was severely weird: even though mmxsupport() doesn't touch
|
||||||
// caused png_do_interlace() to return prematurely on the first row of
|
* ebx (where "row" pointer was stored), it nevertheless managed to zero
|
||||||
// interlaced images (i.e., without expanding the interlaced pixels).
|
* the register (even in static/non-fPIC code--see below), which in turn
|
||||||
// Inspection of the generated assembly code didn't turn up any clues,
|
* caused png_do_interlace() to return prematurely on the first row of
|
||||||
// although it did point at a minor optimization (i.e., get rid of
|
* interlaced images (i.e., without expanding the interlaced pixels).
|
||||||
// mmx_supported_local variable and just use eax). Possibly the CPUID
|
* Inspection of the generated assembly code didn't turn up any clues,
|
||||||
// instruction is more destructive than it looks? (Not yet checked.)
|
* although it did point at a minor optimization (i.e., get rid of
|
||||||
// - "info gcc" was next to useless, so compared fPIC and non-fPIC assembly
|
* mmx_supported_local variable and just use eax). Possibly the CPUID
|
||||||
// listings... Apparently register spillage has to do with ebx, since
|
* instruction is more destructive than it looks? (Not yet checked.)
|
||||||
// it's used to index the global offset table. Commenting it out of the
|
* - "info gcc" was next to useless, so compared fPIC and non-fPIC assembly
|
||||||
// input-reg lists in png_combine_row() eliminated compiler barfage, so
|
* listings... Apparently register spillage has to do with ebx, since
|
||||||
// ifdef'd with __PIC__ macro: if defined, use a global for unmask
|
* it's used to index the global offset table. Commenting it out of the
|
||||||
//
|
* input-reg lists in png_combine_row() eliminated compiler barfage, so
|
||||||
// 19991107:
|
* ifdef'd with __PIC__ macro: if defined, use a global for unmask
|
||||||
// - verified CPUID clobberage: 12-char string constant ("GenuineIntel",
|
*
|
||||||
// "AuthenticAMD", etc.) placed in EBX:ECX:EDX. Still need to polish.
|
* 19991107:
|
||||||
//
|
* - verified CPUID clobberage: 12-char string constant ("GenuineIntel",
|
||||||
// 19991120:
|
* "AuthenticAMD", etc.) placed in EBX:ECX:EDX. Still need to polish.
|
||||||
// - made "diff" variable (now "_dif") global to simplify conversion of
|
*
|
||||||
// filtering routines (running out of regs, sigh). "diff" is still used
|
* 19991120:
|
||||||
// in interlacing routines, however.
|
* - made "diff" variable (now "_dif") global to simplify conversion of
|
||||||
// - fixed up both versions of mmxsupport() (ORIG_THAT_USED_TO_CLOBBER_EBX
|
* filtering routines (running out of regs, sigh). "diff" is still used
|
||||||
// macro determines which is used); original not yet tested.
|
* in interlacing routines, however.
|
||||||
#endif
|
* - fixed up both versions of mmxsupport() (ORIG_THAT_USED_TO_CLOBBER_EBX
|
||||||
|
* macro determines which is used); original not yet tested.
|
||||||
|
*
|
||||||
|
* 20000319:
|
||||||
|
* - fixed a register-name typo in png_do_read_interlace(), default (MMX) case,
|
||||||
|
* pass == 4 or 5, that caused visible corruption of interlaced images
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
@ -1524,17 +1532,20 @@ fflush(stderr);
|
|||||||
width -= width_mmx; // 8 or 9 pix, 24 or 27 bytes
|
width -= width_mmx; // 8 or 9 pix, 24 or 27 bytes
|
||||||
if (width_mmx)
|
if (width_mmx)
|
||||||
{
|
{
|
||||||
|
// png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
|
||||||
|
// sptr points at last pixel in pre-expanded row
|
||||||
|
// dp points at last pixel position in expanded row
|
||||||
__asm__ (
|
__asm__ (
|
||||||
"subl $3, %%esi \n\t"
|
"subl $3, %%esi \n\t"
|
||||||
"subl $9, %%edi \n\t"
|
"subl $9, %%edi \n\t"
|
||||||
// (png_pass_inc[pass] - 1)*pixel_bytes
|
// (png_pass_inc[pass] + 1)*pixel_bytes
|
||||||
|
|
||||||
".loop3_pass4: \n\t"
|
".loop3_pass4: \n\t"
|
||||||
"movq (%%esi), %%mm0 \n\t" // x x 5 4 3 2 1 0
|
"movq (%%esi), %%mm0 \n\t" // x x 5 4 3 2 1 0
|
||||||
"movq %%mm0, %%mm1 \n\t" // x x 5 4 3 2 1 0
|
"movq %%mm0, %%mm1 \n\t" // x x 5 4 3 2 1 0
|
||||||
"movq %%mm0, %%mm2 \n\t" // x x 5 4 3 2 1 0
|
"movq %%mm0, %%mm2 \n\t" // x x 5 4 3 2 1 0
|
||||||
"psllq $24, %%mm0 \n\t" // 4 3 2 1 0 z z z
|
"psllq $24, %%mm0 \n\t" // 4 3 2 1 0 z z z
|
||||||
"pand _const4, %%mm0 \n\t" // z z z z z 2 1 0
|
"pand _const4, %%mm1 \n\t" // z z z z z 2 1 0
|
||||||
"psrlq $24, %%mm2 \n\t" // z z z x x 5 4 3
|
"psrlq $24, %%mm2 \n\t" // z z z x x 5 4 3
|
||||||
"por %%mm1, %%mm0 \n\t" // 4 3 2 1 0 2 1 0
|
"por %%mm1, %%mm0 \n\t" // 4 3 2 1 0 2 1 0
|
||||||
"movq %%mm2, %%mm3 \n\t" // z z z x x 5 4 3
|
"movq %%mm2, %%mm3 \n\t" // z z z x x 5 4 3
|
||||||
|
4
pngget.c
4
pngget.c
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngget.c - retrieval of values from info struct
|
/* pngget.c - retrieval of values from info struct
|
||||||
*
|
*
|
||||||
* libpng 1.0.5s - February 18, 2000
|
* libpng 1.0.6 - March 21, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
@ -489,7 +489,7 @@ png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
|
|||||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||||
png_uint_32
|
png_uint_32
|
||||||
png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
|
png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
|
||||||
png_spalette_pp spalettes)
|
png_sPLT_tpp spalettes)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
|
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
|
||||||
*spalettes = info_ptr->splt_palettes;
|
*spalettes = info_ptr->splt_palettes;
|
||||||
|
2
pngmem.c
2
pngmem.c
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngmem.c - stub functions for memory allocation
|
/* pngmem.c - stub functions for memory allocation
|
||||||
*
|
*
|
||||||
* libpng 1.0.5s - February 18, 2000
|
* libpng 1.0.6 - March 21, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
|
10
pngpread.c
10
pngpread.c
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngpread.c - read a png file in push mode
|
/* pngpread.c - read a png file in push mode
|
||||||
*
|
*
|
||||||
* libpng 1.0.5s - February 18, 2000
|
* libpng 1.0.6 - March 21, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
@ -952,7 +952,7 @@ png_read_push_finish_row(png_structp png_ptr)
|
|||||||
void
|
void
|
||||||
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_BEFORE_IHDR || png_ptr->mode & PNG_HAVE_IEND)
|
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
|
||||||
{
|
{
|
||||||
png_error(png_ptr, "Out of place tEXt");
|
png_error(png_ptr, "Out of place tEXt");
|
||||||
/* to quiet some compiler warnings */
|
/* to quiet some compiler warnings */
|
||||||
@ -1040,7 +1040,7 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
|
|||||||
void
|
void
|
||||||
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_BEFORE_IHDR || png_ptr->mode & PNG_HAVE_IEND)
|
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
|
||||||
{
|
{
|
||||||
png_error(png_ptr, "Out of place zTXt");
|
png_error(png_ptr, "Out of place zTXt");
|
||||||
/* to quiet some compiler warnings */
|
/* to quiet some compiler warnings */
|
||||||
@ -1221,7 +1221,7 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
|||||||
void
|
void
|
||||||
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_BEFORE_IHDR || png_ptr->mode & PNG_HAVE_IEND)
|
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
|
||||||
{
|
{
|
||||||
png_error(png_ptr, "Out of place iTXt");
|
png_error(png_ptr, "Out of place iTXt");
|
||||||
/* to quiet some compiler warnings */
|
/* to quiet some compiler warnings */
|
||||||
@ -1268,7 +1268,7 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
|
|||||||
{
|
{
|
||||||
png_textp text_ptr;
|
png_textp text_ptr;
|
||||||
png_charp key;
|
png_charp key;
|
||||||
int comp_flag = 0;
|
int comp_flag;
|
||||||
png_charp lang;
|
png_charp lang;
|
||||||
png_charp lang_key;
|
png_charp lang_key;
|
||||||
png_charp text;
|
png_charp text;
|
||||||
|
13
pngread.c
13
pngread.c
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngread.c - read a PNG file
|
/* pngread.c - read a PNG file
|
||||||
*
|
*
|
||||||
* libpng 1.0.5s - February 18, 2000
|
* libpng 1.0.6 - March 21, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
@ -641,7 +641,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.5s.
|
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -690,7 +690,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.5s.
|
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
png_read_image(png_structp png_ptr, png_bytepp image)
|
png_read_image(png_structp png_ptr, png_bytepp image)
|
||||||
@ -1113,9 +1113,6 @@ void png_read_png(png_structp png_ptr, png_infop info_ptr,
|
|||||||
{
|
{
|
||||||
int row;
|
int row;
|
||||||
|
|
||||||
if(transforms == 0 || params == (voidp)NULL)
|
|
||||||
/* quiet compiler warnings */ ;
|
|
||||||
|
|
||||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
|
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
|
||||||
/* invert the alpha channel from opacity to transparency */
|
/* invert the alpha channel from opacity to transparency */
|
||||||
if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
|
if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
|
||||||
@ -1237,5 +1234,9 @@ void 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)
|
||||||
|
/* quiet compiler warnings */ return;
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
2
pngrio.c
2
pngrio.c
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngrio.c - functions for data input
|
/* pngrio.c - functions for data input
|
||||||
*
|
*
|
||||||
* libpng 1.0.5s - February 18, 2000
|
* libpng 1.0.6 - March 21, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
|
67
pngrtran.c
67
pngrtran.c
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* 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.5s - February 18, 2000
|
* libpng 1.0.6 - March 21, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
@ -582,14 +582,25 @@ png_set_gray_to_rgb(png_structp png_ptr)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) && \
|
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||||
defined(PNG_FLOATING_POINT_SUPPORTED)
|
#if defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||||
/* Convert a RGB image to a grayscale of the same width. This allows us,
|
/* Convert a RGB image to a grayscale of the same width. This allows us,
|
||||||
* for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image.
|
* for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red,
|
png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red,
|
||||||
double green)
|
double green)
|
||||||
|
{
|
||||||
|
int red_fixed = (int)((float)red*100000.0 + 0.5);
|
||||||
|
int green_fixed = (int)((float)green*100000.0 + 0.5);
|
||||||
|
png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void
|
||||||
|
png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
|
||||||
|
png_fixed_point red, png_fixed_point green)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_rgb_to_gray\n");
|
png_debug(1, "in png_set_rgb_to_gray\n");
|
||||||
switch(error_action)
|
switch(error_action)
|
||||||
@ -610,22 +621,26 @@ png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
png_byte red_byte = (png_byte)((float)red*255.0 + 0.5);
|
png_uint_16 red_int, green_int;
|
||||||
png_byte green_byte = (png_byte)((float)green*255.0 + 0.5);
|
if(red > 0 && green > 0)
|
||||||
if(red < 0.0 || green < 0.0)
|
|
||||||
{
|
{
|
||||||
red_byte = 54;
|
red_int = 6968; /* .212671 * 32768 + .5 */
|
||||||
green_byte = 183;
|
green_int = 23434; /* .715160 * 32768 + .5 */
|
||||||
}
|
}
|
||||||
else if(red_byte + green_byte > 255)
|
else if(red + green < 100000L)
|
||||||
|
{
|
||||||
|
red_int = (png_uint_16)(((png_uint_32)red*32768L)/100000L);
|
||||||
|
green_int = (png_uint_16)(((png_uint_32)green*32768L)/100000L);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "ignoring out of range rgb_to_gray coefficients");
|
png_warning(png_ptr, "ignoring out of range rgb_to_gray coefficients");
|
||||||
red_byte = 54;
|
red_int = 6968;
|
||||||
green_byte = 183;
|
green_int = 23434;
|
||||||
}
|
}
|
||||||
png_ptr->rgb_to_gray_red_coeff = red_byte;
|
png_ptr->rgb_to_gray_red_coeff = red_int;
|
||||||
png_ptr->rgb_to_gray_green_coeff = green_byte;
|
png_ptr->rgb_to_gray_green_coeff = green_int;
|
||||||
png_ptr->rgb_to_gray_blue_coeff = (png_byte)(255-red_byte-green_byte);
|
png_ptr->rgb_to_gray_blue_coeff = (png_uint_16)(32768-red_int-green_int);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -2021,11 +2036,11 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
|
|||||||
*
|
*
|
||||||
* We approximate this with
|
* We approximate this with
|
||||||
*
|
*
|
||||||
* Y = 0.211 * R + 0.715 * G + 0.074 * B
|
* Y = 0.21268 * R + 0.7151 * G + 0.07217 * B
|
||||||
*
|
*
|
||||||
* which can be expressed with integers as
|
* which can be expressed with integers as
|
||||||
*
|
*
|
||||||
* Y = (54 * R + 183 * G + 19 * B)/256
|
* Y = (6969 * R + 23434 * G + 2365 * B)/32768
|
||||||
*
|
*
|
||||||
* The calculation is to be done in a linear colorspace.
|
* The calculation is to be done in a linear colorspace.
|
||||||
*
|
*
|
||||||
@ -2047,9 +2062,9 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
|||||||
#endif
|
#endif
|
||||||
(row_info->color_type & PNG_COLOR_MASK_COLOR))
|
(row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||||
{
|
{
|
||||||
png_byte rc = png_ptr->rgb_to_gray_red_coeff;
|
png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
|
||||||
png_byte gc = png_ptr->rgb_to_gray_green_coeff;
|
png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
|
||||||
png_byte bc = png_ptr->rgb_to_gray_blue_coeff;
|
png_uint_32 bc = png_ptr->rgb_to_gray_blue_coeff;
|
||||||
|
|
||||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||||
{
|
{
|
||||||
@ -2070,7 +2085,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
|||||||
{
|
{
|
||||||
rgb_error |= 1;
|
rgb_error |= 1;
|
||||||
*(dp++) = png_ptr->gamma_from_1[
|
*(dp++) = png_ptr->gamma_from_1[
|
||||||
(rc*red+gc*green+bc*blue)>>8];
|
(rc*red+gc*green+bc*blue)>>15];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*(dp++) = *(sp-1);
|
*(dp++) = *(sp-1);
|
||||||
@ -2089,7 +2104,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
|||||||
if(red != green || red != blue)
|
if(red != green || red != blue)
|
||||||
{
|
{
|
||||||
rgb_error |= 1;
|
rgb_error |= 1;
|
||||||
*(dp++) = (png_byte)((rc*red+gc*green+bc*blue)>>8);
|
*(dp++) = (png_byte)((rc*red+gc*green+bc*blue)>>15);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*(dp++) = *(sp-1);
|
*(dp++) = *(sp-1);
|
||||||
@ -2124,7 +2139,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
|||||||
png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
|
png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
|
||||||
png_ptr->gamma_shift][blue>>8];
|
png_ptr->gamma_shift][blue>>8];
|
||||||
png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1
|
png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1
|
||||||
+ bc*blue_1)>>8);
|
+ bc*blue_1)>>15);
|
||||||
w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
|
w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
|
||||||
png_ptr->gamma_shift][gray16 >> 8];
|
png_ptr->gamma_shift][gray16 >> 8];
|
||||||
rgb_error |= 1;
|
rgb_error |= 1;
|
||||||
@ -2149,7 +2164,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
|||||||
|
|
||||||
if(red != green || red != blue)
|
if(red != green || red != blue)
|
||||||
rgb_error |= 1;
|
rgb_error |= 1;
|
||||||
gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>8);
|
gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15);
|
||||||
*(dp++) = (png_byte)((gray16>>8) & 0xff);
|
*(dp++) = (png_byte)((gray16>>8) & 0xff);
|
||||||
*(dp++) = (png_byte)(gray16 & 0xff);
|
*(dp++) = (png_byte)(gray16 & 0xff);
|
||||||
}
|
}
|
||||||
@ -2173,7 +2188,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
|||||||
if(red != green || red != blue)
|
if(red != green || red != blue)
|
||||||
rgb_error |= 1;
|
rgb_error |= 1;
|
||||||
*(dp++) = png_ptr->gamma_from_1
|
*(dp++) = png_ptr->gamma_from_1
|
||||||
[(rc*red + gc*green + bc*blue)>>8];
|
[(rc*red + gc*green + bc*blue)>>15];
|
||||||
*(dp++) = *(sp++); /* alpha */
|
*(dp++) = *(sp++); /* alpha */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2221,7 +2236,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
|||||||
png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
|
png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
|
||||||
png_ptr->gamma_shift][blue>>8];
|
png_ptr->gamma_shift][blue>>8];
|
||||||
png_uint_16 gray16 = (png_uint_16)((rc * red_1
|
png_uint_16 gray16 = (png_uint_16)((rc * red_1
|
||||||
+ gc * green_1 + bc * blue_1)>>8);
|
+ gc * green_1 + bc * blue_1)>>15);
|
||||||
w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
|
w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
|
||||||
png_ptr->gamma_shift][gray16 >> 8];
|
png_ptr->gamma_shift][gray16 >> 8];
|
||||||
rgb_error |= 1;
|
rgb_error |= 1;
|
||||||
@ -2246,7 +2261,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
|||||||
blue = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2;
|
blue = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2;
|
||||||
if(red != green || red != blue)
|
if(red != green || red != blue)
|
||||||
rgb_error |= 1;
|
rgb_error |= 1;
|
||||||
gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>8);
|
gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15);
|
||||||
*(dp++) = (png_byte)((gray16>>8) & 0xff);
|
*(dp++) = (png_byte)((gray16>>8) & 0xff);
|
||||||
*(dp++) = (png_byte)(gray16 & 0xff);
|
*(dp++) = (png_byte)(gray16 & 0xff);
|
||||||
*(dp++) = *(sp++); /* alpha */
|
*(dp++) = *(sp++); /* alpha */
|
||||||
|
26
pngrutil.c
26
pngrutil.c
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngrutil.c - utilities to read a PNG file
|
/* pngrutil.c - utilities to read a PNG file
|
||||||
*
|
*
|
||||||
* libpng 1.0.5s - February 18, 2000
|
* libpng 1.0.6 - March 21, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
@ -147,7 +147,7 @@ png_charp png_decompress_chunk(png_structp png_ptr, int comp_type,
|
|||||||
{
|
{
|
||||||
static char msg[] = "Error decoding compressed text";
|
static char msg[] = "Error decoding compressed text";
|
||||||
png_charp text = NULL;
|
png_charp text = NULL;
|
||||||
png_size_t text_size = (chunklength - prefix_size);
|
png_size_t text_size;
|
||||||
|
|
||||||
if (comp_type == PNG_TEXT_COMPRESSION_zTXt)
|
if (comp_type == PNG_TEXT_COMPRESSION_zTXt)
|
||||||
{
|
{
|
||||||
@ -161,9 +161,7 @@ png_charp png_decompress_chunk(png_structp png_ptr, int comp_type,
|
|||||||
|
|
||||||
while (png_ptr->zstream.avail_in)
|
while (png_ptr->zstream.avail_in)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
|
||||||
|
|
||||||
ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
|
|
||||||
if (ret != Z_OK && ret != Z_STREAM_END)
|
if (ret != Z_OK && ret != Z_STREAM_END)
|
||||||
{
|
{
|
||||||
if (png_ptr->zstream.msg != NULL)
|
if (png_ptr->zstream.msg != NULL)
|
||||||
@ -262,7 +260,7 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
|
|
||||||
png_debug(1, "in png_handle_IHDR\n");
|
png_debug(1, "in png_handle_IHDR\n");
|
||||||
|
|
||||||
if (png_ptr->mode != PNG_BEFORE_IHDR)
|
if (png_ptr->mode & PNG_HAVE_IHDR)
|
||||||
png_error(png_ptr, "Out of place IHDR");
|
png_error(png_ptr, "Out of place IHDR");
|
||||||
|
|
||||||
/* check the length */
|
/* check the length */
|
||||||
@ -968,7 +966,7 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
{
|
{
|
||||||
png_bytep chunkdata;
|
png_bytep chunkdata;
|
||||||
png_bytep entry_start;
|
png_bytep entry_start;
|
||||||
png_spalette new_palette;
|
png_sPLT_t new_palette;
|
||||||
int data_length, entry_size, i;
|
int data_length, entry_size, i;
|
||||||
png_uint_32 skip = 0;
|
png_uint_32 skip = 0;
|
||||||
png_size_t slength;
|
png_size_t slength;
|
||||||
@ -1028,12 +1026,12 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
new_palette.nentries = data_length / entry_size;
|
new_palette.nentries = data_length / entry_size;
|
||||||
new_palette.entries = (png_spalette_entryp)png_malloc(
|
new_palette.entries = (png_sPLT_entryp)png_malloc(
|
||||||
png_ptr, new_palette.nentries * sizeof(png_spalette_entry));
|
png_ptr, new_palette.nentries * sizeof(png_sPLT_entry));
|
||||||
|
|
||||||
for (i = 0; i < new_palette.nentries; i++)
|
for (i = 0; i < new_palette.nentries; i++)
|
||||||
{
|
{
|
||||||
png_spalette_entryp pp = new_palette.entries + i;
|
png_sPLT_entryp pp = new_palette.entries + i;
|
||||||
|
|
||||||
if (new_palette.depth == 8)
|
if (new_palette.depth == 8)
|
||||||
{
|
{
|
||||||
@ -1090,7 +1088,7 @@ png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
/* Should be an error, but we can cope with it */
|
/* Should be an error, but we can cope with it */
|
||||||
png_warning(png_ptr, "Missing PLTE before tRNS");
|
png_warning(png_ptr, "Missing PLTE before tRNS");
|
||||||
}
|
}
|
||||||
else if (length > png_ptr->num_palette)
|
else if (length > (png_uint_32)png_ptr->num_palette)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "Incorrect tRNS chunk length");
|
png_warning(png_ptr, "Incorrect tRNS chunk length");
|
||||||
png_crc_finish(png_ptr, length);
|
png_crc_finish(png_ptr, length);
|
||||||
@ -1510,7 +1508,7 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
{
|
{
|
||||||
png_charp buffer, ep;
|
png_charp buffer, ep;
|
||||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
double width=0., height=0.;
|
double width, height;
|
||||||
png_charp vp;
|
png_charp vp;
|
||||||
#else
|
#else
|
||||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||||
@ -1723,7 +1721,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
png_textp text_ptr;
|
png_textp text_ptr;
|
||||||
png_charp chunkdata;
|
png_charp chunkdata;
|
||||||
png_charp text;
|
png_charp text;
|
||||||
int comp_type = PNG_TEXT_COMPRESSION_NONE;
|
int comp_type;
|
||||||
png_size_t slength, prefix_len;
|
png_size_t slength, prefix_len;
|
||||||
|
|
||||||
png_debug(1, "in png_handle_zTXt\n");
|
png_debug(1, "in png_handle_zTXt\n");
|
||||||
@ -1798,7 +1796,7 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
png_textp text_ptr;
|
png_textp text_ptr;
|
||||||
png_charp chunkdata;
|
png_charp chunkdata;
|
||||||
png_charp key, lang, text, lang_key;
|
png_charp key, lang, text, lang_key;
|
||||||
int comp_flag = PNG_TEXT_COMPRESSION_NONE;
|
int comp_flag;
|
||||||
int comp_type = 0;
|
int comp_type = 0;
|
||||||
png_size_t slength, prefix_len;
|
png_size_t slength, prefix_len;
|
||||||
|
|
||||||
|
27
pngset.c
27
pngset.c
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngset.c - storage of image information into info struct
|
/* pngset.c - storage of image information into info struct
|
||||||
*
|
*
|
||||||
* libpng 1.0.5s - February 18, 2000
|
* libpng 1.0.6 - March 21, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
@ -312,8 +312,6 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
|
|||||||
if (png_ptr == NULL || info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
png_debug1(3, "allocating PLTE for info (%d bytes)\n", length);
|
|
||||||
|
|
||||||
info_ptr->palette = palette;
|
info_ptr->palette = palette;
|
||||||
|
|
||||||
info_ptr->num_palette = (png_uint_16)num_palette;
|
info_ptr->num_palette = (png_uint_16)num_palette;
|
||||||
@ -613,30 +611,30 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
|||||||
#if defined(PNG_sPLT_SUPPORTED)
|
#if defined(PNG_sPLT_SUPPORTED)
|
||||||
void
|
void
|
||||||
png_set_sPLT(png_structp png_ptr,
|
png_set_sPLT(png_structp png_ptr,
|
||||||
png_infop info_ptr, png_spalette_p entries, int nentries)
|
png_infop info_ptr, png_sPLT_tp entries, int nentries)
|
||||||
{
|
{
|
||||||
png_spalette_p np;
|
png_sPLT_tp np;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
np = (png_spalette_p)png_malloc(png_ptr,
|
np = (png_sPLT_tp)png_malloc(png_ptr,
|
||||||
(info_ptr->splt_palettes_num + nentries) * sizeof(png_spalette));
|
(info_ptr->splt_palettes_num + nentries) * sizeof(png_sPLT_t));
|
||||||
|
|
||||||
png_memcpy(np, info_ptr->splt_palettes,
|
png_memcpy(np, info_ptr->splt_palettes,
|
||||||
info_ptr->splt_palettes_num * sizeof(png_spalette));
|
info_ptr->splt_palettes_num * sizeof(png_sPLT_t));
|
||||||
png_free(png_ptr, info_ptr->splt_palettes);
|
png_free(png_ptr, info_ptr->splt_palettes);
|
||||||
|
|
||||||
for (i = 0; i < nentries; i++)
|
for (i = 0; i < nentries; i++)
|
||||||
{
|
{
|
||||||
png_spalette_p to = np + info_ptr->splt_palettes_num + i;
|
png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;
|
||||||
png_spalette_p 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_spalette_entryp)png_malloc(png_ptr,
|
to->entries = (png_sPLT_entryp)png_malloc(png_ptr,
|
||||||
from->nentries * sizeof(png_spalette));
|
from->nentries * sizeof(png_sPLT_t));
|
||||||
png_memcpy(to->entries, from->entries,
|
png_memcpy(to->entries, from->entries,
|
||||||
from->nentries * sizeof(png_spalette));
|
from->nentries * sizeof(png_sPLT_t));
|
||||||
to->nentries = from->nentries;
|
to->nentries = from->nentries;
|
||||||
to->depth = from->depth;
|
to->depth = from->depth;
|
||||||
}
|
}
|
||||||
@ -687,7 +685,8 @@ png_set_unknown_chunks(png_structp png_ptr,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED)
|
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
|
||||||
|
defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
|
||||||
void
|
void
|
||||||
png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
|
png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
|
||||||
{
|
{
|
||||||
|
32
pngtest.c
32
pngtest.c
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngtest.c - a simple test program to test libpng
|
/* pngtest.c - a simple test program to test libpng
|
||||||
*
|
*
|
||||||
* libpng 1.0.5s - February 18, 2000
|
* libpng 1.0.6 - March 21, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
@ -51,6 +51,11 @@ static float t_start, t_stop, t_decode, t_encode, t_misc;
|
|||||||
|
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
|
||||||
|
/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
|
||||||
|
#ifndef png_jmpbuf
|
||||||
|
# define png_jmpbuf(png_ptr) png_ptr->jmpbuf
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PNGTEST_TIMING
|
#ifdef PNGTEST_TIMING
|
||||||
static float t_start, t_stop, t_decode, t_encode, t_misc;
|
static float t_start, t_stop, t_decode, t_encode, t_misc;
|
||||||
#if !defined(PNG_tIME_SUPPORTED)
|
#if !defined(PNG_tIME_SUPPORTED)
|
||||||
@ -524,7 +529,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
int bit_depth, color_type;
|
int bit_depth, color_type;
|
||||||
#ifdef PNG_SETJMP_SUPPORTED
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
jmp_buf jmp_env;
|
jmp_buf jmpbuf;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -579,11 +584,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_SETJMP_SUPPORTED
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
png_debug(0, "Setting jmp_env for read struct\n");
|
png_debug(0, "Setting jmpbuf for read struct\n");
|
||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
if (setjmp(jmp_env))
|
if (setjmp(jmpbuf))
|
||||||
#else
|
#else
|
||||||
if (setjmp(png_jmp_env(read_ptr)))
|
if (setjmp(png_jmpbuf(read_ptr)))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname);
|
fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname);
|
||||||
@ -595,14 +600,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
png_memcpy(png_jmp_env(read_ptr),jmp_env,sizeof(jmp_buf));
|
png_memcpy(png_jmpbuf(read_ptr),jmpbuf,sizeof(jmp_buf));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_debug(0, "Setting jmp_env for write struct\n");
|
png_debug(0, "Setting jmpbuf for write struct\n");
|
||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
if (setjmp(jmp_env))
|
if (setjmp(jmpbuf))
|
||||||
#else
|
#else
|
||||||
if (setjmp(png_jmp_env(write_ptr)))
|
if (setjmp(png_jmpbuf(write_ptr)))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname);
|
fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname);
|
||||||
@ -614,7 +619,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
png_memcpy(write_ptr->jmpbuf,jmp_env,sizeof(jmp_buf));
|
png_memcpy(png_jmpbuf(write_ptr),jmpbuf,sizeof(jmp_buf));
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1339,9 +1344,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. */
|
||||||
void
|
typedef version_1_0_6 your_png_h_is_not_version_1_0_6;
|
||||||
png_check_pngtest_version
|
|
||||||
(version_1_0_5s png_h_is_not_version_1_0_5s)
|
|
||||||
{
|
|
||||||
if(png_h_is_not_version_1_0_5s == NULL) return;
|
|
||||||
}
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* 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.5s - February 18, 2000
|
* libpng 1.0.6 - March 21, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
|
35
pngtypes.h
35
pngtypes.h
@ -1,35 +0,0 @@
|
|||||||
/* pngtypes.h - array of chunk-types for libpng
|
|
||||||
*
|
|
||||||
* libpng 1.0.5s - February 18, 2000
|
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
|
||||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Constant strings for known chunk types. If you need to add a chunk,
|
|
||||||
* define the string in png.h and invoke it here.
|
|
||||||
*/
|
|
||||||
|
|
||||||
PNG_IHDR;
|
|
||||||
PNG_IDAT;
|
|
||||||
PNG_IEND;
|
|
||||||
PNG_PLTE;
|
|
||||||
PNG_bKGD;
|
|
||||||
PNG_cHRM;
|
|
||||||
PNG_gAMA;
|
|
||||||
PNG_hIST;
|
|
||||||
PNG_iCCP;
|
|
||||||
PNG_iTXt;
|
|
||||||
PNG_oFFs;
|
|
||||||
PNG_pCAL;
|
|
||||||
PNG_pHYs;
|
|
||||||
PNG_sBIT;
|
|
||||||
PNG_sCAL;
|
|
||||||
PNG_sPLT;
|
|
||||||
PNG_sRGB;
|
|
||||||
PNG_tEXt;
|
|
||||||
PNG_tIME;
|
|
||||||
PNG_tRNS;
|
|
||||||
PNG_zTXt;
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
|||||||
*
|
*
|
||||||
* For Intel x86 CPU and Microsoft Visual C++ compiler
|
* For Intel x86 CPU and Microsoft Visual C++ compiler
|
||||||
*
|
*
|
||||||
* libpng 1.0.5s - February 18, 2000
|
* libpng 1.0.6 - March 21, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998, Intel Corporation
|
* Copyright (c) 1998, Intel Corporation
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
|
2
pngwio.c
2
pngwio.c
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngwio.c - functions for data output
|
/* pngwio.c - functions for data output
|
||||||
*
|
*
|
||||||
* libpng 1.0.5s - February 18, 2000
|
* libpng 1.0.6 - March 21, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngwrite.c - general routines to write a PNG file
|
/* pngwrite.c - general routines to write a PNG file
|
||||||
*
|
*
|
||||||
* libpng 1.0.5s - February 18, 2000
|
* libpng 1.0.6 - March 21, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
@ -1187,9 +1187,6 @@ void png_write_png(png_structp png_ptr, png_infop info_ptr,
|
|||||||
int transforms,
|
int transforms,
|
||||||
voidp params)
|
voidp params)
|
||||||
{
|
{
|
||||||
if(transforms == 0 || params == (voidp)NULL)
|
|
||||||
/* quiet compiler warnings */ ;
|
|
||||||
|
|
||||||
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||||
/* invert the alpha channel from opacity to transparency */
|
/* invert the alpha channel from opacity to transparency */
|
||||||
if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
|
if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
|
||||||
@ -1262,5 +1259,8 @@ void 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)
|
||||||
|
/* quiet compiler warnings */ return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* 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.5s - February 18, 2000
|
* libpng 1.0.6 - March 21, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
|
12
pngwutil.c
12
pngwutil.c
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngwutil.c - utilities to write a PNG file
|
/* pngwutil.c - utilities to write a PNG file
|
||||||
*
|
*
|
||||||
* libpng 1.0.5s - February 18, 2000
|
* libpng 1.0.6 - March 21, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
@ -179,7 +179,6 @@ png_text_compress(png_structp png_ptr,
|
|||||||
#else
|
#else
|
||||||
png_warning(png_ptr, "Unknown compression type");
|
png_warning(png_ptr, "Unknown compression type");
|
||||||
#endif
|
#endif
|
||||||
compression = PNG_TEXT_COMPRESSION_zTXt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We can't write the chunk until we find out how much data we have,
|
/* We can't write the chunk until we find out how much data we have,
|
||||||
@ -642,7 +641,7 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (compression_type)
|
if (compression_type)
|
||||||
/* ignore */ ;
|
png_warning(png_ptr, "Unknown compression type in iCCP chunk");
|
||||||
|
|
||||||
if (profile == NULL || *profile == '\0')
|
if (profile == NULL || *profile == '\0')
|
||||||
profile_len = 0;
|
profile_len = 0;
|
||||||
@ -667,7 +666,7 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
|
|||||||
#if defined(PNG_WRITE_sPLT_SUPPORTED)
|
#if defined(PNG_WRITE_sPLT_SUPPORTED)
|
||||||
/* write a sPLT chunk */
|
/* write a sPLT chunk */
|
||||||
void
|
void
|
||||||
png_write_sPLT(png_structp png_ptr, png_spalette_p spalette)
|
png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
|
||||||
{
|
{
|
||||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||||
PNG_sPLT;
|
PNG_sPLT;
|
||||||
@ -677,10 +676,11 @@ png_write_sPLT(png_structp png_ptr, png_spalette_p spalette)
|
|||||||
png_byte entrybuf[10];
|
png_byte entrybuf[10];
|
||||||
int entry_size = (spalette->depth == 8 ? 6 : 10);
|
int entry_size = (spalette->depth == 8 ? 6 : 10);
|
||||||
int palette_size = entry_size * spalette->nentries;
|
int palette_size = entry_size * spalette->nentries;
|
||||||
png_spalette_entryp ep;
|
png_sPLT_entryp ep;
|
||||||
|
|
||||||
png_debug(1, "in png_write_sPLT\n");
|
png_debug(1, "in png_write_sPLT\n");
|
||||||
if (spalette->name == NULL || (name_len = png_check_keyword(png_ptr, spalette->name, &new_name))==0)
|
if (spalette->name == NULL || (name_len = png_check_keyword(png_ptr,
|
||||||
|
spalette->name, &new_name))==0)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "Empty keyword in sPLT chunk");
|
png_warning(png_ptr, "Empty keyword in sPLT chunk");
|
||||||
return;
|
return;
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
make -fmakefile.bor -B -DMODEL=m %1 %2 %3 libpng >buildm.out
|
|
||||||
make -fmakefile.bor -B -DMODEL=l %1 %2 %3 libpng >buildl.out
|
|
151
scripts/makefile.bc32
Normal file
151
scripts/makefile.bc32
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
# Makefile for libpng
|
||||||
|
# 32-bit Borland C++ (Note: All modules are compiled in C mode)
|
||||||
|
# To build the library, do:
|
||||||
|
# "make -fmakefile.bc32"
|
||||||
|
#
|
||||||
|
# ---------- 32-bit Borland C++ ----------
|
||||||
|
|
||||||
|
### Absolutely necessary for this makefile to work
|
||||||
|
.AUTODEPEND
|
||||||
|
|
||||||
|
## Where zlib.h, zconf.h and zlib.lib are
|
||||||
|
ZLIB_DIR=..\zlib
|
||||||
|
|
||||||
|
|
||||||
|
## Compiler, linker and lib stuff
|
||||||
|
CC=bcc32
|
||||||
|
LD=bcc32
|
||||||
|
LIB=tlib
|
||||||
|
|
||||||
|
#TARGET_CPU=6
|
||||||
|
# 3 = 386, 4 = 486, 5 = Pentium etc.
|
||||||
|
!ifndef TARGET_CPU
|
||||||
|
TARGET_CPU=5
|
||||||
|
!endif
|
||||||
|
|
||||||
|
# Use this if you don't want Borland's fancy exception handling
|
||||||
|
NOEHLIB=noeh32.lib
|
||||||
|
|
||||||
|
!ifdef DEBUG
|
||||||
|
CDEBUG=-v
|
||||||
|
LDEBUG=-v
|
||||||
|
!else
|
||||||
|
CDEBUG=
|
||||||
|
LDEBUG=
|
||||||
|
!endif
|
||||||
|
|
||||||
|
# STACKOFLOW=1
|
||||||
|
!ifdef STACKOFLOW
|
||||||
|
CDEBUG=$(CDEBUG) -N
|
||||||
|
LDEBUG=$(LDEBUG) -N
|
||||||
|
!endif
|
||||||
|
|
||||||
|
# -X- turn on dependency generation in the object file
|
||||||
|
# -w set all warnings on
|
||||||
|
# -O2 optimize for speed
|
||||||
|
# -Z global optimization
|
||||||
|
CFLAGS=-O2 -Z -X- -w -I$(ZLIB_DIR) -$(TARGET_CPU) $(CDEBUG)
|
||||||
|
|
||||||
|
# -M generate map file
|
||||||
|
LDFLAGS=-M -L$(ZLIB_DIR) $(LDEBUG)
|
||||||
|
|
||||||
|
|
||||||
|
## Variables
|
||||||
|
OBJS = \
|
||||||
|
png.obj \
|
||||||
|
pngerror.obj \
|
||||||
|
pngget.obj \
|
||||||
|
pngmem.obj \
|
||||||
|
pngpread.obj \
|
||||||
|
pngread.obj \
|
||||||
|
pngrio.obj \
|
||||||
|
pngrtran.obj \
|
||||||
|
pngrutil.obj \
|
||||||
|
pngset.obj \
|
||||||
|
pngtrans.obj \
|
||||||
|
pngwio.obj \
|
||||||
|
pngwrite.obj \
|
||||||
|
pngwtran.obj \
|
||||||
|
pngwutil.obj
|
||||||
|
|
||||||
|
LIBOBJS = \
|
||||||
|
+png.obj \
|
||||||
|
+pngerror.obj \
|
||||||
|
+pngget.obj \
|
||||||
|
+pngmem.obj \
|
||||||
|
+pngpread.obj \
|
||||||
|
+pngread.obj \
|
||||||
|
+pngrio.obj \
|
||||||
|
+pngrtran.obj \
|
||||||
|
+pngrutil.obj \
|
||||||
|
+pngset.obj \
|
||||||
|
+pngtrans.obj \
|
||||||
|
+pngwio.obj \
|
||||||
|
+pngwrite.obj \
|
||||||
|
+pngwtran.obj \
|
||||||
|
+pngwutil.obj
|
||||||
|
|
||||||
|
LIBNAME=libpng.lib
|
||||||
|
|
||||||
|
|
||||||
|
## Implicit rules
|
||||||
|
# Braces let make "batch" calls to the compiler,
|
||||||
|
# 2 calls instead of 12; space is important.
|
||||||
|
.c.obj:
|
||||||
|
$(CC) $(CFLAGS) -c {$*.c }
|
||||||
|
|
||||||
|
.c.exe:
|
||||||
|
$(CC) $(CFLAGS) $(LDFLAGS) $*.c $(LIBNAME) zlib.lib $(NOEHLIB)
|
||||||
|
|
||||||
|
.obj.exe:
|
||||||
|
$(LD) $(LDFLAGS) $*.obj $(LIBNAME) zlib.lib $(NOEHLIB)
|
||||||
|
|
||||||
|
|
||||||
|
## Major targets
|
||||||
|
all: libpng pngtest
|
||||||
|
|
||||||
|
libpng: $(LIBNAME)
|
||||||
|
|
||||||
|
pngtest: pngtest.exe
|
||||||
|
|
||||||
|
test: pngtest.exe
|
||||||
|
pngtest
|
||||||
|
|
||||||
|
|
||||||
|
## Minor Targets
|
||||||
|
|
||||||
|
png.obj: png.c
|
||||||
|
pngerror.obj: pngerror.c
|
||||||
|
pngget.obj: pngget.c
|
||||||
|
pngmem.obj: pngmem.c
|
||||||
|
pngpread.obj: pngpread.c
|
||||||
|
pngread.obj: pngread.c
|
||||||
|
pngrio.obj: pngrio.c
|
||||||
|
pngrtran.obj: pngrtran.c
|
||||||
|
pngrutil.obj: pngrutil.c
|
||||||
|
pngset.obj: pngset.c
|
||||||
|
pngtrans.obj: pngtrans.c
|
||||||
|
pngwio.obj: pngwio.c
|
||||||
|
pngwrite.obj: pngwrite.c
|
||||||
|
pngwtran.obj: pngwtran.c
|
||||||
|
pngwutil.obj: pngwutil.c
|
||||||
|
|
||||||
|
|
||||||
|
$(LIBNAME): $(OBJS)
|
||||||
|
-del $(LIBNAME)
|
||||||
|
$(LIB) $(LIBNAME) @&&|
|
||||||
|
$(LIBOBJS), libpng
|
||||||
|
|
|
||||||
|
|
||||||
|
|
||||||
|
# Clean up anything else you want
|
||||||
|
clean:
|
||||||
|
-del *.obj
|
||||||
|
-del *.exe
|
||||||
|
-del *.lib
|
||||||
|
-del *.lst
|
||||||
|
-del *.map
|
||||||
|
-del *.tds
|
||||||
|
|
||||||
|
|
||||||
|
# End of makefile for libpng
|
@ -1,5 +1,5 @@
|
|||||||
# Makefile for png32bd.dll
|
# Makefile for png32bd.dll
|
||||||
# ------------- Borland C++ 4.5 -------------
|
# ------------- 32-bit Borland C++ -------------
|
||||||
|
|
||||||
# This makefile expects to find zlib.h and zlib32bd.lib in the
|
# This makefile expects to find zlib.h and zlib32bd.lib in the
|
||||||
# $(ZLIBDIR) directory.
|
# $(ZLIBDIR) directory.
|
||||||
@ -12,42 +12,65 @@
|
|||||||
# compress and uncompress functions, nor any of the gz... functions,
|
# compress and uncompress functions, nor any of the gz... functions,
|
||||||
# since libpng does not call them.
|
# since libpng does not call them.
|
||||||
|
|
||||||
ZLIBDIR=..\zlib112
|
.AUTODEPEND
|
||||||
|
|
||||||
|
ZLIBDIR=..\zlib
|
||||||
ZLIB=zlib32bd.lib
|
ZLIB=zlib32bd.lib
|
||||||
PNGDLL=png32bd.dll
|
PNGDLL=png32bd.dll
|
||||||
|
PNGLIB=png32bd.lib
|
||||||
|
|
||||||
CFLAGS= -ps -O2 -C -K -N- -k- -d -3 -r- -w-par -w-aus -WDE -I$(ZLIBDIR)
|
CC=bcc32
|
||||||
CC=f:\bc45\bin\bcc32
|
CFLAGS= -ps -O2 -N- -k- -d -r- -w-par -w-aus -I$(ZLIBDIR) \
|
||||||
LINKFLAGS= -Tpd -aa -c
|
-DPNG_NO_GLOBAL_ARRAYS #-DPNG_DEBUG=5
|
||||||
LINK=f:\bc45\bin\tlink32
|
#LINK=tlink32
|
||||||
LIBDIR=f:\bc45\lib
|
#LINK=ilink32
|
||||||
IMPLIB=f:\bc45\bin\implib
|
LINK=bcc32
|
||||||
|
#LINKFLAGS= -Tpd -aa -c
|
||||||
|
LINKFLAGS= -WDE
|
||||||
|
IMPLIB=implib
|
||||||
|
|
||||||
|
# Use this if you don't want Borland's fancy exception handling
|
||||||
|
NOEHLIB=noeh32.lib
|
||||||
|
|
||||||
.autodepend
|
|
||||||
.c.obj:
|
.c.obj:
|
||||||
$(CC) -c $(CFLAGS) $<
|
$(CC) -c $(CFLAGS) $<
|
||||||
|
|
||||||
|
.c.exe:
|
||||||
|
$(CC) $(CFLAGS) $< $(PNGLIB) $(NOEHLIB)
|
||||||
|
|
||||||
|
|
||||||
OBJ1=png.obj pngerror.obj pngget.obj pngmem.obj pngpread.obj
|
OBJ1=png.obj pngerror.obj pngget.obj pngmem.obj pngpread.obj
|
||||||
OBJ2=pngread.obj pngrio.obj pngrtran.obj pngrutil.obj pngset.obj
|
OBJ2=pngread.obj pngrio.obj pngrtran.obj pngrutil.obj pngset.obj
|
||||||
OBJ3=pngtrans.obj pngwio.obj pngwrite.obj pngwtran.obj pngwutil.obj
|
OBJ3=pngtrans.obj pngwio.obj pngwrite.obj pngwtran.obj pngwutil.obj
|
||||||
|
|
||||||
all: $(PNGDLL)
|
all: $(PNGDLL)
|
||||||
|
|
||||||
|
test: pngtest.exe
|
||||||
|
pngtest
|
||||||
|
|
||||||
|
|
||||||
$(PNGDLL): $(OBJ1) $(OBJ2) $(OBJ3) $(ZLIBDIR)\$(ZLIB)
|
$(PNGDLL): $(OBJ1) $(OBJ2) $(OBJ3) $(ZLIBDIR)\$(ZLIB)
|
||||||
$(LINK) @&&|
|
$(LINK) @&&|
|
||||||
$(LINKFLAGS) $(LIBDIR)\c0d32 +
|
$(LINKFLAGS)
|
||||||
$(OBJ1) +
|
-e$(PNGDLL)
|
||||||
$(OBJ2) +
|
$(OBJ1)
|
||||||
|
$(OBJ2)
|
||||||
$(OBJ3)
|
$(OBJ3)
|
||||||
$@
|
$(ZLIBDIR)\$(ZLIB)
|
||||||
-x
|
$(NOEHLIB)
|
||||||
$(ZLIBDIR)\$(ZLIB) $(LIBDIR)\import32 $(LIBDIR)\cw32
|
|
||||||
|,&&|
|
|
||||||
LIBRARY $(@B)
|
|
||||||
EXETYPE WINDOWS
|
|
||||||
CODE PRELOAD MOVEABLE DISCARDABLE
|
|
||||||
DATA PRELOAD MOVEABLE MULTIPLE
|
|
||||||
|
|
|
|
||||||
$(IMPLIB) -c $(@R).lib $@
|
$(IMPLIB) -c $(@R).lib $@
|
||||||
|
|
||||||
|
|
||||||
|
# Clean up anything else you want
|
||||||
|
clean:
|
||||||
|
-del *.obj
|
||||||
|
-del *.dll
|
||||||
|
-del *.exe
|
||||||
|
-del *.lib
|
||||||
|
-del *.lst
|
||||||
|
-del *.map
|
||||||
|
-del *.tds
|
||||||
|
|
||||||
|
|
||||||
# End of makefile for png32bd.dll
|
# End of makefile for png32bd.dll
|
||||||
|
@ -31,7 +31,7 @@ RANLIB=ranlib
|
|||||||
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
||||||
# have to change it.
|
# have to change it.
|
||||||
PNGMAJ = 2
|
PNGMAJ = 2
|
||||||
PNGMIN = 1.0.5s
|
PNGMIN = 1.0.6
|
||||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||||
|
|
||||||
# where make install puts libpng.a, libpng.so*, and png.h
|
# where make install puts libpng.a, libpng.so*, and png.h
|
||||||
|
@ -1,39 +1,38 @@
|
|||||||
# Makefile for libpng
|
# Makefile for libpng
|
||||||
# Borland C++ 4.5 (Note: All modules are compiled in C mode)
|
# 16-bit Borland C++ (Note: All modules are compiled in C mode)
|
||||||
# Will work with C++ 4.02 also
|
|
||||||
# To build the library, do:
|
# To build the library, do:
|
||||||
# "make -fmakefile.borland -DMODEL=m"
|
# "make -fmakefile.bor -DMODEL=c"
|
||||||
# or: "make -fmakefile.borland -DMODEL=l"
|
# or: "make -fmakefile.bor -DMODEL=l"
|
||||||
#
|
#
|
||||||
# ------------- Borland C++ 4.5 -------------
|
# ------------ Borland C++ ------------
|
||||||
|
|
||||||
### Absolutely necessary for this makefile to work
|
### Absolutely necessary for this makefile to work
|
||||||
.AUTODEPEND
|
.AUTODEPEND
|
||||||
|
|
||||||
## Useful user options
|
## Where zlib.h, zconf.h and zlib_MODEL.lib are
|
||||||
|
ZLIB_DIR=..\zlib
|
||||||
|
|
||||||
# Usually defined in builtins.mak or the environment
|
|
||||||
# Currently unused.
|
|
||||||
!ifndef BCROOT
|
|
||||||
BCROOT=N:\BC45
|
|
||||||
!endif
|
|
||||||
|
|
||||||
# Where zlib.h and zconf.h and zlib.lib are
|
## Compiler, linker and lib stuff
|
||||||
ZLIB_PATH=..\zlib
|
CC=bcc
|
||||||
|
LD=bcc
|
||||||
|
LIB=tlib
|
||||||
|
|
||||||
!ifndef MODEL
|
!ifndef MODEL
|
||||||
MODEL=l
|
MODEL=l
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
|
MODEL_ARG=-m$(MODEL)
|
||||||
|
|
||||||
#TARGET_CPU=3
|
#TARGET_CPU=3
|
||||||
# 2 = 286, 3 = 386, etc.
|
# 2 = 286, 3 = 386, etc.
|
||||||
!ifndef TARGET_CPU
|
!ifndef TARGET_CPU
|
||||||
TARGET_CPU=2
|
TARGET_CPU=2
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
|
# Use this if you don't want Borland's fancy exception handling
|
||||||
# Use this if you don't want Borland's fancy exception handling.
|
# (for Borland C++ 4.0 or later)
|
||||||
NOEHLIB=noeh$(MODEL).lib
|
#NOEHLIB=noeh$(MODEL).lib
|
||||||
|
|
||||||
!ifdef DEBUG
|
!ifdef DEBUG
|
||||||
CDEBUG=-v
|
CDEBUG=-v
|
||||||
@ -49,59 +48,50 @@ CDEBUG=$(CDEBUG) -N
|
|||||||
LDEBUG=$(LDEBUG) -N
|
LDEBUG=$(LDEBUG) -N
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
|
# -X- turn on dependency generation in the object file
|
||||||
## Compiler, linker, and lib stuff
|
# -w set all warnings on
|
||||||
CC=bcc
|
|
||||||
LD=bcc
|
|
||||||
LIB=tlib
|
|
||||||
|
|
||||||
MODELARG=-m$(MODEL)
|
|
||||||
|
|
||||||
# -X- turns on dependency generation in the object file
|
|
||||||
# -w sets all warnings on
|
|
||||||
# -O2 optimize for speed
|
# -O2 optimize for speed
|
||||||
# -Z global optimization
|
# -Z global optimization
|
||||||
CFLAGS=-O2 -Z -X- -w -I$(ZLIB_PATH) -$(TARGET_CPU) $(MODELARG) $(CDEBUG)
|
CFLAGS=-O2 -Z -X- -w -I$(ZLIB_DIR) -$(TARGET_CPU) $(MODEL_ARG) $(CDEBUG)
|
||||||
|
|
||||||
# -M generate map file
|
# -M generate map file
|
||||||
LDFLAGS=-M $(LDEBUG)
|
LDFLAGS=-M -L$(ZLIB_DIR) $(MODEL_ARG) $(LDEBUG)
|
||||||
|
|
||||||
O=obj
|
|
||||||
|
|
||||||
## variables
|
## Variables
|
||||||
OBJS = \
|
OBJS = \
|
||||||
png.$(O) \
|
png.obj \
|
||||||
pngerror.$(O) \
|
pngerror.obj \
|
||||||
pngmem.$(O) \
|
pngget.obj \
|
||||||
pngpread.$(O) \
|
pngmem.obj \
|
||||||
pngset.$(O) \
|
pngpread.obj \
|
||||||
pngget.$(O) \
|
pngread.obj \
|
||||||
pngread.$(O) \
|
pngrio.obj \
|
||||||
pngrio.$(O) \
|
pngrtran.obj \
|
||||||
pngrtran.$(O) \
|
pngrutil.obj \
|
||||||
pngrutil.$(O) \
|
pngset.obj \
|
||||||
pngtrans.$(O) \
|
pngtrans.obj \
|
||||||
pngwrite.$(O) \
|
pngwio.obj \
|
||||||
pngwtran.$(O) \
|
pngwrite.obj \
|
||||||
pngwio.$(O) \
|
pngwtran.obj \
|
||||||
pngwutil.$(O)
|
pngwutil.obj
|
||||||
|
|
||||||
LIBOBJS = \
|
LIBOBJS = \
|
||||||
+png.$(O) \
|
+png.obj \
|
||||||
+pngerror.$(O) \
|
+pngerror.obj \
|
||||||
+pngmem.$(O) \
|
+pngget.obj \
|
||||||
+pngpread.$(O) \
|
+pngmem.obj \
|
||||||
+pngread.$(O) \
|
+pngpread.obj \
|
||||||
+pngset.$(O) \
|
+pngread.obj \
|
||||||
+pngget.$(O) \
|
+pngrio.obj \
|
||||||
+pngrio.$(O) \
|
+pngrtran.obj \
|
||||||
+pngrtran.$(O) \
|
+pngrutil.obj \
|
||||||
+pngrutil.$(O) \
|
+pngset.obj \
|
||||||
+pngtrans.$(O) \
|
+pngtrans.obj \
|
||||||
+pngwrite.$(O) \
|
+pngwio.obj \
|
||||||
+pngwtran.$(O) \
|
+pngwrite.obj \
|
||||||
+pngwio.$(O) \
|
+pngwtran.obj \
|
||||||
+pngwutil.$(O)
|
+pngwutil.obj
|
||||||
|
|
||||||
LIBNAME=libpng$(MODEL).lib
|
LIBNAME=libpng$(MODEL).lib
|
||||||
|
|
||||||
@ -113,10 +103,12 @@ LIBNAME=libpng$(MODEL).lib
|
|||||||
$(CC) $(CFLAGS) -c {$*.c }
|
$(CC) $(CFLAGS) -c {$*.c }
|
||||||
|
|
||||||
.c.exe:
|
.c.exe:
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) $*.c
|
$(CC) $(CFLAGS) $(LDFLAGS) $*.c $(LIBNAME) zlib_$(MODEL).lib $(NOEHLIB)
|
||||||
|
|
||||||
|
|
||||||
## Major targets
|
## Major targets
|
||||||
|
all: libpng pngtest
|
||||||
|
|
||||||
libpng: $(LIBNAME)
|
libpng: $(LIBNAME)
|
||||||
|
|
||||||
pngtest: pngtest$(MODEL).exe
|
pngtest: pngtest$(MODEL).exe
|
||||||
@ -128,17 +120,17 @@ test: pngtest$(MODEL).exe
|
|||||||
## Minor Targets
|
## Minor Targets
|
||||||
|
|
||||||
png.obj: png.c
|
png.obj: png.c
|
||||||
pngset.obj: pngset.c
|
pngerror.obj: pngerror.c
|
||||||
pngget.obj: pngget.c
|
pngget.obj: pngget.c
|
||||||
pngread.obj: pngread.c
|
pngmem.obj: pngmem.c
|
||||||
pngpread.obj: pngpread.c
|
pngpread.obj: pngpread.c
|
||||||
|
pngread.obj: pngread.c
|
||||||
|
pngrio.obj: pngrio.c
|
||||||
pngrtran.obj: pngrtran.c
|
pngrtran.obj: pngrtran.c
|
||||||
pngrutil.obj: pngrutil.c
|
pngrutil.obj: pngrutil.c
|
||||||
pngerror.obj: pngerror.c
|
pngset.obj: pngset.c
|
||||||
pngmem.obj: pngmem.c
|
|
||||||
pngrio.obj: pngrio.c
|
|
||||||
pngwio.obj: pngwio.c
|
|
||||||
pngtrans.obj: pngtrans.c
|
pngtrans.obj: pngtrans.c
|
||||||
|
pngwio.obj: pngwio.c
|
||||||
pngwrite.obj: pngwrite.c
|
pngwrite.obj: pngwrite.c
|
||||||
pngwtran.obj: pngwtran.c
|
pngwtran.obj: pngwtran.c
|
||||||
pngwutil.obj: pngwutil.c
|
pngwutil.obj: pngwutil.c
|
||||||
@ -155,14 +147,16 @@ pngtest$(MODEL).obj: pngtest.c
|
|||||||
$(CC) $(CFLAGS) -opngtest$(MODEL) -c pngtest.c
|
$(CC) $(CFLAGS) -opngtest$(MODEL) -c pngtest.c
|
||||||
|
|
||||||
pngtest$(MODEL).exe: pngtest$(MODEL).obj
|
pngtest$(MODEL).exe: pngtest$(MODEL).obj
|
||||||
$(CC) $(MODELARG) $(LDFLAGS) -L$(ZLIB_PATH) pngtest$(MODEL).obj $(LIBNAME) zlib$(MODEL).lib $(NOEHLIB)
|
$(LD) $(LDFLAGS) pngtest$(MODEL).obj $(LIBNAME) zlib_$(MODEL).lib $(NOEHLIB)
|
||||||
|
|
||||||
|
|
||||||
# Clean up anything else you want
|
# Clean up anything else you want
|
||||||
clean:
|
clean:
|
||||||
-del *.obj
|
-del *.obj
|
||||||
|
-del *.exe
|
||||||
-del *.lib
|
-del *.lib
|
||||||
-del *.lst
|
-del *.lst
|
||||||
|
-del *.map
|
||||||
|
|
||||||
|
|
||||||
# End of makefile for libpng
|
# End of makefile for libpng
|
@ -14,7 +14,7 @@ ZLIBINC=../zlib
|
|||||||
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
||||||
# have to change it.
|
# have to change it.
|
||||||
PNGMAJ = 2
|
PNGMAJ = 2
|
||||||
PNGMIN = 1.0.5s
|
PNGMIN = 1.0.6
|
||||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||||
|
|
||||||
CC=cc
|
CC=cc
|
||||||
|
66
scripts/makefile.gcc
Normal file
66
scripts/makefile.gcc
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
# makefile for libpng using gcc (generic, static library)
|
||||||
|
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||||
|
# Copyright (C) 2000 Cosmin Truta
|
||||||
|
# For conditions of distribution and use, see copyright notice in png.h
|
||||||
|
|
||||||
|
# Location of the zlib library and include files
|
||||||
|
ZLIBINC = ../zlib
|
||||||
|
ZLIBLIB = ../zlib
|
||||||
|
|
||||||
|
# Compiler, linker, lib and other tools
|
||||||
|
CC = gcc
|
||||||
|
LD = $(CC)
|
||||||
|
AR = ar rcs
|
||||||
|
RANLIB = ranlib
|
||||||
|
RM = rm -f
|
||||||
|
|
||||||
|
CDEBUG = -g -DPNG_DEBUG=5
|
||||||
|
LDDEBUG =
|
||||||
|
CRELEASE = -O2
|
||||||
|
LDRELEASE = -s
|
||||||
|
CFLAGS = -I$(ZLIBINC) -Wall $(CRELEASE)
|
||||||
|
LDFLAGS = -L. -L$(ZLIBLIB) -lpng -lz -lm $(LDRELEASE)
|
||||||
|
|
||||||
|
# File extensions
|
||||||
|
O=.o
|
||||||
|
A=.a
|
||||||
|
E=
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \
|
||||||
|
pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \
|
||||||
|
pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O)
|
||||||
|
|
||||||
|
# Targets
|
||||||
|
all: libpng$(A) pngtest$(E)
|
||||||
|
|
||||||
|
libpng$(A): $(OBJS)
|
||||||
|
$(AR) $@ $(OBJS)
|
||||||
|
$(RANLIB) $@
|
||||||
|
|
||||||
|
test: pngtest$(E)
|
||||||
|
./pngtest$(E)
|
||||||
|
|
||||||
|
pngtest$(E): pngtest$(O) libpng$(A)
|
||||||
|
$(LD) -o $@ pngtest$(O) $(LDFLAGS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *$(O) libpng$(A) pngtest$(E) pngout.png
|
||||||
|
|
||||||
|
png$(O): png.h pngconf.h
|
||||||
|
pngerror$(O): png.h pngconf.h
|
||||||
|
pngget$(O): png.h pngconf.h
|
||||||
|
pngmem$(O): png.h pngconf.h
|
||||||
|
pngpread$(O): png.h pngconf.h
|
||||||
|
pngread$(O): png.h pngconf.h
|
||||||
|
pngrio$(O): png.h pngconf.h
|
||||||
|
pngrtran$(O): png.h pngconf.h
|
||||||
|
pngrutil$(O): png.h pngconf.h
|
||||||
|
pngset$(O): png.h pngconf.h
|
||||||
|
pngtest$(O): png.h pngconf.h
|
||||||
|
pngtrans$(O): png.h pngconf.h
|
||||||
|
pngwio$(O): png.h pngconf.h
|
||||||
|
pngwrite$(O): png.h pngconf.h
|
||||||
|
pngwtran$(O): png.h pngconf.h
|
||||||
|
pngwutil$(O): png.h pngconf.h
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
# makefile for libpng on Linux ELF with gcc using MMX assembler code
|
# makefile for libpng on Linux ELF with gcc using MMX assembler code
|
||||||
# Copyright (C) 1996, 1997 Andreas Dilger
|
# Copyright (C) 1996, 1997 Andreas Dilger
|
||||||
# Copyright (C) 1998, 1999, 2000 Greg Roelofs
|
# Copyright (C) 1998-2000 Greg Roelofs
|
||||||
# For conditions of distribution and use, see copyright notice in png.h
|
# For conditions of distribution and use, see copyright notice in png.h
|
||||||
|
|
||||||
CC=gcc
|
CC=gcc
|
||||||
@ -34,7 +34,7 @@ RANLIB=ranlib
|
|||||||
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
||||||
# have to change it.
|
# have to change it.
|
||||||
PNGMAJ = 2
|
PNGMAJ = 2
|
||||||
PNGMIN = 1.0.5s
|
PNGMIN = 1.0.6
|
||||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||||
|
|
||||||
INCPATH=$(prefix)/include
|
INCPATH=$(prefix)/include
|
||||||
@ -53,6 +53,20 @@ OBJSDLL = $(OBJS:.o=.pic.o)
|
|||||||
|
|
||||||
all: libpng.a libpng.so pngtest
|
all: libpng.a libpng.so pngtest
|
||||||
|
|
||||||
|
pnggccrd.o: png.h pngconf.h pngasmrd.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
|
||||||
|
|
||||||
|
pnggccrd.pic.o: png.h pngconf.h pngasmrd.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
|
||||||
|
|
||||||
libpng.a: $(OBJS)
|
libpng.a: $(OBJS)
|
||||||
ar rc $@ $(OBJS)
|
ar rc $@ $(OBJS)
|
||||||
$(RANLIB) $@
|
$(RANLIB) $@
|
||||||
@ -108,6 +122,5 @@ pngwrite.o pngwrite.pic.o: png.h pngconf.h
|
|||||||
pngwtran.o pngwtran.pic.o: png.h pngconf.h
|
pngwtran.o pngwtran.pic.o: png.h pngconf.h
|
||||||
pngwutil.o pngwutil.pic.o: png.h pngconf.h
|
pngwutil.o pngwutil.pic.o: png.h pngconf.h
|
||||||
pngpread.o pngpread.pic.o: png.h pngconf.h
|
pngpread.o pngpread.pic.o: png.h pngconf.h
|
||||||
pnggccrd.o pnggccrd.pic.o: png.h pngconf.h
|
|
||||||
|
|
||||||
pngtest.o: png.h pngconf.h
|
pngtest.o: png.h pngconf.h
|
||||||
|
71
scripts/makefile.ibmvac3
Normal file
71
scripts/makefile.ibmvac3
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
# Makefile for libpng
|
||||||
|
# IBM VisualAge/C++ version 3.x for Win32 and OS/2 (static)
|
||||||
|
# Copyright (C) 2000 Cosmin Truta
|
||||||
|
# Notes:
|
||||||
|
# Derived from makefile.std
|
||||||
|
# All modules are compiled in C mode
|
||||||
|
# Tested with VAC++ 3.6.5 under Win32, expected to work under OS/2 too
|
||||||
|
# Can be easily adapted for IBM VisualAge/C++ for AIX
|
||||||
|
# For conditions of distribution and use, see copyright notice in png.h
|
||||||
|
|
||||||
|
# Location of the zlib library and include files
|
||||||
|
ZLIBINC = ../zlib
|
||||||
|
ZLIBLIB = ../zlib
|
||||||
|
|
||||||
|
# Compiler, linker, lib and other tools
|
||||||
|
CC = icc
|
||||||
|
LD = ilink
|
||||||
|
AR = ilib
|
||||||
|
RM = del
|
||||||
|
|
||||||
|
CFLAGS = -I$(ZLIBINC) -O2 -W3
|
||||||
|
LDFLAGS =
|
||||||
|
|
||||||
|
# File extensions
|
||||||
|
O=.obj
|
||||||
|
A=.lib
|
||||||
|
E=.exe
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \
|
||||||
|
pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \
|
||||||
|
pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O)
|
||||||
|
|
||||||
|
LIBS = libpng$(A) $(ZLIBLIB)/zlib$(A)
|
||||||
|
|
||||||
|
# Targets
|
||||||
|
all: libpng$(A) pngtest$(E)
|
||||||
|
|
||||||
|
libpng$(A): $(OBJS)
|
||||||
|
$(AR) -out:$@ $(OBJS)
|
||||||
|
|
||||||
|
test: pngtest$(E)
|
||||||
|
pngtest$(E)
|
||||||
|
|
||||||
|
pngtest: pngtest$(E)
|
||||||
|
|
||||||
|
pngtest$(E): pngtest$(O) libpng$(A)
|
||||||
|
$(LD) $(LDFLAGS) pngtest$(O) $(LIBS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *$(O)
|
||||||
|
$(RM) libpng$(A)
|
||||||
|
$(RM) pngtest$(E)
|
||||||
|
$(RM) pngout.png
|
||||||
|
|
||||||
|
png$(O): png.h pngconf.h
|
||||||
|
pngerror$(O): png.h pngconf.h
|
||||||
|
pngget$(O): png.h pngconf.h
|
||||||
|
pngmem$(O): png.h pngconf.h
|
||||||
|
pngpread$(O): png.h pngconf.h
|
||||||
|
pngread$(O): png.h pngconf.h
|
||||||
|
pngrio$(O): png.h pngconf.h
|
||||||
|
pngrtran$(O): png.h pngconf.h
|
||||||
|
pngrutil$(O): png.h pngconf.h
|
||||||
|
pngset$(O): png.h pngconf.h
|
||||||
|
pngtest$(O): png.h pngconf.h
|
||||||
|
pngtrans$(O): png.h pngconf.h
|
||||||
|
pngwio$(O): png.h pngconf.h
|
||||||
|
pngwrite$(O): png.h pngconf.h
|
||||||
|
pngwtran$(O): png.h pngconf.h
|
||||||
|
pngwutil$(O): png.h pngconf.h
|
@ -34,7 +34,7 @@ RANLIB=ranlib
|
|||||||
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
||||||
# have to change it.
|
# have to change it.
|
||||||
PNGMAJ = 2
|
PNGMAJ = 2
|
||||||
PNGMIN = 1.0.5s
|
PNGMIN = 1.0.6
|
||||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||||
|
|
||||||
INCPATH=$(prefix)/include
|
INCPATH=$(prefix)/include
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib
|
# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib
|
||||||
|
|
||||||
# -------- Microsoft C 5.1 and later, does not use assembler code -----
|
# -------- Microsoft C 5.1 and later, does not use assembler code -----
|
||||||
MODEL=-AL
|
MODEL=L
|
||||||
CFLAGS=-Oait -Gs -nologo -W3 $(MODEL) -I..\zlib
|
CFLAGS=-Oait -Gs -nologo -W3 -A$(MODEL) -I..\zlib
|
||||||
#-Ox generates bad code with MSC 5.1
|
#-Ox generates bad code with MSC 5.1
|
||||||
CC=cl
|
CC=cl
|
||||||
LD=link
|
LD=link
|
||||||
|
@ -25,7 +25,7 @@ RANLIB=echo
|
|||||||
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
||||||
# have to change it.
|
# have to change it.
|
||||||
PNGMAJ = 2
|
PNGMAJ = 2
|
||||||
PNGMIN = 1.0.5s
|
PNGMIN = 1.0.6
|
||||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||||
|
|
||||||
INCPATH=$(prefix)/include
|
INCPATH=$(prefix)/include
|
||||||
|
90
scripts/makefile.sggcc
Normal file
90
scripts/makefile.sggcc
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
# makefile for libpng, SGI IRIX with gcc
|
||||||
|
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||||
|
# For conditions of distribution and use, see copyright notice in png.h
|
||||||
|
|
||||||
|
# where make install puts libpng.a and png.h
|
||||||
|
prefix=/usr/local
|
||||||
|
|
||||||
|
# Where the zlib library and include files are located
|
||||||
|
ZLIBLIB=/usr/local/lib32
|
||||||
|
ZLIBINC=/usr/local/include
|
||||||
|
#ZLIBLIB=../zlib
|
||||||
|
#ZLIBINC=../zlib
|
||||||
|
|
||||||
|
CC=gcc
|
||||||
|
|
||||||
|
WARNMORE=
|
||||||
|
CFLAGS=-I$(ZLIBINC) -O2 $(WARNMORE) -fPIC -mabi=n32 # -g -DPNG_DEBUG=5
|
||||||
|
# zlib must also be compiled with n32
|
||||||
|
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
|
||||||
|
LDSHARED=gcc -shared
|
||||||
|
|
||||||
|
VER=1.0.6
|
||||||
|
LIBS=libpng.so.1.0.6
|
||||||
|
SHAREDLIB=libpng.so
|
||||||
|
libdir=$(prefix)/lib32
|
||||||
|
|
||||||
|
RANLIB=echo
|
||||||
|
#RANLIB=ranlib
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
all: libpng.a $(SHAREDLIB).$(VER) pngtest
|
||||||
|
|
||||||
|
libpng.a: $(OBJS)
|
||||||
|
ar rc $@ $(OBJS)
|
||||||
|
$(RANLIB) $@
|
||||||
|
|
||||||
|
$(SHAREDLIB).$(VER): $(OBJS)
|
||||||
|
$(LDSHARED) -o $@ $(OBJS)
|
||||||
|
rm -f $(SHAREDLIB) $(SHAREDLIB).1
|
||||||
|
ln -s $@ $(SHAREDLIB)
|
||||||
|
ln -s $@ $(SHAREDLIB).1
|
||||||
|
|
||||||
|
pngtest: pngtest.o libpng.a
|
||||||
|
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
|
||||||
|
|
||||||
|
test: pngtest
|
||||||
|
./pngtest
|
||||||
|
|
||||||
|
install: libpng.a
|
||||||
|
-@mkdir $(prefix)/include
|
||||||
|
-@mkdir $(prefix)/lib
|
||||||
|
cp png.h $(prefix)/include
|
||||||
|
cp pngconf.h $(prefix)/include
|
||||||
|
chmod 644 $(prefix)/include/png.h
|
||||||
|
chmod 644 $(prefix)/include/pngconf.h
|
||||||
|
cp libpng.a $(prefix)/lib
|
||||||
|
chmod 644 $(prefix)/lib/libpng.a
|
||||||
|
cp $(SHAREDLIB).$(VER) $(libdir); chmod 755 $(SHAREDLIB).$(VER)
|
||||||
|
cd $(libdir); if test -f $(SHAREDLIB).$(VER); then \
|
||||||
|
rm -f $(SHAREDLIB) $(SHAREDLIB).1; \
|
||||||
|
ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB); \
|
||||||
|
ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB).1; \
|
||||||
|
(ldconfig || true) >/dev/null 2>&1; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o libpng.a pngtest pngout.png
|
||||||
|
|
||||||
|
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||||
|
|
||||||
|
png.o: png.h pngconf.h
|
||||||
|
pngerror.o: png.h pngconf.h
|
||||||
|
pngrio.o: png.h pngconf.h
|
||||||
|
pngwio.o: png.h pngconf.h
|
||||||
|
pngmem.o: png.h pngconf.h
|
||||||
|
pngset.o: png.h pngconf.h
|
||||||
|
pngget.o: png.h pngconf.h
|
||||||
|
pngread.o: png.h pngconf.h
|
||||||
|
pngrtran.o: png.h pngconf.h
|
||||||
|
pngrutil.o: png.h pngconf.h
|
||||||
|
pngtest.o: png.h pngconf.h
|
||||||
|
pngtrans.o: png.h pngconf.h
|
||||||
|
pngwrite.o: png.h pngconf.h
|
||||||
|
pngwtran.o: png.h pngconf.h
|
||||||
|
pngwutil.o: png.h pngconf.h
|
||||||
|
pngpread.o: png.h pngconf.h
|
||||||
|
|
@ -31,7 +31,7 @@ RANLIB=echo
|
|||||||
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
||||||
# have to change it.
|
# have to change it.
|
||||||
PNGMAJ = 2
|
PNGMAJ = 2
|
||||||
PNGMIN = 1.0.5s
|
PNGMIN = 1.0.6
|
||||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||||
|
|
||||||
INCPATH=$(prefix)/include
|
INCPATH=$(prefix)/include
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
# Makefile for libpng
|
# Makefile for libpng
|
||||||
# TurboC++ 3.0 (Note: All modules are compiled in C mode)
|
# TurboC/C++ (Note: All modules are compiled in C mode)
|
||||||
|
|
||||||
# To use, do "make -fmakefile.turboc3"
|
# To use, do "make -fmakefile.tc3"
|
||||||
|
|
||||||
# ------------- Turbo C++ 3.0 -------------
|
# ------ Turbo C 3.00 (can be modified to work with earlier versions)------
|
||||||
MODEL=-ml
|
|
||||||
CFLAGS=-O2 -Z $(MODEL) -I..\zlib
|
MODEL=l
|
||||||
|
CFLAGS=-O2 -Z -m$(MODEL) -I..\zlib
|
||||||
|
#CFLAGS=-D_NO_PROTO -O2 -Z -m$(MODEL) -I..\zlib # Turbo C older than 3.00
|
||||||
CC=tcc
|
CC=tcc
|
||||||
LD=tcc
|
LD=tcc
|
||||||
LIB=tlib
|
LIB=tlib
|
||||||
LDFLAGS=$(MODEL) -L..\zlib
|
LDFLAGS=-m$(MODEL) -L..\zlib
|
||||||
O=.obj
|
O=.obj
|
||||||
E=.exe
|
E=.exe
|
||||||
|
|
||||||
@ -21,7 +23,12 @@ OBJSL1 = +png$(O) +pngset$(O) +pngget$(O) +pngrutil$(O) +pngtrans$(O)
|
|||||||
OBJSL2 = +pngwutil$(O) +pngmem$(O) +pngpread$(O) +pngread$(O) +pngerror$(O)
|
OBJSL2 = +pngwutil$(O) +pngmem$(O) +pngpread$(O) +pngread$(O) +pngerror$(O)
|
||||||
OBJSL3 = +pngwrite$(O) +pngrtran$(O) +pngwtran$(O) +pngrio$(O) +pngwio$(O)
|
OBJSL3 = +pngwrite$(O) +pngrtran$(O) +pngwtran$(O) +pngrio$(O) +pngwio$(O)
|
||||||
|
|
||||||
all: libpng.lib pngtest.exe
|
all: libpng$(MODEL).lib pngtest$(E)
|
||||||
|
|
||||||
|
pngtest: pngtest$(E)
|
||||||
|
|
||||||
|
test: pngtest$(E)
|
||||||
|
pngtest$(E)
|
||||||
|
|
||||||
png$(O): png.h pngconf.h
|
png$(O): png.h pngconf.h
|
||||||
$(CC) -c $(CFLAGS) $*.c
|
$(CC) -c $(CFLAGS) $*.c
|
||||||
@ -71,12 +78,12 @@ pngwtran$(O): png.h pngconf.h
|
|||||||
pngwutil$(O): png.h pngconf.h
|
pngwutil$(O): png.h pngconf.h
|
||||||
$(CC) -c $(CFLAGS) $*.c
|
$(CC) -c $(CFLAGS) $*.c
|
||||||
|
|
||||||
libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3)
|
libpng$(MODEL).lib: $(OBJS1) $(OBJS2) $(OBJS3)
|
||||||
$(LIB) libpng +$(OBJSL1)
|
$(LIB) libpng$(MODEL) +$(OBJSL1)
|
||||||
$(LIB) libpng +$(OBJSL2)
|
$(LIB) libpng$(MODEL) +$(OBJSL2)
|
||||||
$(LIB) libpng +$(OBJSL3)
|
$(LIB) libpng$(MODEL) +$(OBJSL3)
|
||||||
|
|
||||||
pngtest$(E): pngtest$(O) libpng.lib
|
pngtest$(E): pngtest$(O) libpng$(MODEL).lib
|
||||||
$(CC) $(LDFLAGS) pngtest.obj libpng.lib zlib.lib
|
$(LD) $(LDFLAGS) pngtest.obj libpng$(MODEL).lib zlib_$(MODEL).lib
|
||||||
|
|
||||||
# End of makefile for libpng
|
# End of makefile for libpng
|
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
# If you don't want to use assembler code, use makefile.vcwin32 instead.
|
# If you don't want to use assembler code, use makefile.vcwin32 instead.
|
||||||
|
|
||||||
MODEL=-
|
|
||||||
CFLAGS=-DPNG_USE_PNGVCRD -Ox -GA3s -nologo -W3 -I..\zlib
|
CFLAGS=-DPNG_USE_PNGVCRD -Ox -GA3s -nologo -W3 -I..\zlib
|
||||||
|
|
||||||
CC=cl
|
CC=cl
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
# ---------- Microsoft Visual C++ 4.0 and later, no assembler code------
|
# ---------- Microsoft Visual C++ 4.0 and later, no assembler code------
|
||||||
# If you want to use assembler code, use makefile.vcawin32 instead.
|
# If you want to use assembler code, use makefile.vcawin32 instead.
|
||||||
|
|
||||||
MODEL=-
|
|
||||||
CFLAGS= -Ox -GA3s -nologo -W3 -I..\zlib
|
CFLAGS= -Ox -GA3s -nologo -W3 -I..\zlib
|
||||||
|
|
||||||
CC=cl
|
CC=cl
|
||||||
|
@ -3,7 +3,7 @@ unit pngdef;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
const
|
const
|
||||||
PNG_LIBPNG_VER_STRING = '1.0.5n';
|
PNG_LIBPNG_VER_STRING = '1.0.6';
|
||||||
PNG_LIBPNG_VER = 10006;
|
PNG_LIBPNG_VER = 10006;
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -450,6 +450,10 @@ procedure png_set_cHRM(png_ptr: png_structp; info_ptr: png_infop;
|
|||||||
white_x, white_y, red_x, red_y, green_x, green_y,
|
white_x, white_y, red_x, red_y, green_x, green_y,
|
||||||
blue_x, blue_y: double);
|
blue_x, blue_y: double);
|
||||||
stdcall;
|
stdcall;
|
||||||
|
procedure png_set_cHRM_fixed(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
white_x, white_y, red_x, red_y, green_x, green_y,
|
||||||
|
blue_x, blue_y: png_fixed_point);
|
||||||
|
stdcall;
|
||||||
procedure png_set_compression_level(png_ptr: png_structp; level: int);
|
procedure png_set_compression_level(png_ptr: png_structp; level: int);
|
||||||
stdcall;
|
stdcall;
|
||||||
procedure png_set_compression_mem_level(png_ptr: png_structp;
|
procedure png_set_compression_mem_level(png_ptr: png_structp;
|
||||||
@ -489,6 +493,9 @@ procedure png_set_flush(png_ptr: png_structp; nrows: int);
|
|||||||
procedure png_set_gAMA(png_ptr: png_structp; info_ptr: png_infop;
|
procedure png_set_gAMA(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
file_gamma: double);
|
file_gamma: double);
|
||||||
stdcall;
|
stdcall;
|
||||||
|
procedure png_set_gAMA_fixed(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
file_gamma: png_fixed_point);
|
||||||
|
stdcall;
|
||||||
procedure png_set_gamma(png_ptr: png_structp; screen_gamma,
|
procedure png_set_gamma(png_ptr: png_structp; screen_gamma,
|
||||||
default_file_gamma: double);
|
default_file_gamma: double);
|
||||||
stdcall;
|
stdcall;
|
||||||
@ -540,7 +547,11 @@ procedure png_set_read_user_chunk_fn(png_ptr: png_structp;
|
|||||||
procedure png_set_read_user_transform_fn(png_ptr: png_structp;
|
procedure png_set_read_user_transform_fn(png_ptr: png_structp;
|
||||||
read_user_transform_fn: png_user_transform_ptr);
|
read_user_transform_fn: png_user_transform_ptr);
|
||||||
stdcall;
|
stdcall;
|
||||||
procedure png_set_rgb_to_gray(png_ptr: png_structp; int: error_action);
|
procedure png_set_rgb_to_gray(png_ptr: png_structp; int: error_action;
|
||||||
|
red_weight, green_weight: double);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_rgb_to_gray_fixed(png_ptr: png_structp; int: error_action;
|
||||||
|
red_weight, green_weight: png_fixed_point);
|
||||||
stdcall;
|
stdcall;
|
||||||
procedure png_set_rows(png_ptr: png_structp; info_ptr: png_infop;
|
procedure png_set_rows(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
row_pointers: png_bytepp);
|
row_pointers: png_bytepp);
|
||||||
@ -705,6 +716,7 @@ procedure png_set_bKGD; external pngDLL;
|
|||||||
procedure png_set_background; external pngDLL;
|
procedure png_set_background; external pngDLL;
|
||||||
procedure png_set_bgr; external pngDLL;
|
procedure png_set_bgr; external pngDLL;
|
||||||
procedure png_set_cHRM; external pngDLL;
|
procedure png_set_cHRM; external pngDLL;
|
||||||
|
procedure png_set_cHRM_fixed; external pngDLL;
|
||||||
procedure png_set_compression_level; external pngDLL;
|
procedure png_set_compression_level; external pngDLL;
|
||||||
procedure png_set_compression_mem_level; external pngDLL;
|
procedure png_set_compression_mem_level; external pngDLL;
|
||||||
procedure png_set_compression_method; external pngDLL;
|
procedure png_set_compression_method; external pngDLL;
|
||||||
@ -719,6 +731,7 @@ procedure png_set_filter; external pngDLL;
|
|||||||
procedure png_set_filter_heuristics; external pngDLL;
|
procedure png_set_filter_heuristics; external pngDLL;
|
||||||
procedure png_set_flush; external pngDLL;
|
procedure png_set_flush; external pngDLL;
|
||||||
procedure png_set_gAMA; external pngDLL;
|
procedure png_set_gAMA; external pngDLL;
|
||||||
|
procedure png_set_gAMA_fixed; external pngDLL;
|
||||||
procedure png_set_gamma; external pngDLL;
|
procedure png_set_gamma; external pngDLL;
|
||||||
procedure png_set_gray_to_rgb; external pngDLL;
|
procedure png_set_gray_to_rgb; external pngDLL;
|
||||||
procedure png_set_hIST; external pngDLL;
|
procedure png_set_hIST; external pngDLL;
|
||||||
@ -734,6 +747,8 @@ procedure png_set_progressive_read_fn; external pngDLL;
|
|||||||
procedure png_set_read_fn; external pngDLL;
|
procedure png_set_read_fn; external pngDLL;
|
||||||
procedure png_set_read_status_fn; external pngDLL;
|
procedure png_set_read_status_fn; external pngDLL;
|
||||||
procedure png_set_read_user_transform_fn; external pngDLL;
|
procedure png_set_read_user_transform_fn; external pngDLL;
|
||||||
|
procedure png_set_rgb_to_gray; external pngDLL;
|
||||||
|
procedure png_set_rgb_to_gray_fixed; external pngDLL;
|
||||||
procedure png_set_rows; external pngDLL;
|
procedure png_set_rows; external pngDLL;
|
||||||
procedure png_set_sBIT; external pngDLL;
|
procedure png_set_sBIT; external pngDLL;
|
||||||
procedure png_set_sRGB; external pngDLL;
|
procedure png_set_sRGB; external pngDLL;
|
||||||
|
@ -31,6 +31,7 @@ EXPORTS
|
|||||||
png_set_bgr
|
png_set_bgr
|
||||||
png_set_gray_to_rgb
|
png_set_gray_to_rgb
|
||||||
png_set_rgb_to_gray
|
png_set_rgb_to_gray
|
||||||
|
png_set_rgb_to_gray_fixed
|
||||||
png_set_rows
|
png_set_rows
|
||||||
png_build_grayscale_palette
|
png_build_grayscale_palette
|
||||||
png_set_strip_alpha
|
png_set_strip_alpha
|
||||||
@ -131,8 +132,10 @@ EXPORTS
|
|||||||
png_set_bKGD
|
png_set_bKGD
|
||||||
png_get_cHRM
|
png_get_cHRM
|
||||||
png_set_cHRM
|
png_set_cHRM
|
||||||
|
png_set_cHRM_fixed
|
||||||
png_get_gAMA
|
png_get_gAMA
|
||||||
png_set_gAMA
|
png_set_gAMA
|
||||||
|
png_set_gAMA_fixed
|
||||||
png_get_hIST
|
png_get_hIST
|
||||||
png_set_hIST
|
png_set_hIST
|
||||||
png_get_IHDR
|
png_get_IHDR
|
||||||
|
Reference in New Issue
Block a user