mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Compare commits
15 Commits
v1.0.5h
...
v1.0.7beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc4a143ec6 | ||
|
|
ec61c23d56 | ||
|
|
1ef65b6742 | ||
|
|
752945701e | ||
|
|
98c9d73605 | ||
|
|
6942d53c25 | ||
|
|
326320e5a9 | ||
|
|
228bd390ac | ||
|
|
4accabb590 | ||
|
|
38e6e77419 | ||
|
|
81fdf8aca1 | ||
|
|
68ea243ca3 | ||
|
|
520a764cd7 | ||
|
|
a77ef625a6 | ||
|
|
61c32d9e66 |
151
ANNOUNCE
151
ANNOUNCE
@@ -1,85 +1,80 @@
|
||||
|
||||
Libpng 1.0.5h - December 10, 1999
|
||||
Libpng 1.0.7beta14 - May 17, 2000
|
||||
|
||||
This is not intended to be a public release. It will be replaced
|
||||
within a few weeks by a public version or by another test version.
|
||||
This is a public release of libpng, intended for use in production codes.
|
||||
|
||||
Changes since the last public release (1.0.5):
|
||||
Changes since the last public release (1.0.6):
|
||||
|
||||
version libpng-1.0.5a October 23, 1999
|
||||
Added contrib/pngsuite and contrib/pngminus (Willem van Schaik)
|
||||
Fixed a typo in the png_set_sRGB() function call in example.c (Jan Nijtmans)
|
||||
Further optimization and bugfix of pngvcrd.c
|
||||
Revised pngset.c so that it does not allocate or free memory in the user's
|
||||
text_ptr structure. Instead, it makes its own copy.
|
||||
Created separate write_end_info_struct in pngtest.c for a more severe test.
|
||||
Added code in pngwrite.c to free info_ptr->text[i].key to stop a memory leak.
|
||||
version libpng-1.0.5b November 23, 1999
|
||||
Moved PNG_FLAG_HAVE_CHUNK_HEADER, PNG_FLAG_BACKGROUND_IS_GRAY and
|
||||
PNG_FLAG_WROTE_tIME from flags to mode.
|
||||
Added png_write_info_before_PLTE() function.
|
||||
Fixed some typecasting in contrib/gregbook/*.c
|
||||
Updated scripts/makevms.com and added makevms.com to contrib/gregbook
|
||||
and contrib/pngminus (Martin Zinser)
|
||||
version libpng-1.0.5c November 26, 1999
|
||||
Moved png_get_header_version from png.h to png.c, to accomodate ansi2knr.
|
||||
Removed all global arrays (according to PNG_NO_GLOBAL_ARRAYS macro), to
|
||||
accomodate making DLL's: Moved usr_png_ver from global variable to function
|
||||
png_get_header_ver() in png.c. Moved png_sig to png_sig_bytes in png.c and
|
||||
eliminated use of png_sig in pngwutil.c. Moved the various png_CHNK arrays
|
||||
into pngtypes.h. Eliminated use of global png_pass arrays. Declared the
|
||||
png_CHNK and png_pass arrays to be "const". Made the global arrays
|
||||
available to applications (although none are used in libpng itself) when
|
||||
PNG_NO_GLOBAL_ARRAYS is not defined or when PNG_GLOBAL_ARRAYS is defined.
|
||||
Removed some extraneous "-I" from contrib/pngminus/makefile.std
|
||||
Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2.
|
||||
Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3
|
||||
version libpng-1.0.5d November 29, 1999
|
||||
Add type cast (png_const_charp) two places in png.c
|
||||
Eliminated pngtypes.h; use macros instead to declare PNG_CHNK arrays.
|
||||
Renamed "PNG_GLOBAL_ARRAYS" to "PNG_USE_GLOBAL_ARRAYS" and made available
|
||||
to applications a macro "PNG_USE_LOCAL_ARRAYS".
|
||||
#ifdef out all the new declarations when PNG_USE_GLOBAL_ARRAYS is defined.
|
||||
Added PNG_EXPORT_VAR macro to accommodate making DLL's.
|
||||
version libpng-1.0.5e November 30, 1999
|
||||
Added iCCP, iTXt, and sPLT support; added "lang" member to the png_text
|
||||
structure; refactored the inflate/deflate support to make adding new chunks
|
||||
with trailing compressed parts easier in the future, and added new functions
|
||||
png_free_iCCP, png_free_pCAL, png_free_sPLT, png_free_text, png_get_iCCP,
|
||||
png_get_spalettes, png_set_iCCP, png_set_spalettes (Eric S. Raymond).
|
||||
NOTE: Applications that write text chunks MUST define png_text->lang. Before
|
||||
calling png_set_text(). It must be set to NULL if you want to write tEXt or
|
||||
zTXt chunks. If you want your application to be able to run with older
|
||||
versions of libpng, use
|
||||
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
png_text[i].lang = NULL;
|
||||
#endif
|
||||
|
||||
Changed png_get_oFFs() and png_set_oFFs() to use signed rather than unsigned
|
||||
offsets (Eric S. Raymond).
|
||||
Combined PNG_READ_cHNK_SUPPORTED and PNG_WRITE_cHNK_SUPPORTED macros into
|
||||
PNG_cHNK_SUPPORTED and combined the three types of PNG_text_SUPPORTED
|
||||
macros, leaving the separate macros also available.
|
||||
Removed comments on #endifs at the end of many short, non-nested #if-blocks.
|
||||
version libpng-1.0.5f December 6, 1999
|
||||
Changed makefile.solaris to issue a warning about potential problems when
|
||||
the ucb "ld" is in the path ahead of the ccs "ld".
|
||||
Removed "- [date]" from the "synopsis" line in libpng.3 and libpngpf.3.
|
||||
Added sCAL chunk support (Eric S. Raymond).
|
||||
version libpng-1.0.5g December 7, 1999
|
||||
Fixed "png_free_spallettes" typo in png.h
|
||||
Added code to handle new chunks in pngpread.c
|
||||
Moved PNG_CHNK string macro definitions outside of PNG_NO_EXTERN block
|
||||
Added "translated_key" to png_text structure and png_write_iTXt().
|
||||
Added code in pngwrite.c to work around a newly discovered zlib bug.
|
||||
version 1.0.5h [December 10, 1999]
|
||||
NOTE: regarding the not 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
|
||||
fixed-point functions such as png_set_gAMA_fixed() were added.
|
||||
Changed sprintf() to strcpy() in png_write_sCAL_s() to work without STDIO
|
||||
Added data_length parameter to png_decompress_chunk() function
|
||||
Revised documentation to remove reference to abandoned png_free_chnk functions
|
||||
Fixed an error in png_rgb_to_gray_fixed()
|
||||
Revised example.c, usage of png_destroy_write_struct().
|
||||
Renamed makefile.ibmvac3 to makefile.ibmc, added libpng.icc IBM project file
|
||||
Added a check for info_ptr->free_me&PNG_FREE_TEXT when free'ing text in png.c
|
||||
Simplify png_sig_bytes() function to remove use of non-ISO-C strdup().
|
||||
Added png_data_freer() function.
|
||||
In the code that checks for over-length tRNS chunks, added check of
|
||||
info_ptr->num_trans as well as png_ptr->num_trans (Matthias Benckmann)
|
||||
Check for existing data and free it if the free_me flag is set, in png_set_*()
|
||||
and png_handle_*().
|
||||
Only define PNG_WEIGHTED_FILTERS_SUPPORTED when PNG_FLOATING_POINT_SUPPORTED
|
||||
is defined.
|
||||
Changed several instances of PNG_NO_CONSOLE_ID to PNG_NO_STDIO in pngrutil.c
|
||||
and mentioned the purposes of the two macros in libpng.txt/libpng.3.
|
||||
Revised png_set_iCCP() and png_set_rows() to avoid prematurely freeing data.
|
||||
Add checks in png_set_text() for NULL members of the input text structure.
|
||||
Removed superfluous prototype for png_set_itxt from png.h
|
||||
Removed "else" from pngread.c, after png_error(), and changed "0" to "length".
|
||||
Changed several png_errors about malformed ancillary chunks to png_warnings.
|
||||
Added png_pass-* arrays to pnggccrd.c when PNG_USE_LOCAL_ARRAYS is defined.
|
||||
Relocated paragraph about png_set_background() in libpng.3/libpng.txt
|
||||
and other revisions (Matthias Benckmann)
|
||||
Relocated info_ptr->free_me to restore binary compatibility with libpng-1.0.5
|
||||
(breaks compatibility with libpng-1.0.6).
|
||||
Relocated info_ptr->free_me, png_ptr->free_me, and other info_ptr and
|
||||
png_ptr members to restore binary compatibility with libpng-1.0.5
|
||||
(breaks compatibility with libpng-1.0.6).
|
||||
Rearranged some members at the end of png_info and png_struct, to put
|
||||
unknown_chunks_num and free_me within the original size of the png_structs
|
||||
and free_me, png_read_user_fn, and png_free_fn within the original png_info,
|
||||
because some old applications allocate the structs directly instead of
|
||||
using png_create_*().
|
||||
Added documentation of user memory functions in libpng.txt/libpng.3
|
||||
Modified png_read_png so that it will use user_allocated row_pointers
|
||||
if present, unless free_me directs that it be freed, and added description
|
||||
of the use of png_set_rows() and png_get_rows() in libpng.txt/libpng.3.
|
||||
Added PNG_LEGACY_SUPPORTED macro, and #ifdef out all new (since version
|
||||
1.00) members of png_struct and png_info, to regain binary compatibility
|
||||
when you define this macro. Capabilities lost in this event
|
||||
are user transforms (new in version 1.0.0),the user transform pointer
|
||||
(new in version 1.0.2), rgb_to_gray (new in 1.0.5), iCCP, sCAL, sPLT,
|
||||
the high-level interface, and unknown chunks support (all new in 1.0.6).
|
||||
This was necessary because of old applications that allocate the structs
|
||||
directly as authors were instructed to do in libpng-0.88 and earlier,
|
||||
instead of using png_create_*().
|
||||
Added makefile.intel and updated makefile.watcom (Pawel Mrochen)
|
||||
Overloaded png_read_init() and png_write_init() with macros that convert
|
||||
calls to png_read_init_2() or png_write_init_2() that check the version
|
||||
and structure sizes.
|
||||
Made PNG_NO_ITXT_SUPPORTED the default setting, to avoid memory overrun
|
||||
when old applications fill the info_ptr->text structure directly.
|
||||
Added PNGAPI macro, and added it to the definitions of all exported functions.
|
||||
Made PNG_NO_CONSOLE_IO the default condition when PNG_BUILD_DLL is defined.
|
||||
Use MSC _RPTn debugging instead of fprintf if _MSC_VER is defined.
|
||||
Added png_access_version_number() function.
|
||||
Check for mask&PNG_FREE_CHNK (for TEXT, SCAL, PCAL) in png_free_data().
|
||||
Expanded libpng.3/libpng.txt information about png_data_freer().
|
||||
Changed pnggccrd.c and pngvcrd.c to handle bad adaptive filter types as
|
||||
warnings instead of errors, as pngrutil.c does.
|
||||
Set the PNG_INFO_IDAT valid flag in png_set_rows() so png_write_png()
|
||||
will actually write IDATs.
|
||||
Made the default PNG_USE_LOCAL_ARRAYS depend on PNG_DLL instead of WIN32.
|
||||
Make png_free_data() ignore its final parameter when freeing data that can
|
||||
have multiple instances (text, sPLT, unknowns).
|
||||
Removed info_ptr->valid tests from png_free_data(), as in version 1.0.5.
|
||||
Added png_set_invalid() function.
|
||||
Fixed incorrect illustrations of png_destroy_write_struct() in example.c.
|
||||
|
||||
Send comments/corrections/commendations to
|
||||
png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
|
||||
|
||||
217
CHANGES
217
CHANGES
@@ -123,6 +123,7 @@ version 0.90 [January, 1997]
|
||||
- all chunk handling routines have the same prototypes, so we will
|
||||
be able to handle all chunks via a callback mechanism
|
||||
try to fix Linux "setjmp" buffer size problems
|
||||
removed png_large_malloc, png_large_free, and png_realloc functions.
|
||||
version 0.95 [March, 1997]
|
||||
fixed bug in pngwutil.c allocating "up_row" twice and "avg_row" never
|
||||
fixed bug in PNG file signature compares when start != 0
|
||||
@@ -259,6 +260,7 @@ version 0.99h [March 6, 1998, evening]
|
||||
Minor changes to previous minor changes to pngtest.c
|
||||
Changed PNG_READ_NOT_FULLY_SUPPORTED to PNG_READ_TRANSFORMS_NOT_SUPPORTED
|
||||
and added PNG_PROGRESSIVE_READ_NOT_SUPPORTED macro
|
||||
Added user transform capability
|
||||
version 1.00 [March 7, 1998]
|
||||
Changed several typedefs in pngrutil.c
|
||||
Added makefile.wat (Pawel Mrochen), updated makefile.tc3 (Willem van Schaik)
|
||||
@@ -517,7 +519,7 @@ version 1.0.5e [November 30, 1999]
|
||||
with trailing compressed parts easier in the future, and added new functions
|
||||
png_free_iCCP, png_free_pCAL, png_free_sPLT, png_free_text, png_get_iCCP,
|
||||
png_get_spalettes, png_set_iCCP, png_set_spalettes (Eric S. Raymond).
|
||||
NOTE: Applications that write text chunks MUST define png_text->lang and
|
||||
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
|
||||
@@ -544,9 +546,220 @@ version 1.0.5g [December 7, 1999]
|
||||
Added "translated_key" to png_text structure and png_write_iTXt().
|
||||
Added code in pngwrite.c to work around a newly discovered zlib bug.
|
||||
version 1.0.5h [December 10, 1999]
|
||||
NOTE: regarding the not for version 1.0.5e, the following must also
|
||||
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
|
||||
fixed-point functions such as png_set_gAMA_fixed() were added.
|
||||
Expanded tabs and removed trailing blanks in source files.
|
||||
version 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.
|
||||
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 1.0.5j [December 21, 1999]
|
||||
Changed "unit" parameter of png_write_sCAL from png_byte to int, to work
|
||||
around buggy compilers.
|
||||
Added new type "png_fixed_point" for integers that hold float*100000 values
|
||||
Restored backward compatibility of tEXt/zTXt chunk processing:
|
||||
Restored the first four members of png_text to the same order as v.1.0.5d.
|
||||
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. Added
|
||||
PNG_ITXT_COMPRESSION_NONE (1) and PNG_ITXT_COMPRESSION_zTXt(2) macros.
|
||||
The "Note" above, about backward incompatibility of libpng-1.0.5e, no
|
||||
longer applies.
|
||||
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 1.0.5k [December 27, 1999]
|
||||
Added many parentheses, e.g., "if (a && b & c)" becomes "if (a && (b & c))"
|
||||
Added png_handle_as_unknown() function (Glenn)
|
||||
Added png_free_chunk_list() function and chunk_list and num_chunk_list members
|
||||
of png_ptr.
|
||||
Eliminated erroneous warnings about multiple sPLT chunks and sPLT-after-PLTE.
|
||||
Fixed a libpng-1.0.5h bug in pngrutil.c that was issuing erroneous warnings
|
||||
about ignoring incorrect gAMA with sRGB (gAMA was in fact not ignored)
|
||||
Added png_free_tRNS(); png_set_tRNS() now malloc's its own trans array (ESR).
|
||||
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 1.0.5l [January 1, 2000]
|
||||
Added functions png_set_read_user_chunk_fn() and png_get_user_chunk_ptr()
|
||||
for setting a callback function to handle unknown chunks and for
|
||||
retrieving the associated user pointer (Glenn).
|
||||
version 1.0.5m [January 7, 2000]
|
||||
Added high-level functions png_read_png(), png_write_png(), png_free_pixels().
|
||||
version 1.0.5n [January 9, 2000]
|
||||
Added png_free_PLTE() function, and modified png_set_PLTE() to malloc its
|
||||
own memory for info_ptr->palette. This makes it safe for the calling
|
||||
application to free its copy of the palette any time after it calls
|
||||
png_set_PLTE().
|
||||
version 1.0.5o [January 20, 2000]
|
||||
Cosmetic changes only (removed some trailing blanks and TABs)
|
||||
version 1.0.5p [January 31, 2000]
|
||||
Renamed pngdll.mak to makefile.bd32
|
||||
Cosmetic changes in pngtest.c
|
||||
version 1.0.5q [February 5, 2000]
|
||||
Relocated the makefile.solaris warning about PATH problems.
|
||||
Fixed pngvcrd.c bug by pushing/popping registers in mmxsupport (Bruce Oberg)
|
||||
Revised makefile.gcmmx
|
||||
Added PNG_SETJMP_SUPPORTED, PNG_SETJMP_NOT_SUPPORTED, and PNG_ABORT() macros
|
||||
version 1.0.5r [February 7, 2000]
|
||||
Removed superfluous prototype for png_get_itxt from png.h
|
||||
Fixed a bug in pngrtran.c that improperly expanded the background color.
|
||||
Return *num_text=0 from png_get_text() when appropriate, and fix documentation
|
||||
of png_get_text() in libpng.txt/libpng.3.
|
||||
version 1.0.5s [February 18, 2000]
|
||||
Added "png_jmp_env()" macro to pngconf.h, to help people migrate to the
|
||||
new error handler that's planned for the next libpng release, and changed
|
||||
example.c, pngtest.c, and contrib programs to use this macro.
|
||||
Revised some of the DLL-export macros in pngconf.h (Greg Roelofs)
|
||||
Fixed a bug in png_read_png() that caused it to fail to expand some images
|
||||
that it should have expanded.
|
||||
Fixed some mistakes in the unused and undocumented INCH_CONVERSIONS functions
|
||||
in pngget.c
|
||||
Changed the allocation of palette, history, and trans arrays back to
|
||||
the version 1.0.5 method (linking instead of copying) which restores
|
||||
backward compatibility with version 1.0.5. Added some remarks about
|
||||
that in example.c. Added "free_me" member to info_ptr and png_ptr
|
||||
and added png_free_data() function.
|
||||
Updated makefile.linux and makefile.gccmmx to make directories conditionally.
|
||||
Made cosmetic changes to pngasmrd.h
|
||||
Added png_set_rows() and png_get_rows(), for use with png_read|write_png().
|
||||
Modified png_read_png() to allocate info_ptr->row_pointers only if it
|
||||
hasn't already been allocated.
|
||||
version 1.0.5t [March 4, 2000]
|
||||
Changed png_jmp_env() migration aiding macro to png_jmpbuf().
|
||||
Fixed "interlace" typo (should be "interlaced") in contrib/gregbook/read2-x.c
|
||||
Fixed bug with use of PNG_BEFORE_IHDR bit in png_ptr->mode, introduced when
|
||||
PNG_FLAG_HAVE_CHUNK_HEADER was moved into png_ptr->mode in version 1.0.5b
|
||||
Files in contrib/gregbook were revised to use png_jmpbuf() and to select
|
||||
a 24-bit visual if one is available, and to allow abbreviated options.
|
||||
Files in contrib/pngminus were revised to use the png_jmpbuf() macro.
|
||||
Removed spaces in makefile.linux and makefile.gcmmx, introduced in 1.0.5s
|
||||
version 1.0.5u [March 5, 2000]
|
||||
Simplified the code that detects old png.h in png.c and pngtest.c
|
||||
Renamed png_spalette (_p, _pp) to png_sPLT_t (_tp, _tpp)
|
||||
Increased precision of rgb_to_gray calculations from 8 to 15 bits and
|
||||
added png_set_rgb_to_gray_fixed() function.
|
||||
Added makefile.bc32 (32-bit Borland C++, C mode)
|
||||
version 1.0.5v [March 11, 2000]
|
||||
Added some parentheses to the png_jmpbuf macro definition.
|
||||
Updated references to the zlib home page, which has moved to freesoftware.com.
|
||||
Corrected bugs in documentation regarding png_read_row() and png_write_row().
|
||||
Updated documentation of png_rgb_to_gray calculations in libpng.3/libpng.txt.
|
||||
Renamed makefile.borland,turboc3 back to makefile.bor,tc3 as in version 1.0.3,
|
||||
revised borland makefiles; added makefile.ibmvac3 and makefile.gcc (Cosmin)
|
||||
version 1.0.6 [March 20, 2000]
|
||||
Minor revisions of makefile.bor, libpng.txt, and gregbook/rpng2-win.c
|
||||
Added makefile.sggcc (SGI IRIX with gcc)
|
||||
version 1.0.6d [April 7, 2000]
|
||||
Changed sprintf() to strcpy() in png_write_sCAL_s() to work without STDIO
|
||||
Added data_length parameter to png_decompress_chunk() function
|
||||
Revised documentation to remove reference to abandoned png_free_chnk functions
|
||||
Fixed an error in png_rgb_to_gray_fixed()
|
||||
Revised example.c, usage of png_destroy_write_struct().
|
||||
Renamed makefile.ibmvac3 to makefile.ibmc, added libpng.icc IBM project file
|
||||
Added a check for info_ptr->free_me&PNG_FREE_TEXT when free'ing text in png.c
|
||||
Simplify png_sig_bytes() function to remove use of non-ISO-C strdup().
|
||||
version 1.0.6e [April 9, 2000]
|
||||
Added png_data_freer() function.
|
||||
In the code that checks for over-length tRNS chunks, added check of
|
||||
info_ptr->num_trans as well as png_ptr->num_trans (Matthias Benckmann)
|
||||
Minor revisions of libpng.txt/libpng.3.
|
||||
Check for existing data and free it if the free_me flag is set, in png_set_*()
|
||||
and png_handle_*().
|
||||
Only define PNG_WEIGHTED_FILTERS_SUPPORTED when PNG_FLOATING_POINT_SUPPORTED
|
||||
is defined.
|
||||
Changed several instances of PNG_NO_CONSOLE_ID to PNG_NO_STDIO in pngrutil.c
|
||||
and mentioned the purposes of the two macros in libpng.txt/libpng.3.
|
||||
version 1.0.6f [April 14, 2000]
|
||||
Revised png_set_iCCP() and png_set_rows() to avoid prematurely freeing data.
|
||||
Add checks in png_set_text() for NULL members of the input text structure.
|
||||
Revised libpng.txt/libpng.3.
|
||||
Removed superfluous prototype for png_set_itxt from png.h
|
||||
Removed "else" from pngread.c, after png_error(), and changed "0" to "length".
|
||||
Changed several png_errors about malformed ancillary chunks to png_warnings.
|
||||
version 1.0.6g [April 24, 2000]
|
||||
Added png_pass-* arrays to pnggccrd.c when PNG_USE_LOCAL_ARRAYS is defined.
|
||||
Relocated paragraph about png_set_background() in libpng.3/libpng.txt
|
||||
and other revisions (Matthias Benckmann)
|
||||
Relocated info_ptr->free_me, png_ptr->free_me, and other info_ptr and
|
||||
png_ptr members to restore binary compatibility with libpng-1.0.5
|
||||
(breaks compatibility with libpng-1.0.6).
|
||||
version 1.0.6h [April 24, 2000]
|
||||
Changed shared library so-number pattern from 2.x.y.z to xy.z (this builds
|
||||
libpng.so.10 & libpng.so.10.6h instead of libpng.so.2 & libpng.so.2.1.0.6h)
|
||||
This is a temporary change for test purposes.
|
||||
version 1.0.6i [May 2, 2000]
|
||||
Rearranged some members at the end of png_info and png_struct, to put
|
||||
unknown_chunks_num and free_me within the original size of the png_structs
|
||||
and free_me, png_read_user_fn, and png_free_fn within the original png_info,
|
||||
because some old applications allocate the structs directly instead of
|
||||
using png_create_*().
|
||||
Added documentation of user memory functions in libpng.txt/libpng.3
|
||||
Modified png_read_png so that it will use user_allocated row_pointers
|
||||
if present, unless free_me directs that it be freed, and added description
|
||||
of the use of png_set_rows() and png_get_rows() in libpng.txt/libpng.3.
|
||||
Added PNG_LEGACY_SUPPORTED macro, and #ifdef out all new (since version
|
||||
1.00) members of png_struct and png_info, to regain binary compatibility
|
||||
when you define this macro. Capabilities lost in this event
|
||||
are user transforms (new in version 1.0.0),the user transform pointer
|
||||
(new in version 1.0.2), rgb_to_gray (new in 1.0.5), iCCP, sCAL, sPLT,
|
||||
the high-level interface, and unknown chunks support (all new in 1.0.6).
|
||||
This was necessary because of old applications that allocate the structs
|
||||
directly as authors were instructed to do in libpng-0.88 and earlier,
|
||||
instead of using png_create_*().
|
||||
Added modes PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT which
|
||||
can be used to detect codes that directly allocate the structs, and
|
||||
code to check these modes in png_read_init() and png_write_init() and
|
||||
generate a libpng error if the modes aren't set and PNG_LEGACY_SUPPORTED
|
||||
was not defined.
|
||||
Added makefile.intel and updated makefile.watcom (Pawel Mrochen)
|
||||
version 1.0.6j [May 3, 2000]
|
||||
Overloaded png_read_init() and png_write_init() with macros that convert
|
||||
calls to png_read_init_2() or png_write_init_2() that check the version
|
||||
and structure sizes.
|
||||
version 1.0.7beta11 [May 7, 2000]
|
||||
Removed the new PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT modes
|
||||
which are no longer used.
|
||||
Eliminated the three new members of png_text when PNG_NO_iTXt_SUPPORTED
|
||||
or PNG_LEGACY_SUPPORTED is defined.
|
||||
Made PNG_NO_ITXT_SUPPORTED the default setting, to avoid memory overrun
|
||||
when old applications fill the info_ptr->text structure directly.
|
||||
Added PNGAPI macro, and added it to the definitions of all exported functions.
|
||||
version 1.0.7beta12 [May 12, 2000]
|
||||
Revised pngset.c to avoid a problem with expanding the png_debug macro.
|
||||
Deleted some extraneous defines from pngconf.h
|
||||
Made PNG_NO_CONSOLE_IO the default condition when PNG_BUILD_DLL is defined.
|
||||
Use MSC _RPTn debugging instead of fprintf if _MSC_VER is defined.
|
||||
Added png_access_version_number() function.
|
||||
Check for mask&PNG_FREE_CHNK (for TEXT, SCAL, PCAL) in png_free_data().
|
||||
Expanded libpng.3/libpng.txt information about png_data_freer().
|
||||
version 1.0.7beta13 [May 16, 2000]
|
||||
Changed pnggccrd.c and pngvcrd.c to handle bad adaptive filter types as
|
||||
warnings instead of errors, as pngrutil.c does.
|
||||
Set the PNG_INFO_IDAT valid flag in png_set_rows() so png_write_png()
|
||||
will actually write IDATs.
|
||||
Made the default PNG_USE_LOCAL_ARRAYS depend on PNG_DLL instead of WIN32.
|
||||
Make png_free_data() ignore its final parameter when freeing data that can
|
||||
have multiple instances (text, sPLT, unknowns).
|
||||
version 1.0.7beta14 [May 17, 2000]
|
||||
Fixed a new bug in png_set_rows().
|
||||
Removed info_ptr->valid tests from png_free_data(), as in version 1.0.5.
|
||||
Added png_set_invalid() function.
|
||||
Fixed incorrect illustrations of png_destroy_write_struct() in example.c.
|
||||
|
||||
Send comments/corrections/commendations to
|
||||
png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
|
||||
|
||||
Glenn R-P
|
||||
|
||||
41
INSTALL
41
INSTALL
@@ -1,5 +1,5 @@
|
||||
|
||||
Installing libpng version 1.0.5h - December 10, 1999
|
||||
Installing libpng version 1.0.7beta14 - May 17, 2000
|
||||
|
||||
Before installing libpng, you must first install zlib. zlib
|
||||
can usually be found wherever you got libpng. zlib can be
|
||||
@@ -10,7 +10,7 @@ zlib.h and zconf.h include files that correspond to the
|
||||
version of zlib that's installed.
|
||||
|
||||
You can rename the directories that you downloaded (they
|
||||
might be called "libpng-1.0.5h" or "lpng103" and "zlib-1.1.3"
|
||||
might be called "libpng-1.0.7beta14" or "lpng106" and "zlib-1.1.3"
|
||||
or "zlib113") so that you have directories called "zlib" and "libpng".
|
||||
|
||||
Your directory structure should look like this:
|
||||
@@ -36,23 +36,33 @@ Your directory structure should look like this:
|
||||
contrib
|
||||
etc.
|
||||
|
||||
First enter the zlib directory and follow the instructions
|
||||
in zlib/README. Then come back here and choose the
|
||||
appropriate makefile.sys in the scripts directory.
|
||||
If the line endings in the files look funny, you may wish to get the other
|
||||
distribution of libpng. It is available in both tar.gz (UNIX style line
|
||||
endings) and zip (DOS style line endings) formats.
|
||||
|
||||
First enter the zlib directory and follow the instructions in zlib/README.
|
||||
Then come back here and choose the appropriate makefile.sys in the scripts
|
||||
directory.
|
||||
The files that are presently available in the scripts directory
|
||||
include
|
||||
|
||||
descrip.mms => VMS makefile for MMS or MMK
|
||||
makefile.std => Generic UNIX makefile
|
||||
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
|
||||
makefile.linux => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.7beta14)
|
||||
makefile.gcmmx => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.7beta14,
|
||||
uses assembler code tuned for Intel MMX platform)
|
||||
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
|
||||
makefile.knr => Archaic UNIX Makefile that converts files with
|
||||
ansi2knr (Requires ansi2knr.c from
|
||||
ftp://ftp.cs.wisc.edu/ghost)
|
||||
makefile.dec => DEC Alpha UNIX makefile
|
||||
makefile.hpux => HPUX (10.20 and 11.00) makefile
|
||||
makefile.sgi => Silicon Graphics IRIX makefile
|
||||
makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static)
|
||||
makefile.intel => Intel C/C++ version 4.0 and later
|
||||
libpng.icc => Project file for IBM VisualAge/C++ version 4.0 or later
|
||||
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
|
||||
makefile.sggcc => Silicon Graphics (gcc, creates libpng.so.2.1.0.7beta14)
|
||||
makefile.sunos => Sun makefile
|
||||
makefile.solaris => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.5h)
|
||||
makefile.linux => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.5h)
|
||||
makefile.solaris => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.7beta14)
|
||||
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
|
||||
makefile.mips => MIPS makefile
|
||||
makefile.acorn => Acorn makefile
|
||||
@@ -61,20 +71,21 @@ include
|
||||
(Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc)
|
||||
makefile.atari => Atari makefile
|
||||
makefile.beos => BEOS makefile for X86
|
||||
makefile.borland => Borland makefile
|
||||
build.bat => MS-DOS batch file for Borland compiler
|
||||
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.tc3 => Turbo C 3.0 makefile
|
||||
makefile.dj2 => DJGPP 2 makefile
|
||||
makefile.msc => Microsoft C makefile
|
||||
makefile.vcawin32 => makefile for Microsoft Visual C++ 5.0 and later (uses
|
||||
assembler code)
|
||||
assembler code tuned for Intel MMX platform)
|
||||
makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and later (does
|
||||
not use assembler code)
|
||||
makefile.turboc3 => Turbo C 3.0 makefile
|
||||
makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def)
|
||||
pngos2.def => OS/2 module definition file used by makefile.os2
|
||||
makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model
|
||||
makevms.com => VMS build script
|
||||
pngdll.mak => To make a png32bd.dll with Borland C++ 4.5
|
||||
descrip.mms => VMS makefile for MMS or MMK
|
||||
pngdef.pas => Defines for a png32bd.dll with Borland C++ 4.5
|
||||
SCOPTIONS.ppc => Used with smakefile.ppc
|
||||
|
||||
|
||||
127
KNOWNBUG
127
KNOWNBUG
@@ -1,8 +1,97 @@
|
||||
|
||||
Known bugs and suggested enhancements in libpng-1.0.5
|
||||
Known bugs and suggested enhancements in libpng-1.0.6
|
||||
|
||||
1. April 24, 2000 -- BUG -- binary incompatibility
|
||||
|
||||
1. March 15, 1998 -- OPTIMIZATION -- Kevin Bracey
|
||||
Libpng-1.0.6 is binary incompatible with old applications that
|
||||
allocate the png_struct and png_info structures themselves instead
|
||||
of using png_create_*(). They do not allocate enough space for
|
||||
the structures because they have an incorrect notion of
|
||||
sizeof(png_struct) and sizeof(png_info). Although such applications
|
||||
should be considered broken rather than considering libpng to be broken,
|
||||
they are numerous and include products of the PNG group, such
|
||||
as gif2png and pnmtopng-2.36 (pnmtopng-2.37 is OK), so libpng will
|
||||
be fixed in version 1.0.7 to work around this problem.
|
||||
|
||||
Applications that use png_create_*() instead of png_ptr=malloc(...)
|
||||
are immune to this problem.
|
||||
|
||||
STATUS: Fixed in libpng-1.0.6ad, libpng-1.0.6j, and patch-d
|
||||
which are currently being tested by the PNG group.
|
||||
The fix necessarily reintroduces a binary incompatibility with any
|
||||
application that makes direct access to the png_info and
|
||||
png_struct members that deal with the pCAL chunk, palette_lookup,
|
||||
dither_index, time_buffer, or weighted filtering, i.e., any members
|
||||
coming after the new "free_me" member of either structure. It
|
||||
is believed that applications affected by this reintroduced binary
|
||||
incompatibility are rare (none are known to the PNG group). An
|
||||
effective workaround for this and the next bug is to recompile the
|
||||
old applications with the installed version of libpng.
|
||||
|
||||
2. April 23, 2000 -- BUG -- binary incompatibility
|
||||
|
||||
Libpng-1.0.6 introduced binary incompatibility for applications that
|
||||
make direct access to members of the png_struct and png_info structures,
|
||||
due to the insertion of the free_me member ahead of some previously
|
||||
existing members.
|
||||
|
||||
Applications that use png_set_*(), png_get_*() are immune to this
|
||||
problem, but people are still to this day writing applications that
|
||||
make ill-advised direct access to members of the png_struct and
|
||||
png_info structures, so libpng-1.0.6 will be patched to work around
|
||||
this problem.
|
||||
|
||||
STATUS: Fixed in libpng-1.0.6j and patch-d, which are currently being
|
||||
tested by the PNG group. Users can work around the problem without
|
||||
patching libpng by recompiling their applications.
|
||||
|
||||
3. April 15, 2000 -- BUG -- pnggccrd.c
|
||||
|
||||
If PNG_NO_GLOBAL_ARRAYS is defined, pnggccrd.c will not compile.
|
||||
|
||||
STATUS: Fixed in libpng-1.0.6g
|
||||
|
||||
4. April 1, 2000 -- BUG
|
||||
|
||||
Under some circumstances old applications that make direct access to
|
||||
the info_ptr->text and its members might free the same memory that
|
||||
is also free'ed by libpng during the png_destroy_struct process.
|
||||
|
||||
Fixed in libpng-1.0.6-patch-c and libpng-1.0.6d. The PNG_FREE_TEXT flag
|
||||
bit in info_ptr->free_me is now checked to make sure libpng is responsible
|
||||
for freeing the memory.
|
||||
|
||||
5. April 1, 2000 -- BUG
|
||||
|
||||
The non-ISO-C "strdup()" function is used in png.c
|
||||
|
||||
STATUS: The function has been simplified and no longer uses strdup()
|
||||
in libpng-1.0.6-patch-c and libpng-1.0.6d.
|
||||
|
||||
6. March 24, 2000 -- BUG
|
||||
|
||||
The png_set_rgb_to_gray_fixed() function is setting incorrect weighting
|
||||
factors.
|
||||
|
||||
STATUS: Fixed in libpng-1.0.6-patch-b and libpng-1.0.6d.
|
||||
|
||||
7. March 22, 2000 -- BUG
|
||||
|
||||
There are some printf() and fprintf() statements active in pngwutil.c
|
||||
when PNG_NO_STDIO and PNG_sCAL_SUPPORTED are both defined.
|
||||
|
||||
STATUS: Fixed in libpng-1.0.6-patch-a and libpng-1.0.6d. The strcpy()
|
||||
function is used instead.
|
||||
|
||||
8. March 22, 2000 -- BUG
|
||||
|
||||
The length of the iCCP chunk data is calculated incorrectly; because
|
||||
it can contain zeroes, strlen() doesn't work.
|
||||
|
||||
STATUS: Fixed in libpng-1.0.6-patch-a and libpng-1.0.6d by adding a
|
||||
data_length parameter to the png_decompress_chunk() function.
|
||||
|
||||
9. March 15, 1998 -- OPTIMIZATION -- Kevin Bracey
|
||||
|
||||
Loops need to be optimized everywhere
|
||||
|
||||
@@ -17,7 +106,7 @@ Known bugs and suggested enhancements in libpng-1.0.5
|
||||
libpng-1.1.0. About 160 loops will be turned around
|
||||
in libpng-1.1.Nn, for testing.
|
||||
|
||||
2. July 4, 1998 -- ENHANCEMENT -- Glenn R-P
|
||||
10. July 4, 1998 -- ENHANCEMENT -- Glenn R-P
|
||||
|
||||
libpng-1.0.5 and earlier transform colors to gamma=1.0 space for
|
||||
merging with background, and then back to the image's gamma. The
|
||||
@@ -29,39 +118,15 @@ Known bugs and suggested enhancements in libpng-1.0.5
|
||||
|
||||
STATUS: under development.
|
||||
|
||||
3. September 1999 -- ENHANCEMENT --
|
||||
11. September 1999 -- ENHANCEMENT --
|
||||
|
||||
It should be possible to use libpng without floating-point aritmetic.
|
||||
|
||||
STATUS: Under investigation, implementation postponed until after
|
||||
libpng-1.0.5. The application interface will change because replacements
|
||||
libpng-1.0.6. The application interface will change because replacements
|
||||
for the png_set_gAMA(), png_set_cHRM(), and corresponding png_get_()
|
||||
functions will be needed.
|
||||
|
||||
4. October 1999 -- BUG
|
||||
Much of this was completed in libpng-1.0.6, but gamma compensation
|
||||
is not yet done in fixed-point arithmetic.
|
||||
|
||||
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: Will be fixed before the next public release.
|
||||
|
||||
8
LICENSE
8
LICENSE
@@ -4,8 +4,8 @@ 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 Glenn Randers-Pehrson
|
||||
(libpng versions 0.97, January 1998, through 1.0.5h, December 10, 1999)
|
||||
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
(libpng versions 0.97, January 1998, through 1.0.7beta14, May 17, 2000)
|
||||
|
||||
For the purposes of this copyright and license, "Contributing Authors"
|
||||
is defined as the following set of individuals:
|
||||
@@ -63,9 +63,9 @@ boxes and the like:
|
||||
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
|
||||
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
|
||||
certification mark of the Open Source Initiative.
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
randeg@alum.rpi.edu
|
||||
December 10, 1999
|
||||
May 17, 2000
|
||||
|
||||
45
README
45
README
@@ -1,8 +1,12 @@
|
||||
README for libpng 1.0.5h - December 10, 1999 (shared library 2.1)
|
||||
README for libpng 1.0.7beta14 - May 17, 2000 (shared library 2.1)
|
||||
See the note about version numbers near the top of png.h
|
||||
|
||||
See INSTALL for instructions on how to install libpng.
|
||||
|
||||
Libpng comes in two distribution formats. Get libpng-*.tar.gz if you
|
||||
want UNIX-style line endings in the text files, or lpng*.zip if you want
|
||||
DOS-style line endings.
|
||||
|
||||
Version 0.89 was the first official release of libpng. Don't let the
|
||||
fact that it's the first release fool you. The libpng library has been in
|
||||
extensive use and testing since mid-1995. By late 1997 it had
|
||||
@@ -125,22 +129,26 @@ gladly listen. Even if your suggestion is not used for version
|
||||
|
||||
Files in this distribution:
|
||||
|
||||
ANNOUNCE => Announcement of this version, with recent changes
|
||||
CHANGES => Description of changes between libpng versions
|
||||
KNOWNBUG => List of known bugs and deficiencies
|
||||
LICENSE => License to use and redistribute libpng
|
||||
README => This file
|
||||
TODO => Things not implemented in the current library
|
||||
build.bat => MS-DOS batch file for Borland compiler
|
||||
descrip.mms => VMS project file
|
||||
Y2KINFO => Statement of Y2K compliance
|
||||
example.c => Example code for using libpng functions
|
||||
libpng.3 => manual page for libpng
|
||||
libpng.3 => manual page for libpng (includes libpng.txt)
|
||||
libpng.txt => Description of libpng and its functions
|
||||
libpngpf.3 => manual page for libpng's private functions
|
||||
png.5 => manual page for the PNG format
|
||||
png.c => Basic interface functions common to library
|
||||
png.h => Library function and interface declarations
|
||||
pngconf.h => System specific library configuration
|
||||
pngasmrd.h => Header file for assembler-coded functions
|
||||
pngerror.c => Error/warning message I/O functions
|
||||
pngget.c => Functions for retrieving info from struct
|
||||
pngmem.c => Memory handling functions
|
||||
pngnow.png => PNG logo
|
||||
pngpread.c => Progressive reading functions
|
||||
pngread.c => Read data/helper high-level functions
|
||||
pngrio.c => Lowest-level data read I/O functions
|
||||
@@ -162,18 +170,26 @@ Files in this distribution:
|
||||
pngsuite => Test images
|
||||
scripts => Directory containing scripts for building libpng:
|
||||
descrip.mms => VMS makefile for MMS or MMK
|
||||
makefile.std => Generic UNIX makefile
|
||||
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
|
||||
makefile.linux => Linux/ELF makefile
|
||||
(gcc, creates libpng.so.2.1.0.7beta14)
|
||||
makefile.gcmmx => Linux/ELF makefile (gcc, creates
|
||||
libpng.so.2.1.0.7beta14, uses assembler code
|
||||
tuned for Intel MMX platform)
|
||||
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
|
||||
makefile.knr => Archaic UNIX Makefile that converts files with
|
||||
ansi2knr (Requires ansi2knr.c from
|
||||
ftp://ftp.cs.wisc.edu/ghost)
|
||||
makefile.dec => DEC Alpha UNIX makefile
|
||||
makefile.hpux => HPUX (10.20 and 11.00) makefile
|
||||
makefile.sgi => Silicon Graphics IRIX makefile
|
||||
makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static)
|
||||
makefile.intel => Intel C/C++ version 4.0 and later
|
||||
libpng.icc => Project file, IBM VisualAge/C++ 4.0 or later
|
||||
makefile.sgi => Silicon Graphics IRIX (cc, creates static lib)
|
||||
makefile.sggcc => Silicon Graphics (gcc, creates libpng.so.2.1.0.7beta14)
|
||||
makefile.sunos => Sun makefile
|
||||
makefile.solaris => Solaris 2.X makefile
|
||||
(gcc, creates libpng.so.2.1.0.5h)
|
||||
makefile.linux => Linux/ELF makefile
|
||||
(gcc, creates libpng.so.2.1.0.5h)
|
||||
(gcc, creates libpng.so.2.1.0.7beta14)
|
||||
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
|
||||
makefile.mips => MIPS makefile
|
||||
makefile.acorn => Acorn makefile
|
||||
@@ -183,20 +199,21 @@ Files in this distribution:
|
||||
scripts/SCOPTIONS.ppc)
|
||||
makefile.atari => Atari makefile
|
||||
makefile.beos => BEOS makefile for X86
|
||||
makefile.borland => Borland makefile
|
||||
build.bat => MS-DOS batch file for Borland compiler
|
||||
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.tc3 => Turbo C 3.0 makefile
|
||||
makefile.dj2 => DJGPP 2 makefile
|
||||
makefile.msc => Microsoft C makefile
|
||||
makefile.vcawin32 => makefile for Microsoft Visual C++ 5.0 and
|
||||
later (uses assembler code)
|
||||
later (uses assembler code tuned for Intel MMX
|
||||
platform)
|
||||
makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and
|
||||
later (does not use assembler code)
|
||||
makefile.turboc3 => Turbo C 3.0 makefile
|
||||
makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def)
|
||||
pngos2.def => OS/2 module definition file used by makefile.os2
|
||||
makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model
|
||||
makevms.com => VMS build script
|
||||
pngdll.mak => To make 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
|
||||
|
||||
|
||||
9
TODO
9
TODO
@@ -1,13 +1,12 @@
|
||||
TODO - list of things to do for libpng:
|
||||
|
||||
Final bug fixes.
|
||||
Fix problem with C++ and EXTERN "C".
|
||||
Improve API by hiding the png_struct and png_info structs.
|
||||
Finish work on the no-floating-point version (including gamma compensation)
|
||||
Better C++ wrapper/full C++ implementation?
|
||||
Keep up with public chunks.
|
||||
Fix problem with C++ and EXTERN "C".
|
||||
cHRM transformation.
|
||||
Support for application-defined chunk handlers.
|
||||
Improve setjmp/longjmp usage or remove it in favor of returning error codes.
|
||||
High-level API for reading images.
|
||||
Add "grayscale->palette" transformation and "palette->grayscale" detection.
|
||||
Improved dithering.
|
||||
Multi-lingual error and warning message support.
|
||||
@@ -18,5 +17,3 @@ Better filter selection
|
||||
(counting huffman bits/precompression? filter inertia? filter costs?).
|
||||
Histogram creation.
|
||||
Text conversion between different code pages (Latin-1 -> Mac and DOS).
|
||||
Improve API by hiding the info_ptr.
|
||||
Make a no-floating-point version.
|
||||
|
||||
30
Y2KINFO
30
Y2KINFO
@@ -1,29 +1,29 @@
|
||||
Y2K compliance in libpng:
|
||||
=========================
|
||||
|
||||
December 10, 1999
|
||||
|
||||
|
||||
May 17, 2000
|
||||
|
||||
Since the PNG Development group is an ad-hoc body, we can't make
|
||||
an official declaration.
|
||||
|
||||
|
||||
This is your unofficial assurance that libpng from version 0.71 and
|
||||
upward through 1.0.5h are Y2K compliant. It is my belief that earlier
|
||||
upward through 1.0.7beta14 are Y2K compliant. It is my belief that earlier
|
||||
versions were also Y2K compliant.
|
||||
|
||||
|
||||
Libpng only has three year fields. One is a 2-byte unsigned integer
|
||||
that will hold years up to 65535. The other two hold the date in text
|
||||
format, and will hold years up to 9999.
|
||||
|
||||
|
||||
The integer is
|
||||
"png_uint_16 year" in png_time_struct.
|
||||
|
||||
|
||||
The strings are
|
||||
"png_charp time_buffer" in png_struct and
|
||||
"near_time_buffer", which is a local character string in png.c.
|
||||
|
||||
|
||||
There are seven time-related functions:
|
||||
|
||||
png_convert_to_rfc_1123() in png.c
|
||||
png_convert_to_rfc_1123() in png.c
|
||||
(formerly png_convert_to_rfc_1152() in error)
|
||||
png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
|
||||
png_convert_from_time_t() in pngwrite.c
|
||||
@@ -31,8 +31,8 @@
|
||||
png_handle_tIME() in pngrutil.c, called in pngread.c
|
||||
png_set_tIME() in pngset.c
|
||||
png_write_tIME() in pngwutil.c, called in pngwrite.c
|
||||
|
||||
All appear to handle dates properly in a Y2K environment. The
|
||||
|
||||
All appear to handle dates properly in a Y2K environment. The
|
||||
png_convert_from_time_t() function calls gmtime() to convert from system
|
||||
clock time, which returns (year - 1900), which we properly convert to
|
||||
the full 4-digit year. There is a possibility that applications using
|
||||
@@ -42,14 +42,14 @@
|
||||
but this is not under our control. The libpng documentation has always
|
||||
stated that it works with 4-digit years, and the APIs have been
|
||||
documented as such.
|
||||
|
||||
|
||||
The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
|
||||
integer to hold the year, and can hold years as large as 65535.
|
||||
|
||||
zlib, upon which libpng depends, is also Y2K compliant. It contains
|
||||
no date-related code.
|
||||
|
||||
|
||||
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
libpng maintainer
|
||||
PNG Development Group
|
||||
|
||||
6
configure
vendored
Executable file
6
configure
vendored
Executable file
@@ -0,0 +1,6 @@
|
||||
echo "
|
||||
There is no \"configure\" script for Libpng-1.0.7beta14. 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.
|
||||
# Greg Roelofs
|
||||
# Last modified: 16 February 1999
|
||||
# Last modified: 28 February 2000
|
||||
#
|
||||
# The programs built by this makefile are described in the book,
|
||||
# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and
|
||||
@@ -9,11 +9,12 @@
|
||||
#
|
||||
# Invoke this makefile from a shell prompt in the usual way; for example:
|
||||
#
|
||||
# make -f makefile.unx
|
||||
# make -f Makefile.unx
|
||||
#
|
||||
# This makefile assumes libpng and zlib have already been built or downloaded
|
||||
# and are both installed in /usr/local/{include,lib} (as indicated by the
|
||||
# PNGPATH and ZPATH macros below). Edit as appropriate.
|
||||
# PNG* and Z* macros below). Edit as appropriate--choose only ONE each of
|
||||
# the PNGINC, PNGLIB, ZINC and ZLIB lines.
|
||||
#
|
||||
# This makefile builds statically linked executables (against libpng and zlib,
|
||||
# that is), but that can be changed by uncommenting the appropriate PNGLIB and
|
||||
@@ -22,30 +23,38 @@
|
||||
|
||||
# macros --------------------------------------------------------------------
|
||||
|
||||
PNGPATH = /usr/local
|
||||
PNGINC = -I$(PNGPATH)/include
|
||||
#PNGLIB = -L$(PNGPATH)/lib -lpng
|
||||
PNGLIB = $(PNGPATH)/lib/libpng.a
|
||||
PNGINC = -I/usr/local/include
|
||||
#PNGLIB = -L/usr/local/lib -lpng # dynamically linked against libpng
|
||||
PNGLIB = /usr/local/lib/libpng.a # statically linked against libpng
|
||||
# or:
|
||||
#PNGINC = -I../..
|
||||
#PNGLIB = -L../.. -lpng
|
||||
#PNGLIB = ../../libpng.a
|
||||
|
||||
ZPATH = /usr/local
|
||||
ZINC = -I$(ZPATH)/include
|
||||
#ZLIB = -L$(ZPATH)/lib -lz
|
||||
ZLIB = $(ZPATH)/lib/libz.a
|
||||
ZINC = -I/usr/local/include
|
||||
#ZLIB = -L/usr/local/lib -lz # dynamically linked against zlib
|
||||
ZLIB = /usr/local/lib/libz.a # statically linked against zlib
|
||||
#ZINC = -I../zlib
|
||||
#ZLIB = -L../zlib -lz
|
||||
#ZLIB = ../../../zlib/libz.a
|
||||
|
||||
#XPATH = /usr/X11
|
||||
XPATH = /usr/X11R6
|
||||
XINC = -I$(XPATH)/include
|
||||
XLIB = -L$(XPATH)/lib -lX11
|
||||
#XINC = -I/usr/include/X11 # old-style, stock X distributions
|
||||
#XLIB = -L/usr/lib/X11 -lX11
|
||||
#XINC = -I/usr/openwin/include/X11 # Sun workstations (OpenWindows)
|
||||
#XLIB = -L/usr/openwin/lib -lX11
|
||||
XINC = -I/usr/X11R6/include # new X distributions (XFree86, etc.)
|
||||
XLIB = -L/usr/X11R6/lib -lX11
|
||||
|
||||
INCS = $(PNGINC) $(ZINC) $(XINC)
|
||||
RLIBS = $(PNGLIB) $(ZLIB) $(XLIB) -lm
|
||||
WLIBS = $(PNGLIB) $(ZLIB) -lm
|
||||
WLIBS = $(PNGLIB) $(ZLIB)
|
||||
|
||||
CC = gcc
|
||||
LD = gcc
|
||||
RM = rm -f
|
||||
CFLAGS = -O -Wall $(INCS)
|
||||
# [note that -Wall is a gcc-specific compilation flag ("all warnings on")]
|
||||
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
|
||||
# [-ansi, -pedantic and -W can also be used]
|
||||
LDFLAGS =
|
||||
O = .o
|
||||
E =
|
||||
@@ -10,14 +10,14 @@
|
||||
# Invoke this makefile from a DOS prompt window via:
|
||||
#
|
||||
# %devstudio%\vc\bin\vcvars32.bat
|
||||
# nmake -nologo -f makefile.w32
|
||||
# nmake -nologo -f Makefile.w32
|
||||
#
|
||||
# where %devstudio% is the installation directory for MSVC / DevStudio. If
|
||||
# you get "environment out of space" errors, create a desktop shortcut with
|
||||
# "c:\windows\command.com /e:4096" as the program command line and set the
|
||||
# working directory to this directory. Then double-click to open the new
|
||||
# DOS-prompt window with a bigger environment and retry the commands above.
|
||||
#
|
||||
#
|
||||
# This makefile assumes libpng and zlib have already been built or downloaded
|
||||
# and are in subdirectories at the same level as the current subdirectory
|
||||
# (as indicated by the PNGPATH and ZPATH macros below). Edit as appropriate.
|
||||
@@ -32,12 +32,12 @@
|
||||
|
||||
# macros --------------------------------------------------------------------
|
||||
|
||||
PNGPATH = ../libpng
|
||||
PNGPATH = ../..
|
||||
PNGINC = -I$(PNGPATH)
|
||||
#PNGLIB = $(PNGPATH)/pngdll.lib
|
||||
PNGLIB = $(PNGPATH)/libpng.lib
|
||||
|
||||
ZPATH = ../zlib
|
||||
ZPATH = ../../../zlib
|
||||
ZINC = -I$(ZPATH)
|
||||
#ZLIB = $(ZPATH)/zlibdll.lib
|
||||
ZLIB = $(ZPATH)/zlibstat.lib
|
||||
@@ -1,52 +1,183 @@
|
||||
PNG: The Definitive Guide: Source Code
|
||||
===========================
|
||||
PNG: The Definitive Guide
|
||||
===========================
|
||||
|
||||
Chapters 13, 14 and 15 of PNG: The Definitive Guide discuss three
|
||||
Source Code
|
||||
|
||||
Chapters 13, 14 and 15 of "PNG: The Definitive Guide" discuss three free,
|
||||
cross-platform demo programs that show how to use the libpng reference
|
||||
library: rpng, rpng2 and wpng. rpng and rpng2 are viewers; the first is a
|
||||
very simple example that that shows how a standard file-viewer might use
|
||||
libpng, while the second is designed to process streaming data and shows how
|
||||
a web browser might be written. wpng is a simple command-line program that
|
||||
reads binary PPM files (the ``raw'' RGB subset of NetPBM) and converts them
|
||||
to PNG.
|
||||
library: rpng, rpng2 and wpng. rpng and rpng2 are viewers; the first is
|
||||
a very simple example that that shows how a standard file-viewer might use
|
||||
libpng, while the second is designed to process streaming data and shows
|
||||
how a web browser might be written. wpng is a simple command-line program
|
||||
that reads binary PGM and PPM files (the ``raw'' grayscale and RGB subsets
|
||||
of PBMPLUS/NetPBM) and converts them to PNG.
|
||||
|
||||
The source code for all three demo programs currently compiles only under
|
||||
Unix and 32-bit Windows. It has been tested with gcc 2.7.2.3 under Linux and
|
||||
Solaris and with Microsoft Visual C++ 5.0 under Windows 95. Brief
|
||||
instructions for compiling the programs are included at the top of the
|
||||
makefiles; makefile.unx is the Unix version, and makefile.w32 is (you
|
||||
guessed it!) the version for 32-bit Windows. libpng and zlib are required.
|
||||
The source code for all three demo programs currently compiles under
|
||||
Unix, OpenVMS, and 32-bit Windows. (Special thanks to Martin Zinser,
|
||||
zinser@decus.de, for making the necessary changes for OpenVMS and for
|
||||
providing an appropriate build script.) Build instructions can be
|
||||
found below.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Files:
|
||||
|
||||
License
|
||||
README this file
|
||||
README.w32 additional Windows-specific information
|
||||
LICENSE terms of distribution and reuse (BSD-like)
|
||||
|
||||
The source code to the demo programs may be used and distributed freely
|
||||
(even if you didn't buy the book--but feel free to do so at any time),
|
||||
subject to the terms of the following BSD-like license:
|
||||
Makefile.unx Unix makefile
|
||||
Makefile.w32 Windows (MSVC) makefile
|
||||
makevms.com OpenVMS build script
|
||||
|
||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
||||
rpng-win.c Windows front end for the basic viewer
|
||||
rpng-x.c X Window System (Unix, OpenVMS) front end
|
||||
readpng.c generic back end for the basic viewer
|
||||
readpng.h header file for the basic viewer
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
be held liable for any damages arising in any way from the use of
|
||||
this software.
|
||||
rpng2-win.c Windows front end for the progressive viewer
|
||||
rpng2-x.c X front end for the progressive viewer
|
||||
readpng2.c generic back end for the progressive viewer
|
||||
readpng2.h header file for the progressive viewer
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
wpng.c generic (text) front end for the converter
|
||||
writepng.c generic back end for the converter
|
||||
writepng.h header file for the converter
|
||||
|
||||
1. Redistributions of source code must retain the above
|
||||
copyright notice, disclaimer, and this list of conditions.
|
||||
2. Redistributions in binary form must reproduce the above
|
||||
copyright notice, disclaimer, and this list of conditions in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. All advertising materials mentioning features or use of this
|
||||
software must display the following acknowledgment:
|
||||
toucan.png transparent PNG for testing (by Stefan Schneider)
|
||||
|
||||
This product includes software developed by Greg Roelofs
|
||||
and contributors for the book, "PNG: The Definitive
|
||||
Guide," published by O'Reilly and Associates.
|
||||
Note that the programs are designed to be functional, but their primary
|
||||
purpose is to demonstrate how to use libpng to add PNG support to other
|
||||
programs. As such, their user interfaces are crude and definitely not
|
||||
intended for everyday use.
|
||||
|
||||
----------------------------------------------------------
|
||||
http://www.cdrom.com/pub/png/book/sources.html
|
||||
Please see http://www.cdrom.com/pub/png/pngbook.html for further infor-
|
||||
mation and links to the latest version of the source code, and Chapters
|
||||
13-15 of the book for detailed discussion of the three programs.
|
||||
|
||||
Greg Roelofs
|
||||
19 March 2000
|
||||
|
||||
|
||||
BUILD INSTRUCTIONS
|
||||
|
||||
- Prerequisites:
|
||||
|
||||
- zlib ftp://ftp.cdrom.com/pub/infozip/zlib/zlib.html
|
||||
- libpng http://www.cdrom.com/pub/png/pngcode.html
|
||||
- pngbook http://www.cdrom.com/pub/png/book/sources.html
|
||||
|
||||
The pngbook demo programs are explicitly designed to demonstrate proper
|
||||
coding techniques for using the libpng reference library. As a result,
|
||||
you need to download and build both zlib (on which libpng depends) and
|
||||
libpng. A common build setup is to place the zlib, libpng and pngbook
|
||||
subdirectory trees ("folders") in the same parent directory. Then the
|
||||
libpng build can refer to files in ../zlib (or ..\zlib or [-.zlib]),
|
||||
and similarly for the pngbook build.
|
||||
|
||||
Note that all three packages are designed to be built from a command
|
||||
line by default; those who wish to use a graphical or other integrated
|
||||
development environments are on their own.
|
||||
|
||||
|
||||
- Unix:
|
||||
|
||||
Unpack the latest pngbook sources (which should correspond to this
|
||||
README file) into a directory and change into that directory.
|
||||
|
||||
Copy Makefile.unx to Makefile and edit the PNG* and Z* variables
|
||||
appropriately (possibly also the X* variables if necessary).
|
||||
|
||||
make
|
||||
|
||||
There is no "install" target, so copy the three executables somewhere
|
||||
in your path or run them from the current directory. All three will
|
||||
print a basic usage screen when run without any command-line arguments;
|
||||
see the book for more details.
|
||||
|
||||
|
||||
- Windows:
|
||||
|
||||
Unpack the latest pngbook sources (which should correspond to this
|
||||
README file) into a folder, open a "DOS shell" or "command prompt"
|
||||
or equivalent command-line window, and cd into the folder where you
|
||||
unpacked the source code.
|
||||
|
||||
For MSVC, set up the necessary environment variables by invoking
|
||||
|
||||
%devstudio%\vc\bin\vcvars32.bat
|
||||
|
||||
where where %devstudio% is the installation directory for MSVC /
|
||||
DevStudio. If you get "environment out of space" errors under 95/98,
|
||||
create a desktop shortcut with "c:\windows\command.com /e:4096" as
|
||||
the program command line and set the working directory to the pngbook
|
||||
directory. Then double-click to open the new DOS-prompt window with
|
||||
a bigger environment and retry the commands above.
|
||||
|
||||
Copy Makefile.w32 to Makefile and edit the PNGPATH and ZPATH variables
|
||||
appropriately (possibly also the "INC" and "LIB" variables if needed).
|
||||
Note that the names of the dynamic and static libpng and zlib libraries
|
||||
used in the makefile may change in later releases of the libraries.
|
||||
Also note that, as of libpng version 1.0.5, MSVC DLL builds do not work.
|
||||
This makefile therefore builds statically linked executables, but if
|
||||
the DLL problems ever get fixed, uncommenting the appropriate PNGLIB
|
||||
and ZLIB lines will build dynamically linked executables instead.
|
||||
|
||||
Do the build by typing
|
||||
|
||||
nmake
|
||||
|
||||
The result should be three executables: rpng-win.exe, rpng2-win.exe,
|
||||
and wpng.exe. Copy them somewhere in your PATH or run them from the
|
||||
current folder. Unlike the Unix versions, the two windowed programs
|
||||
(rpng and rpng2) do not display a usage screen when invoked without
|
||||
command-line arguments; see README.w32 for brief help or the book for
|
||||
details. Note that the programs use the Unix-style "-" character to
|
||||
specify options, instead of the more common DOS/Windows "/" character.
|
||||
|
||||
|
||||
- OpenVMS:
|
||||
|
||||
Unpack the pngbook sources into a subdirectory and change into that
|
||||
subdirectory.
|
||||
|
||||
Edit makevms.com appropriately, specifically the zpath and pngpath
|
||||
variables.
|
||||
|
||||
@makevms
|
||||
|
||||
To run the programs, they probably first need to be set up as "foreign
|
||||
symbols," with "disk" and "dir" set appropriately:
|
||||
|
||||
$ rpng == "$disk:[dir]rpng-x.exe"
|
||||
$ rpng2 == "$disk:[dir]rpng2-x.exe"
|
||||
$ wpng == "$disk:[dir]wpng.exe"
|
||||
|
||||
All three will print a basic usage screen when run without any command-
|
||||
line arguments; see the book for more details. Note that the options
|
||||
style is Unix-like, i.e., preceded by "-" rather than "/".
|
||||
|
||||
|
||||
RUNNING THE PROGRAMS: (VERY) BRIEF INTRO
|
||||
|
||||
rpng is a simple PNG viewer that can display transparent PNGs with a
|
||||
specified background color; for example,
|
||||
|
||||
rpng -bgcolor #ff0000 toucan.png
|
||||
|
||||
would display the image with a red background. rpng2 is a progressive
|
||||
viewer that simulates a web browser in some respects; it can display
|
||||
images against either a background color or a dynamically generated
|
||||
background image. For example:
|
||||
|
||||
rpng2 -bgpat 16 toucan.png
|
||||
|
||||
wpng is a purely command-line image converter from binary PBMPLUS/NetPBM
|
||||
format (.pgm or .ppm) to PNG; for example,
|
||||
|
||||
wpng -time < toucan.ppm > toucan.png
|
||||
|
||||
would convert the specified PPM file (using redirection) to PNG, auto-
|
||||
matically setting the PNG modification-time chunk.
|
||||
|
||||
All options can be abbreviated to the shortest unique value; for example,
|
||||
"-bgc" for -bgcolor (versus "-bgp" for -bgpat), or "-g" for -gamma.
|
||||
|
||||
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]"
|
||||
$ ccopt="/include=(''zlibsrc',[--])"
|
||||
$ zpath = "[-.zlib]"
|
||||
$ pngpath = "[-.libpng]"
|
||||
$!
|
||||
$! USE THESE INSTEAD if building from libpng's [.contrib.gregbook] directory:
|
||||
$! zpath = "[---.zlib]"
|
||||
$! pngpath = "[--]"
|
||||
$!
|
||||
$! Look for the compiler used.
|
||||
$!
|
||||
$ ccopt="/include=(''zpath',''pngpath')"
|
||||
$ if f$getsyi("HW_MODEL").ge.1024
|
||||
$ then
|
||||
$ ccopt = "/prefix=all"+ccopt
|
||||
@@ -29,13 +40,16 @@ $ comp = "__decc__=1"
|
||||
$ endif
|
||||
$ endif
|
||||
$ open/write lopt lib.opt
|
||||
$ write lopt "[--]libpng.olb/lib"
|
||||
$ write lopt "''zlibsrc'libz.olb/lib"
|
||||
$ write lopt "''pngpath'libpng.olb/lib"
|
||||
$ write lopt "''zpath'libz.olb/lib"
|
||||
$ close lopt
|
||||
$ open/write xopt x11.opt
|
||||
$ write xopt "sys$library:decw$xlibshr.exe/share"
|
||||
$ close xopt
|
||||
$ write sys$output "Compiling PNG contrib programs ..."
|
||||
$!
|
||||
$! Build 'em.
|
||||
$!
|
||||
$ write sys$output "Compiling PNG book programs ..."
|
||||
$ CALL MAKE readpng.OBJ "cc ''CCOPT' readpng" -
|
||||
readpng.c readpng.h
|
||||
$ CALL MAKE readpng2.OBJ "cc ''CCOPT' readpng2" -
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
||||
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -32,8 +32,13 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "png.h" /* libpng header; includes zlib.h */
|
||||
#include "readpng.h" /* typedefs, common macros, public prototypes */
|
||||
#include "png.h" /* libpng header; includes zlib.h */
|
||||
#include "readpng.h" /* typedefs, common macros, public prototypes */
|
||||
|
||||
/* future versions of libpng will provide this macro: */
|
||||
#ifndef png_jmpbuf
|
||||
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
|
||||
#endif
|
||||
|
||||
|
||||
static png_structp png_ptr = NULL;
|
||||
@@ -44,7 +49,7 @@ int bit_depth, color_type;
|
||||
uch *image_data = NULL;
|
||||
|
||||
|
||||
void readpng_version_info()
|
||||
void readpng_version_info(void)
|
||||
{
|
||||
fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n",
|
||||
PNG_LIBPNG_VER_STRING, png_libpng_ver);
|
||||
@@ -55,7 +60,7 @@ void readpng_version_info()
|
||||
|
||||
/* return value = 0 for success, 1 for bad sig, 2 for bad IHDR, 4 for no mem */
|
||||
|
||||
int readpng_init(FILE *infile, long *pWidth, long *pHeight)
|
||||
int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight)
|
||||
{
|
||||
uch sig[8];
|
||||
|
||||
@@ -89,7 +94,7 @@ int readpng_init(FILE *infile, long *pWidth, long *pHeight)
|
||||
/* setjmp() must be called in every function that calls a PNG-reading
|
||||
* libpng function */
|
||||
|
||||
if (setjmp(png_ptr->jmpbuf)) {
|
||||
if (setjmp(png_jmpbuf(png_ptr))) {
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
return 2;
|
||||
}
|
||||
@@ -130,7 +135,7 @@ int readpng_get_bgcolor(uch *red, uch *green, uch *blue)
|
||||
/* setjmp() must be called in every function that calls a PNG-reading
|
||||
* libpng function */
|
||||
|
||||
if (setjmp(png_ptr->jmpbuf)) {
|
||||
if (setjmp(png_jmpbuf(png_ptr))) {
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
return 2;
|
||||
}
|
||||
@@ -184,7 +189,7 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
|
||||
/* setjmp() must be called in every function that calls a PNG-reading
|
||||
* libpng function */
|
||||
|
||||
if (setjmp(png_ptr->jmpbuf)) {
|
||||
if (setjmp(png_jmpbuf(png_ptr))) {
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, 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,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -54,7 +54,7 @@ typedef unsigned long ulg;
|
||||
|
||||
void readpng_version_info(void);
|
||||
|
||||
int readpng_init(FILE *infile, long *pWidth, long *pHeight);
|
||||
int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight);
|
||||
|
||||
int readpng_get_bgcolor(uch *bg_red, uch *bg_green, uch *bg_blue);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
||||
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -30,10 +30,10 @@
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include <stdlib.h> /* for exit() prototype */
|
||||
#include <stdlib.h> /* for exit() prototype */
|
||||
|
||||
#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
|
||||
#include "readpng2.h" /* typedefs, common macros, public prototypes */
|
||||
#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
|
||||
#include "readpng2.h" /* typedefs, common macros, public prototypes */
|
||||
|
||||
|
||||
/* local prototypes */
|
||||
@@ -47,7 +47,7 @@ static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg);
|
||||
|
||||
|
||||
|
||||
void readpng2_version_info()
|
||||
void readpng2_version_info(void)
|
||||
{
|
||||
fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n",
|
||||
PNG_LIBPNG_VER_STRING, png_libpng_ver);
|
||||
@@ -70,7 +70,7 @@ int readpng2_check_sig(uch *sig, int num)
|
||||
|
||||
int readpng2_init(mainprog_info *mainprog_ptr)
|
||||
{
|
||||
png_structp png_ptr; /* note: temporary variables! */
|
||||
png_structp png_ptr; /* note: temporary variables! */
|
||||
png_infop info_ptr;
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
mainprog_ptr = png_get_progressive_ptr(png_ptr);
|
||||
|
||||
if (mainprog_ptr == NULL) { /* we be hosed */
|
||||
if (mainprog_ptr == NULL) { /* we be hosed */
|
||||
fprintf(stderr,
|
||||
"readpng2 error: main struct not recoverable in info_callback.\n");
|
||||
fflush(stderr);
|
||||
@@ -283,7 +283,7 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
png_read_update_info(png_ptr, info_ptr);
|
||||
|
||||
mainprog_ptr->rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
mainprog_ptr->rowbytes = (int)png_get_rowbytes(png_ptr, info_ptr);
|
||||
mainprog_ptr->channels = png_get_channels(png_ptr, info_ptr);
|
||||
|
||||
|
||||
@@ -323,6 +323,11 @@ static void readpng2_row_callback(png_structp png_ptr, png_bytep new_row,
|
||||
mainprog_ptr = png_get_progressive_ptr(png_ptr);
|
||||
|
||||
|
||||
/* save the pass number for optional use by the front end */
|
||||
|
||||
mainprog_ptr->pass = pass;
|
||||
|
||||
|
||||
/* have libpng either combine the new row data with the existing row data
|
||||
* from previous passes (if interlaced) or else just copy the new row
|
||||
* into the main program's image buffer */
|
||||
@@ -408,7 +413,7 @@ static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg)
|
||||
fflush(stderr);
|
||||
|
||||
mainprog_ptr = png_get_error_ptr(png_ptr);
|
||||
if (mainprog_ptr == NULL) { /* we are completely hosed now */
|
||||
if (mainprog_ptr == NULL) { /* we are completely hosed now */
|
||||
fprintf(stderr,
|
||||
"readpng2 severe error: jmpbuf not recoverable; terminating.\n");
|
||||
fflush(stderr);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
||||
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -61,7 +61,8 @@ typedef struct _mainprog_info {
|
||||
uch *image_data;
|
||||
uch **row_pointers;
|
||||
jmp_buf jmpbuf;
|
||||
int passes; /* not used */
|
||||
int passes; /* not used */
|
||||
int pass;
|
||||
int rowbytes;
|
||||
int channels;
|
||||
int need_bgcolor;
|
||||
|
||||
@@ -16,7 +16,16 @@
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
||||
Changelog:
|
||||
- 1.00: initial public release
|
||||
- 1.01: modified to allow abbreviated options; fixed long/ulong mis-
|
||||
match; switched to png_jmpbuf() macro
|
||||
- 1.02: added extra set of parentheses to png_jmpbuf() macro; fixed
|
||||
command-line parsing bug
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -43,7 +52,7 @@
|
||||
|
||||
#define PROGNAME "rpng-win"
|
||||
#define LONGNAME "Simple PNG Viewer for Windows"
|
||||
#define VERSION "1.0 of 20 February 1999"
|
||||
#define VERSION "1.02 of 19 March 2000"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -53,7 +62,7 @@
|
||||
|
||||
/* #define DEBUG : this enables the Trace() macros */
|
||||
|
||||
#include "readpng.h" /* typedefs, common macros, readpng prototypes */
|
||||
#include "readpng.h" /* typedefs, common macros, readpng prototypes */
|
||||
|
||||
|
||||
/* could just include png.h, but this macro is the only thing we need
|
||||
@@ -61,10 +70,10 @@
|
||||
* only happen with alpha (which could easily be avoided with
|
||||
* "ush acopy = (alpha);") */
|
||||
|
||||
#define alpha_composite(composite, fg, alpha, bg) { \
|
||||
ush temp = ((ush)(fg)*(ush)(alpha) + \
|
||||
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
|
||||
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
|
||||
#define alpha_composite(composite, fg, alpha, bg) { \
|
||||
ush temp = ((ush)(fg)*(ush)(alpha) + \
|
||||
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
|
||||
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +87,7 @@ LRESULT CALLBACK rpng_win_wndproc(HWND, UINT, WPARAM, LPARAM);
|
||||
static char titlebar[1024], *window_name = titlebar;
|
||||
static char *progname = PROGNAME;
|
||||
static char *appname = LONGNAME;
|
||||
static char *icon_name = PROGNAME; /* GRR: not (yet) used */
|
||||
static char *icon_name = PROGNAME; /* GRR: not (yet) used */
|
||||
static char *filename;
|
||||
static FILE *infile;
|
||||
|
||||
@@ -104,15 +113,15 @@ static HWND global_hwnd;
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
{
|
||||
char *args[1024]; /* arbitrary limit, but should suffice */
|
||||
char *args[1024]; /* arbitrary limit, but should suffice */
|
||||
char *p, *q, **argv = args;
|
||||
int argc = 0;
|
||||
int rc, alen, flen;
|
||||
int error = 0;
|
||||
int have_bg = FALSE;
|
||||
double LUT_exponent; /* just the lookup table */
|
||||
double CRT_exponent = 2.2; /* just the monitor */
|
||||
double default_display_exponent; /* whole display system */
|
||||
double LUT_exponent; /* just the lookup table */
|
||||
double CRT_exponent = 2.2; /* just the monitor */
|
||||
double default_display_exponent; /* whole display system */
|
||||
MSG msg;
|
||||
|
||||
|
||||
@@ -199,20 +208,24 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
/* Now parse the command line for options and the PNG filename. */
|
||||
|
||||
while (*++argv && !error) {
|
||||
if (!strcmp(*argv, "-gamma")) {
|
||||
if (!strncmp(*argv, "-gamma", 2)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
display_exponent = atof(*argv);
|
||||
if (display_exponent <= 0.0)
|
||||
++error;
|
||||
} else if (!strcmp(*argv, "-bgcolor")) {
|
||||
else {
|
||||
display_exponent = atof(*argv);
|
||||
if (display_exponent <= 0.0)
|
||||
++error;
|
||||
}
|
||||
} else if (!strncmp(*argv, "-bgcolor", 2)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
bgstr = *argv;
|
||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||
++error;
|
||||
else
|
||||
have_bg = TRUE;
|
||||
else {
|
||||
bgstr = *argv;
|
||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||
++error;
|
||||
else
|
||||
have_bg = TRUE;
|
||||
}
|
||||
} else {
|
||||
if (**argv != '-') {
|
||||
filename = *argv;
|
||||
@@ -255,6 +268,9 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
fclose(infile);
|
||||
}
|
||||
|
||||
|
||||
/* usage screen */
|
||||
|
||||
if (error) {
|
||||
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
||||
readpng_version_info();
|
||||
@@ -265,7 +281,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
"\t\t to the product of the lookup-table exponent (varies)\n"
|
||||
"\t\t and the CRT exponent (usually 2.2); must be positive\n"
|
||||
" bg \tdesired background color in 7-character hex RGB format\n"
|
||||
"\t\t (e.g., ``#ff7f00'' for orange: same as HTML colors);\n"
|
||||
"\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
|
||||
"\t\t used with transparent images\n"
|
||||
"\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n"
|
||||
"\n", PROGNAME, default_display_exponent);
|
||||
@@ -336,6 +352,10 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
|
||||
/* wait for the user to tell us when to quit */
|
||||
|
||||
printf(
|
||||
"Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n");
|
||||
fflush(stdout);
|
||||
|
||||
while (GetMessage(&msg, NULL, 0, 0)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
@@ -371,7 +391,7 @@ static int rpng_win_create_window(HINSTANCE hInst, int showmode)
|
||||
if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) +
|
||||
wimage_rowbytes*image_height)))
|
||||
{
|
||||
return 4; /* fail */
|
||||
return 4; /* fail */
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
@@ -477,7 +497,7 @@ static int rpng_win_display_image()
|
||||
g = *src++;
|
||||
b = *src++;
|
||||
*dest++ = b;
|
||||
*dest++ = g; /* note reverse order */
|
||||
*dest++ = g; /* note reverse order */
|
||||
*dest++ = r;
|
||||
}
|
||||
} else /* if (image_channels == 4) */ {
|
||||
@@ -582,15 +602,15 @@ LRESULT CALLBACK rpng_win_wndproc(HWND hwnd, UINT iMsg, WPARAM wP, LPARAM lP)
|
||||
|
||||
/* wait for the user to tell us when to quit */
|
||||
case WM_CHAR:
|
||||
switch (wP) { /* only need one, so ignore repeat count */
|
||||
switch (wP) { /* only need one, so ignore repeat count */
|
||||
case 'q':
|
||||
case 'Q':
|
||||
case 0x1B: /* Esc key */
|
||||
case 0x1B: /* Esc key */
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_LBUTTONDOWN: /* another way of quitting */
|
||||
case WM_LBUTTONDOWN: /* another way of quitting */
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
This program decodes and displays PNG images, with gamma correction and
|
||||
optionally with a user-specified background color (in case the image has
|
||||
transparency). It is very nearly the most basic PNG viewer possible.
|
||||
This version is for the X Window System (tested under Unix, but may work
|
||||
under VMS or OS/2 with a little tweaking).
|
||||
This version is for the X Window System (tested by author under Unix and
|
||||
by Martin Zinser under OpenVMS; may work under OS/2 with some tweaking).
|
||||
|
||||
to do:
|
||||
- 8-bit support
|
||||
@@ -14,7 +14,17 @@
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
||||
Changelog:
|
||||
- 1.01: initial public release
|
||||
- 1.02: modified to allow abbreviated options; fixed long/ulong mis-
|
||||
match; switched to png_jmpbuf() macro
|
||||
- 1.10: added support for non-default visuals; fixed X pixel-conversion
|
||||
- 1.11: added extra set of parentheses to png_jmpbuf() macro; fixed
|
||||
command-line parsing bug
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -41,7 +51,7 @@
|
||||
|
||||
#define PROGNAME "rpng-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 <stdlib.h>
|
||||
@@ -54,7 +64,7 @@
|
||||
|
||||
/* #define DEBUG : this enables the Trace() macros */
|
||||
|
||||
#include "readpng.h" /* typedefs, common macros, readpng prototypes */
|
||||
#include "readpng.h" /* typedefs, common macros, readpng prototypes */
|
||||
|
||||
|
||||
/* could just include png.h, but this macro is the only thing we need
|
||||
@@ -95,15 +105,16 @@ static uch *image_data;
|
||||
static char *displayname;
|
||||
static XImage *ximage;
|
||||
static Display *display;
|
||||
static int bitmap_order;
|
||||
static int depth;
|
||||
static Visual *visual;
|
||||
static int RPixelShift, GPixelShift, BPixelShift;
|
||||
static ulg RedMask, GreenMask, BlueMask;
|
||||
static XVisualInfo *visual_list;
|
||||
static int RShift, GShift, BShift;
|
||||
static ulg RMask, GMask, BMask;
|
||||
static Window window;
|
||||
static GC gc;
|
||||
static Colormap colormap;
|
||||
|
||||
static int have_nondefault_visual = FALSE;
|
||||
static int have_colormap = FALSE;
|
||||
static int have_window = FALSE;
|
||||
/*
|
||||
@@ -123,9 +134,9 @@ int main(int argc, char **argv)
|
||||
int rc, alen, flen;
|
||||
int error = 0;
|
||||
int have_bg = FALSE;
|
||||
double LUT_exponent; /* just the lookup table */
|
||||
double CRT_exponent = 2.2; /* just the monitor */
|
||||
double default_display_exponent; /* whole display system */
|
||||
double LUT_exponent; /* just the lookup table */
|
||||
double CRT_exponent = 2.2; /* just the monitor */
|
||||
double default_display_exponent; /* whole display system */
|
||||
XEvent e;
|
||||
KeySym k;
|
||||
|
||||
@@ -188,24 +199,29 @@ int main(int argc, char **argv)
|
||||
/* Now parse the command line for options and the PNG filename. */
|
||||
|
||||
while (*++argv && !error) {
|
||||
if (!strcmp(*argv, "-display")) {
|
||||
if (!strncmp(*argv, "-display", 2)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
displayname = *argv;
|
||||
} else if (!strcmp(*argv, "-gamma")) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
display_exponent = atof(*argv);
|
||||
if (display_exponent <= 0.0)
|
||||
++error;
|
||||
} else if (!strcmp(*argv, "-bgcolor")) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
bgstr = *argv;
|
||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||
++error;
|
||||
else
|
||||
have_bg = TRUE;
|
||||
displayname = *argv;
|
||||
} else if (!strncmp(*argv, "-gamma", 2)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
else {
|
||||
display_exponent = atof(*argv);
|
||||
if (display_exponent <= 0.0)
|
||||
++error;
|
||||
}
|
||||
} else if (!strncmp(*argv, "-bgcolor", 2)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
else {
|
||||
bgstr = *argv;
|
||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||
++error;
|
||||
else
|
||||
have_bg = TRUE;
|
||||
}
|
||||
} else {
|
||||
if (**argv != '-') {
|
||||
filename = *argv;
|
||||
@@ -222,8 +238,7 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename);
|
||||
++error;
|
||||
} else {
|
||||
if ((rc = readpng_init(infile, (long *)(&image_width),
|
||||
(long *)(&image_height))) != 0) {
|
||||
if ((rc = readpng_init(infile, &image_width, &image_height)) != 0) {
|
||||
switch (rc) {
|
||||
case 1:
|
||||
fprintf(stderr, PROGNAME
|
||||
@@ -257,21 +272,25 @@ int main(int argc, char **argv)
|
||||
fclose(infile);
|
||||
}
|
||||
|
||||
|
||||
/* usage screen */
|
||||
|
||||
if (error) {
|
||||
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
||||
readpng_version_info();
|
||||
fprintf(stderr, "\n"
|
||||
"Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg] file.png\n"
|
||||
" xdpy\tname of the target X display (e.g., ``hostname:0'')\n"
|
||||
" exp \ttransfer-function exponent (``gamma'') of the display\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 and the CRT exponent (usually 2.2); must be positive\n"
|
||||
" bg \tdesired background color in 7-character hex RGB format\n"
|
||||
"\t\t (e.g., ``#ff7f00'' for orange: same as HTML colors);\n"
|
||||
"\t\t used with transparent images\n"
|
||||
"\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n"
|
||||
"\n", PROGNAME, default_display_exponent);
|
||||
"Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg] file.png\n"
|
||||
" xdpy\tname of the target X display (e.g., ``hostname:0'')\n"
|
||||
" exp \ttransfer-function exponent (``gamma'') of the display\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 and the CRT exponent (usually 2.2); must be positive\n"
|
||||
" bg \tdesired background color in 7-character hex RGB format\n"
|
||||
"\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
|
||||
"\t\t used with transparent images\n"
|
||||
"\nPress Q, Esc or mouse button 1 (within image window, after image\n"
|
||||
"is displayed) to quit.\n"
|
||||
"\n", PROGNAME, default_display_exponent);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -344,6 +363,10 @@ int main(int argc, char **argv)
|
||||
|
||||
/* 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
|
||||
XNextEvent(display, &e);
|
||||
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;
|
||||
int need_colormap = FALSE;
|
||||
int screen, pad;
|
||||
ulg bg_pixel = 0L;
|
||||
ulg attrmask;
|
||||
Window root;
|
||||
XEvent e;
|
||||
XGCValues gcvalues;
|
||||
@@ -378,11 +403,15 @@ static int rpng_x_create_window()
|
||||
XWMHints *wm_hints;
|
||||
|
||||
|
||||
bitmap_order = BitmapBitOrder(display);
|
||||
screen = DefaultScreen(display);
|
||||
depth = DisplayPlanes(display, screen);
|
||||
root = RootWindow(display, screen);
|
||||
|
||||
#ifdef DEBUG
|
||||
XSynchronize(display, True);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* GRR: add 8-bit support */
|
||||
if (/* depth != 8 && */ depth != 16 && depth != 24 && depth != 32) {
|
||||
fprintf(stderr,
|
||||
@@ -394,27 +423,73 @@ static int rpng_x_create_window()
|
||||
XMatchVisualInfo(display, screen, depth,
|
||||
(depth == 8)? PseudoColor : TrueColor, &visual_info);
|
||||
visual = visual_info.visual;
|
||||
#else
|
||||
if (depth != 16 && depth != 24 && depth != 32) {
|
||||
int visuals_matched = 0;
|
||||
|
||||
RedMask = visual->red_mask;
|
||||
GreenMask = visual->green_mask;
|
||||
BlueMask = visual->blue_mask;
|
||||
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;
|
||||
}
|
||||
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 */
|
||||
if (depth == 8) {
|
||||
if (depth == 8 || need_colormap) {
|
||||
colormap = XCreateColormap(display, root, visual, AllocNone);
|
||||
if (!colormap) {
|
||||
fprintf(stderr, "XCreateColormap() failed\n");
|
||||
return 2;
|
||||
}
|
||||
have_colormap = TRUE;
|
||||
} else if (depth == 16) {
|
||||
RPixelShift = 15 - rpng_x_msb(RedMask); /* these are right-shifts */
|
||||
GPixelShift = 15 - rpng_x_msb(GreenMask);
|
||||
BPixelShift = 15 - rpng_x_msb(BlueMask);
|
||||
} else /* if (depth > 16) */ {
|
||||
RPixelShift = rpng_x_msb(RedMask) - 7; /* these are left-shifts */
|
||||
GPixelShift = rpng_x_msb(GreenMask) - 7;
|
||||
BPixelShift = rpng_x_msb(BlueMask) - 7;
|
||||
}
|
||||
if (depth == 15 || depth == 16) {
|
||||
RShift = 15 - rpng_x_msb(RMask); /* these are right-shifts */
|
||||
GShift = 15 - rpng_x_msb(GMask);
|
||||
BShift = 15 - rpng_x_msb(BMask);
|
||||
} else if (depth > 16) {
|
||||
#define NO_24BIT_MASKS
|
||||
#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.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,
|
||||
0, depth, InputOutput, visual, CWBackingStore | CWEventMask, &attr);
|
||||
window = XCreateWindow(display, root, 0, 0, image_width, image_height, 0,
|
||||
depth, InputOutput, visual, attrmask, &attr);
|
||||
|
||||
if (window == None) {
|
||||
fprintf(stderr, "XCreateWindow() failed\n");
|
||||
@@ -446,8 +528,8 @@ static int rpng_x_create_window()
|
||||
if ((size_hints = XAllocSizeHints()) != NULL) {
|
||||
/* window will not be resizable */
|
||||
size_hints->flags = PMinSize | PMaxSize;
|
||||
size_hints->min_width = size_hints->max_width = image_width;
|
||||
size_hints->min_height = size_hints->max_height = image_height;
|
||||
size_hints->min_width = size_hints->max_width = (int)image_width;
|
||||
size_hints->min_height = size_hints->max_height = (int)image_height;
|
||||
}
|
||||
|
||||
if ((wm_hints = XAllocWMHints()) != NULL) {
|
||||
@@ -469,13 +551,13 @@ static int rpng_x_create_window()
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
if (depth == 24 || depth == 32) {
|
||||
bg_pixel = ((ulg)bg_red << RPixelShift) |
|
||||
((ulg)bg_green << GPixelShift) |
|
||||
((ulg)bg_blue << BPixelShift);
|
||||
bg_pixel = ((ulg)bg_red << RShift) |
|
||||
((ulg)bg_green << GShift) |
|
||||
((ulg)bg_blue << BShift);
|
||||
} else if (depth == 16) {
|
||||
bg_pixel = ((((ulg)bg_red << 8) >> RPixelShift) & RedMask) |
|
||||
((((ulg)bg_green << 8) >> GPixelShift) & GreenMask) |
|
||||
((((ulg)bg_blue << 8) >> BPixelShift) & BlueMask);
|
||||
bg_pixel = ((((ulg)bg_red << 8) >> RShift) & RMask) |
|
||||
((((ulg)bg_green << 8) >> GShift) & GMask) |
|
||||
((((ulg)bg_blue << 8) >> BShift) & BMask);
|
||||
} else /* depth == 8 */ {
|
||||
|
||||
/* GRR: add 8-bit support */
|
||||
@@ -524,7 +606,7 @@ static int rpng_x_create_window()
|
||||
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
|
||||
* 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
|
||||
@@ -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;
|
||||
char *dest;
|
||||
uch r, g, b, a;
|
||||
int ximage_rowbytes = ximage->bytes_per_line;
|
||||
ulg i, row, lastrow = 0;
|
||||
ulg pixel;
|
||||
int ximage_rowbytes = ximage->bytes_per_line;
|
||||
/* int bpp = ximage->bits_per_pixel; */
|
||||
|
||||
|
||||
Trace((stderr, "beginning display loop (image_channels == %d)\n",
|
||||
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))
|
||||
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) {
|
||||
ulg red, green, blue;
|
||||
@@ -567,14 +653,27 @@ static int rpng_x_display_image()
|
||||
red = *src++;
|
||||
green = *src++;
|
||||
blue = *src++;
|
||||
pixel = (red << RPixelShift) |
|
||||
(green << GPixelShift) |
|
||||
(blue << BPixelShift);
|
||||
#ifdef NO_24BIT_MASKS
|
||||
pixel = (red << RShift) |
|
||||
(green << GShift) |
|
||||
(blue << BShift);
|
||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||
*dest++ = ((uch *)&pixel)[3];
|
||||
*dest++ = ((uch *)&pixel)[2];
|
||||
*dest++ = ((uch *)&pixel)[1];
|
||||
*dest++ = ((uch *)&pixel)[0];
|
||||
/* GRR BUG: this assumes bpp == 32, but may be 24: */
|
||||
*dest++ = (char)((pixel >> 24) & 0xff);
|
||||
*dest++ = (char)((pixel >> 16) & 0xff);
|
||||
*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) */ {
|
||||
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(blue, b, a, bg_blue);
|
||||
}
|
||||
pixel = (red << RPixelShift) |
|
||||
(green << GPixelShift) |
|
||||
(blue << BPixelShift);
|
||||
pixel = (red << RShift) |
|
||||
(green << GShift) |
|
||||
(blue << BShift);
|
||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||
*dest++ = ((uch *)&pixel)[3];
|
||||
*dest++ = ((uch *)&pixel)[2];
|
||||
*dest++ = ((uch *)&pixel)[1];
|
||||
*dest++ = ((uch *)&pixel)[0];
|
||||
*dest++ = (char)((pixel >> 24) & 0xff);
|
||||
*dest++ = (char)((pixel >> 16) & 0xff);
|
||||
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||
*dest++ = (char)( pixel & 0xff);
|
||||
}
|
||||
}
|
||||
/* display after every 16 lines */
|
||||
if (((row+1) & 0xf) == 0) {
|
||||
XPutImage(display, window, gc, ximage, 0, lastrow, 0, lastrow,
|
||||
image_width, 16);
|
||||
XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0,
|
||||
(int)lastrow, image_width, 16);
|
||||
XFlush(display);
|
||||
lastrow = row + 1;
|
||||
}
|
||||
@@ -631,12 +730,12 @@ static int rpng_x_display_image()
|
||||
++src;
|
||||
blue = ((ush)(*src) << 8);
|
||||
++src;
|
||||
pixel = ((red >> RPixelShift) & RedMask) |
|
||||
((green >> GPixelShift) & GreenMask) |
|
||||
((blue >> BPixelShift) & BlueMask);
|
||||
pixel = ((red >> RShift) & RMask) |
|
||||
((green >> GShift) & GMask) |
|
||||
((blue >> BShift) & BMask);
|
||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||
*dest++ = ((uch *)&pixel)[1];
|
||||
*dest++ = ((uch *)&pixel)[0];
|
||||
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||
*dest++ = (char)( pixel & 0xff);
|
||||
}
|
||||
} else /* if (image_channels == 4) */ {
|
||||
for (i = image_width; i > 0; --i) {
|
||||
@@ -663,18 +762,18 @@ static int rpng_x_display_image()
|
||||
green = ((ush)g << 8);
|
||||
blue = ((ush)b << 8);
|
||||
}
|
||||
pixel = ((red >> RPixelShift) & RedMask) |
|
||||
((green >> GPixelShift) & GreenMask) |
|
||||
((blue >> BPixelShift) & BlueMask);
|
||||
pixel = ((red >> RShift) & RMask) |
|
||||
((green >> GShift) & GMask) |
|
||||
((blue >> BShift) & BMask);
|
||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||
*dest++ = ((uch *)&pixel)[1];
|
||||
*dest++ = ((uch *)&pixel)[0];
|
||||
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||
*dest++ = (char)( pixel & 0xff);
|
||||
}
|
||||
}
|
||||
/* display after every 16 lines */
|
||||
if (((row+1) & 0xf) == 0) {
|
||||
XPutImage(display, window, gc, ximage, 0, lastrow, 0, lastrow,
|
||||
image_width, 16);
|
||||
XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0,
|
||||
(int)lastrow, image_width, 16);
|
||||
XFlush(display);
|
||||
lastrow = row + 1;
|
||||
}
|
||||
@@ -688,8 +787,8 @@ static int rpng_x_display_image()
|
||||
|
||||
Trace((stderr, "calling final XPutImage()\n"))
|
||||
if (lastrow < image_height) {
|
||||
XPutImage(display, window, gc, ximage, 0, lastrow, 0, lastrow,
|
||||
image_width, image_height-lastrow);
|
||||
XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0,
|
||||
(int)lastrow, image_width, image_height-lastrow);
|
||||
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) {
|
||||
free(image_data);
|
||||
@@ -722,6 +821,9 @@ static void rpng_x_cleanup()
|
||||
|
||||
if (have_colormap)
|
||||
XFreeColormap(display, colormap);
|
||||
|
||||
if (have_nondefault_visual)
|
||||
XFree(visual_list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,10 +22,13 @@
|
||||
Changelog:
|
||||
- 1.01: initial public release
|
||||
- 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,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -52,14 +55,14 @@
|
||||
|
||||
#define PROGNAME "rpng2-win"
|
||||
#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 <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <setjmp.h> /* for jmpbuf declaration in readpng2.h */
|
||||
#include <setjmp.h> /* for jmpbuf declaration in readpng2.h */
|
||||
#include <time.h>
|
||||
#include <math.h> /* only for PvdM background code */
|
||||
#include <math.h> /* only for PvdM background code */
|
||||
#include <windows.h>
|
||||
|
||||
/* all for PvdM background code: */
|
||||
@@ -80,9 +83,9 @@
|
||||
#define rgb2_max bg_bsat
|
||||
#define rgb2_min bg_brot
|
||||
|
||||
/* #define DEBUG */ /* this enables the Trace() macros */
|
||||
/* #define DEBUG */ /* this enables the Trace() macros */
|
||||
|
||||
#include "readpng2.h" /* typedefs, common macros, readpng2 prototypes */
|
||||
#include "readpng2.h" /* typedefs, common macros, readpng2 prototypes */
|
||||
|
||||
|
||||
/* could just include png.h, but this macro is the only thing we need
|
||||
@@ -90,18 +93,18 @@
|
||||
* only happen with alpha (which could easily be avoided with
|
||||
* "ush acopy = (alpha);") */
|
||||
|
||||
#define alpha_composite(composite, fg, alpha, bg) { \
|
||||
ush temp = ((ush)(fg)*(ush)(alpha) + \
|
||||
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
|
||||
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
|
||||
#define alpha_composite(composite, fg, alpha, bg) { \
|
||||
ush temp = ((ush)(fg)*(ush)(alpha) + \
|
||||
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
|
||||
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
|
||||
}
|
||||
|
||||
|
||||
#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this
|
||||
* block size corresponds roughly to a download
|
||||
* speed 10% faster than theoretical 33.6K maximum
|
||||
* (assuming 8 data bits, 1 stop bit and no other
|
||||
* overhead) */
|
||||
#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this
|
||||
* block size corresponds roughly to a download
|
||||
* speed 10% faster than theoretical 33.6K maximum
|
||||
* (assuming 8 data bits, 1 stop bit and no other
|
||||
* overhead) */
|
||||
|
||||
/* local prototypes */
|
||||
static void rpng2_win_init(void);
|
||||
@@ -116,7 +119,7 @@ LRESULT CALLBACK rpng2_win_wndproc(HWND, UINT, WPARAM, LPARAM);
|
||||
static char titlebar[1024], *window_name = titlebar;
|
||||
static char *progname = PROGNAME;
|
||||
static char *appname = LONGNAME;
|
||||
static char *icon_name = PROGNAME; /* GRR: not (yet) used */
|
||||
static char *icon_name = PROGNAME; /* GRR: not (yet) used */
|
||||
static char *filename;
|
||||
static FILE *infile;
|
||||
|
||||
@@ -125,7 +128,7 @@ static mainprog_info rpng2_info;
|
||||
static uch inbuf[INBUFSIZE];
|
||||
static int incount;
|
||||
|
||||
static int pat = 6; /* must be less than num_bgpat */
|
||||
static int pat = 6; /* must be less than num_bgpat */
|
||||
static int bg_image = 0;
|
||||
static int bgscale = 16;
|
||||
static ulg bg_rowbytes;
|
||||
@@ -134,22 +137,22 @@ static uch *bg_data;
|
||||
static struct rgb_color {
|
||||
uch r, g, b;
|
||||
} rgb[] = {
|
||||
{ 0, 0, 0}, /* 0: black */
|
||||
{255, 255, 255}, /* 1: white */
|
||||
{173, 132, 57}, /* 2: tan */
|
||||
{ 64, 132, 0}, /* 3: medium green */
|
||||
{189, 117, 1}, /* 4: gold */
|
||||
{253, 249, 1}, /* 5: yellow */
|
||||
{ 0, 0, 255}, /* 6: blue */
|
||||
{ 0, 0, 120}, /* 7: medium blue */
|
||||
{255, 0, 255}, /* 8: magenta */
|
||||
{ 64, 0, 64}, /* 9: dark magenta */
|
||||
{255, 0, 0}, /* 10: red */
|
||||
{ 64, 0, 0}, /* 11: dark red */
|
||||
{255, 127, 0}, /* 12: orange */
|
||||
{192, 96, 0}, /* 13: darker orange */
|
||||
{ 24, 60, 0}, /* 14: dark green-yellow */
|
||||
{ 85, 125, 200} /* 15: ice blue */
|
||||
{ 0, 0, 0}, /* 0: black */
|
||||
{255, 255, 255}, /* 1: white */
|
||||
{173, 132, 57}, /* 2: tan */
|
||||
{ 64, 132, 0}, /* 3: medium green */
|
||||
{189, 117, 1}, /* 4: gold */
|
||||
{253, 249, 1}, /* 5: yellow */
|
||||
{ 0, 0, 255}, /* 6: blue */
|
||||
{ 0, 0, 120}, /* 7: medium blue */
|
||||
{255, 0, 255}, /* 8: magenta */
|
||||
{ 64, 0, 64}, /* 9: dark magenta */
|
||||
{255, 0, 0}, /* 10: red */
|
||||
{ 64, 0, 0}, /* 11: dark red */
|
||||
{255, 127, 0}, /* 12: orange */
|
||||
{192, 96, 0}, /* 13: darker orange */
|
||||
{ 24, 60, 0}, /* 14: dark green-yellow */
|
||||
{ 85, 125, 200} /* 15: ice blue */
|
||||
};
|
||||
/* not used for now, but should be for error-checking:
|
||||
static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color);
|
||||
@@ -174,25 +177,25 @@ static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color);
|
||||
*/
|
||||
static struct background_pattern {
|
||||
ush type;
|
||||
int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */
|
||||
int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/
|
||||
int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */
|
||||
int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/
|
||||
} bg[] = {
|
||||
{0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */
|
||||
{0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */
|
||||
{0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */
|
||||
{0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */
|
||||
{0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */
|
||||
{0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */
|
||||
{0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */
|
||||
{1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */
|
||||
{1, 12,0, 11,0}, /* diamonds: orange vs. dark red */
|
||||
{1, 10,0, 7,0}, /* diamonds: red vs. medium blue */
|
||||
{1, 4,0, 5,0}, /* diamonds: gold vs. yellow */
|
||||
{1, 3,0, 0,0}, /* diamonds: medium green vs. black */
|
||||
{2, 16, 100, 20, 0}, /* radial: ~hard radial color-beams */
|
||||
{2, 18, 100, 10, 2}, /* radial: soft, curved radial color-beams */
|
||||
{2, 16, 256, 100, 250}, /* radial: very tight spiral */
|
||||
{2, 10000, 256, 11, 0} /* radial: dipole-moire' (almost fractal) */
|
||||
{0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */
|
||||
{0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */
|
||||
{0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */
|
||||
{0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */
|
||||
{0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */
|
||||
{0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */
|
||||
{0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */
|
||||
{1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */
|
||||
{1, 12,0, 11,0}, /* diamonds: orange vs. dark red */
|
||||
{1, 10,0, 7,0}, /* diamonds: red vs. medium blue */
|
||||
{1, 4,0, 5,0}, /* diamonds: gold vs. yellow */
|
||||
{1, 3,0, 0,0}, /* diamonds: medium green vs. black */
|
||||
{2, 16, 100, 20, 0}, /* radial: ~hard radial color-beams */
|
||||
{2, 18, 100, 10, 2}, /* radial: soft, curved radial color-beams */
|
||||
{2, 16, 256, 100, 250}, /* radial: very tight spiral */
|
||||
{2, 10000, 256, 11, 0} /* radial: dipole-moire' (almost fractal) */
|
||||
};
|
||||
static int num_bgpat = sizeof(bg) / sizeof(struct background_pattern);
|
||||
|
||||
@@ -212,16 +215,17 @@ static int global_showmode;
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
{
|
||||
char *args[1024]; /* arbitrary limit, but should suffice */
|
||||
char *p, *q, *bgstr = NULL, **argv = args;
|
||||
char *args[1024]; /* arbitrary limit, but should suffice */
|
||||
char **argv = args;
|
||||
char *p, *q, *bgstr = NULL;
|
||||
int argc = 0;
|
||||
int rc, alen, flen;
|
||||
int error = 0;
|
||||
int timing = FALSE;
|
||||
int have_bg = FALSE;
|
||||
double LUT_exponent; /* just the lookup table */
|
||||
double CRT_exponent = 2.2; /* just the monitor */
|
||||
double default_display_exponent; /* whole display system */
|
||||
double LUT_exponent; /* just the lookup table */
|
||||
double CRT_exponent = 2.2; /* just the monitor */
|
||||
double default_display_exponent; /* whole display system */
|
||||
MSG msg;
|
||||
|
||||
|
||||
@@ -316,33 +320,39 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
/* Now parse the command line for options and the PNG filename. */
|
||||
|
||||
while (*++argv && !error) {
|
||||
if (!strcmp(*argv, "-gamma")) {
|
||||
if (!strncmp(*argv, "-gamma", 2)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
rpng2_info.display_exponent = atof(*argv);
|
||||
if (rpng2_info.display_exponent <= 0.0)
|
||||
++error;
|
||||
} else if (!strcmp(*argv, "-bgcolor")) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
bgstr = *argv;
|
||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||
++error;
|
||||
else {
|
||||
have_bg = TRUE;
|
||||
bg_image = FALSE;
|
||||
rpng2_info.display_exponent = atof(*argv);
|
||||
if (rpng2_info.display_exponent <= 0.0)
|
||||
++error;
|
||||
}
|
||||
} else if (!strcmp(*argv, "-bgpat")) {
|
||||
} else if (!strncmp(*argv, "-bgcolor", 4)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
pat = atoi(*argv) - 1;
|
||||
if (pat < 0 || pat >= num_bgpat)
|
||||
else {
|
||||
bgstr = *argv;
|
||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||
++error;
|
||||
else {
|
||||
have_bg = TRUE;
|
||||
bg_image = FALSE;
|
||||
}
|
||||
}
|
||||
} else if (!strncmp(*argv, "-bgpat", 4)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
else {
|
||||
bg_image = TRUE;
|
||||
have_bg = FALSE;
|
||||
pat = atoi(*argv) - 1;
|
||||
if (pat < 0 || pat >= num_bgpat)
|
||||
++error;
|
||||
else {
|
||||
bg_image = TRUE;
|
||||
have_bg = FALSE;
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(*argv, "-timing")) {
|
||||
} else if (!strncmp(*argv, "-timing", 2)) {
|
||||
timing = TRUE;
|
||||
} else {
|
||||
if (**argv != '-') {
|
||||
@@ -387,6 +397,9 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
fclose(infile);
|
||||
}
|
||||
|
||||
|
||||
/* usage screen */
|
||||
|
||||
if (error) {
|
||||
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
||||
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 and the CRT exponent (usually 2.2); must be positive\n"
|
||||
" bg \tdesired background color in 7-character hex RGB format\n"
|
||||
"\t\t (e.g., ``#ff7f00'' for orange: same as HTML colors);\n"
|
||||
"\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
|
||||
"\t\t used with transparent images; overrides -bgpat\n"
|
||||
" pat \tdesired background pattern number (1-%d); used with\n"
|
||||
"\t\t transparent images; overrides -bgcolor\n"
|
||||
" -timing\tenables delay for every block read, to simulate modem\n"
|
||||
"\t\t download of image (~36 Kbps)\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);
|
||||
}
|
||||
|
||||
@@ -560,7 +573,7 @@ static int rpng2_win_create_window()
|
||||
if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) +
|
||||
wimage_rowbytes*rpng2_info.height)))
|
||||
{
|
||||
return 4; /* fail */
|
||||
return 4; /* fail */
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
@@ -655,7 +668,7 @@ static int rpng2_win_create_window()
|
||||
TextOut(hdc, ((x < 0)? 0 : x), ((y < 0)? 0 : y), msg, len);
|
||||
ReleaseDC(global_hwnd, hdc);
|
||||
|
||||
rpng2_win_load_bg_image(); /* resets bg_image if fails */
|
||||
rpng2_win_load_bg_image(); /* resets bg_image if fails */
|
||||
}
|
||||
|
||||
if (!bg_image) {
|
||||
@@ -753,7 +766,7 @@ static int rpng2_win_load_bg_image()
|
||||
even_odd = even_odd_vert ^ even_odd_horiz;
|
||||
invert_column =
|
||||
(even_odd_horiz && (bg[pat].type & 0x10));
|
||||
if (even_odd == 0) { /* gradient #1 */
|
||||
if (even_odd == 0) { /* gradient #1 */
|
||||
if (invert_column) {
|
||||
*dest++ = r1_inv;
|
||||
*dest++ = g1_inv;
|
||||
@@ -763,16 +776,16 @@ static int rpng2_win_load_bg_image()
|
||||
*dest++ = g1;
|
||||
*dest++ = b1;
|
||||
}
|
||||
} else { /* gradient #2 */
|
||||
} else { /* gradient #2 */
|
||||
if ((invert_column && invert_gradient2) ||
|
||||
(!invert_column && !invert_gradient2))
|
||||
{
|
||||
*dest++ = r2; /* not inverted or */
|
||||
*dest++ = g2; /* doubly inverted */
|
||||
*dest++ = r2; /* not inverted or */
|
||||
*dest++ = g2; /* doubly inverted */
|
||||
*dest++ = b2;
|
||||
} else {
|
||||
*dest++ = r2_inv;
|
||||
*dest++ = g2_inv; /* singly inverted */
|
||||
*dest++ = g2_inv; /* singly inverted */
|
||||
*dest++ = b2_inv;
|
||||
}
|
||||
}
|
||||
@@ -908,7 +921,7 @@ static int rpng2_win_load_bg_image()
|
||||
g1 = *src++;
|
||||
b1 = *src++;
|
||||
*dest++ = b1;
|
||||
*dest++ = g1; /* note reverse order */
|
||||
*dest++ = g1; /* note reverse order */
|
||||
*dest++ = r1;
|
||||
}
|
||||
}
|
||||
@@ -962,7 +975,7 @@ static void rpng2_win_display_row(ulg row)
|
||||
g = *src++;
|
||||
b = *src++;
|
||||
*dest++ = b;
|
||||
*dest++ = g; /* note reverse order */
|
||||
*dest++ = g; /* note reverse order */
|
||||
*dest++ = r;
|
||||
}
|
||||
} else /* if (rpng2_info.channels == 4) */ {
|
||||
@@ -1028,7 +1041,9 @@ static void rpng2_win_finish_display()
|
||||
* that the image is done */
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1084,15 +1099,15 @@ LRESULT CALLBACK rpng2_win_wndproc(HWND hwnd, UINT iMsg, WPARAM wP, LPARAM lP)
|
||||
|
||||
/* wait for the user to tell us when to quit */
|
||||
case WM_CHAR:
|
||||
switch (wP) { /* only need one, so ignore repeat count */
|
||||
switch (wP) { /* only need one, so ignore repeat count */
|
||||
case 'q':
|
||||
case 'Q':
|
||||
case 0x1B: /* Esc key */
|
||||
case 0x1B: /* Esc key */
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_LBUTTONDOWN: /* another way of quitting */
|
||||
case WM_LBUTTONDOWN: /* another way of quitting */
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
|
||||
@@ -6,9 +6,11 @@
|
||||
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-
|
||||
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
|
||||
with a little tweaking). Thanks to Adam Costello and Pieter S. van der
|
||||
Meulen for the "diamond" and "radial waves" patterns, respectively.
|
||||
for the X Window System (tested by the author under Unix and by Martin
|
||||
Zinser under OpenVMS; may work under OS/2 with a little tweaking).
|
||||
|
||||
Thanks to Adam Costello and Pieter S. van der Meulen for the "diamond"
|
||||
and "radial waves" patterns, respectively.
|
||||
|
||||
to do:
|
||||
- 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,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -44,21 +55,21 @@
|
||||
|
||||
#define PROGNAME "rpng2-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 <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <setjmp.h> /* for jmpbuf declaration in readpng2.h */
|
||||
#include <setjmp.h> /* for jmpbuf declaration in readpng2.h */
|
||||
#include <time.h>
|
||||
#include <math.h> /* only for PvdM background code */
|
||||
#include <math.h> /* only for PvdM background code */
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xos.h>
|
||||
#include <X11/keysym.h> /* defines XK_* macros */
|
||||
#include <X11/keysym.h> /* defines XK_* macros */
|
||||
|
||||
#ifdef VMS
|
||||
#include <unistd.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
/* all for PvdM background code: */
|
||||
@@ -79,9 +90,9 @@
|
||||
#define rgb2_max bg_bsat
|
||||
#define rgb2_min bg_brot
|
||||
|
||||
/* #define DEBUG */ /* this enables the Trace() macros */
|
||||
/* #define DEBUG */ /* this enables the Trace() macros */
|
||||
|
||||
#include "readpng2.h" /* typedefs, common macros, readpng2 prototypes */
|
||||
#include "readpng2.h" /* typedefs, common macros, readpng2 prototypes */
|
||||
|
||||
|
||||
/* could just include png.h, but this macro is the only thing we need
|
||||
@@ -89,18 +100,18 @@
|
||||
* only happen with alpha (which could easily be avoided with
|
||||
* "ush acopy = (alpha);") */
|
||||
|
||||
#define alpha_composite(composite, fg, alpha, bg) { \
|
||||
ush temp = ((ush)(fg)*(ush)(alpha) + \
|
||||
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
|
||||
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
|
||||
#define alpha_composite(composite, fg, alpha, bg) { \
|
||||
ush temp = ((ush)(fg)*(ush)(alpha) + \
|
||||
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
|
||||
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
|
||||
}
|
||||
|
||||
|
||||
#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this
|
||||
* block size corresponds roughly to a download
|
||||
* speed 10% faster than theoretical 33.6K maximum
|
||||
* (assuming 8 data bits, 1 stop bit and no other
|
||||
* overhead) */
|
||||
#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this
|
||||
* block size corresponds roughly to a download
|
||||
* speed 10% faster than theoretical 33.6K maximum
|
||||
* (assuming 8 data bits, 1 stop bit and no other
|
||||
* overhead) */
|
||||
|
||||
/* local prototypes */
|
||||
static void rpng2_x_init(void);
|
||||
@@ -123,12 +134,16 @@ static mainprog_info rpng2_info;
|
||||
static uch inbuf[INBUFSIZE];
|
||||
static int incount;
|
||||
|
||||
static int pat = 6; /* must be less than num_bgpat */
|
||||
static int pat = 6; /* must be less than num_bgpat */
|
||||
static int bg_image = 0;
|
||||
static int bgscale = 16;
|
||||
static ulg bg_rowbytes;
|
||||
static uch *bg_data;
|
||||
|
||||
int pause_after_pass = FALSE;
|
||||
int demo_timing = FALSE;
|
||||
ulg usleep_duration = 0L;
|
||||
|
||||
static struct rgb_color {
|
||||
uch r, g, b;
|
||||
} rgb[] = {
|
||||
@@ -201,12 +216,14 @@ static XImage *ximage;
|
||||
static Display *display;
|
||||
static int depth;
|
||||
static Visual *visual;
|
||||
static int RPixelShift, GPixelShift, BPixelShift;
|
||||
static ulg RedMask, GreenMask, BlueMask;
|
||||
static XVisualInfo *visual_list;
|
||||
static int RShift, GShift, BShift;
|
||||
static ulg RMask, GMask, BMask;
|
||||
static Window window;
|
||||
static GC gc;
|
||||
static Colormap colormap;
|
||||
|
||||
static int have_nondefault_visual = FALSE;
|
||||
static int have_colormap = FALSE;
|
||||
static int have_window = FALSE;
|
||||
|
||||
@@ -294,37 +311,53 @@ int main(int argc, char **argv)
|
||||
/* Now parse the command line for options and the PNG filename. */
|
||||
|
||||
while (*++argv && !error) {
|
||||
if (!strcmp(*argv, "-display")) {
|
||||
if (!strncmp(*argv, "-display", 2)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
displayname = *argv;
|
||||
} else if (!strcmp(*argv, "-gamma")) {
|
||||
else
|
||||
displayname = *argv;
|
||||
} else if (!strncmp(*argv, "-gamma", 2)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
rpng2_info.display_exponent = atof(*argv);
|
||||
if (rpng2_info.display_exponent <= 0.0)
|
||||
++error;
|
||||
} else if (!strcmp(*argv, "-bgcolor")) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
bgstr = *argv;
|
||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||
++error;
|
||||
else {
|
||||
have_bg = TRUE;
|
||||
bg_image = FALSE;
|
||||
rpng2_info.display_exponent = atof(*argv);
|
||||
if (rpng2_info.display_exponent <= 0.0)
|
||||
++error;
|
||||
}
|
||||
} else if (!strcmp(*argv, "-bgpat")) {
|
||||
} else if (!strncmp(*argv, "-bgcolor", 4)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
pat = atoi(*argv) - 1;
|
||||
if (pat < 0 || pat >= num_bgpat)
|
||||
else {
|
||||
bgstr = *argv;
|
||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||
++error;
|
||||
else {
|
||||
have_bg = TRUE;
|
||||
bg_image = FALSE;
|
||||
}
|
||||
}
|
||||
} else if (!strncmp(*argv, "-bgpat", 4)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
else {
|
||||
bg_image = TRUE;
|
||||
have_bg = FALSE;
|
||||
pat = atoi(*argv) - 1;
|
||||
if (pat < 0 || pat >= num_bgpat)
|
||||
++error;
|
||||
else {
|
||||
bg_image = TRUE;
|
||||
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;
|
||||
} else {
|
||||
if (**argv != '-') {
|
||||
@@ -377,25 +410,32 @@ int main(int argc, char **argv)
|
||||
fclose(infile);
|
||||
}
|
||||
|
||||
|
||||
/* usage screen */
|
||||
|
||||
if (error) {
|
||||
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
||||
readpng2_version_info();
|
||||
fprintf(stderr, "\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"
|
||||
" exp \ttransfer-function exponent (``gamma'') of the display\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 and the CRT exponent (usually 2.2); must be positive\n"
|
||||
" bg \tdesired background color in 7-character hex RGB format\n"
|
||||
"\t\t (e.g., ``#ff7f00'' for orange: same as HTML colors);\n"
|
||||
"\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
|
||||
"\t\t used with transparent images; overrides -bgpat\n"
|
||||
" pat \tdesired background pattern number (1-%d); used with\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"
|
||||
"\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,
|
||||
num_bgpat);
|
||||
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
|
||||
* 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 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_green = rpng2_info.bg_green;
|
||||
ulg bg_blue = rpng2_info.bg_blue;
|
||||
ulg bg_pixel = 0L;
|
||||
ulg attrmask;
|
||||
int need_colormap = FALSE;
|
||||
int screen, pad;
|
||||
uch *xdata;
|
||||
Window root;
|
||||
@@ -556,39 +598,70 @@ static int rpng2_x_create_window()
|
||||
depth = DisplayPlanes(display, screen);
|
||||
root = RootWindow(display, screen);
|
||||
|
||||
/* GRR: add 8-bit support */
|
||||
if (/* depth != 8 && */ depth != 16 && depth != 24 && depth != 32) {
|
||||
fprintf(stderr,
|
||||
"screen depth %d not supported (only 16-, 24- or 32-bit TrueColor)\n",
|
||||
depth);
|
||||
return 2;
|
||||
#ifdef DEBUG
|
||||
XSynchronize(display, True);
|
||||
#endif
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
XMatchVisualInfo(display, screen, depth,
|
||||
(depth == 8)? PseudoColor : TrueColor, &visual_info);
|
||||
visual = visual_info.visual;
|
||||
|
||||
RedMask = visual->red_mask;
|
||||
GreenMask = visual->green_mask;
|
||||
BlueMask = visual->blue_mask;
|
||||
RMask = visual->red_mask;
|
||||
GMask = visual->green_mask;
|
||||
BMask = visual->blue_mask;
|
||||
|
||||
/* GRR: add/check 8-bit support */
|
||||
if (depth == 8) {
|
||||
if (depth == 8 || need_colormap) {
|
||||
colormap = XCreateColormap(display, root, visual, AllocNone);
|
||||
if (!colormap) {
|
||||
fprintf(stderr, "XCreateColormap() failed\n");
|
||||
return 2;
|
||||
}
|
||||
have_colormap = TRUE;
|
||||
bg_image = FALSE; /* gradient just wastes palette entries */
|
||||
} else if (depth == 16) {
|
||||
RPixelShift = 15 - rpng2_x_msb(RedMask); /* these are right-shifts */
|
||||
GPixelShift = 15 - rpng2_x_msb(GreenMask);
|
||||
BPixelShift = 15 - rpng2_x_msb(BlueMask);
|
||||
} else /* if (depth > 16) */ {
|
||||
RPixelShift = rpng2_x_msb(RedMask) - 7; /* these are left-shifts */
|
||||
GPixelShift = rpng2_x_msb(GreenMask) - 7;
|
||||
BPixelShift = rpng2_x_msb(BlueMask) - 7;
|
||||
if (depth == 8)
|
||||
bg_image = FALSE; /* gradient just wastes palette entries */
|
||||
}
|
||||
if (depth == 15 || depth == 16) {
|
||||
RShift = 15 - rpng2_x_msb(RMask); /* these are right-shifts */
|
||||
GShift = 15 - rpng2_x_msb(GMask);
|
||||
BShift = 15 - rpng2_x_msb(BMask);
|
||||
} else if (depth > 16) {
|
||||
RShift = rpng2_x_msb(RMask) - 7; /* these are left-shifts */
|
||||
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.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,
|
||||
rpng2_info.height, 0, depth, InputOutput, visual,
|
||||
CWBackingStore | CWEventMask, &attr);
|
||||
rpng2_info.height, 0, depth, InputOutput, visual, attrmask, &attr);
|
||||
|
||||
if (window == None) {
|
||||
fprintf(stderr, "XCreateWindow() failed\n");
|
||||
@@ -621,8 +700,9 @@ static int rpng2_x_create_window()
|
||||
if ((size_hints = XAllocSizeHints()) != NULL) {
|
||||
/* window will not be resizable */
|
||||
size_hints->flags = PMinSize | PMaxSize;
|
||||
size_hints->min_width = size_hints->max_width = rpng2_info.width;
|
||||
size_hints->min_height = size_hints->max_height = rpng2_info.height;
|
||||
size_hints->min_width = size_hints->max_width = (int)rpng2_info.width;
|
||||
size_hints->min_height = size_hints->max_height =
|
||||
(int)rpng2_info.height;
|
||||
}
|
||||
|
||||
if ((wm_hints = XAllocWMHints()) != NULL) {
|
||||
@@ -668,7 +748,7 @@ static int rpng2_x_create_window()
|
||||
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
|
||||
* 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
|
||||
@@ -684,17 +764,17 @@ static int rpng2_x_create_window()
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
if (bg_image)
|
||||
rpng2_x_load_bg_image(); /* resets bg_image if fails */
|
||||
rpng2_x_load_bg_image(); /* resets bg_image if fails */
|
||||
|
||||
if (!bg_image) {
|
||||
if (depth == 24 || depth == 32) {
|
||||
bg_pixel = (bg_red << RPixelShift) |
|
||||
(bg_green << GPixelShift) |
|
||||
(bg_blue << BPixelShift);
|
||||
bg_pixel = (bg_red << RShift) |
|
||||
(bg_green << GShift) |
|
||||
(bg_blue << BShift);
|
||||
} else if (depth == 16) {
|
||||
bg_pixel = (((bg_red << 8) >> RPixelShift) & RedMask) |
|
||||
(((bg_green << 8) >> GPixelShift) & GreenMask) |
|
||||
(((bg_blue << 8) >> BPixelShift) & BlueMask);
|
||||
bg_pixel = (((bg_red << 8) >> RShift) & RMask) |
|
||||
(((bg_green << 8) >> GShift) & GMask) |
|
||||
(((bg_blue << 8) >> BShift) & BMask);
|
||||
} else /* depth == 8 */ {
|
||||
|
||||
/* 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;
|
||||
char *dest;
|
||||
@@ -772,8 +852,8 @@ static int rpng2_x_load_bg_image()
|
||||
int b2_diff = rgb[bg[pat].rgb2_max].b - b2_min;
|
||||
|
||||
for (row = 0; row < rpng2_info.height; ++row) {
|
||||
yidx = row % bgscale;
|
||||
even_odd_vert = (row / bgscale) & 1;
|
||||
yidx = (int)(row % bgscale);
|
||||
even_odd_vert = (int)((row / bgscale) & 1);
|
||||
|
||||
r1 = r1_min + (r1_diff * yidx) / yidx_max;
|
||||
g1 = g1_min + (g1_diff * yidx) / yidx_max;
|
||||
@@ -789,13 +869,13 @@ static int rpng2_x_load_bg_image()
|
||||
g2_inv = g2_min + (g2_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) {
|
||||
even_odd_horiz = (i / bgscale) & 1;
|
||||
even_odd_horiz = (int)((i / bgscale) & 1);
|
||||
even_odd = even_odd_vert ^ even_odd_horiz;
|
||||
invert_column =
|
||||
(even_odd_horiz && (bg[pat].type & 0x10));
|
||||
if (even_odd == 0) { /* gradient #1 */
|
||||
if (even_odd == 0) { /* gradient #1 */
|
||||
if (invert_column) {
|
||||
*dest++ = r1_inv;
|
||||
*dest++ = g1_inv;
|
||||
@@ -805,16 +885,16 @@ static int rpng2_x_load_bg_image()
|
||||
*dest++ = g1;
|
||||
*dest++ = b1;
|
||||
}
|
||||
} else { /* gradient #2 */
|
||||
} else { /* gradient #2 */
|
||||
if ((invert_column && invert_gradient2) ||
|
||||
(!invert_column && !invert_gradient2))
|
||||
{
|
||||
*dest++ = r2; /* not inverted or */
|
||||
*dest++ = g2; /* doubly inverted */
|
||||
*dest++ = r2; /* not inverted or */
|
||||
*dest++ = g2; /* doubly inverted */
|
||||
*dest++ = b2;
|
||||
} else {
|
||||
*dest++ = r2_inv;
|
||||
*dest++ = g2_inv; /* singly inverted */
|
||||
*dest++ = g2_inv; /* singly inverted */
|
||||
*dest++ = b2_inv;
|
||||
}
|
||||
}
|
||||
@@ -839,12 +919,12 @@ static int rpng2_x_load_bg_image()
|
||||
b2 = rgb[bg[pat].rgb2_max].b;
|
||||
|
||||
for (row = 0; row < rpng2_info.height; ++row) {
|
||||
yidx = row % bgscale;
|
||||
yidx = (int)(row % bgscale);
|
||||
if (yidx > hmax)
|
||||
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) {
|
||||
xidx = i % bgscale;
|
||||
xidx = (int)(i % bgscale);
|
||||
if (xidx > hmax)
|
||||
xidx = bgscale-1 - xidx;
|
||||
k = xidx + yidx;
|
||||
@@ -871,8 +951,8 @@ static int rpng2_x_load_bg_image()
|
||||
PROGNAME);
|
||||
fflush(stderr);
|
||||
|
||||
hh = rpng2_info.height / 2;
|
||||
hw = rpng2_info.width / 2;
|
||||
hh = (int)(rpng2_info.height / 2);
|
||||
hw = (int)(rpng2_info.width / 2);
|
||||
|
||||
/* variables for radial waves:
|
||||
* 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));
|
||||
|
||||
for (row = 0; row < rpng2_info.height; ++row) {
|
||||
y = row - hh;
|
||||
dest = (char *)(bg_data + row*bg_rowbytes);
|
||||
y = (int)(row - hh);
|
||||
dest = (char *)bg_data + row*bg_rowbytes;
|
||||
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);
|
||||
gray = (double)MAX(ABS(y), ABS(x)) / grayspot;
|
||||
gray = MIN(1.0, gray);
|
||||
@@ -951,14 +1031,15 @@ static int rpng2_x_load_bg_image()
|
||||
red = *src++;
|
||||
green = *src++;
|
||||
blue = *src++;
|
||||
pixel = (red << RPixelShift) |
|
||||
(green << GPixelShift) |
|
||||
(blue << BPixelShift);
|
||||
pixel = (red << RShift) |
|
||||
(green << GShift) |
|
||||
(blue << BShift);
|
||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||
*dest++ = ((uch *)&pixel)[3];
|
||||
*dest++ = ((uch *)&pixel)[2];
|
||||
*dest++ = ((uch *)&pixel)[1];
|
||||
*dest++ = ((uch *)&pixel)[0];
|
||||
/* GRR BUG: this assumes bpp == 32, but may be 24: */
|
||||
*dest++ = (char)((pixel >> 24) & 0xff);
|
||||
*dest++ = (char)((pixel >> 16) & 0xff);
|
||||
*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;
|
||||
dest = ximage->data + row*ximage_rowbytes;
|
||||
for (i = rpng2_info.width; i > 0; --i) {
|
||||
red = ((ush)(*src) << 8);
|
||||
++src;
|
||||
green = ((ush)(*src) << 8);
|
||||
++src;
|
||||
blue = ((ush)(*src) << 8);
|
||||
++src;
|
||||
pixel = ((red >> RPixelShift) & RedMask) |
|
||||
((green >> GPixelShift) & GreenMask) |
|
||||
((blue >> BPixelShift) & BlueMask);
|
||||
red = ((ush)(*src) << 8); ++src;
|
||||
green = ((ush)(*src) << 8); ++src;
|
||||
blue = ((ush)(*src) << 8); ++src;
|
||||
pixel = ((red >> RShift) & RMask) |
|
||||
((green >> GShift) & GMask) |
|
||||
((blue >> BShift) & BMask);
|
||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||
*dest++ = ((uch *)&pixel)[1];
|
||||
*dest++ = ((uch *)&pixel)[0];
|
||||
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||
*dest++ = (char)( pixel & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1011,7 +1089,7 @@ static void rpng2_x_display_row(ulg row)
|
||||
uch r, g, b, a;
|
||||
int ximage_rowbytes = ximage->bytes_per_line;
|
||||
ulg i, pixel;
|
||||
static int rows=0;
|
||||
static int rows=0, prevpass=(-1);
|
||||
static ulg firstrow;
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
@@ -1022,8 +1100,28 @@ static void rpng2_x_display_row(ulg row)
|
||||
|
||||
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)
|
||||
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 */
|
||||
|
||||
@@ -1046,14 +1144,15 @@ static void rpng2_x_display_row(ulg row)
|
||||
red = *src++;
|
||||
green = *src++;
|
||||
blue = *src++;
|
||||
pixel = (red << RPixelShift) |
|
||||
(green << GPixelShift) |
|
||||
(blue << BPixelShift);
|
||||
/* recall that we set ximage->byte_order = MSBFirst */
|
||||
*dest++ = ((uch *)&pixel)[3];
|
||||
*dest++ = ((uch *)&pixel)[2];
|
||||
*dest++ = ((uch *)&pixel)[1];
|
||||
*dest++ = ((uch *)&pixel)[0];
|
||||
pixel = (red << RShift) |
|
||||
(green << GShift) |
|
||||
(blue << BShift);
|
||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||
/* GRR BUG: this assumes bpp == 32, but may be 24: */
|
||||
*dest++ = (char)((pixel >> 24) & 0xff);
|
||||
*dest++ = (char)((pixel >> 16) & 0xff);
|
||||
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||
*dest++ = (char)( pixel & 0xff);
|
||||
}
|
||||
} else /* if (rpng2_info.channels == 4) */ {
|
||||
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(blue, b, a, bg_blue);
|
||||
}
|
||||
pixel = (red << RPixelShift) |
|
||||
(green << GPixelShift) |
|
||||
(blue << BPixelShift);
|
||||
/* recall that we set ximage->byte_order = MSBFirst */
|
||||
*dest++ = ((uch *)&pixel)[3];
|
||||
*dest++ = ((uch *)&pixel)[2];
|
||||
*dest++ = ((uch *)&pixel)[1];
|
||||
*dest++ = ((uch *)&pixel)[0];
|
||||
pixel = (red << RShift) |
|
||||
(green << GShift) |
|
||||
(blue << BShift);
|
||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||
/* GRR BUG: this assumes bpp == 32, but may be 24: */
|
||||
*dest++ = (char)((pixel >> 24) & 0xff);
|
||||
*dest++ = (char)((pixel >> 16) & 0xff);
|
||||
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||
*dest++ = (char)( pixel & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1108,12 +1208,12 @@ static void rpng2_x_display_row(ulg row)
|
||||
++src;
|
||||
blue = ((ush)(*src) << 8);
|
||||
++src;
|
||||
pixel = ((red >> RPixelShift) & RedMask) |
|
||||
((green >> GPixelShift) & GreenMask) |
|
||||
((blue >> BPixelShift) & BlueMask);
|
||||
/* recall that we set ximage->byte_order = MSBFirst */
|
||||
*dest++ = ((uch *)&pixel)[1];
|
||||
*dest++ = ((uch *)&pixel)[0];
|
||||
pixel = ((red >> RShift) & RMask) |
|
||||
((green >> GShift) & GMask) |
|
||||
((blue >> BShift) & BMask);
|
||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||
*dest++ = (char)( pixel & 0xff);
|
||||
}
|
||||
} else /* if (rpng2_info.channels == 4) */ {
|
||||
for (i = rpng2_info.width; i > 0; --i) {
|
||||
@@ -1145,12 +1245,12 @@ static void rpng2_x_display_row(ulg row)
|
||||
green = ((ush)g << 8);
|
||||
blue = ((ush)b << 8);
|
||||
}
|
||||
pixel = ((red >> RPixelShift) & RedMask) |
|
||||
((green >> GPixelShift) & GreenMask) |
|
||||
((blue >> BPixelShift) & BlueMask);
|
||||
/* recall that we set ximage->byte_order = MSBFirst */
|
||||
*dest++ = ((uch *)&pixel)[1];
|
||||
*dest++ = ((uch *)&pixel)[0];
|
||||
pixel = ((red >> RShift) & RMask) |
|
||||
((green >> GShift) & GMask) |
|
||||
((blue >> BShift) & BMask);
|
||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||
*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
|
||||
previously displayed lines due to interlacing--i.e., not contiguous.)
|
||||
Display after every 16 rows or when on one of last two rows. (Region
|
||||
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) {
|
||||
XPutImage(display, window, gc, ximage, 0, firstrow, 0, firstrow,
|
||||
rpng2_info.width, row - firstrow + 1);
|
||||
if (demo_timing && (row - firstrow >= 16 || row >= rpng2_info.height-2)) {
|
||||
XPutImage(display, window, gc, ximage, 0, (int)firstrow, 0,
|
||||
(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);
|
||||
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"))
|
||||
|
||||
@@ -1188,14 +1298,16 @@ static void rpng2_x_finish_display()
|
||||
* the image is done */
|
||||
|
||||
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) {
|
||||
free(bg_data);
|
||||
@@ -1228,6 +1340,9 @@ static void rpng2_x_cleanup()
|
||||
|
||||
if (have_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,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -45,7 +53,7 @@
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
#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"
|
||||
|
||||
#if defined(__MSDOS__) || defined(__OS2__)
|
||||
@@ -57,27 +65,27 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <setjmp.h> /* for jmpbuf declaration in writepng.h */
|
||||
#include <setjmp.h> /* for jmpbuf declaration in writepng.h */
|
||||
#include <time.h>
|
||||
|
||||
#ifdef DOS_OS2_W32
|
||||
# include <io.h> /* for isatty(), setmode() prototypes */
|
||||
# include <fcntl.h> /* O_BINARY for fdopen() without text translation */
|
||||
# include <io.h> /* for isatty(), setmode() prototypes */
|
||||
# include <fcntl.h> /* O_BINARY for fdopen() without text translation */
|
||||
# ifdef __EMX__
|
||||
# ifndef getch
|
||||
# define getch() _read_kbd(0, 1, 0) /* need getche() */
|
||||
# define getch() _read_kbd(0, 1, 0) /* need getche() */
|
||||
# endif
|
||||
# else /* !__EMX__ */
|
||||
# ifdef __GO32__
|
||||
# include <pc.h>
|
||||
# define getch() getkey() /* GRR: need getche() */
|
||||
# define getch() getkey() /* GRR: need getche() */
|
||||
# else
|
||||
# include <conio.h> /* for getche() console input */
|
||||
# include <conio.h> /* for getche() console input */
|
||||
# endif
|
||||
# endif /* ?__EMX__ */
|
||||
# define FGETS(buf,len,stream) dos_kbd_gets(buf,len)
|
||||
#else
|
||||
# include <unistd.h> /* for isatty() prototype */
|
||||
# include <unistd.h> /* for isatty() prototype */
|
||||
# define FGETS fgets
|
||||
#endif
|
||||
|
||||
@@ -87,7 +95,7 @@
|
||||
text that includes control characters discouraged by the PNG spec; text
|
||||
that includes an escape character (27) must be re-entered regardless */
|
||||
|
||||
#include "writepng.h" /* typedefs, common macros, writepng prototypes */
|
||||
#include "writepng.h" /* typedefs, common macros, writepng prototypes */
|
||||
|
||||
|
||||
|
||||
@@ -112,7 +120,7 @@ int main(int argc, char **argv)
|
||||
FILE *keybd;
|
||||
#endif
|
||||
#ifdef sgi
|
||||
FILE *tmpfile; /* or we could just use keybd, since no overlap */
|
||||
FILE *tmpfile; /* or we could just use keybd, since no overlap */
|
||||
char tmpline[80];
|
||||
#endif
|
||||
char *inname = NULL, outname[256];
|
||||
@@ -204,36 +212,40 @@ int main(int argc, char **argv)
|
||||
/* Now parse the command line for options and the PNM filename. */
|
||||
|
||||
while (*++argv && !error) {
|
||||
if (!strcmp(*argv, "-interlaced")) {
|
||||
if (!strncmp(*argv, "-i", 2)) {
|
||||
wpng_info.interlaced = TRUE;
|
||||
} else if (!strcmp(*argv, "-time")) {
|
||||
} else if (!strncmp(*argv, "-time", 3)) {
|
||||
wpng_info.modtime = time(NULL);
|
||||
wpng_info.have_time = TRUE;
|
||||
} else if (!strcmp(*argv, "-text")) {
|
||||
} else if (!strncmp(*argv, "-text", 3)) {
|
||||
text = TRUE;
|
||||
} else if (!strcmp(*argv, "-gamma")) {
|
||||
} else if (!strncmp(*argv, "-gamma", 2)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
wpng_info.gamma = atof(*argv);
|
||||
if (wpng_info.gamma <= 0.0)
|
||||
++error;
|
||||
else if (wpng_info.gamma > 1.01)
|
||||
fprintf(stderr, PROGNAME
|
||||
" warning: file gammas are usually less than 1.0\n");
|
||||
} else if (!strcmp(*argv, "-bgcolor")) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
bgstr = *argv;
|
||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||
++error;
|
||||
else {
|
||||
unsigned r, g, b; /* this approach quiets compiler warnings */
|
||||
wpng_info.gamma = atof(*argv);
|
||||
if (wpng_info.gamma <= 0.0)
|
||||
++error;
|
||||
else if (wpng_info.gamma > 1.01)
|
||||
fprintf(stderr, PROGNAME
|
||||
" warning: file gammas are usually less than 1.0\n");
|
||||
}
|
||||
} else if (!strncmp(*argv, "-bgcolor", 4)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
else {
|
||||
bgstr = *argv;
|
||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||
++error;
|
||||
else {
|
||||
unsigned r, g, b; /* this way quiets compiler warnings */
|
||||
|
||||
sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b);
|
||||
wpng_info.bg_red = (uch)r;
|
||||
wpng_info.bg_green = (uch)g;
|
||||
wpng_info.bg_blue = (uch)b;
|
||||
wpng_info.have_bg = TRUE;
|
||||
sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b);
|
||||
wpng_info.bg_red = (uch)r;
|
||||
wpng_info.bg_green = (uch)g;
|
||||
wpng_info.bg_blue = (uch)b;
|
||||
wpng_info.have_bg = TRUE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (**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 first varies, second is usually 2.2, all are positive)\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"
|
||||
" -text\tprompt interactively for text info (tEXt chunks)\n"
|
||||
" -time\tinclude a tIME chunk (last modification time)\n"
|
||||
@@ -419,7 +431,7 @@ int main(int argc, char **argv)
|
||||
wpng_info.have_text &= ~TEXT_TITLE;
|
||||
valid = FALSE;
|
||||
#else
|
||||
if (p[result] == 27) { /* escape character */
|
||||
if (p[result] == 27) { /* escape character */
|
||||
wpng_info.have_text &= ~TEXT_TITLE;
|
||||
valid = FALSE;
|
||||
}
|
||||
@@ -449,7 +461,7 @@ int main(int argc, char **argv)
|
||||
wpng_info.have_text &= ~TEXT_AUTHOR;
|
||||
valid = FALSE;
|
||||
#else
|
||||
if (p[result] == 27) { /* escape character */
|
||||
if (p[result] == 27) { /* escape character */
|
||||
wpng_info.have_text &= ~TEXT_AUTHOR;
|
||||
valid = FALSE;
|
||||
}
|
||||
@@ -489,7 +501,7 @@ int main(int argc, char **argv)
|
||||
wpng_info.have_text &= ~TEXT_DESC;
|
||||
valid = FALSE;
|
||||
#else
|
||||
if (p[result] == 27) { /* escape character */
|
||||
if (p[result] == 27) { /* escape character */
|
||||
wpng_info.have_text &= ~TEXT_DESC;
|
||||
valid = FALSE;
|
||||
}
|
||||
@@ -519,7 +531,7 @@ int main(int argc, char **argv)
|
||||
wpng_info.have_text &= ~TEXT_COPY;
|
||||
valid = FALSE;
|
||||
#else
|
||||
if (p[result] == 27) { /* escape character */
|
||||
if (p[result] == 27) { /* escape character */
|
||||
wpng_info.have_text &= ~TEXT_COPY;
|
||||
valid = FALSE;
|
||||
}
|
||||
@@ -549,7 +561,7 @@ int main(int argc, char **argv)
|
||||
wpng_info.have_text &= ~TEXT_EMAIL;
|
||||
valid = FALSE;
|
||||
#else
|
||||
if (p[result] == 27) { /* escape character */
|
||||
if (p[result] == 27) { /* escape character */
|
||||
wpng_info.have_text &= ~TEXT_EMAIL;
|
||||
valid = FALSE;
|
||||
}
|
||||
@@ -579,7 +591,7 @@ int main(int argc, char **argv)
|
||||
wpng_info.have_text &= ~TEXT_URL;
|
||||
valid = FALSE;
|
||||
#else
|
||||
if (p[result] == 27) { /* escape character */
|
||||
if (p[result] == 27) { /* escape character */
|
||||
wpng_info.have_text &= ~TEXT_URL;
|
||||
valid = FALSE;
|
||||
}
|
||||
@@ -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) {
|
||||
fclose(wpng_info.outfile);
|
||||
@@ -791,11 +803,11 @@ static char *dos_kbd_gets(char *buf, int len)
|
||||
buf[count++] = ch = getche();
|
||||
} while (ch != '\r' && count < len-1);
|
||||
|
||||
buf[count--] = '\0'; /* terminate string */
|
||||
if (buf[count] == '\r') /* Enter key makes CR, so change to newline */
|
||||
buf[count--] = '\0'; /* terminate string */
|
||||
if (buf[count] == '\r') /* Enter key makes CR, so change to newline */
|
||||
buf[count] = '\n';
|
||||
|
||||
fprintf(stderr, "\n"); /* Enter key does *not* cause a newline */
|
||||
fprintf(stderr, "\n"); /* Enter key does *not* cause a newline */
|
||||
fflush(stderr);
|
||||
|
||||
return buf;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
||||
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -30,10 +30,10 @@
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include <stdlib.h> /* for exit() prototype */
|
||||
#include <stdlib.h> /* for exit() prototype */
|
||||
|
||||
#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
|
||||
#include "writepng.h" /* typedefs, common macros, public prototypes */
|
||||
#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
|
||||
#include "writepng.h" /* typedefs, common macros, public prototypes */
|
||||
|
||||
|
||||
/* local prototype */
|
||||
@@ -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",
|
||||
PNG_LIBPNG_VER_STRING, png_libpng_ver);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
||||
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
|
||||
@@ -42,6 +42,11 @@
|
||||
|
||||
#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 */
|
||||
|
||||
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 */
|
||||
}
|
||||
|
||||
if (setjmp (png_ptr->jmpbuf))
|
||||
if (setjmp (png_jmpbuf(png_ptr)))
|
||||
{
|
||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||
return FALSE;
|
||||
|
||||
@@ -40,6 +40,11 @@
|
||||
|
||||
#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 */
|
||||
|
||||
int main (int argc, char *argv[]);
|
||||
@@ -77,7 +82,8 @@ int main(int argc, char *argv[])
|
||||
if ((fp_al = fopen (argv[argi], "rb")) == NULL)
|
||||
{
|
||||
fprintf (stderr, "PNM2PNG\n");
|
||||
fprintf (stderr, "Error: alpha-channel file %s does not exist\n", argv[argi]);
|
||||
fprintf (stderr, "Error: alpha-channel file %s does not exist\n",
|
||||
argv[argi]);
|
||||
exit (1);
|
||||
}
|
||||
break;
|
||||
@@ -385,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 */
|
||||
if (setjmp (png_ptr->jmpbuf))
|
||||
if (setjmp (png_jmpbuf(png_ptr)))
|
||||
{
|
||||
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
|
||||
return FALSE;
|
||||
@@ -511,8 +517,8 @@ png_uint_32 get_value (FILE *pnm_file, int depth)
|
||||
for (i = 0; i < depth; i++)
|
||||
mask = (mask << 1) | 0x01;
|
||||
|
||||
get_token (pnm_file, token);
|
||||
sscanf (token, "%lu", &ret_value);
|
||||
get_token (pnm_file, (char *) token);
|
||||
sscanf ((const char *) token, "%lu", &ret_value);
|
||||
|
||||
ret_value &= mask;
|
||||
|
||||
|
||||
99
example.c
99
example.c
@@ -6,17 +6,28 @@
|
||||
/* 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
|
||||
* 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
|
||||
* does not require a copyright notice.
|
||||
* implementation. This is not officially part of libpng, is hereby placed
|
||||
* in the public domain, and therefore does not require a copyright notice.
|
||||
*
|
||||
* This file does not currently compile, because it is missing certain
|
||||
* 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
|
||||
* 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"
|
||||
|
||||
/* 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()
|
||||
* returns zero if the image is a PNG and nonzero if it isn't a PNG.
|
||||
*
|
||||
@@ -43,7 +54,7 @@ int check_if_png(char *file_name, FILE **fp)
|
||||
char buf[PNG_BYTES_TO_CHECK];
|
||||
|
||||
/* Open the prospective PNG file. */
|
||||
if ((*fp = fopen(file_name, "rb")) != NULL);
|
||||
if ((*fp = fopen(file_name, "rb")) == NULL)
|
||||
return 0;
|
||||
|
||||
/* Read in some of the signature bytes */
|
||||
@@ -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
|
||||
* set up your own error handlers in the png_create_read_struct() earlier.
|
||||
*/
|
||||
if (setjmp(png_ptr->jmpbuf))
|
||||
|
||||
if (setjmp(png_jmpbuf(png_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);
|
||||
@@ -136,6 +148,19 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
/* If we have already read some of the signature */
|
||||
png_set_sig_bytes(png_ptr, sig_read);
|
||||
|
||||
#ifdef hilevel
|
||||
/*
|
||||
* If you have enough memory to read in the entire image at once,
|
||||
* and you need to specify only transforms that can be controlled
|
||||
* with one of the PNG_TRANSFORM_* bits (this presently excludes
|
||||
* dithering, filling, setting background, and doing gamma
|
||||
* adjustment), then you can read the entire image (including
|
||||
* pixels) into the info structure with this call:
|
||||
*/
|
||||
png_read_png(png_ptr, info_ptr, png_transforms, NULL);
|
||||
#else
|
||||
/* OK, you're doing it the hard way, with the lower-level functions */
|
||||
|
||||
/* The call to png_read_info() gives us all of the information from the
|
||||
* PNG file before the first IDAT (image data chunk). REQUIRED
|
||||
*/
|
||||
@@ -218,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 */
|
||||
}
|
||||
|
||||
/* 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
|
||||
* by the user at run time by the user. It is strongly suggested that
|
||||
* your application support gamma correction.
|
||||
@@ -227,7 +252,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
int 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
|
||||
{
|
||||
double image_gamma;
|
||||
@@ -275,14 +300,15 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
*/
|
||||
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT))
|
||||
{
|
||||
png_color8p sig_bit;
|
||||
png_color_8p sig_bit;
|
||||
|
||||
png_get_sBIT(png_ptr, info_ptr, &sig_bit);
|
||||
png_set_shift(png_ptr, sig_bit);
|
||||
}
|
||||
|
||||
/* flip the RGB pixels to BGR (or RGBA to BGRA) */
|
||||
png_set_bgr(png_ptr);
|
||||
if (color_type & PNG_COLOR_MASK_COLOR)
|
||||
png_set_bgr(png_ptr);
|
||||
|
||||
/* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
|
||||
png_set_swap_alpha(png_ptr);
|
||||
@@ -350,6 +376,9 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
|
||||
/* read rest of file, and get additional chunks in info_ptr - REQUIRED */
|
||||
png_read_end(png_ptr, info_ptr);
|
||||
#endif hilevel
|
||||
|
||||
/* At this point you have read the entire image */
|
||||
|
||||
/* clean up after the read, and free any memory allocated - REQUIRED */
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
|
||||
@@ -389,7 +418,7 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (setjmp((*png_ptr)->jmpbuf))
|
||||
if (setjmp(png_jmpbuf((*png_ptr))))
|
||||
{
|
||||
png_destroy_read_struct(png_ptr, info_ptr, (png_infopp)NULL);
|
||||
return ERROR;
|
||||
@@ -417,7 +446,7 @@ int
|
||||
process_data(png_structp *png_ptr, png_infop *info_ptr,
|
||||
png_bytep buffer, png_uint_32 length)
|
||||
{
|
||||
if (setjmp((*png_ptr)->jmpbuf))
|
||||
if (setjmp(png_jmpbuf((*png_ptr))))
|
||||
{
|
||||
/* Free the png_ptr and info_ptr memory on error */
|
||||
png_destroy_read_struct(png_ptr, info_ptr, (png_infopp)NULL);
|
||||
@@ -499,6 +528,7 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
FILE *fp;
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr;
|
||||
png_colorp palette;
|
||||
|
||||
/* open the file */
|
||||
fp = fopen(file_name, "wb");
|
||||
@@ -530,13 +560,13 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
}
|
||||
|
||||
/* Set error handling. REQUIRED if you aren't supplying your own
|
||||
* error hadnling 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 */
|
||||
fclose(fp);
|
||||
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
|
||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -552,6 +582,15 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
/* where user_io_ptr is a structure you want available to the callbacks */
|
||||
#endif no_streams /* only use one initialization method */
|
||||
|
||||
#ifdef hilevel
|
||||
/* This is the easy way. Use it if you already have all the
|
||||
* image info living info in the structure. You could "|" many
|
||||
* PNG_TRANSFORM flags into the png_transforms integer here.
|
||||
*/
|
||||
png_write_png(png_ptr, info_ptr, png_transforms, NULL);
|
||||
#else
|
||||
/* This is the hard way */
|
||||
|
||||
/* Set the image information here. Width and height are up to 2^31,
|
||||
* bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
|
||||
* the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,
|
||||
@@ -567,6 +606,9 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
palette = (png_colorp)png_malloc(png_ptr, 256 * sizeof (png_color));
|
||||
/* ... set palette colors ... */
|
||||
png_set_PLTE(png_ptr, info_ptr, palette, 256);
|
||||
/* You must not free palette here, because png_set_PLTE only makes a link to
|
||||
the palette that you malloced. Wait until you are about to destroy
|
||||
the png structure. */
|
||||
|
||||
/* optional significant bit chunk */
|
||||
/* if we are dealing with a grayscale image then */
|
||||
@@ -603,7 +645,7 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
png_set_text(png_ptr, info_ptr, text_ptr, 3);
|
||||
|
||||
/* 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 */
|
||||
|
||||
/* Write the file header information. REQUIRED */
|
||||
@@ -615,6 +657,9 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
* png_write_info_before_PLTE(write_ptr, write_info_ptr);
|
||||
* write_my_chunk();
|
||||
* png_write_info(png_ptr, info_ptr);
|
||||
*
|
||||
* However, given the level of known- and unknown-chunk support in 1.1.0
|
||||
* and up, this should no longer be necessary.
|
||||
*/
|
||||
|
||||
/* Once we write out the header, the compression type on the text
|
||||
@@ -666,10 +711,10 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
* use the first method if you aren't handling interlacing yourself.
|
||||
*/
|
||||
png_uint_32 k, height, width;
|
||||
png_byte image[height][width];
|
||||
png_byte image[height][width*bytes_per_pixel];
|
||||
png_bytep row_pointers[height];
|
||||
for (k = 0; k < height; k++)
|
||||
row_pointers[k] = image + k*width;
|
||||
row_pointers[k] = image + k*width*bytes_per_pixel;
|
||||
|
||||
/* One of the following output methods is REQUIRED */
|
||||
#ifdef entire /* write out the entire image data in one call */
|
||||
@@ -695,17 +740,29 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
#endif no_entire /* use only one output method */
|
||||
|
||||
/* You can write optional chunks like tEXt, zTXt, and tIME at the end
|
||||
* as well.
|
||||
* as well. Shouldn't be necessary in 1.1.0 and up as all the public
|
||||
* chunks are supported and you can use png_set_unknown_chunks() to
|
||||
* register unknown chunks into the info structure to be written out.
|
||||
*/
|
||||
|
||||
/* It is REQUIRED to call this to finish writing the rest of the file */
|
||||
png_write_end(png_ptr, info_ptr);
|
||||
#endif hilevel
|
||||
|
||||
/* if you malloced the palette, free it here */
|
||||
free(info_ptr->palette);
|
||||
/* If you png_malloced a palette, free it here (don't free info_ptr->palette,
|
||||
as recommended in versions 1.0.5m and earlier of this example; if
|
||||
libpng mallocs info_ptr->palette, libpng will free it). If you
|
||||
allocated it with malloc() instead of png_malloc(), use free() instead
|
||||
of png_free(). */
|
||||
png_free(png_ptr, palette);
|
||||
|
||||
/* Similarly, if you png_malloced any data that you passed in with
|
||||
png_set_something(), such as a hist or trans array, free it here,
|
||||
when you can be sure that libpng is through with it. */
|
||||
png_free(png_ptr, trans);
|
||||
|
||||
/* clean up after the write, and free any memory allocated */
|
||||
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
|
||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||
|
||||
/* close the file */
|
||||
fclose(fp);
|
||||
|
||||
981
libpng.txt
981
libpng.txt
File diff suppressed because it is too large
Load Diff
24
libpngpf.3
24
libpngpf.3
@@ -1,6 +1,6 @@
|
||||
.TH LIBPNGPF 3 December 10, 1999
|
||||
.TH LIBPNGPF 3 "May 17, 2000"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5h
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.7beta14
|
||||
(private functions)
|
||||
.SH SYNOPSIS
|
||||
\fB#include <png.h>\fP
|
||||
@@ -55,6 +55,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5h
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBpng_charp png_decompress_chunk (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcomp_type\fP\fB, png_charp \fP\fIchunkdata\fP\fB, png_size_t \fP\fIchunklength\fP\fB, png_size_t \fP\fIprefix_length\fP\fB, png_size_t \fI*data_length\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_destroy_struct (png_voidp \fIstruct_ptr\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
@@ -187,6 +191,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5h
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBint png_handle_as_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_handle_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
@@ -375,10 +383,6 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5h
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_read_init (png_structp \fIpng_ptr\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_read_push_finish_row (png_structp \fIpng_ptr\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
@@ -461,10 +465,6 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5h
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_write_init (png_structp \fIpng_ptr\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_write_iTXt (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcompression\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fIlang\fP\fB, png_charp \fP\fItranslated_key\fP\fB, png_charp \fItext)\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
@@ -505,9 +505,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5h
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_write_sPLT (png_structp \fP\fIpng_ptr\fP\fB, \fIpng_spalette_p
|
||||
|
||||
\fI\fBpalette\fP\fB);\fP
|
||||
\fBvoid png_write_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_spalette_p \fIpalette\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
|
||||
8
png.5
8
png.5
@@ -1,4 +1,4 @@
|
||||
.TH PNG 5 "December 10, 1999"
|
||||
.TH PNG 5 "May 17, 2000"
|
||||
.SH NAME
|
||||
png \- Portable Network Graphics (PNG) format
|
||||
.SH DESCRIPTION
|
||||
@@ -20,10 +20,12 @@ platforms.
|
||||
.SH "SEE ALSO"
|
||||
.IR libpng(3), zlib(3), deflate(5), and zlib(5)
|
||||
.LP
|
||||
PNG 1.1 specification, January 1999:
|
||||
PNG 1.2 specification, July 1999:
|
||||
.IP
|
||||
.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
|
||||
PNG 1.0 specification, October 1996:
|
||||
.IP
|
||||
|
||||
404
png.c
404
png.c
@@ -1,24 +1,27 @@
|
||||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* libpng version 1.0.5h - December 10, 1999
|
||||
* libpng version 1.0.7beta14 - May 17, 2000
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
*
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#define PNG_NO_EXTERN
|
||||
#include <assert.h>
|
||||
#include "png.h"
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef version_1_0_7beta14 Your_png_h_is_not_version_1_0_7beta14;
|
||||
|
||||
/* 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
|
||||
/* png_libpng_ver was changed to a function in version 1.0.5c */
|
||||
char png_libpng_ver[12] = "1.0.5h";
|
||||
char png_libpng_ver[12] = "1.0.7beta14";
|
||||
|
||||
/* png_sig was changed to a function in version 1.0.5c */
|
||||
/* Place to hold the signature string for a PNG file. */
|
||||
@@ -61,10 +64,10 @@ int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
|
||||
/* offset to next interlace block in the y direction */
|
||||
int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
||||
|
||||
/* Width of interlace block. This is not currently used - if you need
|
||||
* it, uncomment it here and in png.h
|
||||
/* width of interlace block (used in assembler routines only) */
|
||||
#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
|
||||
int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1};
|
||||
*/
|
||||
#endif
|
||||
|
||||
/* Height of interlace block. This is not currently used - if you need
|
||||
* it, uncomment it here and in png.h
|
||||
@@ -85,7 +88,7 @@ int FARDATA png_pass_dsp_mask[] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
||||
* or write any of the magic bytes before it starts on the IHDR.
|
||||
*/
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_sig_bytes(png_structp png_ptr, int num_bytes)
|
||||
{
|
||||
png_debug(1, "in png_set_sig_bytes\n");
|
||||
@@ -103,7 +106,7 @@ png_set_sig_bytes(png_structp png_ptr, int num_bytes)
|
||||
* respectively, to be less than, to match, or be greater than the correct
|
||||
* PNG signature (this is the same behaviour as strcmp, memcmp, etc).
|
||||
*/
|
||||
int
|
||||
int PNGAPI
|
||||
png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
|
||||
{
|
||||
png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
@@ -125,14 +128,14 @@ png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
|
||||
* to check a partial signature. This function might be removed in the
|
||||
* future - use png_sig_cmp(). Returns true (nonzero) if the file is a PNG.
|
||||
*/
|
||||
int
|
||||
int PNGAPI
|
||||
png_check_sig(png_bytep sig, int num)
|
||||
{
|
||||
return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num));
|
||||
}
|
||||
|
||||
/* Function to allocate memory for zlib. */
|
||||
voidpf
|
||||
/* Function to allocate memory for zlib and clear it to 0. */
|
||||
voidpf PNGAPI
|
||||
png_zalloc(voidpf png_ptr, uInt items, uInt size)
|
||||
{
|
||||
png_uint_32 num_bytes = (png_uint_32)items * size;
|
||||
@@ -152,7 +155,7 @@ png_zalloc(voidpf png_ptr, uInt items, uInt size)
|
||||
}
|
||||
|
||||
/* function to free memory for zlib */
|
||||
void
|
||||
void PNGAPI
|
||||
png_zfree(voidpf png_ptr, voidpf ptr)
|
||||
{
|
||||
png_free((png_structp)png_ptr, (png_voidp)ptr);
|
||||
@@ -161,7 +164,7 @@ png_zfree(voidpf png_ptr, voidpf ptr)
|
||||
/* Reset the CRC variable to 32 bits of 1's. Care must be taken
|
||||
* in case CRC is > 32 bits to leave the top bits 0.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_reset_crc(png_structp png_ptr)
|
||||
{
|
||||
png_ptr->crc = crc32(0, Z_NULL, 0);
|
||||
@@ -172,7 +175,7 @@ png_reset_crc(png_structp png_ptr)
|
||||
* also check that this data will actually be used before going to the
|
||||
* trouble of calculating it.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length)
|
||||
{
|
||||
int need_crc = 1;
|
||||
@@ -199,7 +202,7 @@ png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length)
|
||||
* and png_info_init() so that applications that want to use a shared
|
||||
* libpng don't have to be recompiled if png_info changes size.
|
||||
*/
|
||||
png_infop
|
||||
png_infop PNGAPI
|
||||
png_create_info_struct(png_structp png_ptr)
|
||||
{
|
||||
png_infop info_ptr;
|
||||
@@ -224,7 +227,7 @@ png_create_info_struct(png_structp png_ptr)
|
||||
* png_destroy_write_struct() to free an info struct, but this may be
|
||||
* useful for some applications.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
|
||||
{
|
||||
png_infop info_ptr = NULL;
|
||||
@@ -250,7 +253,7 @@ png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
|
||||
* and applications using it are urged to use png_create_info_struct()
|
||||
* instead.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_info_init(png_infop info_ptr)
|
||||
{
|
||||
png_debug(1, "in png_info_init\n");
|
||||
@@ -258,160 +261,258 @@ png_info_init(png_infop info_ptr)
|
||||
png_memset(info_ptr, 0, sizeof (png_info));
|
||||
}
|
||||
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
void PNGAPI
|
||||
png_data_freer(png_structp png_ptr, png_infop info_ptr,
|
||||
int freer, png_uint_32 mask)
|
||||
{
|
||||
png_debug(1, "in png_data_freer\n");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
if(freer == PNG_DESTROY_WILL_FREE_DATA)
|
||||
info_ptr->free_me |= mask;
|
||||
else if(freer == PNG_USER_WILL_FREE_DATA)
|
||||
info_ptr->free_me &= ~mask;
|
||||
else
|
||||
png_warning(png_ptr,
|
||||
"Unknown freer parameter in png_data_freer.");
|
||||
}
|
||||
#endif
|
||||
|
||||
void PNGAPI
|
||||
png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, int num)
|
||||
{
|
||||
png_debug(1, "in png_free_data\n");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
#if defined(PNG_TEXT_SUPPORTED)
|
||||
/* free text item num or (if num == -1) all text items */
|
||||
void
|
||||
png_free_text(png_structp png_ptr, png_infop info_ptr, int num)
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_TEXT) & info_ptr->free_me)
|
||||
#else
|
||||
if (mask & PNG_FREE_TEXT)
|
||||
#endif
|
||||
{
|
||||
if (num != -1)
|
||||
{
|
||||
if (info_ptr->text[num].key)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->text[num].key);
|
||||
info_ptr->text[num].key = NULL;
|
||||
}
|
||||
if (info_ptr->text[num].lang)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->text[num].lang);
|
||||
info_ptr->text[num].lang = NULL;
|
||||
}
|
||||
}
|
||||
else if (info_ptr->text != NULL)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < info_ptr->num_text; i++)
|
||||
png_free_text(png_ptr, info_ptr, i);
|
||||
png_free(png_ptr, info_ptr->text);
|
||||
info_ptr->text = NULL;
|
||||
}
|
||||
if (num != -1)
|
||||
{
|
||||
if (info_ptr->text && info_ptr->text[num].key)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->text[num].key);
|
||||
info_ptr->text[num].key = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < info_ptr->num_text; i++)
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i);
|
||||
png_free(png_ptr, info_ptr->text);
|
||||
info_ptr->text = NULL;
|
||||
info_ptr->num_text=0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_tRNS_SUPPORTED)
|
||||
/* free any tRNS entry */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_TRNS) & info_ptr->free_me)
|
||||
#else
|
||||
if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS))
|
||||
#endif
|
||||
{
|
||||
png_free(png_ptr, info_ptr->trans);
|
||||
info_ptr->valid &= ~PNG_INFO_tRNS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_sCAL_SUPPORTED)
|
||||
/* free any sCAL entry */
|
||||
void
|
||||
png_free_sCAL(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (info_ptr->valid & PNG_INFO_sCAL)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->scal_unit);
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_free(png_ptr, info_ptr->scal_s_width);
|
||||
png_free(png_ptr, info_ptr->scal_s_height);
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_SCAL) & info_ptr->free_me)
|
||||
#else
|
||||
if (mask & PNG_FREE_SCAL)
|
||||
#endif
|
||||
info_ptr->valid &= ~PNG_INFO_sCAL;
|
||||
}
|
||||
{
|
||||
#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
png_free(png_ptr, info_ptr->scal_s_width);
|
||||
png_free(png_ptr, info_ptr->scal_s_height);
|
||||
#endif
|
||||
info_ptr->valid &= ~PNG_INFO_sCAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_pCAL_SUPPORTED)
|
||||
/* free any pCAL entry */
|
||||
void
|
||||
png_free_pCAL(png_structp png_ptr, png_infop info_ptr)
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_PCAL) & info_ptr->free_me)
|
||||
#else
|
||||
if (mask & PNG_FREE_PCAL)
|
||||
#endif
|
||||
{
|
||||
if (info_ptr->valid & PNG_INFO_pCAL)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->pcal_purpose);
|
||||
png_free(png_ptr, info_ptr->pcal_units);
|
||||
if (info_ptr->pcal_params != NULL)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->pcal_params[i]);
|
||||
}
|
||||
png_free(png_ptr, info_ptr->pcal_params);
|
||||
}
|
||||
info_ptr->valid &= ~PNG_INFO_pCAL;
|
||||
}
|
||||
png_free(png_ptr, info_ptr->pcal_purpose);
|
||||
png_free(png_ptr, info_ptr->pcal_units);
|
||||
if (info_ptr->pcal_params != NULL)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
|
||||
png_free(png_ptr, info_ptr->pcal_params[i]);
|
||||
png_free(png_ptr, info_ptr->pcal_params);
|
||||
}
|
||||
info_ptr->valid &= ~PNG_INFO_pCAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_iCCP_SUPPORTED)
|
||||
/* free any pCAL entry */
|
||||
void
|
||||
png_free_iCCP(png_structp png_ptr, png_infop info_ptr)
|
||||
/* free any iCCP entry */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_ICCP) & info_ptr->free_me)
|
||||
#else
|
||||
if (mask & PNG_FREE_ICCP)
|
||||
#endif
|
||||
{
|
||||
if (info_ptr->valid & PNG_INFO_iCCP)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->iccp_name);
|
||||
png_free(png_ptr, info_ptr->iccp_profile);
|
||||
info_ptr->valid &= ~PNG_INFO_iCCP;
|
||||
}
|
||||
png_free(png_ptr, info_ptr->iccp_name);
|
||||
png_free(png_ptr, info_ptr->iccp_profile);
|
||||
info_ptr->valid &= ~PNG_INFO_iCCP;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_sPLT_SUPPORTED)
|
||||
/* free a given sPLT entry, or (if num == -1) all sPLT entries */
|
||||
void
|
||||
png_free_spalette(png_structp png_ptr, png_infop info_ptr, int num)
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_SPLT) & info_ptr->free_me)
|
||||
#else
|
||||
if (mask & PNG_FREE_SPLT)
|
||||
#endif
|
||||
{
|
||||
if (num != -1)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->splt_palettes[num].name);
|
||||
png_free(png_ptr, info_ptr->splt_palettes[num].entries);
|
||||
if(info_ptr->splt_palettes)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->splt_palettes[num].name);
|
||||
png_free(png_ptr, info_ptr->splt_palettes[num].entries);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
png_uint_32 i;
|
||||
if(info_ptr->splt_palettes_num)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i);
|
||||
|
||||
for (i = 0; i < info_ptr->splt_palettes_num; i++)
|
||||
png_free_spalette(png_ptr, info_ptr, num);
|
||||
|
||||
png_free(png_ptr, info_ptr->splt_palettes);
|
||||
info_ptr->splt_palettes_num = 0;
|
||||
png_free(png_ptr, info_ptr->splt_palettes);
|
||||
info_ptr->splt_palettes_num = 0;
|
||||
}
|
||||
info_ptr->valid &= ~PNG_INFO_sPLT;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
void
|
||||
png_free_unknown_chunk(png_structp png_ptr, png_infop info_ptr, int num)
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)
|
||||
#else
|
||||
if (mask & PNG_FREE_UNKN)
|
||||
#endif
|
||||
{
|
||||
if (num != -1)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->unknown_chunks[num].data);
|
||||
info_ptr->unknown_chunks[num].data = NULL;
|
||||
if(info_ptr->unknown_chunks)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->unknown_chunks[num].data);
|
||||
info_ptr->unknown_chunks[num].data = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
png_uint_32 i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < info_ptr->unknown_chunks_num; i++)
|
||||
png_free_unknown_chunk(png_ptr, info_ptr, num);
|
||||
if(info_ptr->unknown_chunks_num)
|
||||
{
|
||||
for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++)
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i);
|
||||
|
||||
png_free(png_ptr, info_ptr->unknown_chunks);
|
||||
info_ptr->unknown_chunks_num = 0;
|
||||
png_free(png_ptr, info_ptr->unknown_chunks);
|
||||
info_ptr->unknown_chunks_num = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_hIST_SUPPORTED)
|
||||
/* free any hIST entry */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_HIST) & info_ptr->free_me)
|
||||
#else
|
||||
if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST))
|
||||
#endif
|
||||
{
|
||||
png_free(png_ptr, info_ptr->hist);
|
||||
info_ptr->valid &= ~PNG_INFO_hIST;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* free any PLTE entry that was internally allocated */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_PLTE) & info_ptr->free_me)
|
||||
#else
|
||||
if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE))
|
||||
#endif
|
||||
{
|
||||
png_zfree(png_ptr, info_ptr->palette);
|
||||
info_ptr->valid &= ~PNG_INFO_PLTE;
|
||||
info_ptr->num_palette = 0;
|
||||
}
|
||||
|
||||
#if defined(PNG_INFO_IMAGE_SUPPORTED)
|
||||
/* free any image bits attached to the info structure */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_ROWS) & info_ptr->free_me)
|
||||
#else
|
||||
if (mask & PNG_FREE_ROWS)
|
||||
#endif
|
||||
{
|
||||
if(info_ptr->row_pointers)
|
||||
{
|
||||
int row;
|
||||
for (row = 0; row < (int)info_ptr->height; row++)
|
||||
png_free(png_ptr, info_ptr->row_pointers[row]);
|
||||
png_free(png_ptr, info_ptr->row_pointers);
|
||||
info_ptr->row_pointers=NULL;
|
||||
}
|
||||
info_ptr->valid &= ~PNG_INFO_IDAT;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if(num == -1)
|
||||
info_ptr->free_me &= ~mask;
|
||||
else
|
||||
info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* This is an internal routine to free any memory that the info struct is
|
||||
* pointing to before re-using it or freeing the struct itself. Recall
|
||||
* that png_free() checks for NULL pointers for us.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_info_destroy(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_debug(1, "in png_info_destroy\n");
|
||||
#if defined(PNG_READ_TEXT_SUPPORTED)
|
||||
png_free_text(png_ptr, info_ptr, -1);
|
||||
#endif
|
||||
#if defined(PNG_READ_sCAL_SUPPORTED)
|
||||
png_free_sCAL(png_ptr, info_ptr);
|
||||
#endif
|
||||
#if defined(PNG_READ_pCAL_SUPPORTED)
|
||||
png_free_pCAL(png_ptr, info_ptr);
|
||||
#endif
|
||||
#if defined(PNG_READ_iCCP_SUPPORTED)
|
||||
png_free_iCCP(png_ptr, info_ptr);
|
||||
#endif
|
||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||
png_free_spalette(png_ptr, info_ptr, -1);
|
||||
#endif
|
||||
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
png_free_unknown_chunk(png_ptr, info_ptr, -1);
|
||||
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
if (png_ptr->num_chunk_list)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->chunk_list);
|
||||
png_ptr->num_chunk_list=0;
|
||||
}
|
||||
#endif
|
||||
|
||||
png_info_init(info_ptr);
|
||||
}
|
||||
|
||||
@@ -419,7 +520,7 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
|
||||
* functions. The application should free any memory associated with this
|
||||
* pointer before png_write_destroy() or png_read_destroy() are called.
|
||||
*/
|
||||
png_voidp
|
||||
png_voidp PNGAPI
|
||||
png_get_io_ptr(png_structp png_ptr)
|
||||
{
|
||||
return (png_ptr->io_ptr);
|
||||
@@ -428,9 +529,11 @@ png_get_io_ptr(png_structp png_ptr)
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
/* Initialize the default input/output functions for the PNG file. If you
|
||||
* use your own read or write routines, you can call either png_set_read_fn()
|
||||
* or png_set_write_fn() instead of png_init_io().
|
||||
* or png_set_write_fn() instead of png_init_io(). If you have defined
|
||||
* PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't
|
||||
* necessarily available.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_init_io(png_structp png_ptr, FILE *fp)
|
||||
{
|
||||
png_debug(1, "in png_init_io\n");
|
||||
@@ -442,7 +545,7 @@ png_init_io(png_structp png_ptr, FILE *fp)
|
||||
/* Convert the supplied time into an RFC 1123 string suitable for use in
|
||||
* a "Creation Time" or other text-based time string.
|
||||
*/
|
||||
png_charp
|
||||
png_charp PNGAPI
|
||||
png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
||||
{
|
||||
static PNG_CONST char short_months[12][4] =
|
||||
@@ -475,24 +578,23 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
||||
}
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
|
||||
#if 0
|
||||
/* Signature string for a PNG file. */
|
||||
png_bytep
|
||||
png_sig_bytes(png_structp png_ptr)
|
||||
png_bytep PNGAPI
|
||||
png_sig_bytes(void)
|
||||
{
|
||||
const png_byte png_sig_numbers[9] = {137, 80, 78, 71, 13, 10, 26, 10, 0};
|
||||
if (png_ptr == NULL) /* silence compiler warning */
|
||||
return ((png_bytep) strdup((png_const_charp)png_sig_numbers));
|
||||
return ((png_bytep) strdup((png_const_charp)png_sig_numbers));
|
||||
return ((png_bytep)"\211\120\116\107\015\012\032\012");
|
||||
}
|
||||
#endif
|
||||
|
||||
png_charp
|
||||
png_charp PNGAPI
|
||||
png_get_copyright(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */
|
||||
return ("\n libpng version 1.0.5h - December 10, 1999\n\
|
||||
return ("\n libpng version 1.0.7beta14 - May 17, 2000\n\
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n\
|
||||
Copyright (c) 1996, 1997 Andreas Dilger\n\
|
||||
Copyright (c) 1998, 1999 Glenn Randers-Pehrson\n");
|
||||
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson\n");
|
||||
return ("");
|
||||
}
|
||||
|
||||
@@ -502,16 +604,16 @@ png_get_copyright(png_structp png_ptr)
|
||||
* in png.h.
|
||||
*/
|
||||
|
||||
png_charp
|
||||
png_charp PNGAPI
|
||||
png_get_libpng_ver(png_structp png_ptr)
|
||||
{
|
||||
/* Version of *.c files used when building libpng */
|
||||
if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
|
||||
return("1.0.5h");
|
||||
return("1.0.5h");
|
||||
return("1.0.7beta14");
|
||||
return("1.0.7beta14");
|
||||
}
|
||||
|
||||
png_charp
|
||||
png_charp PNGAPI
|
||||
png_get_header_ver(png_structp png_ptr)
|
||||
{
|
||||
/* Version of *.h files used when building libpng */
|
||||
@@ -520,7 +622,7 @@ png_get_header_ver(png_structp png_ptr)
|
||||
return(PNG_LIBPNG_VER_STRING);
|
||||
}
|
||||
|
||||
png_charp
|
||||
png_charp PNGAPI
|
||||
png_get_header_version(png_structp png_ptr)
|
||||
{
|
||||
/* Returns longer string containing both version and date */
|
||||
@@ -529,11 +631,33 @@ png_get_header_version(png_structp png_ptr)
|
||||
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_5h png_h_is_not_version_1_0_5h)
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
int PNGAPI
|
||||
png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
|
||||
{
|
||||
if(png_h_is_not_version_1_0_5h == NULL)
|
||||
return;
|
||||
/* check chunk_name and return "keep" value if it's on the list, else 0 */
|
||||
int i;
|
||||
png_bytep p;
|
||||
if((png_ptr == NULL && chunk_name == NULL) || png_ptr->num_chunk_list<=0)
|
||||
return 0;
|
||||
p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5;
|
||||
for (i = png_ptr->num_chunk_list; i; i--, p-=5)
|
||||
if (!png_memcmp(chunk_name, p, 4))
|
||||
return ((int)*(p+4));
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This function, added to libpng-1.0.6g, is untested. */
|
||||
int PNGAPI
|
||||
png_reset_zstream(png_structp png_ptr)
|
||||
{
|
||||
return (inflateReset(&png_ptr->zstream));
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_access_version_number(void)
|
||||
{
|
||||
/* Version of *.c files used when building libpng */
|
||||
return((png_uint_32) 10007L);
|
||||
}
|
||||
|
||||
29
pngasmrd.h
29
pngasmrd.h
@@ -1,32 +1,35 @@
|
||||
/* pngasmrd.h - assembler version of utilities to read a PNG file
|
||||
*
|
||||
* libpng 1.0.5h - December 10, 1999
|
||||
* libpng 1.0.7beta14 - May 17, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1999 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1999, 2000 Glenn Randers-Pehrson
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
|
||||
|
||||
/* Set this in the makefile for VC++ on Pentium, not in pngconf.h */
|
||||
#ifdef PNG_USE_PNGVCRD
|
||||
/* Platform must be Pentium. Makefile must assemble and load pngvcrd.c .
|
||||
* MMX will be detected at run time and used if present.
|
||||
*/
|
||||
#define PNG_HAVE_ASSEMBLER_COMBINE_ROW
|
||||
#define PNG_HAVE_ASSEMBLER_READ_INTERLACE
|
||||
#define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
|
||||
#ifdef PNG_USE_PNGVCRD
|
||||
# define PNG_HAVE_ASSEMBLER_COMBINE_ROW
|
||||
# define PNG_HAVE_ASSEMBLER_READ_INTERLACE
|
||||
# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
|
||||
#endif
|
||||
|
||||
/* Set this in the makefile for gcc on Pentium, not in pngconf.h */
|
||||
#ifdef PNG_USE_PNGGCCRD
|
||||
/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c
|
||||
* (not available in libpng 1.0.5h).
|
||||
/* Set this in the makefile for gcc/as on Pentium, not in pngconf.h */
|
||||
/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c .
|
||||
* MMX will be detected at run time and used if present.
|
||||
*/
|
||||
#define PNG_HAVE_ASSEMBLER_COMBINE_ROW
|
||||
#define PNG_HAVE_ASSEMBLER_READ_INTERLACE
|
||||
#define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
|
||||
#ifdef PNG_USE_PNGGCCRD
|
||||
# define PNG_HAVE_ASSEMBLER_COMBINE_ROW
|
||||
# define PNG_HAVE_ASSEMBLER_READ_INTERLACE
|
||||
# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
|
||||
#endif
|
||||
/*
|
||||
GRR notes:
|
||||
- see pnggccrd.c for info about what is currently enabled
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
563
pngconf.h
563
pngconf.h
@@ -1,11 +1,10 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng 1.0.5h - December 10, 1999
|
||||
* libpng 1.0.7beta14 - May 17, 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 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
*/
|
||||
|
||||
/* Any machine specific code is near the front of this file, so if you
|
||||
@@ -59,6 +58,14 @@
|
||||
* #define PNG_NO_STDIO
|
||||
*/
|
||||
|
||||
#ifdef PNG_BUILD_DLL
|
||||
# ifndef PNG_CONSOLE_IO_SUPPORTED
|
||||
# ifndef PNG_NO_CONSOLE_IO
|
||||
# define PNG_NO_CONSOLE_IO
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
# ifdef PNG_NO_STDIO
|
||||
# ifndef PNG_NO_CONSOLE_IO
|
||||
# define PNG_NO_CONSOLE_IO
|
||||
@@ -111,29 +118,35 @@
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifndef PNG_SETJMP_NOT_SUPPORTED
|
||||
# define PNG_SETJMP_SUPPORTED
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
/* This is an attempt to force a single setjmp behaviour on Linux. If
|
||||
* the X config stuff didn't define _BSD_SOURCE we wouldn't need this.
|
||||
*/
|
||||
#ifdef __linux__
|
||||
#ifdef _BSD_SOURCE
|
||||
#define _PNG_SAVE_BSD_SOURCE
|
||||
#undef _BSD_SOURCE
|
||||
#endif
|
||||
#ifdef _SETJMP_H
|
||||
__png.h__ already includes setjmp.h
|
||||
__dont__ include it again
|
||||
#endif
|
||||
# ifdef __linux__
|
||||
# ifdef _BSD_SOURCE
|
||||
# define _PNG_SAVE_BSD_SOURCE
|
||||
# undef _BSD_SOURCE
|
||||
# endif
|
||||
# ifdef _SETJMP_H
|
||||
__png.h__ already includes setjmp.h
|
||||
__dont__ include it again
|
||||
# endif
|
||||
#endif /* __linux__ */
|
||||
|
||||
/* include setjmp.h for error handling */
|
||||
#include <setjmp.h>
|
||||
|
||||
#ifdef __linux__
|
||||
#ifdef _PNG_SAVE_BSD_SOURCE
|
||||
#define _BSD_SOURCE
|
||||
#undef _PNG_SAVE_BSD_SOURCE
|
||||
#endif
|
||||
#endif /* __linux__ */
|
||||
# ifdef __linux__
|
||||
# ifdef _PNG_SAVE_BSD_SOURCE
|
||||
# define _BSD_SOURCE
|
||||
# undef _PNG_SAVE_BSD_SOURCE
|
||||
# endif
|
||||
# endif /* __linux__ */
|
||||
#endif /* PNG_SETJMP_SUPPORTED */
|
||||
|
||||
#ifdef BSD
|
||||
#include <strings.h>
|
||||
@@ -158,6 +171,7 @@ __dont__ include it again
|
||||
* them inside an appropriate ifdef/endif pair for portability.
|
||||
*/
|
||||
|
||||
#if !defined(PNG_NO_FLOATING_POINT_SUPPORTED)
|
||||
#if defined(MACOS)
|
||||
/* We need to check that <math.h> hasn't already been included earlier
|
||||
* as it seems it doesn't agree with <fp.h>, yet we should really use
|
||||
@@ -169,6 +183,7 @@ __dont__ include it again
|
||||
#else
|
||||
#include <math.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Codewarrior on NT has linking problems without this. */
|
||||
#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__)
|
||||
@@ -247,19 +262,76 @@ __dont__ include it again
|
||||
* things to happen if the library and/or application ever change.
|
||||
*/
|
||||
|
||||
/* Any transformations you will not be using can be undef'ed here */
|
||||
/* Any features you will not be using can be undef'ed here */
|
||||
|
||||
/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user
|
||||
to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS
|
||||
on the compile line, then pick and choose which ones to define without
|
||||
having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED
|
||||
if you only want to have a png-compliant reader/writer but don't need
|
||||
any of the extra transformations. This saves about 80 kbytes in a
|
||||
typical installation of the library. (PNG_NO_* form added in version
|
||||
1.0.1c, for consistency)
|
||||
* to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS
|
||||
* on the compile line, then pick and choose which ones to define without
|
||||
* having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED
|
||||
* if you only want to have a png-compliant reader/writer but don't need
|
||||
* any of the extra transformations. This saves about 80 kbytes in a
|
||||
* typical installation of the library. (PNG_NO_* form added in version
|
||||
* 1.0.1c, for consistency)
|
||||
*/
|
||||
|
||||
/* The size of the png_text structure changed in libpng-1.0.6 when
|
||||
* iTXt is supported. It is turned off by default, to support old apps
|
||||
* that malloc the png_text structure instead of calling png_set_text()
|
||||
* and letting libpng malloc it. It will be turned on by default in
|
||||
* libpng-2.0.0.
|
||||
*/
|
||||
|
||||
#ifndef PNG_iTXt_SUPPORTED
|
||||
# ifndef PNG_READ_iTXt_SUPPORTED
|
||||
# define PNG_NO_READ_iTXt
|
||||
# endif
|
||||
# ifndef PNG_WRITE_iTXt_SUPPORTED
|
||||
# define PNG_NO_WRITE_iTXt
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The following support, added after version 1.0.0, can be turned off here en
|
||||
* masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility
|
||||
* with old applications that require the length of png_struct and png_info
|
||||
* to remain unchanged.
|
||||
*/
|
||||
|
||||
#ifdef PNG_LEGACY_SUPPORTED
|
||||
#define PNG_NO_FREE_ME
|
||||
#define PNG_NO_READ_UNKNOWN_CHUNKS
|
||||
#define PNG_NO_WRITE_UNKNOWN_CHUNKS
|
||||
#define PNG_NO_READ_USER_CHUNKS
|
||||
#define PNG_NO_READ_iCCP
|
||||
#define PNG_NO_WRITE_iCCP
|
||||
#define PNG_NO_READ_iTXt
|
||||
#define PNG_NO_WRITE_iTXt
|
||||
#define PNG_NO_READ_sCAL
|
||||
#define PNG_NO_WRITE_sCAL
|
||||
#define PNG_NO_READ_sPLT
|
||||
#define PNG_NO_WRITE_sPLT
|
||||
#define PNG_NO_INFO_IMAGE
|
||||
#define PNG_NO_READ_RGB_TO_GRAY
|
||||
#define PNG_NO_READ_USER_TRANSFORM
|
||||
#define PNG_NO_WRITE_USER_TRANSFORM
|
||||
#define PNG_NO_USER_MEM
|
||||
#define PNG_NO_READ_EMPTY_PLTE
|
||||
#define PNG_NO_FIXED_POINT_SUPPORTED
|
||||
#endif
|
||||
|
||||
#ifndef PNG_NO_FLOATING_POINT_SUPPORTED
|
||||
#define PNG_FLOATING_POINT_SUPPORTED
|
||||
#endif
|
||||
|
||||
/* Ignore attempt to turn off both floating and fixed point support */
|
||||
|
||||
#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \
|
||||
!defined(PNG_NO_FIXED_POINT_SUPPORTED)
|
||||
#define PNG_FIXED_POINT_SUPPORTED
|
||||
#endif
|
||||
|
||||
#ifndef PNG_NO_FREE_ME
|
||||
#define PNG_FREE_ME_SUPPORTED
|
||||
#endif
|
||||
|
||||
#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
|
||||
!defined(PNG_NO_READ_TRANSFORMS)
|
||||
@@ -334,9 +406,11 @@ __dont__ include it again
|
||||
/* still have interlacing unless you change the following line: */
|
||||
#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */
|
||||
|
||||
#ifndef PNG_NO_READ_COMPOSITED_NODIV
|
||||
#ifndef PNG_NO_READ_COMPOSITE_NODIV
|
||||
#ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */
|
||||
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel and SGI */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef PNG_NO_READ_EMPTY_PLTE
|
||||
#define PNG_READ_EMPTY_PLTE_SUPPORTED /* useful for MNG applications */
|
||||
@@ -375,11 +449,19 @@ __dont__ include it again
|
||||
#endif
|
||||
#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
#ifndef PNG_NO_USER_TRANSFORM_PTR
|
||||
#define PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant
|
||||
encoders, but can cause trouble
|
||||
if left undefined */
|
||||
|
||||
#ifndef PNG_NO_WRITE_WEIGHTED_FILTER
|
||||
#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \
|
||||
defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
#endif
|
||||
|
||||
@@ -415,34 +497,19 @@ __dont__ include it again
|
||||
#define PNG_EASY_ACCESS_SUPPORTED
|
||||
#endif
|
||||
|
||||
#ifndef PNG_NO_ASSEMBLER_CODE
|
||||
#if defined(PNG_USE_PNGVCRD) || defined(PNG_USE_PNGGCCRD) && \
|
||||
!defined(PNG_NO_ASSEMBLER_CODE)
|
||||
#define PNG_ASSEMBLER_CODE_SUPPORTED
|
||||
#endif
|
||||
|
||||
#ifndef PNG_NO_FLOATING_POINT_SUPPORTED
|
||||
#define PNG_FLOATING_POINT_SUPPORTED
|
||||
#endif
|
||||
|
||||
#ifndef PNG_NO_FIXED_POINT_SUPPORTED
|
||||
#define PNG_FIXED_POINT_SUPPORTED
|
||||
#endif
|
||||
|
||||
/* Do not use global arrays (helps with building DLL's)
|
||||
* They are no longer used in libpng itself, since version 1.0.5c,
|
||||
* but might be required for some pre-1.0.5c applications.
|
||||
*/
|
||||
#ifdef PNG_NO_GLOBAL_ARRAYS
|
||||
#define PNG_USE_LOCAL_ARRAYS
|
||||
#else
|
||||
#define PNG_USE_GLOBAL_ARRAYS
|
||||
#endif
|
||||
|
||||
/* These are currently experimental features, define them if you want */
|
||||
|
||||
/* very little testing */
|
||||
/*
|
||||
#define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
|
||||
#ifndef PNG_NO_USER_MEM
|
||||
#define PNG_USER_MEM_SUPPORTED
|
||||
#endif
|
||||
*/
|
||||
|
||||
/* This is only for PowerPC big-endian and 680x0 systems */
|
||||
@@ -473,209 +540,249 @@ __dont__ include it again
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
|
||||
|
||||
#ifdef PNG_NO_READ_TEXT
|
||||
# define PNG_NO_READ_iTXt
|
||||
# define PNG_NO_READ_tEXt
|
||||
# define PNG_NO_READ_zTXt
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_bKGD
|
||||
#define PNG_READ_bKGD_SUPPORTED
|
||||
#define PNG_bKGD_SUPPORTED
|
||||
# define PNG_READ_bKGD_SUPPORTED
|
||||
# define PNG_bKGD_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_cHRM
|
||||
#define PNG_READ_cHRM_SUPPORTED
|
||||
#define PNG_cHRM_SUPPORTED
|
||||
# define PNG_READ_cHRM_SUPPORTED
|
||||
# define PNG_cHRM_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_gAMA
|
||||
#define PNG_READ_gAMA_SUPPORTED
|
||||
#define PNG_gAMA_SUPPORTED
|
||||
# define PNG_READ_gAMA_SUPPORTED
|
||||
# define PNG_gAMA_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_hIST
|
||||
#define PNG_READ_hIST_SUPPORTED
|
||||
#define PNG_hIST_SUPPORTED
|
||||
# define PNG_READ_hIST_SUPPORTED
|
||||
# define PNG_hIST_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_iCCP
|
||||
#define PNG_READ_iCCP_SUPPORTED
|
||||
#define PNG_iCCP_SUPPORTED
|
||||
# define PNG_READ_iCCP_SUPPORTED
|
||||
# define PNG_iCCP_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_iTXt
|
||||
#define PNG_READ_iTXt_SUPPORTED
|
||||
#define PNG_iTXt_SUPPORTED
|
||||
# define PNG_READ_iTXt_SUPPORTED
|
||||
# define PNG_iTXt_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_oFFs
|
||||
#define PNG_READ_oFFs_SUPPORTED
|
||||
#define PNG_oFFs_SUPPORTED
|
||||
# define PNG_READ_oFFs_SUPPORTED
|
||||
# define PNG_oFFs_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_pCAL
|
||||
#define PNG_READ_pCAL_SUPPORTED
|
||||
#define PNG_pCAL_SUPPORTED
|
||||
# define PNG_READ_pCAL_SUPPORTED
|
||||
# define PNG_pCAL_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_sCAL
|
||||
#define PNG_READ_sCAL_SUPPORTED
|
||||
#define PNG_sCAL_SUPPORTED
|
||||
# define PNG_READ_sCAL_SUPPORTED
|
||||
# define PNG_sCAL_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_pHYs
|
||||
#define PNG_READ_pHYs_SUPPORTED
|
||||
#define PNG_pHYs_SUPPORTED
|
||||
# define PNG_READ_pHYs_SUPPORTED
|
||||
# define PNG_pHYs_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_sBIT
|
||||
#define PNG_READ_sBIT_SUPPORTED
|
||||
#define PNG_sBIT_SUPPORTED
|
||||
# define PNG_READ_sBIT_SUPPORTED
|
||||
# define PNG_sBIT_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_sPLT
|
||||
#define PNG_READ_sPLT_SUPPORTED
|
||||
#define PNG_sPLT_SUPPORTED
|
||||
# define PNG_READ_sPLT_SUPPORTED
|
||||
# define PNG_sPLT_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_sRGB
|
||||
#define PNG_READ_sRGB_SUPPORTED
|
||||
#define PNG_sRGB_SUPPORTED
|
||||
# define PNG_READ_sRGB_SUPPORTED
|
||||
# define PNG_sRGB_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_tEXt
|
||||
#define PNG_READ_tEXt_SUPPORTED
|
||||
#define PNG_tEXt_SUPPORTED
|
||||
# define PNG_READ_tEXt_SUPPORTED
|
||||
# define PNG_tEXt_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_tIME
|
||||
#define PNG_READ_tIME_SUPPORTED
|
||||
#define PNG_tIME_SUPPORTED
|
||||
# define PNG_READ_tIME_SUPPORTED
|
||||
# define PNG_tIME_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_tRNS
|
||||
#define PNG_READ_tRNS_SUPPORTED
|
||||
#define PNG_tRNS_SUPPORTED
|
||||
# define PNG_READ_tRNS_SUPPORTED
|
||||
# define PNG_tRNS_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_zTXt
|
||||
#define PNG_READ_zTXt_SUPPORTED
|
||||
#define PNG_zTXt_SUPPORTED
|
||||
# define PNG_READ_zTXt_SUPPORTED
|
||||
# define PNG_zTXt_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
|
||||
#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# define PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# endif
|
||||
# ifndef PNG_NO_HANDLE_AS_UNKNOWN
|
||||
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
#if !defined (PNG_NO_READ_USER_CHUNKS) && \
|
||||
defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
# define PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
# define PNG_USER_CHUNKS_SUPPORTED
|
||||
# ifdef PNG_NO_READ_UNKNOWN_CHUNKS
|
||||
# undef PNG_NO_READ_UNKNOWN_CHUNKS
|
||||
# endif
|
||||
# ifdef PNG_NO_HANDLE_AS_UNKNOWN
|
||||
# undef PNG_NO_HANDLE_AS_UNKNOWN
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_OPT_PLTE
|
||||
#define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the optional */
|
||||
#endif /* PLTE chunk in RGB and RGBA images */
|
||||
# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */
|
||||
#endif /* optional PLTE chunk in RGB and RGBA images */
|
||||
#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \
|
||||
defined(PNG_READ_zTXt_SUPPORTED)
|
||||
#define PNG_READ_TEXT_SUPPORTED
|
||||
#define PNG_TEXT_SUPPORTED
|
||||
# define PNG_READ_TEXT_SUPPORTED
|
||||
# define PNG_TEXT_SUPPORTED
|
||||
#endif
|
||||
#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
|
||||
|
||||
#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#ifndef PNG_NO_WRITE_bKGD
|
||||
#define PNG_WRITE_bKGD_SUPPORTED
|
||||
#ifndef PNG_bKGD_SUPPORTED
|
||||
# define PNG_bKGD_SUPPORTED
|
||||
#ifdef PNG_NO_WRITE_TEXT
|
||||
# define PNG_NO_WRITE_iTXt
|
||||
# define PNG_NO_WRITE_tEXt
|
||||
# define PNG_NO_WRITE_zTXt
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_bKGD
|
||||
# define PNG_WRITE_bKGD_SUPPORTED
|
||||
# ifndef PNG_bKGD_SUPPORTED
|
||||
# define PNG_bKGD_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_cHRM
|
||||
#define PNG_WRITE_cHRM_SUPPORTED
|
||||
#ifndef PNG_cHRM_SUPPORTED
|
||||
# define PNG_cHRM_SUPPORTED
|
||||
#endif
|
||||
# define PNG_WRITE_cHRM_SUPPORTED
|
||||
# ifndef PNG_cHRM_SUPPORTED
|
||||
# define PNG_cHRM_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_gAMA
|
||||
#define PNG_WRITE_gAMA_SUPPORTED
|
||||
#ifndef PNG_gAMA_SUPPORTED
|
||||
# define PNG_gAMA_SUPPORTED
|
||||
#endif
|
||||
# define PNG_WRITE_gAMA_SUPPORTED
|
||||
# ifndef PNG_gAMA_SUPPORTED
|
||||
# define PNG_gAMA_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_hIST
|
||||
#define PNG_WRITE_hIST_SUPPORTED
|
||||
#ifndef PNG_hIST_SUPPORTED
|
||||
# define PNG_hIST_SUPPORTED
|
||||
#endif
|
||||
# define PNG_WRITE_hIST_SUPPORTED
|
||||
# ifndef PNG_hIST_SUPPORTED
|
||||
# define PNG_hIST_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_iCCP
|
||||
#define PNG_WRITE_iCCP_SUPPORTED
|
||||
#ifndef PNG_iCCP_SUPPORTED
|
||||
# define PNG_iCCP_SUPPORTED
|
||||
#endif
|
||||
# define PNG_WRITE_iCCP_SUPPORTED
|
||||
# ifndef PNG_iCCP_SUPPORTED
|
||||
# define PNG_iCCP_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_iTXt
|
||||
#define PNG_WRITE_iTXt_SUPPORTED
|
||||
#ifndef PNG_iTXt_SUPPORTED
|
||||
# define PNG_iTXt_SUPPORTED
|
||||
#endif
|
||||
# define PNG_WRITE_iTXt_SUPPORTED
|
||||
# ifndef PNG_iTXt_SUPPORTED
|
||||
# define PNG_iTXt_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_oFFs
|
||||
#define PNG_WRITE_oFFs_SUPPORTED
|
||||
#ifndef PNG_oFFs_SUPPORTED
|
||||
# define PNG_oFFs_SUPPORTED
|
||||
#endif
|
||||
# define PNG_WRITE_oFFs_SUPPORTED
|
||||
# ifndef PNG_oFFs_SUPPORTED
|
||||
# define PNG_oFFs_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_pCAL
|
||||
#define PNG_WRITE_pCAL_SUPPORTED
|
||||
#ifndef PNG_pCAL_SUPPORTED
|
||||
# define PNG_pCAL_SUPPORTED
|
||||
#endif
|
||||
# define PNG_WRITE_pCAL_SUPPORTED
|
||||
# ifndef PNG_pCAL_SUPPORTED
|
||||
# define PNG_pCAL_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_sCAL
|
||||
#define PNG_WRITE_sCAL_SUPPORTED
|
||||
#ifndef PNG_sCAL_SUPPORTED
|
||||
# define PNG_sCAL_SUPPORTED
|
||||
#endif
|
||||
# define PNG_WRITE_sCAL_SUPPORTED
|
||||
# ifndef PNG_sCAL_SUPPORTED
|
||||
# define PNG_sCAL_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_pHYs
|
||||
#define PNG_WRITE_pHYs_SUPPORTED
|
||||
#ifndef PNG_pHYs_SUPPORTED
|
||||
# define PNG_pHYs_SUPPORTED
|
||||
#endif
|
||||
# define PNG_WRITE_pHYs_SUPPORTED
|
||||
# ifndef PNG_pHYs_SUPPORTED
|
||||
# define PNG_pHYs_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_sBIT
|
||||
#define PNG_WRITE_sBIT_SUPPORTED
|
||||
#ifndef PNG_sBIT_SUPPORTED
|
||||
# define PNG_sBIT_SUPPORTED
|
||||
#endif
|
||||
# define PNG_WRITE_sBIT_SUPPORTED
|
||||
# ifndef PNG_sBIT_SUPPORTED
|
||||
# define PNG_sBIT_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_sPLT
|
||||
#define PNG_WRITE_sPLT_SUPPORTED
|
||||
#ifndef PNG_sPLT_SUPPORTED
|
||||
# define PNG_sPLT_SUPPORTED
|
||||
#endif
|
||||
# define PNG_WRITE_sPLT_SUPPORTED
|
||||
# ifndef PNG_sPLT_SUPPORTED
|
||||
# define PNG_sPLT_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_sRGB
|
||||
#define PNG_WRITE_sRGB_SUPPORTED
|
||||
#ifndef PNG_sRGB_SUPPORTED
|
||||
# define PNG_sRGB_SUPPORTED
|
||||
#endif
|
||||
# define PNG_WRITE_sRGB_SUPPORTED
|
||||
# ifndef PNG_sRGB_SUPPORTED
|
||||
# define PNG_sRGB_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_tEXt
|
||||
#define PNG_WRITE_tEXt_SUPPORTED
|
||||
#ifndef PNG_tEXt_SUPPORTED
|
||||
# define PNG_tEXt_SUPPORTED
|
||||
#endif
|
||||
# define PNG_WRITE_tEXt_SUPPORTED
|
||||
# ifndef PNG_tEXt_SUPPORTED
|
||||
# define PNG_tEXt_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_tIME
|
||||
#define PNG_WRITE_tIME_SUPPORTED
|
||||
#ifndef PNG_tIME_SUPPORTED
|
||||
# define PNG_tIME_SUPPORTED
|
||||
#endif
|
||||
# define PNG_WRITE_tIME_SUPPORTED
|
||||
# ifndef PNG_tIME_SUPPORTED
|
||||
# define PNG_tIME_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_tRNS
|
||||
#define PNG_WRITE_tRNS_SUPPORTED
|
||||
#ifndef PNG_tRNS_SUPPORTED
|
||||
# define PNG_tRNS_SUPPORTED
|
||||
#endif
|
||||
# define PNG_WRITE_tRNS_SUPPORTED
|
||||
# ifndef PNG_tRNS_SUPPORTED
|
||||
# define PNG_tRNS_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_zTXt
|
||||
#define PNG_WRITE_zTXt_SUPPORTED
|
||||
#ifndef PNG_zTXt_SUPPORTED
|
||||
# define PNG_zTXt_SUPPORTED
|
||||
#endif
|
||||
# define PNG_WRITE_zTXt_SUPPORTED
|
||||
# ifndef PNG_zTXt_SUPPORTED
|
||||
# define PNG_zTXt_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
|
||||
#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# define PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#endif
|
||||
# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# define PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# endif
|
||||
# ifndef PNG_NO_HANDLE_AS_UNKNOWN
|
||||
# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
|
||||
defined(PNG_WRITE_zTXt_SUPPORTED)
|
||||
#define PNG_WRITE_TEXT_SUPPORTED
|
||||
#ifndef PNG_TEXT_SUPPORTED
|
||||
# define PNG_TEXT_SUPPORTED
|
||||
#endif
|
||||
# define PNG_WRITE_TEXT_SUPPORTED
|
||||
# ifndef PNG_TEXT_SUPPORTED
|
||||
# define PNG_TEXT_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
|
||||
|
||||
/* Turn this off to disable png_read_png() and
|
||||
* png_write_png() and leave the row_pointers member
|
||||
* out of the info structure.
|
||||
*/
|
||||
#ifndef PNG_NO_INFO_IMAGE
|
||||
# define PNG_INFO_IMAGE_SUPPORTED
|
||||
#endif
|
||||
|
||||
/* need the time information for reading tIME chunks */
|
||||
#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
|
||||
#include <time.h>
|
||||
#if defined(PNG_tIME_SUPPORTED)
|
||||
# include <time.h>
|
||||
#endif
|
||||
|
||||
/* Some typedefs to get us started. These should be safe on most of the
|
||||
@@ -758,6 +865,10 @@ typedef size_t png_size_t;
|
||||
#define FARDATA
|
||||
#endif
|
||||
|
||||
/* Typedef for floating-point numbers that are converted
|
||||
to fixed-point with a multiple of 100,000, e.g., int_gamma */
|
||||
typedef png_int_32 png_fixed_point;
|
||||
|
||||
/* Add typedefs for pointers */
|
||||
typedef void FAR * png_voidp;
|
||||
typedef png_byte FAR * png_bytep;
|
||||
@@ -767,6 +878,7 @@ typedef png_uint_16 FAR * png_uint_16p;
|
||||
typedef png_int_16 FAR * png_int_16p;
|
||||
typedef PNG_CONST char FAR * png_const_charp;
|
||||
typedef char FAR * png_charp;
|
||||
typedef png_fixed_point FAR * png_fixed_point_p;
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
typedef double FAR * png_doublep;
|
||||
#endif
|
||||
@@ -779,6 +891,7 @@ typedef png_uint_16 FAR * FAR * png_uint_16pp;
|
||||
typedef png_int_16 FAR * FAR * png_int_16pp;
|
||||
typedef PNG_CONST char FAR * FAR * png_const_charpp;
|
||||
typedef char FAR * FAR * png_charpp;
|
||||
typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
typedef double FAR * FAR * png_doublepp;
|
||||
#endif
|
||||
@@ -794,60 +907,112 @@ typedef charf * png_zcharp;
|
||||
typedef charf * FAR * png_zcharpp;
|
||||
typedef z_stream FAR * png_zstreamp;
|
||||
|
||||
/*
|
||||
* Define PNG_BUILD_DLL if the module being built is a Windows
|
||||
* LIBPNG DLL.
|
||||
*
|
||||
* Define PNG_DLL if you want to *link* to the Windows LIBPNG DLL.
|
||||
* It is equivalent to Microsoft predefined macro _DLL which is
|
||||
* automatically defined when you compile using the share
|
||||
* version of the CRT (C Run-Time library)
|
||||
*/
|
||||
|
||||
#ifndef PNG_EXPORT
|
||||
/* allow for compilation as dll under MS Windows */
|
||||
# ifdef __WIN32DLL__
|
||||
# define PNG_EXPORT(type,symbol) __declspec(dllexport) type symbol
|
||||
#if !defined(PNG_DLL) && defined(PNG_BUILD_DLL)
|
||||
# define PNG_DLL
|
||||
#endif
|
||||
|
||||
/* Do not use global arrays (helps with building DLL's)
|
||||
* They are no longer used in libpng itself, since version 1.0.5c,
|
||||
* but might be required for some pre-1.0.5c applications.
|
||||
*/
|
||||
#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
|
||||
# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL))
|
||||
# define PNG_USE_LOCAL_ARRAYS
|
||||
# else
|
||||
# define PNG_USE_GLOBAL_ARRAYS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF)
|
||||
# define PNG_IMPEXP
|
||||
#endif
|
||||
|
||||
#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \
|
||||
defined(_Windows) || defined(_WINDOWS) || \
|
||||
defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
|
||||
|
||||
# define PNGAPI _cdecl
|
||||
|
||||
# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \
|
||||
0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */)
|
||||
# define PNG_IMPEXP
|
||||
# endif
|
||||
|
||||
/* this variant is used in Mozilla; may correspond to MSVC++ 6.0 changes */
|
||||
# ifdef ALT_WIN32_DLL
|
||||
# define PNG_EXPORT(type,symbol) type __attribute__((dllexport)) symbol
|
||||
# endif
|
||||
# if !defined(PNG_IMPEXP)
|
||||
|
||||
/* allow for compilation as dll with Borland C++ 5.0 */
|
||||
# if defined(__BORLANDC__) && defined(_Windows) && defined(__DLL__)
|
||||
# define PNG_EXPORT(type,symbol) type _export symbol
|
||||
# endif
|
||||
# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol
|
||||
# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol
|
||||
|
||||
/* allow for compilation as shared lib under BeOS */
|
||||
# ifdef __BEOSDLL__
|
||||
# define PNG_EXPORT(type,symbol) __declspec(export) type symbol
|
||||
/* Borland/Microsoft */
|
||||
# if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500)
|
||||
# define PNG_EXPORT PNG_EXPORT_TYPE1
|
||||
# else
|
||||
# define PNG_EXPORT PNG_EXPORT_TYPE2
|
||||
# if defined(PNG_BUILD_DLL)
|
||||
# define PNG_IMPEXP __export
|
||||
# else
|
||||
# define PNG_IMPEXP /*__import*/ /* doesn't exist AFAIK in
|
||||
VC++*/
|
||||
# endif /* Exists in Borland C++ for
|
||||
C++ classes (== huge) */
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if !defined(PNG_IMPEXP)
|
||||
# if defined(PNG_BUILD_DLL)
|
||||
# define PNG_IMPEXP __declspec(dllexport)
|
||||
# else
|
||||
# define PNG_IMPEXP __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
# endif /* PNG_IMPEXP */
|
||||
#else
|
||||
# if 0 /* ... other platforms, with other meanings */
|
||||
# else
|
||||
# define PNGAPI
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef PNG_EXPORT
|
||||
# define PNG_EXPORT(type,symbol) type symbol
|
||||
# define PNG_EXPORT(type,symbol) type PNGAPI symbol
|
||||
#endif
|
||||
|
||||
#if defined(__MINGW32__) || defined(__CYGWIN32__)
|
||||
# define PNG_ATTR_DLLIMP
|
||||
#endif
|
||||
|
||||
#ifdef PNG_USE_GLOBAL_ARRAYS
|
||||
#ifndef PNG_EXPORT_VAR
|
||||
# ifdef PNG_DECL_DLLEXP
|
||||
# define PNG_EXPORT_VAR(type) extern __declspec(dllexport) type
|
||||
# endif
|
||||
# ifdef PNG_ATTR_DLLEXP
|
||||
# define PNG_EXPORT_VAR(type) extern type __attribute__((dllexport))
|
||||
# endif
|
||||
# ifdef PNG_DECL_DLLIMP
|
||||
# define PNG_EXPORT_VAR(type) extern __declspec(dllimport) type
|
||||
# endif
|
||||
# ifdef PNG_ATTR_DLLIMP
|
||||
# define PNG_EXPORT_VAR(type) extern type __attribute__((dllimport))
|
||||
# endif
|
||||
# define PNG_EXPORT_VAR(type) extern type
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef PNG_EXPORT_VAR
|
||||
# define PNG_EXPORT_VAR(type) extern type
|
||||
#endif
|
||||
|
||||
/* User may want to use these so not in PNG_INTERNAL. Any library functions
|
||||
* that are passed far data must be model independent.
|
||||
/* User may want to use these so they are not in PNG_INTERNAL. Any library
|
||||
* functions that are passed far data must be model independent.
|
||||
*/
|
||||
|
||||
#ifndef PNG_ABORT
|
||||
# define PNG_ABORT() abort()
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
|
||||
#else
|
||||
# define png_jmpbuf(png_ptr) \
|
||||
(LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED)
|
||||
#endif
|
||||
|
||||
#if defined(USE_FAR_KEYWORD) /* memory model independent fns */
|
||||
/* use this to make far-to-near assignments */
|
||||
# define CHECK 1
|
||||
|
||||
53
pngerror.c
53
pngerror.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* libpng 1.0.5h - December 10, 1999
|
||||
* libpng 1.0.7beta14 - May 17, 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 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
*
|
||||
* This file provides a location for all error handling. Users who
|
||||
* need special error handling are expected to write replacement functions
|
||||
@@ -16,9 +16,11 @@
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
static void png_default_error PNGARG((png_structp png_ptr,
|
||||
static void /* PRIVATE */
|
||||
png_default_error PNGARG((png_structp png_ptr,
|
||||
png_const_charp message));
|
||||
static void png_default_warning PNGARG((png_structp png_ptr,
|
||||
static void /* PRIVATE */
|
||||
png_default_warning PNGARG((png_structp png_ptr,
|
||||
png_const_charp message));
|
||||
|
||||
/* This function is called whenever there is a fatal error. This function
|
||||
@@ -26,7 +28,7 @@ static void png_default_warning PNGARG((png_structp png_ptr,
|
||||
* you should supply a replacement error function and use png_set_error_fn()
|
||||
* to replace the error function at run-time.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_error(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
if (png_ptr->error_fn != NULL)
|
||||
@@ -42,7 +44,7 @@ png_error(png_structp png_ptr, png_const_charp message)
|
||||
* you should supply a replacement warning function and use
|
||||
* png_set_error_fn() to replace the warning function at run-time.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_warning(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
if (png_ptr->warning_fn != NULL)
|
||||
@@ -62,26 +64,31 @@ static PNG_CONST char png_digit[16] = {
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
|
||||
};
|
||||
|
||||
static void
|
||||
static void /* PRIVATE */
|
||||
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp message)
|
||||
{
|
||||
int iout = 0, iin = 0;
|
||||
|
||||
while (iin < 4) {
|
||||
while (iin < 4)
|
||||
{
|
||||
int c = png_ptr->chunk_name[iin++];
|
||||
if (isnonalpha(c)) {
|
||||
if (isnonalpha(c))
|
||||
{
|
||||
buffer[iout++] = '[';
|
||||
buffer[iout++] = png_digit[(c & 0xf0) >> 4];
|
||||
buffer[iout++] = png_digit[c & 0xf];
|
||||
buffer[iout++] = png_digit[c & 0x0f];
|
||||
buffer[iout++] = ']';
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[iout++] = (png_byte)c;
|
||||
}
|
||||
}
|
||||
|
||||
if (message == NULL)
|
||||
buffer[iout] = 0;
|
||||
else {
|
||||
else
|
||||
{
|
||||
buffer[iout++] = ':';
|
||||
buffer[iout++] = ' ';
|
||||
png_memcpy(buffer+iout, message, 64);
|
||||
@@ -89,7 +96,7 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp message
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_chunk_error(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
char msg[16+64];
|
||||
@@ -97,7 +104,7 @@ png_chunk_error(png_structp png_ptr, png_const_charp message)
|
||||
png_error(png_ptr, msg);
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_chunk_warning(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
char msg[16+64];
|
||||
@@ -110,21 +117,27 @@ png_chunk_warning(png_structp png_ptr, png_const_charp message)
|
||||
* function is used by default, or if the program supplies NULL for the
|
||||
* error function pointer in png_set_error_fn().
|
||||
*/
|
||||
static void
|
||||
static void /* PRIVATE */
|
||||
png_default_error(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
#ifndef PNG_NO_CONSOLE_IO
|
||||
fprintf(stderr, "libpng error: %s\n", message);
|
||||
#endif
|
||||
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
# ifdef USE_FAR_KEYWORD
|
||||
{
|
||||
jmp_buf jmpbuf;
|
||||
png_memcpy(jmpbuf,png_ptr->jmpbuf,sizeof(jmp_buf));
|
||||
longjmp(jmpbuf, 1);
|
||||
}
|
||||
#else
|
||||
# else
|
||||
longjmp(png_ptr->jmpbuf, 1);
|
||||
# endif
|
||||
#else
|
||||
if (png_ptr == NULL)
|
||||
/* make compiler happy */ ;
|
||||
PNG_ABORT();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -133,7 +146,7 @@ png_default_error(png_structp png_ptr, png_const_charp message)
|
||||
* here if you don't want them to. In the default configuration, png_ptr is
|
||||
* not used, but it is passed in case it may be useful.
|
||||
*/
|
||||
static void
|
||||
static void /* PRIVATE */
|
||||
png_default_warning(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
#ifndef PNG_NO_CONSOLE_IO
|
||||
@@ -148,7 +161,7 @@ png_default_warning(png_structp png_ptr, png_const_charp message)
|
||||
* return to the calling routine or serious problems will occur. The return
|
||||
* method used in the default routine calls longjmp(png_ptr->jmpbuf, 1)
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
||||
png_error_ptr error_fn, png_error_ptr warning_fn)
|
||||
{
|
||||
@@ -162,7 +175,7 @@ png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
||||
* functions. The application should free any memory associated with this
|
||||
* pointer before png_write_destroy and png_read_destroy are called.
|
||||
*/
|
||||
png_voidp
|
||||
png_voidp PNGAPI
|
||||
png_get_error_ptr(png_structp png_ptr)
|
||||
{
|
||||
return ((png_voidp)png_ptr->error_ptr);
|
||||
|
||||
4651
pnggccrd.c
Normal file
4651
pnggccrd.c
Normal file
File diff suppressed because it is too large
Load Diff
196
pngget.c
196
pngget.c
@@ -1,17 +1,17 @@
|
||||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* libpng 1.0.5h - December 10, 1999
|
||||
* libpng 1.0.7beta14 - May 17, 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 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -20,7 +20,7 @@ png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
|
||||
return(0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -29,9 +29,20 @@ png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
|
||||
return(0);
|
||||
}
|
||||
|
||||
#if defined(PNG_INFO_IMAGE_SUPPORTED)
|
||||
png_bytepp PNGAPI
|
||||
png_get_rows(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return(info_ptr->row_pointers);
|
||||
else
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_EASY_ACCESS_SUPPORTED
|
||||
/* easy access to info, added in libpng-0.99 */
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_image_width(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -41,7 +52,7 @@ png_get_image_width(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_image_height(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -51,7 +62,7 @@ png_get_image_height(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte
|
||||
png_byte PNGAPI
|
||||
png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -61,7 +72,7 @@ png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte
|
||||
png_byte PNGAPI
|
||||
png_get_color_type(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -71,7 +82,7 @@ png_get_color_type(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte
|
||||
png_byte PNGAPI
|
||||
png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -81,7 +92,7 @@ png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte
|
||||
png_byte PNGAPI
|
||||
png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -91,7 +102,7 @@ png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte
|
||||
png_byte PNGAPI
|
||||
png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -101,7 +112,7 @@ png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_pHYs_SUPPORTED)
|
||||
@@ -117,7 +128,7 @@ png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_pHYs_SUPPORTED)
|
||||
@@ -133,7 +144,7 @@ png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_pHYs_SUPPORTED)
|
||||
@@ -151,7 +162,7 @@ png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||
}
|
||||
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
float
|
||||
float PNGAPI
|
||||
png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_pHYs_SUPPORTED)
|
||||
@@ -170,7 +181,7 @@ png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
|
||||
}
|
||||
#endif
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_oFFs_SUPPORTED)
|
||||
@@ -186,7 +197,7 @@ png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_oFFs_SUPPORTED)
|
||||
@@ -202,7 +213,7 @@ png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_oFFs_SUPPORTED)
|
||||
@@ -218,7 +229,7 @@ png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_oFFs_SUPPORTED)
|
||||
@@ -235,49 +246,49 @@ png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
||||
}
|
||||
|
||||
#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr)
|
||||
*.03937 +.5)
|
||||
*.0254 +.5);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr)
|
||||
*.03937 +.5)
|
||||
*.0254 +.5);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr)
|
||||
*.03937 +.5)
|
||||
*.0254 +.5);
|
||||
}
|
||||
|
||||
float
|
||||
float PNGAPI
|
||||
png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
return ((float)png_get_x_offset_microns(png_ptr, info_ptr)
|
||||
*.03937/1000000. +.5)
|
||||
*.00003937);
|
||||
}
|
||||
|
||||
float
|
||||
float PNGAPI
|
||||
png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
|
||||
*.03937/1000000. +.5)
|
||||
*.00003937)
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED)
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
|
||||
{
|
||||
png_uint_32 retval = 0;
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_pHYs)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "pHYs");
|
||||
if (res_x != NULL)
|
||||
@@ -296,21 +307,21 @@ png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
|
||||
retval |= PNG_INFO_pHYs;
|
||||
if(unit_type == 1)
|
||||
{
|
||||
if (res_x != NULL) *res_x = (png_uint_32)(*res_x * 39.37 + .50);
|
||||
if (res_y != NULL) *res_y = (png_uint_32)(*res_y * 39.37 + .50);
|
||||
if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
|
||||
if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (retval);
|
||||
}
|
||||
#endif /* PNG_READ_pHYs_SUPPORTED */
|
||||
#endif /* PNG_INCH_CONVERSIONS $$ PNG_FLOATING_POINT_SUPPORTED */
|
||||
#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
|
||||
|
||||
/* png_get_channels really belongs in here, too, but it's been around longer */
|
||||
|
||||
#endif /* PNG_EASY_ACCESS_SUPPORTED */
|
||||
|
||||
png_byte
|
||||
png_byte PNGAPI
|
||||
png_get_channels(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -319,7 +330,7 @@ png_get_channels(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_bytep
|
||||
png_bytep PNGAPI
|
||||
png_get_signature(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -329,7 +340,7 @@ png_get_signature(png_structp png_ptr, png_infop info_ptr)
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_bKGD_SUPPORTED)
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
|
||||
png_color_16p *background)
|
||||
{
|
||||
@@ -346,7 +357,7 @@ png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#if defined(PNG_READ_cHRM_SUPPORTED)
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
double *white_x, double *white_y, double *red_x, double *red_y,
|
||||
double *green_x, double *green_y, double *blue_x, double *blue_y)
|
||||
@@ -376,11 +387,11 @@ png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 *white_x, png_uint_32 *white_y, png_uint_32 *red_x,
|
||||
png_uint_32 *red_y, png_uint_32 *green_x, png_uint_32 *green_y,
|
||||
png_uint_32 *blue_x, png_uint_32 *blue_y)
|
||||
png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
|
||||
png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
|
||||
png_fixed_point *blue_x, png_fixed_point *blue_y)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
|
||||
{
|
||||
@@ -410,7 +421,7 @@ png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#if defined(PNG_READ_gAMA_SUPPORTED)
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
|
||||
@@ -424,9 +435,9 @@ png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
|
||||
}
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 *int_file_gamma)
|
||||
png_fixed_point *int_file_gamma)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
|
||||
&& int_file_gamma != NULL)
|
||||
@@ -441,7 +452,7 @@ png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
|
||||
@@ -456,10 +467,10 @@ png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_iCCP_SUPPORTED)
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
|
||||
png_charpp name, int *compression_type,
|
||||
png_charpp profile, png_int_32 *proflen)
|
||||
png_charpp profile, png_uint_32 *proflen)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
|
||||
&& name != NULL && profile != NULL && proflen != NULL)
|
||||
@@ -477,10 +488,10 @@ png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_sPLT_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
|
||||
png_uint_32
|
||||
png_get_spalettes(png_structp png_ptr, png_infop info_ptr,
|
||||
png_spalette_pp spalettes)
|
||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
|
||||
png_sPLT_tpp spalettes)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
|
||||
*spalettes = info_ptr->splt_palettes;
|
||||
@@ -489,7 +500,7 @@ png_get_spalettes(png_structp png_ptr, png_infop info_ptr,
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
|
||||
@@ -503,7 +514,7 @@ png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
|
||||
}
|
||||
#endif
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 *width, png_uint_32 *height, int *bit_depth,
|
||||
int *color_type, int *interlace_type, int *compression_type,
|
||||
@@ -550,7 +561,7 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED)
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
|
||||
png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
|
||||
{
|
||||
@@ -568,13 +579,13 @@ png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_pCAL_SUPPORTED)
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
|
||||
png_charp *units, png_charpp *params)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_pCAL &&
|
||||
purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
|
||||
&& purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
|
||||
nparams != NULL && units != NULL && params != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "pCAL");
|
||||
@@ -593,11 +604,12 @@ png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED)
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
png_charpp unit, double *width, double *height)
|
||||
int *unit, double *width, double *height)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_sCAL)
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_sCAL))
|
||||
{
|
||||
*unit = info_ptr->scal_unit;
|
||||
*width = info_ptr->scal_pixel_width;
|
||||
@@ -606,12 +618,14 @@ png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
png_uint_32
|
||||
#else
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
|
||||
png_charpp unit, png_charpp width, png_charpp height)
|
||||
int *unit, png_charpp width, png_charpp height)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_sCAL)
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_sCAL))
|
||||
{
|
||||
*unit = info_ptr->scal_unit;
|
||||
*width = info_ptr->scal_s_width;
|
||||
@@ -621,15 +635,18 @@ png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED)
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
|
||||
{
|
||||
png_uint_32 retval = 0;
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_pHYs)
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "pHYs");
|
||||
if (res_x != NULL)
|
||||
@@ -652,12 +669,12 @@ png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
#endif
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
|
||||
int *num_palette)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_PLTE &&
|
||||
palette != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
|
||||
&& palette != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "PLTE");
|
||||
*palette = info_ptr->palette;
|
||||
@@ -669,11 +686,11 @@ png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_sBIT_SUPPORTED)
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_sBIT &&
|
||||
sig_bit != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
|
||||
&& sig_bit != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "sBIT");
|
||||
*sig_bit = &(info_ptr->sig_bit);
|
||||
@@ -684,7 +701,7 @@ png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_TEXT_SUPPORTED)
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
|
||||
int *num_text)
|
||||
{
|
||||
@@ -699,16 +716,18 @@ png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
|
||||
*num_text = info_ptr->num_text;
|
||||
return ((png_uint_32)info_ptr->num_text);
|
||||
}
|
||||
if (num_text != NULL)
|
||||
*num_text = 0;
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_tIME_SUPPORTED)
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_tIME &&
|
||||
mod_time != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
|
||||
&& mod_time != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "tIME");
|
||||
*mod_time = &(info_ptr->mod_time);
|
||||
@@ -719,12 +738,12 @@ png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_tRNS_SUPPORTED)
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||
png_bytep *trans, int *num_trans, png_color_16p *trans_values)
|
||||
{
|
||||
png_uint_32 retval = 0;
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_tRNS)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "tRNS");
|
||||
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
@@ -758,7 +777,7 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
|
||||
png_unknown_chunkpp unknowns)
|
||||
{
|
||||
@@ -769,9 +788,24 @@ png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
png_byte
|
||||
png_byte PNGAPI
|
||||
png_get_rgb_to_gray_status (png_structp png_ptr)
|
||||
{
|
||||
return png_ptr->rgb_to_gray_status;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|
||||
png_voidp PNGAPI
|
||||
png_get_user_chunk_ptr(png_structp png_ptr)
|
||||
{
|
||||
return (png_ptr->user_chunk_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_compression_buffer_size(png_structp png_ptr)
|
||||
{
|
||||
return(png_ptr->zbuf_size);
|
||||
}
|
||||
|
||||
44
pngmem.c
44
pngmem.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* libpng 1.0.5h - December 10, 1999
|
||||
* libpng 1.0.7beta14 - May 17, 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 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
*
|
||||
* This file provides a location for all memory allocation. Users who
|
||||
* need special memory handling are expected to supply replacement
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
/* Allocate memory for a png_struct. The malloc and memset can be replaced
|
||||
by a single call to calloc() if this is thought to improve performance. */
|
||||
png_voidp
|
||||
png_voidp /* PRIVATE */
|
||||
png_create_struct(int type)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
@@ -31,7 +31,7 @@ png_create_struct(int type)
|
||||
}
|
||||
|
||||
/* Alternate version of png_create_struct, for use with user-defined malloc. */
|
||||
png_voidp
|
||||
png_voidp /* PRIVATE */
|
||||
png_create_struct_2(int type, png_malloc_ptr malloc_fn)
|
||||
{
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
@@ -62,7 +62,7 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn)
|
||||
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct(png_voidp struct_ptr)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
@@ -70,7 +70,7 @@ png_destroy_struct(png_voidp struct_ptr)
|
||||
}
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
|
||||
{
|
||||
#endif
|
||||
@@ -108,7 +108,7 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
|
||||
* result, we would be truncating potentially larger memory requests
|
||||
* (which should cause a fatal error) and introducing major problems.
|
||||
*/
|
||||
png_voidp
|
||||
png_voidp PNGAPI
|
||||
png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
@@ -124,7 +124,7 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
return png_malloc_default(png_ptr, size);
|
||||
}
|
||||
|
||||
png_voidp
|
||||
png_voidp PNGAPI
|
||||
png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
png_voidp ret;
|
||||
@@ -224,7 +224,7 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
||||
/* free a pointer allocated by png_malloc(). In the default
|
||||
configuration, png_ptr is not used, but is passed in case it
|
||||
is needed. If ptr is NULL, return without taking any action. */
|
||||
void
|
||||
void PNGAPI
|
||||
png_free(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
@@ -239,7 +239,7 @@ png_free(png_structp png_ptr, png_voidp ptr)
|
||||
else png_free_default(png_ptr, ptr);
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
@@ -277,7 +277,7 @@ png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||
/* Allocate memory for a png_struct or a png_info. The malloc and
|
||||
memset can be replaced by a single call to calloc() if this is thought
|
||||
to improve performance noticably.*/
|
||||
png_voidp
|
||||
png_voidp /* PRIVATE */
|
||||
png_create_struct(int type)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
@@ -287,7 +287,7 @@ png_create_struct(int type)
|
||||
/* Allocate memory for a png_struct or a png_info. The malloc and
|
||||
memset can be replaced by a single call to calloc() if this is thought
|
||||
to improve performance noticably.*/
|
||||
png_voidp
|
||||
png_voidp /* PRIVATE */
|
||||
png_create_struct_2(int type, png_malloc_ptr malloc_fn)
|
||||
{
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
@@ -328,7 +328,7 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn)
|
||||
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct(png_voidp struct_ptr)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
@@ -336,7 +336,7 @@ png_destroy_struct(png_voidp struct_ptr)
|
||||
}
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
|
||||
{
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
@@ -370,7 +370,7 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
|
||||
need to allocate exactly 64K, so whatever you call here must
|
||||
have the ability to do that. */
|
||||
|
||||
png_voidp
|
||||
png_voidp PNGAPI
|
||||
png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
@@ -385,7 +385,7 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
else
|
||||
return (png_malloc_default(png_ptr, size));
|
||||
}
|
||||
png_voidp
|
||||
png_voidp /* PRIVATE */
|
||||
png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
png_voidp ret;
|
||||
@@ -416,7 +416,7 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
||||
|
||||
/* Free a pointer allocated by png_malloc(). If ptr is NULL, return
|
||||
without taking any action. */
|
||||
void
|
||||
void PNGAPI
|
||||
png_free(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
@@ -430,7 +430,7 @@ png_free(png_structp png_ptr, png_voidp ptr)
|
||||
}
|
||||
else png_free_default(png_ptr, ptr);
|
||||
}
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
@@ -451,7 +451,7 @@ png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||
|
||||
#endif /* Not Borland DOS special memory handler */
|
||||
|
||||
png_voidp
|
||||
png_voidp /* PRIVATE */
|
||||
png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2,
|
||||
png_uint_32 length)
|
||||
{
|
||||
@@ -464,7 +464,7 @@ png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2,
|
||||
return(png_memcpy (s1, s2, size));
|
||||
}
|
||||
|
||||
png_voidp
|
||||
png_voidp /* PRIVATE */
|
||||
png_memset_check (png_structp png_ptr, png_voidp s1, int value,
|
||||
png_uint_32 length)
|
||||
{
|
||||
@@ -482,7 +482,7 @@ png_memset_check (png_structp png_ptr, png_voidp s1, int value,
|
||||
/* This function is called when the application wants to use another method
|
||||
* of allocating and freeing memory.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||
malloc_fn, png_free_ptr free_fn)
|
||||
{
|
||||
@@ -495,7 +495,7 @@ png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||
* functions. The application should free any memory associated with this
|
||||
* pointer before png_write_destroy and png_read_destroy are called.
|
||||
*/
|
||||
png_voidp
|
||||
png_voidp PNGAPI
|
||||
png_get_mem_ptr(png_structp png_ptr)
|
||||
{
|
||||
return ((png_voidp)png_ptr->mem_ptr);
|
||||
|
||||
BIN
pngnow.png
BIN
pngnow.png
Binary file not shown.
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
185
pngpread.c
185
pngpread.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* libpng 1.0.5h - December 10, 1999
|
||||
* libpng 1.0.7beta14 - May 17, 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 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@@ -24,7 +24,7 @@
|
||||
#define PNG_READ_iTXt_MODE 7
|
||||
#define PNG_ERROR_MODE 8
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_process_data(png_structp png_ptr, png_infop info_ptr,
|
||||
png_bytep buffer, png_size_t buffer_size)
|
||||
{
|
||||
@@ -39,7 +39,7 @@ png_process_data(png_structp png_ptr, png_infop info_ptr,
|
||||
/* What we do with the incoming data depends on what we were previously
|
||||
* doing before we ran out of data...
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_process_some_data(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
switch (png_ptr->process_mode)
|
||||
@@ -99,7 +99,7 @@ png_process_some_data(png_structp png_ptr, png_infop info_ptr)
|
||||
* checked by the calling application, or because of multiple calls to this
|
||||
* routine.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_size_t num_checked = png_ptr->sig_bytes,
|
||||
@@ -131,7 +131,7 @@ png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -151,27 +151,30 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||
PNG_hIST;
|
||||
#endif
|
||||
#if defined(PNG_READ_iCCP_SUPPORTED)
|
||||
PNG_iCCP;
|
||||
#endif
|
||||
#if defined(PNG_READ_iTXt_SUPPORTED)
|
||||
PNG_iTXt;
|
||||
#endif
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED)
|
||||
PNG_oFFs;
|
||||
#endif
|
||||
#if defined(PNG_READ_pCAL_SUPPORTED)
|
||||
PNG_pCAL;
|
||||
#endif
|
||||
#if defined(PNG_READ_sCAL_SUPPORTED)
|
||||
PNG_sCAL;
|
||||
#endif
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED)
|
||||
PNG_pHYs;
|
||||
#endif
|
||||
#if defined(PNG_READ_sBIT_SUPPORTED)
|
||||
PNG_sBIT;
|
||||
#endif
|
||||
#if defined(PNG_READ_sCAL_SUPPORTED)
|
||||
PNG_sCAL;
|
||||
#endif
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||
PNG_sRGB;
|
||||
#endif
|
||||
#if defined(PNG_READ_iCCP_SUPPORTED)
|
||||
PNG_iCCP;
|
||||
#endif
|
||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||
PNG_sPLT;
|
||||
#endif
|
||||
@@ -447,7 +450,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_iTXt_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
|
||||
{
|
||||
png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
@@ -460,14 +463,14 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_crc_skip(png_structp png_ptr, png_uint_32 skip)
|
||||
{
|
||||
png_ptr->process_mode = PNG_SKIP_MODE;
|
||||
png_ptr->skip_length = skip;
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_crc_finish(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr->skip_length && png_ptr->save_buffer_size)
|
||||
@@ -515,7 +518,7 @@ png_push_crc_finish(png_structp png_ptr)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
||||
{
|
||||
png_bytep ptr;
|
||||
@@ -553,7 +556,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_save_buffer(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr->save_buffer_size)
|
||||
@@ -597,7 +600,7 @@ png_push_save_buffer(png_structp png_ptr)
|
||||
png_ptr->buffer_size = 0;
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_restore_buffer(png_structp png_ptr, png_bytep buffer,
|
||||
png_size_t buffer_length)
|
||||
{
|
||||
@@ -607,7 +610,7 @@ png_push_restore_buffer(png_structp png_ptr, png_bytep buffer,
|
||||
png_ptr->current_buffer_ptr = png_ptr->current_buffer;
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_read_IDAT(png_structp png_ptr)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -697,7 +700,7 @@ png_push_read_IDAT(png_structp png_ptr)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
|
||||
png_size_t buffer_length)
|
||||
{
|
||||
@@ -739,7 +742,7 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_process_row(png_structp png_ptr)
|
||||
{
|
||||
png_ptr->row_info.color_type = png_ptr->color_type;
|
||||
@@ -881,7 +884,7 @@ png_push_process_row(png_structp png_ptr)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_read_push_finish_row(png_structp png_ptr)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -946,10 +949,10 @@ png_read_push_finish_row(png_structp png_ptr)
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED)
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
{
|
||||
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");
|
||||
/* to quiet some compiler warnings */
|
||||
@@ -976,7 +979,7 @@ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length
|
||||
png_ptr->process_mode = PNG_READ_tEXt_MODE;
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr->buffer_size && png_ptr->current_text_left)
|
||||
@@ -1021,8 +1024,11 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
|
||||
text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
text_ptr->lang = (char *)NULL;
|
||||
text_ptr->key = key;
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
text_ptr->lang = (char *)NULL;
|
||||
text_ptr->lang_key = (char *)NULL;
|
||||
#endif
|
||||
text_ptr->text = text;
|
||||
|
||||
png_set_text(png_ptr, info_ptr, text_ptr, 1);
|
||||
@@ -1033,10 +1039,10 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_zTXt_SUPPORTED)
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
{
|
||||
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");
|
||||
/* to quiet some compiler warnings */
|
||||
@@ -1065,7 +1071,7 @@ png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length
|
||||
png_ptr->process_mode = PNG_READ_zTXt_MODE;
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr->buffer_size && png_ptr->current_text_left)
|
||||
@@ -1201,8 +1207,11 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
|
||||
text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||
text_ptr->lang = (char *)NULL;
|
||||
text_ptr->key = key;
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
text_ptr->lang = (char *)NULL;
|
||||
text_ptr->lang_key = (char *)NULL;
|
||||
#endif
|
||||
text_ptr->text = text;
|
||||
|
||||
png_set_text(png_ptr, info_ptr, text_ptr, 1);
|
||||
@@ -1213,10 +1222,10 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_iTXt_SUPPORTED)
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
{
|
||||
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");
|
||||
/* to quiet some compiler warnings */
|
||||
@@ -1243,9 +1252,10 @@ png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length
|
||||
png_ptr->process_mode = PNG_READ_iTXt_MODE;
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
|
||||
if (png_ptr->buffer_size && png_ptr->current_text_left)
|
||||
{
|
||||
png_size_t text_size;
|
||||
@@ -1261,9 +1271,11 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
|
||||
if (!(png_ptr->current_text_left))
|
||||
{
|
||||
png_textp text_ptr;
|
||||
png_charp text;
|
||||
png_charp lang;
|
||||
png_charp key;
|
||||
int comp_flag;
|
||||
png_charp lang;
|
||||
png_charp lang_key;
|
||||
png_charp text;
|
||||
|
||||
if (png_ptr->buffer_size < 4)
|
||||
{
|
||||
@@ -1278,26 +1290,36 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
|
||||
return;
|
||||
#endif
|
||||
|
||||
lang = png_ptr->current_text;
|
||||
key = png_ptr->current_text;
|
||||
png_ptr->current_text = 0;
|
||||
|
||||
for (key = lang; *key; key++)
|
||||
for (lang = key; *lang; lang++)
|
||||
/* empty loop */ ;
|
||||
|
||||
if (key != lang + png_ptr->current_text_size)
|
||||
key++;
|
||||
if (lang != key + png_ptr->current_text_size)
|
||||
lang++;
|
||||
|
||||
for (text = key; *text; text++)
|
||||
comp_flag = *lang++;
|
||||
lang++; /* skip comp_type, always zero */
|
||||
|
||||
for (lang_key = lang; *lang_key; lang_key++)
|
||||
/* empty loop */ ;
|
||||
lang_key++; /* skip NUL separator */
|
||||
|
||||
for (text = lang_key; *text; text++)
|
||||
/* empty loop */ ;
|
||||
|
||||
if (text != key + png_ptr->current_text_size)
|
||||
text++;
|
||||
|
||||
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
|
||||
text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
text_ptr->lang = lang;
|
||||
text_ptr->compression = comp_flag + 2;
|
||||
text_ptr->key = key;
|
||||
text_ptr->lang = lang;
|
||||
text_ptr->lang_key = lang_key;
|
||||
text_ptr->text = text;
|
||||
text_ptr->text_length = 0;
|
||||
text_ptr->itxt_length = png_strlen(text);
|
||||
|
||||
png_set_text(png_ptr, info_ptr, text_ptr, 1);
|
||||
|
||||
@@ -1307,42 +1329,89 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
|
||||
#endif
|
||||
|
||||
/* This function is called when we haven't found a handler for this
|
||||
* chunk. In the future we will have code here that can handle
|
||||
* user-defined callback functions for unknown chunks before they are
|
||||
* ignored or cause an error. If there isn't a problem with the
|
||||
* chunk itself (ie a bad chunk name or a critical chunk), the chunk
|
||||
* is (currently) silently ignored.
|
||||
* chunk. If there isn't a problem with the chunk itself (ie a bad chunk
|
||||
* name or a critical chunk), the chunk is (currently) silently ignored.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
{
|
||||
png_uint_32 skip=0;
|
||||
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
|
||||
|
||||
if (!(png_ptr->chunk_name[0] & 0x20))
|
||||
{
|
||||
png_chunk_error(png_ptr, "unknown critical chunk");
|
||||
/* to quiet some compiler warnings */
|
||||
if(info_ptr == NULL) return;
|
||||
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
|
||||
HANDLE_CHUNK_ALWAYS
|
||||
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|
||||
&& png_ptr->read_user_chunk_fn == (png_user_chunk_ptr)NULL
|
||||
#endif
|
||||
)
|
||||
#endif
|
||||
png_chunk_error(png_ptr, "unknown critical chunk");
|
||||
|
||||
/* to quiet compiler warnings about unused info_ptr */
|
||||
if (info_ptr == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
png_push_crc_skip(png_ptr, length);
|
||||
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
|
||||
{
|
||||
png_unknown_chunk chunk;
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
if (length > (png_uint_32)65535L)
|
||||
{
|
||||
png_warning(png_ptr, "unknown chunk too large to fit in memory");
|
||||
skip = length - (png_uint_32)65535L;
|
||||
length = (png_uint_32)65535L;
|
||||
}
|
||||
#endif
|
||||
|
||||
strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name);
|
||||
chunk.data = (png_bytep)png_malloc(png_ptr, length);
|
||||
png_crc_read(png_ptr, chunk.data, length);
|
||||
chunk.size = length;
|
||||
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|
||||
if(png_ptr->read_user_chunk_fn != (png_user_chunk_ptr)NULL)
|
||||
{
|
||||
/* callback to user unknown chunk handler */
|
||||
if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0)
|
||||
{
|
||||
if (!(png_ptr->chunk_name[0] & 0x20))
|
||||
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
|
||||
HANDLE_CHUNK_ALWAYS)
|
||||
png_chunk_error(png_ptr, "unknown critical chunk");
|
||||
}
|
||||
png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
|
||||
png_free(png_ptr, chunk.data);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
skip=length;
|
||||
png_push_crc_skip(png_ptr, skip);
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_have_info(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr->info_fn != NULL)
|
||||
(*(png_ptr->info_fn))(png_ptr, info_ptr);
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_have_end(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr->end_fn != NULL)
|
||||
(*(png_ptr->end_fn))(png_ptr, info_ptr);
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_have_row(png_structp png_ptr, png_bytep row)
|
||||
{
|
||||
if (png_ptr->row_fn != NULL)
|
||||
@@ -1350,7 +1419,7 @@ png_push_have_row(png_structp png_ptr, png_bytep row)
|
||||
(int)png_ptr->pass);
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_progressive_combine_row (png_structp png_ptr,
|
||||
png_bytep old_row, png_bytep new_row)
|
||||
{
|
||||
@@ -1361,7 +1430,7 @@ png_progressive_combine_row (png_structp png_ptr,
|
||||
png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]);
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr,
|
||||
png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
|
||||
png_progressive_end_ptr end_fn)
|
||||
@@ -1373,7 +1442,7 @@ png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr,
|
||||
png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer);
|
||||
}
|
||||
|
||||
png_voidp
|
||||
png_voidp PNGAPI
|
||||
png_get_progressive_ptr(png_structp png_ptr)
|
||||
{
|
||||
return png_ptr->io_ptr;
|
||||
|
||||
359
pngread.c
359
pngread.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* libpng 1.0.5h - December 10, 1999
|
||||
* libpng 1.0.7beta14 - May 17, 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 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
*
|
||||
* This file contains routines that an application calls directly to
|
||||
* read a PNG file or stream.
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "png.h"
|
||||
|
||||
/* Create a PNG structure for reading, and allocate any memory needed. */
|
||||
png_structp
|
||||
png_structp PNGAPI
|
||||
png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
png_error_ptr error_fn, png_error_ptr warn_fn)
|
||||
{
|
||||
@@ -26,7 +26,7 @@ png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
}
|
||||
|
||||
/* Alternate create PNG structure for reading, and allocate any memory needed. */
|
||||
png_structp
|
||||
png_structp PNGAPI
|
||||
png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
|
||||
png_malloc_ptr malloc_fn, png_free_ptr free_fn)
|
||||
@@ -34,9 +34,15 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
png_structp png_ptr;
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
jmp_buf jmpbuf;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int i;
|
||||
|
||||
png_debug(1, "in png_create_read_struct\n");
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
|
||||
@@ -47,6 +53,8 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
{
|
||||
return (png_structp)NULL;
|
||||
}
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
if (setjmp(jmpbuf))
|
||||
#else
|
||||
@@ -60,6 +68,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn);
|
||||
@@ -67,16 +76,38 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
|
||||
png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
|
||||
|
||||
/* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
|
||||
* we must recompile any applications that use any older library version.
|
||||
* For versions after libpng 1.0, we will be compatible, so we need
|
||||
* only check the first digit.
|
||||
*/
|
||||
if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
|
||||
(user_png_ver[0] == '0' && user_png_ver[2] < '9'))
|
||||
i=0;
|
||||
do
|
||||
{
|
||||
png_error(png_ptr,
|
||||
"Incompatible libpng version in application and library");
|
||||
if(user_png_ver[i] != png_libpng_ver[i])
|
||||
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||
} while (png_libpng_ver[i++]);
|
||||
|
||||
if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
|
||||
{
|
||||
/* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
|
||||
* we must recompile any applications that use any older library version.
|
||||
* For versions after libpng 1.0, we will be compatible, so we need
|
||||
* only check the first digit.
|
||||
*/
|
||||
if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
|
||||
(user_png_ver[0] == '0' && user_png_ver[2] < '9'))
|
||||
{
|
||||
png_error(png_ptr,
|
||||
"Incompatible libpng version in application and library");
|
||||
}
|
||||
|
||||
/* Libpng 1.0.6 was not binary compatible, due to insertion of the
|
||||
info_ptr->free_me member. Note to maintainer: this test can be
|
||||
removed from version 2.0.0 and beyond because the previous test
|
||||
would have already rejected it. */
|
||||
|
||||
if (user_png_ver[4] == '6' && user_png_ver[2] == '0' &&
|
||||
user_png_ver[0] == '1' && user_png_ver[5] == '\0')
|
||||
{
|
||||
png_error(png_ptr,
|
||||
"Application must be recompiled; version 1.0.6 was incompatible");
|
||||
}
|
||||
}
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
@@ -107,20 +138,59 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
/* Initialize PNG structure for reading, and allocate any memory needed.
|
||||
This interface is deprecated in favour of the png_create_read_struct(),
|
||||
and it will eventually disappear. */
|
||||
void
|
||||
#undef png_read_init
|
||||
void PNGAPI
|
||||
png_read_init(png_structp png_ptr)
|
||||
{
|
||||
jmp_buf tmp_jmp; /* to save current jump buffer */
|
||||
/* We only come here via pre-1.0.7-compiled applications */
|
||||
png_read_init_2(png_ptr, "1.0.0", 10000, 10000);
|
||||
}
|
||||
|
||||
png_debug(1, "in png_read_init\n");
|
||||
void PNGAPI
|
||||
png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver,
|
||||
png_size_t png_struct_size, png_size_t png_info_size)
|
||||
{
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
jmp_buf tmp_jmp; /* to save current jump buffer */
|
||||
#endif
|
||||
|
||||
int i=0;
|
||||
do
|
||||
{
|
||||
if(user_png_ver[i] != png_libpng_ver[i])
|
||||
{
|
||||
#ifdef PNG_LEGACY_SUPPORTED
|
||||
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||
#else
|
||||
png_ptr->error_fn=(png_error_ptr)NULL;
|
||||
png_error(png_ptr,
|
||||
"Application uses deprecated png_read_init() and must be recompiled.");
|
||||
#endif
|
||||
}
|
||||
} while (png_libpng_ver[i++]);
|
||||
|
||||
if(sizeof(png_struct) > png_struct_size ||
|
||||
sizeof(png_info) > png_info_size)
|
||||
{
|
||||
png_ptr->error_fn=(png_error_ptr)NULL;
|
||||
png_error(png_ptr,
|
||||
"Application and library have different sized structs. Please recompile.");
|
||||
}
|
||||
|
||||
png_debug(1, "in png_read_init_2\n");
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
/* save jump buffer and error functions */
|
||||
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
|
||||
#endif
|
||||
|
||||
/* reset all variables to 0 */
|
||||
png_memset(png_ptr, 0, sizeof (png_struct));
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
/* restore jump buffer */
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
|
||||
#endif
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||
@@ -153,7 +223,7 @@ png_read_init(png_structp png_ptr)
|
||||
* here. The application can then have access to the signature bytes we
|
||||
* read if it is determined that this isn't a valid PNG file.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_debug(1, "in png_read_info\n");
|
||||
@@ -214,7 +284,7 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||
#if defined(PNG_READ_sBIT_SUPPORTED)
|
||||
PNG_sBIT;
|
||||
#endif
|
||||
#if defined(PNG_READ_pCAL_SUPPORTED)
|
||||
#if defined(PNG_READ_sCAL_SUPPORTED)
|
||||
PNG_sCAL;
|
||||
#endif
|
||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||
@@ -253,10 +323,29 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||
*/
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
|
||||
png_handle_IHDR(png_ptr, info_ptr, length);
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
||||
png_handle_PLTE(png_ptr, info_ptr, length);
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
|
||||
png_handle_IEND(png_ptr, info_ptr, length);
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name))
|
||||
{
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
png_handle_unknown(png_ptr, info_ptr, length);
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
||||
png_ptr->mode |= PNG_HAVE_PLTE;
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
png_error(png_ptr, "Missing IHDR before IDAT");
|
||||
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
!(png_ptr->mode & PNG_HAVE_PLTE))
|
||||
png_error(png_ptr, "Missing PLTE before IDAT");
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
||||
png_handle_PLTE(png_ptr, info_ptr, length);
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
@@ -343,7 +432,7 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||
}
|
||||
|
||||
/* optional call to update the users info_ptr structure */
|
||||
void
|
||||
void PNGAPI
|
||||
png_read_update_info(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_debug(1, "in png_read_update_info\n");
|
||||
@@ -358,7 +447,7 @@ png_read_update_info(png_structp png_ptr, png_infop info_ptr)
|
||||
* the user to obtain a gamma-corrected palette, for example.
|
||||
* If the user doesn't call this, we will do it ourselves.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_start_read_image(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_start_read_image\n");
|
||||
@@ -367,7 +456,7 @@ png_start_read_image(png_structp png_ptr)
|
||||
png_read_start_row(png_ptr);
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -421,7 +510,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
switch (png_ptr->pass)
|
||||
{
|
||||
case 0:
|
||||
if (png_ptr->row_number & 7)
|
||||
if (png_ptr->row_number & 0x07)
|
||||
{
|
||||
if (dsp_row != NULL)
|
||||
png_combine_row(png_ptr, dsp_row,
|
||||
@@ -431,7 +520,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if ((png_ptr->row_number & 7) || png_ptr->width < 5)
|
||||
if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)
|
||||
{
|
||||
if (dsp_row != NULL)
|
||||
png_combine_row(png_ptr, dsp_row,
|
||||
@@ -441,7 +530,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if ((png_ptr->row_number & 7) != 4)
|
||||
if ((png_ptr->row_number & 0x07) != 4)
|
||||
{
|
||||
if (dsp_row != NULL && (png_ptr->row_number & 4))
|
||||
png_combine_row(png_ptr, dsp_row,
|
||||
@@ -546,6 +635,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
|
||||
(png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
|
||||
|
||||
if(png_ptr->row_buf[0])
|
||||
png_read_filter_row(png_ptr, &(png_ptr->row_info),
|
||||
png_ptr->row_buf + 1, png_ptr->prev_row + 1,
|
||||
(int)(png_ptr->row_buf[0]));
|
||||
@@ -607,10 +697,10 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
* not called png_set_interlace_handling(), the display_row buffer will
|
||||
* be ignored, so pass NULL to it.
|
||||
*
|
||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.5h.
|
||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.7beta14
|
||||
*/
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_read_rows(png_structp png_ptr, png_bytepp row,
|
||||
png_bytepp display_row, png_uint_32 num_rows)
|
||||
{
|
||||
@@ -656,9 +746,9 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
|
||||
* only call this function once. If you desire to have an image for
|
||||
* each pass of a interlaced image, use png_read_rows() instead.
|
||||
*
|
||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.5h.
|
||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.7beta14
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_read_image(png_structp png_ptr, png_bytepp image)
|
||||
{
|
||||
png_uint_32 i,image_height;
|
||||
@@ -696,7 +786,7 @@ png_read_image(png_structp png_ptr, png_bytepp image)
|
||||
* file, will verify the end is accurate, and will read any comments
|
||||
* or time information at the end of the file, if info is not NULL.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_read_end(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_byte chunk_length[4];
|
||||
@@ -743,7 +833,7 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
|
||||
#if defined(PNG_READ_sBIT_SUPPORTED)
|
||||
PNG_sBIT;
|
||||
#endif
|
||||
#if defined(PNG_READ_pCAL_SUPPORTED)
|
||||
#if defined(PNG_READ_sCAL_SUPPORTED)
|
||||
PNG_sCAL;
|
||||
#endif
|
||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||
@@ -776,6 +866,23 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
|
||||
png_handle_IHDR(png_ptr, info_ptr, length);
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
|
||||
png_handle_IEND(png_ptr, info_ptr, length);
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name))
|
||||
{
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
{
|
||||
if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT)
|
||||
png_error(png_ptr, "Too many IDAT's found");
|
||||
}
|
||||
else
|
||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||
png_handle_unknown(png_ptr, info_ptr, length);
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
||||
png_ptr->mode |= PNG_HAVE_PLTE;
|
||||
}
|
||||
#endif
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
{
|
||||
/* Zero length IDATs are legal after the last IDAT has been
|
||||
@@ -783,13 +890,10 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
|
||||
*/
|
||||
if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT)
|
||||
png_error(png_ptr, "Too many IDAT's found");
|
||||
else
|
||||
png_crc_finish(png_ptr, 0);
|
||||
png_crc_finish(png_ptr, length);
|
||||
}
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
||||
png_handle_PLTE(png_ptr, info_ptr, length);
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
|
||||
png_handle_IEND(png_ptr, info_ptr, length);
|
||||
#if defined(PNG_READ_bKGD_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4))
|
||||
png_handle_bKGD(png_ptr, info_ptr, length);
|
||||
@@ -864,7 +968,7 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
|
||||
}
|
||||
|
||||
/* free all memory used by the read */
|
||||
void
|
||||
void PNGAPI
|
||||
png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
||||
png_infopp end_info_ptr_ptr)
|
||||
{
|
||||
@@ -894,7 +998,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
#if defined(PNG_TEXT_SUPPORTED)
|
||||
png_free(png_ptr, info_ptr->text);
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, -1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
@@ -908,7 +1012,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
||||
if (end_info_ptr != NULL)
|
||||
{
|
||||
#if defined(PNG_READ_TEXT_SUPPORTED)
|
||||
png_free(png_ptr, end_info_ptr->text);
|
||||
png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1);
|
||||
#endif
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_destroy_struct_2((png_voidp)end_info_ptr, free_fn);
|
||||
@@ -930,10 +1034,12 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
||||
}
|
||||
|
||||
/* free all memory used by the read (old method) */
|
||||
void
|
||||
void PNGAPI
|
||||
png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr)
|
||||
{
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
jmp_buf tmp_jmp;
|
||||
#endif
|
||||
png_error_ptr error_fn;
|
||||
png_error_ptr warning_fn;
|
||||
png_voidp error_ptr;
|
||||
@@ -963,16 +1069,37 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
png_free(png_ptr, png_ptr->gamma_from_1);
|
||||
png_free(png_ptr, png_ptr->gamma_to_1);
|
||||
#endif
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_PALETTE)
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if (png_ptr->free_me & PNG_FREE_PLTE)
|
||||
png_zfree(png_ptr, png_ptr->palette);
|
||||
png_ptr->free_me &= ~PNG_FREE_PLTE;
|
||||
#else
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_PLTE)
|
||||
png_zfree(png_ptr, png_ptr->palette);
|
||||
png_ptr->flags &= ~PNG_FLAG_FREE_PLTE;
|
||||
#endif
|
||||
#if defined(PNG_tRNS_SUPPORTED) || \
|
||||
defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_TRANS)
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if (png_ptr->free_me & PNG_FREE_TRNS)
|
||||
png_free(png_ptr, png_ptr->trans);
|
||||
png_ptr->free_me &= ~PNG_FREE_TRNS;
|
||||
#else
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_TRNS)
|
||||
png_free(png_ptr, png_ptr->trans);
|
||||
png_ptr->flags &= ~PNG_FLAG_FREE_TRNS;
|
||||
#endif
|
||||
#endif
|
||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if (png_ptr->free_me & PNG_FREE_HIST)
|
||||
png_free(png_ptr, png_ptr->hist);
|
||||
png_ptr->free_me &= ~PNG_FREE_HIST;
|
||||
#else
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_HIST)
|
||||
png_free(png_ptr, png_ptr->hist);
|
||||
png_ptr->flags &= ~PNG_FLAG_FREE_HIST;
|
||||
#endif
|
||||
#endif
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
if (png_ptr->gamma_16_table != NULL)
|
||||
@@ -1020,7 +1147,9 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
/* Save the important info out of the png_struct, in case it is
|
||||
* being used again.
|
||||
*/
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
|
||||
#endif
|
||||
|
||||
error_fn = png_ptr->error_fn;
|
||||
warning_fn = png_ptr->warning_fn;
|
||||
@@ -1038,11 +1167,155 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
png_ptr->free_fn = free_fn;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn)
|
||||
{
|
||||
png_ptr->read_row_fn = read_row_fn;
|
||||
}
|
||||
|
||||
#if defined(PNG_INFO_IMAGE_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_read_png(png_structp png_ptr, png_infop info_ptr,
|
||||
int transforms,
|
||||
voidp params)
|
||||
{
|
||||
int row;
|
||||
|
||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
|
||||
/* invert the alpha channel from opacity to transparency */
|
||||
if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
|
||||
png_set_invert_alpha(png_ptr);
|
||||
#endif
|
||||
|
||||
/* The call to png_read_info() gives us all of the information from the
|
||||
* PNG file before the first IDAT (image data chunk).
|
||||
*/
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
/* -------------- image transformations start here ------------------- */
|
||||
|
||||
#if defined(PNG_READ_16_TO_8_SUPPORTED)
|
||||
/* tell libpng to strip 16 bit/color files down to 8 bits/color */
|
||||
if (transforms & PNG_TRANSFORM_STRIP_16)
|
||||
png_set_strip_16(png_ptr);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||
/* Strip alpha bytes from the input data without combining with the
|
||||
* background (not recommended).
|
||||
*/
|
||||
if (transforms & PNG_TRANSFORM_STRIP_ALPHA)
|
||||
png_set_strip_alpha(png_ptr);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_PACK_SUPPORTED) && !defined(PNG_READ_EXPAND_SUPPORTED)
|
||||
/* Extract multiple pixels with bit depths of 1, 2, and 4 from a single
|
||||
* byte into separate bytes (useful for paletted and grayscale images).
|
||||
*/
|
||||
if (transforms & PNG_TRANSFORM_PACKING)
|
||||
png_set_packing(png_ptr);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
|
||||
/* Change the order of packed pixels to least significant bit first
|
||||
* (not useful if you are using png_set_packing). */
|
||||
if (transforms & PNG_TRANSFORM_PACKSWAP)
|
||||
png_set_packswap(png_ptr);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_EXPAND_SUPPORTED)
|
||||
/* Expand paletted colors into true RGB triplets
|
||||
* Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel
|
||||
* Expand paletted or RGB images with transparency to full alpha
|
||||
* channels so the data will be available as RGBA quartets.
|
||||
*/
|
||||
if (transforms & PNG_TRANSFORM_EXPAND)
|
||||
if ((png_ptr->bit_depth < 8) ||
|
||||
(png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ||
|
||||
(png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)))
|
||||
png_set_expand(png_ptr);
|
||||
#endif
|
||||
|
||||
/* We don't handle background color or gamma transformation or dithering. */
|
||||
|
||||
#if defined(PNG_READ_INVERT_SUPPORTED)
|
||||
/* invert monochrome files to have 0 as white and 1 as black */
|
||||
if (transforms & PNG_TRANSFORM_INVERT_MONO)
|
||||
png_set_invert_mono(png_ptr);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED)
|
||||
/* If you want to shift the pixel values from the range [0,255] or
|
||||
* [0,65535] to the original [0,7] or [0,31], or whatever range the
|
||||
* colors were originally in:
|
||||
*/
|
||||
if ((transforms & PNG_TRANSFORM_SHIFT)
|
||||
&& png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT))
|
||||
{
|
||||
png_color_8p sig_bit;
|
||||
|
||||
png_get_sBIT(png_ptr, info_ptr, &sig_bit);
|
||||
png_set_shift(png_ptr, sig_bit);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_BGR_SUPPORTED)
|
||||
/* flip the RGB pixels to BGR (or RGBA to BGRA) */
|
||||
if (transforms & PNG_TRANSFORM_BGR)
|
||||
png_set_bgr(png_ptr);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
|
||||
/* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
|
||||
if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
|
||||
png_set_swap_alpha(png_ptr);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SWAP_SUPPORTED)
|
||||
/* swap bytes of 16 bit files to least significant byte first */
|
||||
if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
|
||||
png_set_swap(png_ptr);
|
||||
#endif
|
||||
|
||||
/* We don't handle adding filler bytes */
|
||||
|
||||
/* Optional call to gamma correct and add the background to the palette
|
||||
* and update info structure. REQUIRED if you are expecting libpng to
|
||||
* update the palette for you (ie you selected such a transform above).
|
||||
*/
|
||||
png_read_update_info(png_ptr, info_ptr);
|
||||
|
||||
/* -------------- image transformations end here ------------------- */
|
||||
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
|
||||
#endif
|
||||
if(info_ptr->row_pointers == NULL)
|
||||
{
|
||||
info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
|
||||
info_ptr->height * sizeof(png_bytep));
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_ROWS;
|
||||
#endif
|
||||
for (row = 0; row < (int)info_ptr->height; row++)
|
||||
info_ptr->row_pointers[row] = png_malloc(png_ptr,
|
||||
png_get_rowbytes(png_ptr, info_ptr));
|
||||
}
|
||||
|
||||
png_read_image(png_ptr, info_ptr->row_pointers);
|
||||
info_ptr->valid |= PNG_INFO_IDAT;
|
||||
|
||||
/* read rest of file, and get additional chunks in info_ptr - REQUIRED */
|
||||
png_read_end(png_ptr, info_ptr);
|
||||
|
||||
if(transforms == 0 || params == (voidp)NULL)
|
||||
/* quiet compiler warnings */ return;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
12
pngrio.c
12
pngrio.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* libpng 1.0.5h - December 10, 1999
|
||||
* libpng 1.0.7beta14 - May 17, 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 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
*
|
||||
* This file provides a location for all input. Users who need
|
||||
* special handling are expected to write a function that has the same
|
||||
@@ -23,7 +23,7 @@
|
||||
with very small lengths, so you should implement some kind of simple
|
||||
buffering if you are using unbuffered reads. This should never be asked
|
||||
to read more then 64K on a 16 bit machine. */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_debug1(4,"reading %d bytes\n", length);
|
||||
@@ -39,7 +39,7 @@ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
read_data function and use it at run time with png_set_read_fn(), rather
|
||||
than changing the library. */
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
static void
|
||||
static void /* PRIVATE */
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_size_t check;
|
||||
@@ -64,7 +64,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
static void
|
||||
static void /* PRIVATE */
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
int check;
|
||||
@@ -119,7 +119,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
unsigned int that is the number of bytes to be read.
|
||||
To exit and output any fatal error messages the new write
|
||||
function should call png_error(png_ptr, "Error msg"). */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr read_data_fn)
|
||||
{
|
||||
|
||||
250
pngrtran.c
250
pngrtran.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* libpng 1.0.5h - December 10, 1999
|
||||
* libpng 1.0.7beta14 - May 17, 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 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
*
|
||||
* This file contains functions optionally called by an application
|
||||
* in order to tell libpng how to handle data when reading a PNG.
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "png.h"
|
||||
|
||||
/* Set the action on getting a CRC error for an ancillary or critical chunk. */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
|
||||
{
|
||||
png_debug(1, "in png_set_crc_action\n");
|
||||
@@ -72,7 +72,7 @@ png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
|
||||
defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
/* handle alpha and tRNS via a background color */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_background(png_structp png_ptr,
|
||||
png_color_16p background_color, int background_gamma_code,
|
||||
int need_expand, double background_gamma)
|
||||
@@ -105,7 +105,7 @@ png_set_background(png_structp png_ptr,
|
||||
|
||||
#if defined(PNG_READ_16_TO_8_SUPPORTED)
|
||||
/* strip 16 bit depth files to 8 bit depth */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_strip_16(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_strip_16\n");
|
||||
@@ -114,7 +114,7 @@ png_set_strip_16(png_structp png_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_strip_alpha(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_strip_alpha\n");
|
||||
@@ -141,7 +141,7 @@ typedef struct png_dsort_struct
|
||||
typedef png_dsort FAR * png_dsortp;
|
||||
typedef png_dsort FAR * FAR * png_dsortpp;
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
int num_palette, int maximum_colors, png_uint_16p histogram,
|
||||
int full_dither)
|
||||
@@ -367,7 +367,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
{
|
||||
int j, next_j;
|
||||
|
||||
if (num_new_palette & 1)
|
||||
if (num_new_palette & 0x01)
|
||||
{
|
||||
j = p->left;
|
||||
next_j = p->right;
|
||||
@@ -511,7 +511,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
* are not close reciprocals, otherwise it slows things down slightly, and
|
||||
* also needlessly introduces small errors.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
|
||||
{
|
||||
png_debug(1, "in png_set_gamma\n");
|
||||
@@ -527,7 +527,7 @@ png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
|
||||
* less than 8-bit depth to 8-bit depth, and expand tRNS chunks
|
||||
* to alpha channels.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_expand(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_expand\n");
|
||||
@@ -549,7 +549,7 @@ png_set_expand(png_structp png_ptr)
|
||||
*/
|
||||
|
||||
/* Expand paletted images to RGB. */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_palette_to_rgb(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_expand\n");
|
||||
@@ -557,7 +557,7 @@ png_set_palette_to_rgb(png_structp png_ptr)
|
||||
}
|
||||
|
||||
/* Expand grayscale images of less than 8-bit depth to 8 bits. */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_gray_1_2_4_to_8(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_expand\n");
|
||||
@@ -565,7 +565,7 @@ png_set_gray_1_2_4_to_8(png_structp png_ptr)
|
||||
}
|
||||
|
||||
/* Expand tRNS chunks to alpha channels. */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_tRNS_to_alpha(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_expand\n");
|
||||
@@ -574,7 +574,7 @@ png_set_tRNS_to_alpha(png_structp png_ptr)
|
||||
#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */
|
||||
|
||||
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_gray_to_rgb(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_gray_to_rgb\n");
|
||||
@@ -582,14 +582,25 @@ png_set_gray_to_rgb(png_structp png_ptr)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) && \
|
||||
defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
#if defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
/* 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.
|
||||
*/
|
||||
void
|
||||
|
||||
void PNGAPI
|
||||
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 PNGAPI
|
||||
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");
|
||||
switch(error_action)
|
||||
@@ -610,41 +621,54 @@ png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red,
|
||||
}
|
||||
#endif
|
||||
{
|
||||
png_byte red_byte = (png_byte)((float)red*255.0 + 0.5);
|
||||
png_byte green_byte = (png_byte)((float)green*255.0 + 0.5);
|
||||
if(red < 0.0 || green < 0.0)
|
||||
png_uint_16 red_int, green_int;
|
||||
if(red < 0 || green < 0)
|
||||
{
|
||||
red_byte = 54;
|
||||
green_byte = 183;
|
||||
red_int = 6968; /* .212671 * 32768 + .5 */
|
||||
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");
|
||||
red_byte = 54;
|
||||
green_byte = 183;
|
||||
red_int = 6968;
|
||||
green_int = 23434;
|
||||
}
|
||||
png_ptr->rgb_to_gray_red_coeff = red_byte;
|
||||
png_ptr->rgb_to_gray_green_coeff = green_byte;
|
||||
png_ptr->rgb_to_gray_blue_coeff = (png_byte)(255-red_byte-green_byte);
|
||||
png_ptr->rgb_to_gray_red_coeff = red_int;
|
||||
png_ptr->rgb_to_gray_green_coeff = green_int;
|
||||
png_ptr->rgb_to_gray_blue_coeff = (png_uint_16)(32768-red_int-green_int);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
void
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_LEGACY_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
|
||||
read_user_transform_fn)
|
||||
{
|
||||
png_debug(1, "in png_set_read_user_transform_fn\n");
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
png_ptr->transformations |= PNG_USER_TRANSFORM;
|
||||
png_ptr->read_user_transform_fn = read_user_transform_fn;
|
||||
#endif
|
||||
#ifdef PNG_LEGACY_SUPPORTED
|
||||
if(read_user_transform_fn)
|
||||
png_warning(png_ptr,
|
||||
"This version of libpng does not support user transforms");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialize everything needed for the read. This includes modifying
|
||||
* the palette.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_init_read_transformations(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_init_read_transformations\n");
|
||||
@@ -658,7 +682,8 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_BACKGROUND_EXPAND)
|
||||
if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
|
||||
(png_ptr->transformations & PNG_EXPAND))
|
||||
{
|
||||
if (!(color_type & PNG_COLOR_MASK_COLOR)) /* i.e., GRAY or GRAY_ALPHA */
|
||||
{
|
||||
@@ -897,8 +922,8 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
#endif
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
/* No GAMMA transformation */
|
||||
if (png_ptr->transformations & PNG_BACKGROUND &&
|
||||
color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
if ((png_ptr->transformations & PNG_BACKGROUND) &&
|
||||
(color_type == PNG_COLOR_TYPE_PALETTE))
|
||||
{
|
||||
int i;
|
||||
int istop = (int)png_ptr->num_trans;
|
||||
@@ -931,7 +956,7 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_SHIFT) &&
|
||||
color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
(color_type == PNG_COLOR_TYPE_PALETTE))
|
||||
{
|
||||
png_uint_16 i;
|
||||
png_uint_16 istop = png_ptr->num_palette;
|
||||
@@ -960,7 +985,7 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
* info should be updated so a PNG file could be written with it,
|
||||
* assuming the transformations result in valid PNG data.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_debug(1, "in png_read_transform_info\n");
|
||||
@@ -1009,7 +1034,7 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_16_TO_8_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_16_TO_8) && info_ptr->bit_depth == 16)
|
||||
if ((png_ptr->transformations & PNG_16_TO_8) && (info_ptr->bit_depth == 16))
|
||||
info_ptr->bit_depth = 8;
|
||||
#endif
|
||||
|
||||
@@ -1026,7 +1051,7 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_PACK_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_PACK) && info_ptr->bit_depth < 8)
|
||||
if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8))
|
||||
info_ptr->bit_depth = 8;
|
||||
#endif
|
||||
|
||||
@@ -1057,13 +1082,14 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED)
|
||||
/* STRIP_ALPHA and FILLER allowed: MASK_ALPHA bit stripped above */
|
||||
if (png_ptr->transformations & PNG_FILLER &&
|
||||
(info_ptr->color_type == PNG_COLOR_TYPE_RGB ||
|
||||
info_ptr->color_type == PNG_COLOR_TYPE_GRAY))
|
||||
if ((png_ptr->transformations & PNG_FILLER) &&
|
||||
((info_ptr->color_type == PNG_COLOR_TYPE_RGB) ||
|
||||
(info_ptr->color_type == PNG_COLOR_TYPE_GRAY)))
|
||||
info_ptr->channels++;
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \
|
||||
defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
if(png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||
{
|
||||
if(info_ptr->bit_depth < png_ptr->user_transform_depth)
|
||||
@@ -1083,7 +1109,7 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||
* and is very touchy. If you add a transformation, take care to
|
||||
* decide how it fits in with the other transformations here.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_read_transformations(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_do_read_transformations\n");
|
||||
@@ -1177,7 +1203,7 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
|
||||
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
|
||||
/* if gray -> RGB, do so now only if background is non-gray; else do later
|
||||
* for performance reasons */
|
||||
if (png_ptr->transformations & PNG_GRAY_TO_RGB &&
|
||||
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
|
||||
!(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
|
||||
png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
@@ -1251,8 +1277,8 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
|
||||
|
||||
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
|
||||
/* if gray -> RGB, do so now only if we did not do so above */
|
||||
if (png_ptr->transformations & PNG_GRAY_TO_RGB &&
|
||||
png_ptr->mode & PNG_BACKGROUND_IS_GRAY)
|
||||
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
|
||||
(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
|
||||
png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
@@ -1291,10 +1317,12 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
|
||||
/* png_byte channels; number of channels (1-4) */
|
||||
/* png_byte pixel_depth; bits per pixel (depth*channels) */
|
||||
png_ptr->row_buf + 1); /* start of pixel data for row */
|
||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
if(png_ptr->user_transform_depth)
|
||||
png_ptr->row_info.bit_depth = png_ptr->user_transform_depth;
|
||||
if(png_ptr->user_transform_channels)
|
||||
png_ptr->row_info.channels = png_ptr->user_transform_channels;
|
||||
#endif
|
||||
png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth *
|
||||
png_ptr->row_info.channels);
|
||||
png_ptr->row_info.rowbytes = (png_ptr->row_info.width *
|
||||
@@ -1311,7 +1339,7 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
|
||||
* the numbers 0 or 1. If you would rather they contain 0 and 255, use
|
||||
* png_do_shift() after this.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_unpack(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_unpack\n");
|
||||
@@ -1330,10 +1358,10 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_bytep sp = row + (png_size_t)((row_width - 1) >> 3);
|
||||
png_bytep dp = row + (png_size_t)row_width - 1;
|
||||
png_uint_32 shift = 7 - (int)((row_width + 7) & 7);
|
||||
png_uint_32 shift = 7 - (int)((row_width + 7) & 0x07);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*dp = (png_byte)((*sp >> shift) & 0x1);
|
||||
*dp = (png_byte)((*sp >> shift) & 0x01);
|
||||
if (shift == 7)
|
||||
{
|
||||
shift = 0;
|
||||
@@ -1351,10 +1379,10 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
||||
|
||||
png_bytep sp = row + (png_size_t)((row_width - 1) >> 2);
|
||||
png_bytep dp = row + (png_size_t)row_width - 1;
|
||||
png_uint_32 shift = (int)((3 - ((row_width + 3) & 3)) << 1);
|
||||
png_uint_32 shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*dp = (png_byte)((*sp >> shift) & 0x3);
|
||||
*dp = (png_byte)((*sp >> shift) & 0x03);
|
||||
if (shift == 6)
|
||||
{
|
||||
shift = 0;
|
||||
@@ -1371,10 +1399,10 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_bytep sp = row + (png_size_t)((row_width - 1) >> 1);
|
||||
png_bytep dp = row + (png_size_t)row_width - 1;
|
||||
png_uint_32 shift = (int)((1 - ((row_width + 1) & 1)) << 2);
|
||||
png_uint_32 shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*dp = (png_byte)((*sp >> shift) & 0xf);
|
||||
*dp = (png_byte)((*sp >> shift) & 0x0f);
|
||||
if (shift == 4)
|
||||
{
|
||||
shift = 0;
|
||||
@@ -1401,7 +1429,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
||||
* a row of bit depth 8, but only 5 are significant, this will shift
|
||||
* the values back to 0 through 31.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
|
||||
{
|
||||
png_debug(1, "in png_do_unshift\n");
|
||||
@@ -1507,7 +1535,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
|
||||
|
||||
#if defined(PNG_READ_16_TO_8_SUPPORTED)
|
||||
/* chop rows of bit depth 16 down to 8 */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_chop(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_chop\n");
|
||||
@@ -1561,7 +1589,7 @@ png_do_chop(png_row_infop row_info, png_bytep row)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_read_swap_alpha\n");
|
||||
@@ -1653,7 +1681,7 @@ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_read_invert_alpha\n");
|
||||
@@ -1674,9 +1702,15 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*(--dp) = (png_byte)(255 - *(--sp));
|
||||
|
||||
/* This does nothing:
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
We can replace it with:
|
||||
*/
|
||||
sp-=3;
|
||||
dp=sp;
|
||||
}
|
||||
}
|
||||
/* This inverts the alpha channel in RRGGBBAA */
|
||||
@@ -1690,12 +1724,18 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
*(--dp) = (png_byte)(255 - *(--sp));
|
||||
*(--dp) = (png_byte)(255 - *(--sp));
|
||||
|
||||
/* This does nothing:
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
We can replace it with:
|
||||
*/
|
||||
sp-=6;
|
||||
dp=sp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1725,8 +1765,12 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
*(--dp) = (png_byte)(255 - *(--sp));
|
||||
*(--dp) = (png_byte)(255 - *(--sp));
|
||||
/*
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*/
|
||||
sp-=2;
|
||||
dp=sp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1736,7 +1780,7 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED)
|
||||
/* Add filler channel if we have RGB color */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
png_uint_32 filler, png_uint_32 flags)
|
||||
{
|
||||
@@ -1912,7 +1956,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
|
||||
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
|
||||
/* expand grayscale files to RGB, with or without alpha */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_uint_32 i;
|
||||
@@ -2004,17 +2048,17 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Other integer coefficents can be used via png_set_rgb_to_gray().
|
||||
*/
|
||||
int
|
||||
int /* PRIVATE */
|
||||
png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
|
||||
{
|
||||
@@ -2030,9 +2074,9 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
#endif
|
||||
(row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
{
|
||||
png_byte rc = png_ptr->rgb_to_gray_red_coeff;
|
||||
png_byte gc = png_ptr->rgb_to_gray_green_coeff;
|
||||
png_byte bc = png_ptr->rgb_to_gray_blue_coeff;
|
||||
png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
|
||||
png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
|
||||
png_uint_32 bc = png_ptr->rgb_to_gray_blue_coeff;
|
||||
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
{
|
||||
@@ -2053,7 +2097,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
rgb_error |= 1;
|
||||
*(dp++) = png_ptr->gamma_from_1[
|
||||
(rc*red+gc*green+bc*blue)>>8];
|
||||
(rc*red+gc*green+bc*blue)>>15];
|
||||
}
|
||||
else
|
||||
*(dp++) = *(sp-1);
|
||||
@@ -2072,7 +2116,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
if(red != green || red != blue)
|
||||
{
|
||||
rgb_error |= 1;
|
||||
*(dp++) = (png_byte)((rc*red+gc*green+bc*blue)>>8);
|
||||
*(dp++) = (png_byte)((rc*red+gc*green+bc*blue)>>15);
|
||||
}
|
||||
else
|
||||
*(dp++) = *(sp-1);
|
||||
@@ -2107,7 +2151,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_ptr->gamma_shift][blue>>8];
|
||||
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) >>
|
||||
png_ptr->gamma_shift][gray16 >> 8];
|
||||
rgb_error |= 1;
|
||||
@@ -2132,7 +2176,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
|
||||
if(red != green || red != blue)
|
||||
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 & 0xff);
|
||||
}
|
||||
@@ -2156,7 +2200,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
if(red != green || red != blue)
|
||||
rgb_error |= 1;
|
||||
*(dp++) = png_ptr->gamma_from_1
|
||||
[(rc*red + gc*green + bc*blue)>>8];
|
||||
[(rc*red + gc*green + bc*blue)>>15];
|
||||
*(dp++) = *(sp++); /* alpha */
|
||||
}
|
||||
}
|
||||
@@ -2204,7 +2248,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_ptr->gamma_shift][blue>>8];
|
||||
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) >>
|
||||
png_ptr->gamma_shift][gray16 >> 8];
|
||||
rgb_error |= 1;
|
||||
@@ -2229,7 +2273,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;
|
||||
if(red != green || red != blue)
|
||||
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 & 0xff);
|
||||
*(dp++) = *(sp++); /* alpha */
|
||||
@@ -2254,7 +2298,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
* paletted. Most useful for gamma correction and simplification
|
||||
* of code.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_build_grayscale_palette(int bit_depth, png_colorp palette)
|
||||
{
|
||||
int num_palette;
|
||||
@@ -2300,7 +2344,7 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette)
|
||||
|
||||
/* This function is currently unused. Do we really need it? */
|
||||
#if defined(PNG_READ_DITHER_SUPPORTED) && defined(PNG_CORRECT_PALETTE_SUPPORTED)
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_correct_palette(png_structp png_ptr, png_colorp palette,
|
||||
int num_palette)
|
||||
{
|
||||
@@ -2485,7 +2529,7 @@ png_correct_palette(png_structp png_ptr, png_colorp palette,
|
||||
* "background" is already in the screen gamma, while "background_1" is
|
||||
* at a gamma of 1.0. Paletted files have already been taken care of.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_background(png_row_infop row_info, png_bytep row,
|
||||
png_color_16p trans_values, png_color_16p background,
|
||||
png_color_16p background_1,
|
||||
@@ -2518,7 +2562,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
shift = 7;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if ((png_uint_16)((*sp >> shift) & 0x1)
|
||||
if ((png_uint_16)((*sp >> shift) & 0x01)
|
||||
== trans_values->gray)
|
||||
{
|
||||
*sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff);
|
||||
@@ -2543,7 +2587,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
shift = 6;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if ((png_uint_16)((*sp >> shift) & 0x3)
|
||||
if ((png_uint_16)((*sp >> shift) & 0x03)
|
||||
== trans_values->gray)
|
||||
{
|
||||
*sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
|
||||
@@ -2551,9 +2595,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
else
|
||||
{
|
||||
png_byte p = (png_byte)((*sp >> shift) & 0x3);
|
||||
png_byte p = (png_byte)((*sp >> shift) & 0x03);
|
||||
png_byte g = (png_byte)((gamma_table [p | (p << 2) |
|
||||
(p << 4) | (p << 6)] >> 6) & 0x3);
|
||||
(p << 4) | (p << 6)] >> 6) & 0x03);
|
||||
*sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
|
||||
*sp |= (png_byte)(g << shift);
|
||||
}
|
||||
@@ -2573,7 +2617,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
shift = 6;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if ((png_uint_16)((*sp >> shift) & 0x3)
|
||||
if ((png_uint_16)((*sp >> shift) & 0x03)
|
||||
== trans_values->gray)
|
||||
{
|
||||
*sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
|
||||
@@ -2599,7 +2643,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
shift = 4;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if ((png_uint_16)((*sp >> shift) & 0xf)
|
||||
if ((png_uint_16)((*sp >> shift) & 0x0f)
|
||||
== trans_values->gray)
|
||||
{
|
||||
*sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
|
||||
@@ -2607,9 +2651,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
else
|
||||
{
|
||||
png_byte p = (png_byte)((*sp >> shift) & 0xf);
|
||||
png_byte p = (png_byte)((*sp >> shift) & 0x0f);
|
||||
png_byte g = (png_byte)((gamma_table[p |
|
||||
(p << 4)] >> 4) & 0xf);
|
||||
(p << 4)] >> 4) & 0x0f);
|
||||
*sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
|
||||
*sp |= (png_byte)(g << shift);
|
||||
}
|
||||
@@ -2629,7 +2673,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
shift = 4;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if ((png_uint_16)((*sp >> shift) & 0xf)
|
||||
if ((png_uint_16)((*sp >> shift) & 0x0f)
|
||||
== trans_values->gray)
|
||||
{
|
||||
*sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
|
||||
@@ -3156,7 +3200,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
* is 16, use gamma_16_table and gamma_shift. Build these with
|
||||
* build_gamma_table().
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_gamma(png_row_infop row_info, png_bytep row,
|
||||
png_bytep gamma_table, png_uint_16pp gamma_16_table,
|
||||
int gamma_shift)
|
||||
@@ -3338,7 +3382,7 @@ png_do_gamma(png_row_infop row_info, png_bytep row,
|
||||
/* Expands a palette row to an RGB or RGBA row depending
|
||||
* upon whether you supply trans and num_trans.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
png_colorp palette, png_bytep trans, int num_trans)
|
||||
{
|
||||
@@ -3362,10 +3406,10 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
sp = row + (png_size_t)((row_width - 1) >> 3);
|
||||
dp = row + (png_size_t)row_width - 1;
|
||||
shift = 7 - (int)((row_width + 7) & 7);
|
||||
shift = 7 - (int)((row_width + 7) & 0x07);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if ((*sp >> shift) & 0x1)
|
||||
if ((*sp >> shift) & 0x01)
|
||||
*dp = 1;
|
||||
else
|
||||
*dp = 0;
|
||||
@@ -3385,10 +3429,10 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
sp = row + (png_size_t)((row_width - 1) >> 2);
|
||||
dp = row + (png_size_t)row_width - 1;
|
||||
shift = (int)((3 - ((row_width + 3) & 3)) << 1);
|
||||
shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
value = (*sp >> shift) & 0x3;
|
||||
value = (*sp >> shift) & 0x03;
|
||||
*dp = (png_byte)value;
|
||||
if (shift == 6)
|
||||
{
|
||||
@@ -3406,10 +3450,10 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
sp = row + (png_size_t)((row_width - 1) >> 1);
|
||||
dp = row + (png_size_t)row_width - 1;
|
||||
shift = (int)((row_width & 1) << 2);
|
||||
shift = (int)((row_width & 0x01) << 2);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
value = (*sp >> shift) & 0xf;
|
||||
value = (*sp >> shift) & 0x0f;
|
||||
*dp = (png_byte)value;
|
||||
if (shift == 4)
|
||||
{
|
||||
@@ -3481,7 +3525,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
/* If the bit depth < 8, it is expanded to 8. Also, if the
|
||||
* transparency value is supplied, an alpha channel is built.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
png_color_16p trans_value)
|
||||
{
|
||||
@@ -3508,10 +3552,10 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
gray = (png_uint_16)(gray*0xff);
|
||||
sp = row + (png_size_t)((row_width - 1) >> 3);
|
||||
dp = row + (png_size_t)row_width - 1;
|
||||
shift = 7 - (int)((row_width + 7) & 7);
|
||||
shift = 7 - (int)((row_width + 7) & 0x07);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if ((*sp >> shift) & 0x1)
|
||||
if ((*sp >> shift) & 0x01)
|
||||
*dp = 0xff;
|
||||
else
|
||||
*dp = 0;
|
||||
@@ -3532,10 +3576,10 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
gray = (png_uint_16)(gray*0x55);
|
||||
sp = row + (png_size_t)((row_width - 1) >> 2);
|
||||
dp = row + (png_size_t)row_width - 1;
|
||||
shift = (int)((3 - ((row_width + 3) & 3)) << 1);
|
||||
shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
value = (*sp >> shift) & 0x3;
|
||||
value = (*sp >> shift) & 0x03;
|
||||
*dp = (png_byte)(value | (value << 2) | (value << 4) |
|
||||
(value << 6));
|
||||
if (shift == 6)
|
||||
@@ -3555,10 +3599,10 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
gray = (png_uint_16)(gray*0x11);
|
||||
sp = row + (png_size_t)((row_width - 1) >> 1);
|
||||
dp = row + (png_size_t)row_width - 1;
|
||||
shift = (int)((1 - ((row_width + 1) & 1)) << 2);
|
||||
shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
value = (*sp >> shift) & 0xf;
|
||||
value = (*sp >> shift) & 0x0f;
|
||||
*dp = (png_byte)(value | (value << 4));
|
||||
if (shift == 4)
|
||||
{
|
||||
@@ -3680,7 +3724,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_DITHER_SUPPORTED)
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_dither(png_row_infop row_info, png_bytep row,
|
||||
png_bytep palette_lookup, png_bytep dither_lookup)
|
||||
{
|
||||
@@ -3782,7 +3826,7 @@ static int png_gamma_shift[] =
|
||||
* the future. Note also how the gamma_16 tables are segmented so that
|
||||
* we don't need to allocate > 64K chunks for a full 16-bit table.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_build_gamma_table(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_build_gamma_table\n");
|
||||
@@ -3809,7 +3853,7 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
|
||||
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
if (png_ptr->transformations & (PNG_BACKGROUND | PNG_RGB_TO_GRAY))
|
||||
if (png_ptr->transformations & ((PNG_BACKGROUND) | PNG_RGB_TO_GRAY))
|
||||
{
|
||||
|
||||
g = 1.0 / (png_ptr->gamma);
|
||||
|
||||
543
pngrutil.c
543
pngrutil.c
File diff suppressed because it is too large
Load Diff
396
pngset.c
396
pngset.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* libpng 1.0.5h - December 10, 1999
|
||||
* libpng 1.0.7beta14 - May 17, 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 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
*
|
||||
* The functions here are used during reads to store data from the file
|
||||
* into the info struct, and during writes to store application data
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "png.h"
|
||||
|
||||
#if defined(PNG_bKGD_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "bKGD");
|
||||
@@ -31,7 +31,7 @@ png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
|
||||
|
||||
#if defined(PNG_cHRM_SUPPORTED)
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
double white_x, double white_y, double red_x, double red_y,
|
||||
double green_x, double green_y, double blue_x, double blue_y)
|
||||
@@ -48,15 +48,25 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
info_ptr->y_green = (float)green_y;
|
||||
info_ptr->x_blue = (float)blue_x;
|
||||
info_ptr->y_blue = (float)blue_y;
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
info_ptr->int_x_white = (png_fixed_point)(white_x*100000.+0.5);
|
||||
info_ptr->int_y_white = (png_fixed_point)(white_y*100000.+0.5);
|
||||
info_ptr->int_x_red = (png_fixed_point)(red_x*100000.+0.5);
|
||||
info_ptr->int_y_red = (png_fixed_point)(red_y*100000.+0.5);
|
||||
info_ptr->int_x_green = (png_fixed_point)(green_x*100000.+0.5);
|
||||
info_ptr->int_y_green = (png_fixed_point)(green_y*100000.+0.5);
|
||||
info_ptr->int_x_blue = (png_fixed_point)(blue_x*100000.+0.5);
|
||||
info_ptr->int_y_blue = (png_fixed_point)(blue_y*100000.+0.5);
|
||||
#endif
|
||||
info_ptr->valid |= PNG_INFO_cHRM;
|
||||
}
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 white_x, png_uint_32 white_y, png_uint_32 red_x,
|
||||
png_uint_32 red_y, png_uint_32 green_x, png_uint_32 green_y,
|
||||
png_uint_32 blue_x, png_uint_32 blue_y)
|
||||
png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x,
|
||||
png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y,
|
||||
png_fixed_point blue_x, png_fixed_point blue_y)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "cHRM");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
@@ -70,6 +80,16 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
|
||||
info_ptr->int_y_green = green_y;
|
||||
info_ptr->int_x_blue = blue_x;
|
||||
info_ptr->int_y_blue = blue_y;
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
info_ptr->x_white = (float)(white_x/100000.);
|
||||
info_ptr->y_white = (float)(white_y/100000.);
|
||||
info_ptr->x_red = (float)(red_x/100000.);
|
||||
info_ptr->y_red = (float)(red_y/100000.);
|
||||
info_ptr->x_green = (float)(green_x/100000.);
|
||||
info_ptr->y_green = (float)(green_y/100000.);
|
||||
info_ptr->x_blue = (float)(blue_x/100000.);
|
||||
info_ptr->y_blue = (float)(blue_y/100000.);
|
||||
#endif
|
||||
info_ptr->valid |= PNG_INFO_cHRM;
|
||||
}
|
||||
#endif
|
||||
@@ -77,7 +97,7 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#if defined(PNG_gAMA_SUPPORTED)
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "gAMA");
|
||||
@@ -92,24 +112,25 @@ png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
void
|
||||
png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_uint_32 int_gamma)
|
||||
void PNGAPI
|
||||
png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
|
||||
int_gamma)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "gAMA");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
info_ptr->gamma = (float)int_gamma/100000.;
|
||||
info_ptr->gamma = (float)(int_gamma/100000.);
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
info_ptr->int_gamma = int_gamma;
|
||||
#endif
|
||||
info_ptr->valid |= PNG_INFO_gAMA;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_hIST_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "hIST");
|
||||
@@ -121,7 +142,7 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 width, png_uint_32 height, int bit_depth,
|
||||
int color_type, int interlace_type, int compression_type,
|
||||
@@ -162,7 +183,7 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
|
||||
#if defined(PNG_oFFs_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_oFFs(png_structp png_ptr, png_infop info_ptr,
|
||||
png_int_32 offset_x, png_int_32 offset_y, int unit_type)
|
||||
{
|
||||
@@ -178,7 +199,7 @@ png_set_oFFs(png_structp png_ptr, png_infop info_ptr,
|
||||
#endif
|
||||
|
||||
#if defined(PNG_pCAL_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams,
|
||||
png_charp units, png_charpp params)
|
||||
@@ -219,34 +240,33 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
|
||||
info_ptr->valid |= PNG_INFO_pCAL;
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_PCAL;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED)
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_sCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
png_charp unit, double width, double height)
|
||||
int unit, double width, double height)
|
||||
{
|
||||
png_uint_32 length;
|
||||
|
||||
png_debug1(1, "in %s storage function\n", "sCAL");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
length = png_strlen(unit) + 1;
|
||||
png_debug1(3, "allocating unit for info (%d bytes)\n", length);
|
||||
info_ptr->scal_unit = (png_charp)png_malloc(png_ptr, length);
|
||||
png_memcpy(info_ptr->scal_unit, unit, (png_size_t)length);
|
||||
info_ptr->scal_unit = (png_byte)unit;
|
||||
info_ptr->scal_pixel_width = width;
|
||||
info_ptr->scal_pixel_height = height;
|
||||
|
||||
info_ptr->valid |= PNG_INFO_sCAL;
|
||||
}
|
||||
#endif
|
||||
void
|
||||
#else
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
|
||||
png_charp unit, png_charp swidth, png_charp sheight)
|
||||
int unit, png_charp swidth, png_charp sheight)
|
||||
{
|
||||
png_uint_32 length;
|
||||
|
||||
@@ -254,10 +274,7 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
length = png_strlen(unit) + 1;
|
||||
png_debug1(3, "allocating unit for info (%d bytes)\n", length);
|
||||
info_ptr->scal_unit = (png_charp)png_malloc(png_ptr, length);
|
||||
png_memcpy(info_ptr->scal_unit, unit, (png_size_t)length);
|
||||
info_ptr->scal_unit = (png_byte)unit;
|
||||
|
||||
length = png_strlen(swidth) + 1;
|
||||
png_debug1(3, "allocating unit for info (%d bytes)\n", length);
|
||||
@@ -270,11 +287,16 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
|
||||
png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length);
|
||||
|
||||
info_ptr->valid |= PNG_INFO_sCAL;
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_SCAL;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_pHYs_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_pHYs(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 res_x, png_uint_32 res_y, int unit_type)
|
||||
{
|
||||
@@ -289,21 +311,23 @@ png_set_pHYs(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
|
||||
png_colorp palette, int num_palette)
|
||||
{
|
||||
|
||||
png_debug1(1, "in %s storage function\n", "PLTE");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
info_ptr->palette = palette;
|
||||
|
||||
info_ptr->num_palette = (png_uint_16)num_palette;
|
||||
info_ptr->valid |= PNG_INFO_PLTE;
|
||||
}
|
||||
|
||||
#if defined(PNG_sBIT_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
|
||||
png_color_8p sig_bit)
|
||||
{
|
||||
@@ -317,7 +341,7 @@ png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
|
||||
#endif
|
||||
|
||||
#if defined(PNG_sRGB_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "sRGB");
|
||||
@@ -328,7 +352,7 @@ png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent)
|
||||
info_ptr->valid |= PNG_INFO_sRGB;
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
int intent)
|
||||
{
|
||||
@@ -337,7 +361,7 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
float file_gamma;
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_uint_32 int_file_gamma;
|
||||
png_fixed_point int_file_gamma;
|
||||
#endif
|
||||
#endif
|
||||
#if defined(PNG_cHRM_SUPPORTED)
|
||||
@@ -345,7 +369,7 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_uint_32 int_white_x, int_white_y, int_red_x, int_red_y, int_green_x,
|
||||
png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x,
|
||||
int_green_y, int_blue_x, int_blue_y;
|
||||
#endif
|
||||
#endif
|
||||
@@ -400,29 +424,40 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
|
||||
#if defined(PNG_iCCP_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
|
||||
png_charp name, int compression_type,
|
||||
png_charp profile, int proflen)
|
||||
png_charp profile, png_uint_32 proflen)
|
||||
{
|
||||
png_charp new_iccp_name;
|
||||
png_charp new_iccp_profile;
|
||||
|
||||
png_debug1(1, "in %s storage function\n", "iCCP");
|
||||
if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)
|
||||
return;
|
||||
|
||||
info_ptr->iccp_name = png_malloc(png_ptr, png_strlen(name)+1);
|
||||
strcpy(info_ptr->iccp_name, name);
|
||||
info_ptr->iccp_profile = png_malloc(png_ptr, proflen);
|
||||
memcpy(info_ptr->iccp_profile, profile, proflen);
|
||||
info_ptr->iccp_proflen = (png_uint_32)proflen;
|
||||
new_iccp_name = png_malloc(png_ptr, png_strlen(name)+1);
|
||||
strcpy(new_iccp_name, name);
|
||||
new_iccp_profile = png_malloc(png_ptr, proflen);
|
||||
png_memcpy(new_iccp_profile, profile, (png_size_t)proflen);
|
||||
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0);
|
||||
|
||||
info_ptr->iccp_proflen = proflen;
|
||||
info_ptr->iccp_name = new_iccp_name;
|
||||
info_ptr->iccp_profile = new_iccp_profile;
|
||||
/* Compression is always zero but is here so the API and info structure
|
||||
* does not have to change * if we introduce multiple compression types */
|
||||
* does not have to change if we introduce multiple compression types */
|
||||
info_ptr->iccp_compression = (png_byte)compression_type;
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_ICCP;
|
||||
#endif
|
||||
info_ptr->valid |= PNG_INFO_iCCP;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_TEXT_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||
int num_text)
|
||||
{
|
||||
@@ -459,61 +494,112 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||
info_ptr->num_text = 0;
|
||||
info_ptr->text = (png_textp)png_malloc(png_ptr,
|
||||
(png_uint_32)(info_ptr->max_text * sizeof (png_text)));
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_TEXT;
|
||||
#endif
|
||||
}
|
||||
png_debug1(3, "allocated %d entries for info_ptr->text\n",
|
||||
info_ptr->max_text);
|
||||
}
|
||||
|
||||
for (i = 0; i < num_text; i++)
|
||||
{
|
||||
png_size_t text_length,key_len;
|
||||
png_size_t lang_len,lang_key_len;
|
||||
png_textp textp = &(info_ptr->text[info_ptr->num_text]);
|
||||
png_charp key,text;
|
||||
|
||||
if (text_ptr[i].key == (png_charp)NULL)
|
||||
continue;
|
||||
|
||||
key_len = png_strlen(text_ptr[i].key);
|
||||
|
||||
if(text_ptr[i].compression <= 0)
|
||||
{
|
||||
lang_len = 0;
|
||||
lang_key_len = 0;
|
||||
}
|
||||
else
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
textp->lang = text_ptr[i].lang;
|
||||
textp->translated_key = text_ptr[i].translated_key;
|
||||
{
|
||||
/* set iTXt data */
|
||||
if (text_ptr[i].key != (png_charp)NULL)
|
||||
lang_len = png_strlen(text_ptr[i].lang);
|
||||
else
|
||||
lang_len = 0;
|
||||
if (text_ptr[i].lang_key != (png_charp)NULL)
|
||||
lang_key_len = png_strlen(text_ptr[i].lang_key);
|
||||
else
|
||||
lang_key_len = 0;
|
||||
}
|
||||
#else
|
||||
textp->lang = NULL;
|
||||
textp->translated_key = NULL;
|
||||
{
|
||||
png_warning(png_ptr, "iTXt chunk not supported.");
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (text_ptr[i].text[0] == '\0')
|
||||
if (text_ptr[i].text == (png_charp)NULL || text_ptr[i].text[0] == '\0')
|
||||
{
|
||||
textp->text_length = 0;
|
||||
textp->compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
text_length = 0;
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
if(text_ptr[i].compression > 0)
|
||||
textp->compression = PNG_ITXT_COMPRESSION_NONE;
|
||||
else
|
||||
#endif
|
||||
textp->compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
textp->text_length = png_strlen(text_ptr[i].text);
|
||||
text_length = png_strlen(text_ptr[i].text);
|
||||
textp->compression = text_ptr[i].compression;
|
||||
}
|
||||
key=text_ptr[i].key;
|
||||
for (text = key; *text++;)
|
||||
/* empty loop to find the byte after the zero byte after the
|
||||
end of key */ ;
|
||||
|
||||
textp->key = (png_charp)png_malloc(png_ptr,
|
||||
(png_uint_32)(text+textp->text_length - key)+1);
|
||||
/* Caution: the calling program, not libpng, is responsible for
|
||||
freeing this, if libpng wasn't the caller. */
|
||||
(png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4));
|
||||
png_debug2(2, "Allocated %d bytes at %x in png_set_text\n",
|
||||
text+textp->text_length-key+1, textp->key);
|
||||
key_len + lang_len + lang_key_len + text_length + 4, textp->key);
|
||||
|
||||
png_memcpy(textp->key, text_ptr[i].key,
|
||||
(png_size_t)(text - key)); /* includes the zero-byte separator */
|
||||
|
||||
textp->text = textp->key + (text-key);
|
||||
if(textp->text_length)
|
||||
(png_size_t)(key_len));
|
||||
*(textp->key+key_len) = '\0';
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
if (text_ptr[i].compression > 0)
|
||||
{
|
||||
png_memcpy(textp->text, text_ptr[i].text,
|
||||
(png_size_t)(textp->text_length));
|
||||
*(textp->text+textp->text_length) = '\0';
|
||||
textp->lang=textp->key + key_len + 1;
|
||||
png_memcpy(textp->lang, text_ptr[i].lang, lang_len);
|
||||
*(textp->lang+lang_len) = '\0';
|
||||
textp->lang_key=textp->lang + lang_len + 1;
|
||||
png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len);
|
||||
*(textp->lang_key+lang_key_len) = '\0';
|
||||
textp->text=textp->lang_key + lang_key_len + 1;
|
||||
}
|
||||
else
|
||||
textp->text--;
|
||||
#endif
|
||||
{
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
textp->lang=(png_charp)NULL;
|
||||
textp->lang_key=(png_charp)NULL;
|
||||
#endif
|
||||
textp->text=textp->key + key_len + 1;
|
||||
}
|
||||
if(text_length)
|
||||
png_memcpy(textp->text, text_ptr[i].text,
|
||||
(png_size_t)(text_length));
|
||||
*(textp->text+text_length) = '\0';
|
||||
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
if(textp->compression > 0)
|
||||
{
|
||||
textp->text_length = 0;
|
||||
textp->itxt_length = text_length;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
textp->text_length = text_length;
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
textp->itxt_length = 0;
|
||||
#endif
|
||||
}
|
||||
info_ptr->text[info_ptr->num_text]= *textp;
|
||||
info_ptr->num_text++;
|
||||
png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text);
|
||||
@@ -522,7 +608,7 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||
#endif
|
||||
|
||||
#if defined(PNG_tIME_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "tIME");
|
||||
@@ -536,7 +622,7 @@ png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_tRNS_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||
png_bytep trans, int num_trans, png_color_16p trans_values)
|
||||
{
|
||||
@@ -545,9 +631,7 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||
return;
|
||||
|
||||
if (trans != NULL)
|
||||
{
|
||||
info_ptr->trans = trans;
|
||||
}
|
||||
|
||||
if (trans_values != NULL)
|
||||
{
|
||||
@@ -562,75 +646,97 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||
#endif
|
||||
|
||||
#if defined(PNG_sPLT_SUPPORTED)
|
||||
void
|
||||
png_set_spalettes(png_structp png_ptr,
|
||||
png_infop info_ptr, png_spalette_p entries, int nentries)
|
||||
void PNGAPI
|
||||
png_set_sPLT(png_structp png_ptr,
|
||||
png_infop info_ptr, png_sPLT_tp entries, int nentries)
|
||||
{
|
||||
png_spalette_p np;
|
||||
png_sPLT_tp np;
|
||||
int i;
|
||||
|
||||
np = (png_spalette_p)png_malloc(png_ptr,
|
||||
(info_ptr->splt_palettes_num + nentries) * sizeof(png_spalette));
|
||||
np = (png_sPLT_tp)png_malloc(png_ptr,
|
||||
(info_ptr->splt_palettes_num + nentries) * sizeof(png_sPLT_t));
|
||||
|
||||
memcpy(np, info_ptr->splt_palettes,
|
||||
info_ptr->splt_palettes_num * sizeof(png_spalette));
|
||||
png_memcpy(np, info_ptr->splt_palettes,
|
||||
info_ptr->splt_palettes_num * sizeof(png_sPLT_t));
|
||||
png_free(png_ptr, info_ptr->splt_palettes);
|
||||
|
||||
for (i = 0; i < nentries; i++)
|
||||
{
|
||||
png_spalette_p to = np + info_ptr->splt_palettes_num + i;
|
||||
png_spalette_p from = entries + i;
|
||||
png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;
|
||||
png_sPLT_tp from = entries + i;
|
||||
|
||||
to->name = (png_charp)png_malloc(png_ptr,
|
||||
png_strlen(from->name) + 1);
|
||||
png_strcpy(to->name, from->name);
|
||||
to->entries = (png_spalette_entryp)png_malloc(png_ptr,
|
||||
from->nentries * sizeof(png_spalette));
|
||||
memcpy(to->entries, from->entries,
|
||||
from->nentries * sizeof(png_spalette));
|
||||
to->entries = (png_sPLT_entryp)png_malloc(png_ptr,
|
||||
from->nentries * sizeof(png_sPLT_t));
|
||||
png_memcpy(to->entries, from->entries,
|
||||
from->nentries * sizeof(png_sPLT_t));
|
||||
to->nentries = from->nentries;
|
||||
to->depth = from->depth;
|
||||
}
|
||||
|
||||
info_ptr->splt_palettes = np;
|
||||
info_ptr->splt_palettes_num += nentries;
|
||||
info_ptr->valid |= PNG_INFO_sPLT;
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_SPLT;
|
||||
#endif
|
||||
}
|
||||
#endif /* PNG_sPLT_SUPPORTED */
|
||||
|
||||
#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_unknown_chunks(png_structp png_ptr,
|
||||
png_infop info_ptr, png_unknown_chunkp unknowns, int nunknowns)
|
||||
png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)
|
||||
{
|
||||
png_unknown_chunkp np;
|
||||
int i;
|
||||
|
||||
np = (png_unknown_chunkp)png_malloc(png_ptr,
|
||||
(info_ptr->unknown_chunks_num + nunknowns) * sizeof(png_unknown_chunk));
|
||||
if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0)
|
||||
return;
|
||||
|
||||
memcpy(np, info_ptr->unknown_chunks,
|
||||
np = (png_unknown_chunkp)png_malloc(png_ptr,
|
||||
(info_ptr->unknown_chunks_num + num_unknowns) *
|
||||
sizeof(png_unknown_chunk));
|
||||
|
||||
png_memcpy(np, info_ptr->unknown_chunks,
|
||||
info_ptr->unknown_chunks_num * sizeof(png_unknown_chunk));
|
||||
png_free(png_ptr, info_ptr->unknown_chunks);
|
||||
|
||||
for (i = 0; i < nunknowns; i++)
|
||||
for (i = 0; i < num_unknowns; i++)
|
||||
{
|
||||
png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
|
||||
png_unknown_chunkp from = unknowns + i;
|
||||
|
||||
png_strcpy(to->name, from->name);
|
||||
png_strcpy((png_charp)to->name, (png_charp)from->name);
|
||||
to->data = (png_bytep)png_malloc(png_ptr, from->size);
|
||||
memcpy(to->data, from->data, from->size);
|
||||
png_memcpy(to->data, from->data, from->size);
|
||||
to->size = from->size;
|
||||
|
||||
/* note our location in the read or write sequence */
|
||||
to->location = png_ptr->mode;
|
||||
to->location = (png_byte)(png_ptr->mode & 0xff);
|
||||
}
|
||||
|
||||
info_ptr->unknown_chunks = np;
|
||||
info_ptr->unknown_chunks_num += nunknowns;
|
||||
info_ptr->unknown_chunks_num += num_unknowns;
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_UNKN;
|
||||
#endif
|
||||
}
|
||||
void PNGAPI
|
||||
png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr,
|
||||
int chunk, int location)
|
||||
{
|
||||
if(png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk <
|
||||
(int)info_ptr->unknown_chunks_num)
|
||||
info_ptr->unknown_chunks[chunk].location = (png_byte)location;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED)
|
||||
void
|
||||
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
|
||||
defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
|
||||
{
|
||||
png_debug1(1, "in png_permit_empty_plte\n", "");
|
||||
@@ -640,9 +746,89 @@ png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep
|
||||
chunk_list, int num_chunks)
|
||||
{
|
||||
png_bytep new_list, p;
|
||||
int i, old_num_chunks;
|
||||
if (num_chunks == 0)
|
||||
{
|
||||
if(keep == HANDLE_CHUNK_ALWAYS || keep == HANDLE_CHUNK_IF_SAFE)
|
||||
png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS;
|
||||
else
|
||||
png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS;
|
||||
|
||||
if(keep == HANDLE_CHUNK_ALWAYS)
|
||||
png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS;
|
||||
else
|
||||
png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS;
|
||||
return;
|
||||
}
|
||||
if (chunk_list == NULL)
|
||||
return;
|
||||
old_num_chunks=png_ptr->num_chunk_list;
|
||||
new_list=png_malloc(png_ptr,5*(num_chunks+old_num_chunks));
|
||||
if(png_ptr->chunk_list != (png_bytep)NULL)
|
||||
{
|
||||
png_memcpy(new_list, png_ptr->chunk_list, 5*old_num_chunks);
|
||||
png_free(png_ptr, png_ptr->chunk_list);
|
||||
}
|
||||
png_memcpy(new_list+5*old_num_chunks, chunk_list, 5*num_chunks);
|
||||
for (p=new_list+5*old_num_chunks+4, i=0; i<num_chunks; i++, p+=5)
|
||||
*p=(png_byte)keep;
|
||||
png_ptr->num_chunk_list=old_num_chunks+num_chunks;
|
||||
png_ptr->chunk_list=new_list;
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
png_ptr->free_me |= PNG_FREE_LIST;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr,
|
||||
png_user_chunk_ptr read_user_chunk_fn)
|
||||
{
|
||||
png_debug(1, "in png_set_read_user_chunk_fn\n");
|
||||
png_ptr->read_user_chunk_fn = read_user_chunk_fn;
|
||||
png_ptr->user_chunk_ptr = user_chunk_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_INFO_IMAGE_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "rows");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
if(info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers))
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
|
||||
info_ptr->row_pointers = row_pointers;
|
||||
if(row_pointers)
|
||||
info_ptr->valid |= PNG_INFO_IDAT;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
void PNGAPI
|
||||
png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
if(png_ptr->zbuf)
|
||||
png_free(png_ptr, png_ptr->zbuf);
|
||||
png_ptr->zbuf_size = (png_size_t)size;
|
||||
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size);
|
||||
png_ptr->zstream.next_out = png_ptr->zbuf;
|
||||
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask)
|
||||
{
|
||||
if (png_ptr && info_ptr)
|
||||
info_ptr->valid &= ~(mask);
|
||||
}
|
||||
|
||||
210
pngtest.c
210
pngtest.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
*
|
||||
* libpng 1.0.5h - December 10, 1999
|
||||
* libpng 1.0.7beta14 - May 17, 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 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
*
|
||||
* This program reads in a PNG image, writes it out again, and then
|
||||
* compares the two files. If the files are identical, this shows that
|
||||
@@ -15,11 +15,11 @@
|
||||
*
|
||||
* The program will report "FAIL" in certain legitimate cases:
|
||||
* 1) when the compression level or filter selection method is changed.
|
||||
* 2) when the chunk size is not 8K.
|
||||
* 2) when the maximum IDAT size (PNG_ZBUF_SIZE in pngconf.h) is not 8192.
|
||||
* 3) unknown ancillary chunks exist in the input file.
|
||||
* 4) others not listed here...
|
||||
* In these cases, it is best to check with another tool such as "pngcheck"
|
||||
* to see what the differences between the two images are.
|
||||
* to see what the differences between the two files are.
|
||||
*
|
||||
* If a filename is given on the command-line, then this file is used
|
||||
* for the input, rather than the default "pngtest.png". This allows
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
/* Makes pngtest verbose so we can find problems (needs to be before png.h) */
|
||||
#ifndef PNG_DEBUG
|
||||
@@ -50,6 +51,11 @@ static float t_start, t_stop, t_decode, t_encode, t_misc;
|
||||
|
||||
#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
|
||||
static float t_start, t_stop, t_decode, t_encode, t_misc;
|
||||
#if !defined(PNG_tIME_SUPPORTED)
|
||||
@@ -151,7 +157,7 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||
{
|
||||
if(row_info->bit_depth == 1)
|
||||
{
|
||||
if(((*dp << pos++ )& 0x80) == 0) zero_samples++;
|
||||
if(((*dp << pos++ ) & 0x80) == 0) zero_samples++;
|
||||
if(pos == 8)
|
||||
{
|
||||
pos = 0;
|
||||
@@ -160,7 +166,7 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||
}
|
||||
if(row_info->bit_depth == 2)
|
||||
{
|
||||
if(((*dp << (pos+=2))& 0xc0) == 0) zero_samples++;
|
||||
if(((*dp << (pos+=2)) & 0xc0) == 0) zero_samples++;
|
||||
if(pos == 8)
|
||||
{
|
||||
pos = 0;
|
||||
@@ -169,7 +175,7 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||
}
|
||||
if(row_info->bit_depth == 4)
|
||||
{
|
||||
if(((*dp << (pos+=4))& 0xf0) == 0) zero_samples++;
|
||||
if(((*dp << (pos+=4)) & 0xf0) == 0) zero_samples++;
|
||||
if(pos == 8)
|
||||
{
|
||||
pos = 0;
|
||||
@@ -409,7 +415,8 @@ png_default_error(png_structp png_ptr, png_const_charp message)
|
||||
|
||||
This piece of code can be compiled to validate max 64K allocations
|
||||
by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K. */
|
||||
typedef struct memory_information {
|
||||
typedef struct memory_information
|
||||
{
|
||||
png_uint_32 size;
|
||||
png_voidp pointer;
|
||||
struct memory_information FAR *next;
|
||||
@@ -426,7 +433,8 @@ extern PNG_EXPORT(void,png_debug_free) PNGARG((png_structp png_ptr,
|
||||
png_voidp ptr));
|
||||
|
||||
png_voidp
|
||||
png_debug_malloc(png_structp png_ptr, png_uint_32 size) {
|
||||
png_debug_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
|
||||
/* png_malloc has already tested for NULL; png_create_struct calls
|
||||
png_debug_malloc directly, with png_ptr == NULL which is OK */
|
||||
@@ -451,6 +459,7 @@ png_debug_malloc(png_structp png_ptr, png_uint_32 size) {
|
||||
if(verbose)
|
||||
printf("png_malloc %d bytes at %x\n",size,pinfo->pointer);
|
||||
#endif
|
||||
assert(pinfo->size != 12345);
|
||||
return (png_voidp)(pinfo->pointer);
|
||||
}
|
||||
}
|
||||
@@ -461,7 +470,8 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
fprintf(STDERR, "NULL pointer to png_debug_free.\n");
|
||||
if (ptr == 0) {
|
||||
if (ptr == 0)
|
||||
{
|
||||
#if 0 /* This happens all the time. */
|
||||
fprintf(STDERR, "WARNING: freeing NULL pointer\n");
|
||||
#endif
|
||||
@@ -471,9 +481,11 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
|
||||
/* Unlink the element from the list. */
|
||||
{
|
||||
memory_infop FAR *ppinfo = &pinformation;
|
||||
for (;;) {
|
||||
for (;;)
|
||||
{
|
||||
memory_infop pinfo = *ppinfo;
|
||||
if (pinfo->pointer == ptr) {
|
||||
if (pinfo->pointer == ptr)
|
||||
{
|
||||
*ppinfo = pinfo->next;
|
||||
current_allocation -= pinfo->size;
|
||||
if (current_allocation < 0)
|
||||
@@ -484,7 +496,8 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
|
||||
png_free_default(png_ptr, pinfo);
|
||||
break;
|
||||
}
|
||||
if (pinfo->next == NULL) {
|
||||
if (pinfo->next == NULL)
|
||||
{
|
||||
fprintf(STDERR, "Pointer %x not found\n", ptr);
|
||||
break;
|
||||
}
|
||||
@@ -514,8 +527,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_uint_32 width, height;
|
||||
int num_pass, pass;
|
||||
int bit_depth, color_type;
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
jmp_buf jmpbuf;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
char inbuf[256], outbuf[256];
|
||||
@@ -568,11 +583,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
png_debug(0, "Setting jmpbuf for read struct\n");
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
if (setjmp(jmpbuf))
|
||||
#else
|
||||
if (setjmp(read_ptr->jmpbuf))
|
||||
if (setjmp(png_jmpbuf(read_ptr)))
|
||||
#endif
|
||||
{
|
||||
fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname);
|
||||
@@ -584,14 +600,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
return (1);
|
||||
}
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
png_memcpy(read_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
|
||||
png_memcpy(png_jmpbuf(read_ptr),jmpbuf,sizeof(jmp_buf));
|
||||
#endif
|
||||
|
||||
png_debug(0, "Setting jmpbuf for write struct\n");
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
if (setjmp(jmpbuf))
|
||||
#else
|
||||
if (setjmp(write_ptr->jmpbuf))
|
||||
if (setjmp(png_jmpbuf(write_ptr)))
|
||||
#endif
|
||||
{
|
||||
fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname);
|
||||
@@ -603,7 +619,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
return (1);
|
||||
}
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
png_memcpy(write_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
|
||||
png_memcpy(png_jmpbuf(write_ptr),jmpbuf,sizeof(jmp_buf));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
png_debug(0, "Initializing input and output streams\n");
|
||||
@@ -643,6 +660,15 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_set_write_user_transform_fn(write_ptr, count_zero_samples);
|
||||
#endif
|
||||
|
||||
#define HANDLE_CHUNK_IF_SAFE 2
|
||||
#define HANDLE_CHUNK_ALWAYS 3
|
||||
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
png_set_keep_unknown_chunks(read_ptr, HANDLE_CHUNK_ALWAYS, NULL, 0);
|
||||
#endif
|
||||
#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_IF_SAFE, NULL, 0);
|
||||
#endif
|
||||
|
||||
png_debug(0, "Reading info struct\n");
|
||||
png_read_info(read_ptr, read_info_ptr);
|
||||
|
||||
@@ -661,11 +687,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#if defined(PNG_FIXED_POINT_SUPPORTED)
|
||||
#if defined(PNG_cHRM_SUPPORTED)
|
||||
{
|
||||
png_uint_32 white_x, white_y, red_x, red_y, green_x, green_y, blue_x,
|
||||
png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x,
|
||||
blue_y;
|
||||
|
||||
if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y, &red_x,
|
||||
&red_y, &green_x, &green_y, &blue_x, &blue_y))
|
||||
{
|
||||
@@ -676,7 +702,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
#endif
|
||||
#if defined(PNG_gAMA_SUPPORTED)
|
||||
{
|
||||
png_uint_32 gamma;
|
||||
png_fixed_point gamma;
|
||||
|
||||
if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma))
|
||||
{
|
||||
@@ -684,11 +710,37 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#else /* Use floating point versions */
|
||||
#if defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
#if defined(PNG_cHRM_SUPPORTED)
|
||||
{
|
||||
double white_x, white_y, red_x, red_y, green_x, green_y, blue_x,
|
||||
blue_y;
|
||||
if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x,
|
||||
&red_y, &green_x, &green_y, &blue_x, &blue_y))
|
||||
{
|
||||
png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x,
|
||||
red_y, green_x, green_y, blue_x, blue_y);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_gAMA_SUPPORTED)
|
||||
{
|
||||
double gamma;
|
||||
|
||||
if (png_get_gAMA(read_ptr, read_info_ptr, &gamma))
|
||||
{
|
||||
png_set_gAMA(write_ptr, write_info_ptr, gamma);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* floating point */
|
||||
#endif /* fixed point */
|
||||
#if defined(PNG_iCCP_SUPPORTED)
|
||||
{
|
||||
png_charp name;
|
||||
png_charp profile;
|
||||
png_int_32 proflen;
|
||||
png_uint_32 proflen;
|
||||
int compression_type;
|
||||
|
||||
if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type,
|
||||
@@ -740,7 +792,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
#endif
|
||||
#if defined(PNG_oFFs_SUPPORTED)
|
||||
{
|
||||
long offset_x, offset_y;
|
||||
png_int_32 offset_x, offset_y;
|
||||
int unit_type;
|
||||
|
||||
if (png_get_oFFs(read_ptr, read_info_ptr,&offset_x,&offset_y,&unit_type))
|
||||
@@ -788,7 +840,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
#if defined(PNG_sCAL_SUPPORTED)
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
{
|
||||
png_charp unit;
|
||||
int unit;
|
||||
double width, height;
|
||||
|
||||
if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &width, &height))
|
||||
@@ -797,9 +849,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
}
|
||||
}
|
||||
#else
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
{
|
||||
png_charp unit, width, height;
|
||||
int unit;
|
||||
png_charp width, height;
|
||||
|
||||
if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &width, &height))
|
||||
{
|
||||
@@ -807,6 +860,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#if defined(PNG_TEXT_SUPPORTED)
|
||||
{
|
||||
png_textp text_ptr;
|
||||
@@ -850,6 +905,25 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
{
|
||||
png_unknown_chunkp unknowns;
|
||||
int num_unknowns = (int)png_get_unknown_chunks(read_ptr, read_info_ptr,
|
||||
&unknowns);
|
||||
if (num_unknowns)
|
||||
{
|
||||
png_size_t i;
|
||||
png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns,
|
||||
num_unknowns);
|
||||
/* copy the locations from the read_info_ptr. The automatically
|
||||
generated locations in write_info_ptr are wrong because we
|
||||
haven't written anything yet */
|
||||
for (i = 0; i < (png_size_t)num_unknowns; i++)
|
||||
png_set_unknown_chunk_location(write_ptr, write_info_ptr, i,
|
||||
unknowns[i].location);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
png_debug(0, "\nWriting info struct\n");
|
||||
|
||||
@@ -906,7 +980,15 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
png_free_data(read_ptr, read_info_ptr, PNG_FREE_UNKN, -1);
|
||||
#endif
|
||||
#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1);
|
||||
#endif
|
||||
|
||||
png_debug(0, "Reading and writing end_info data\n");
|
||||
|
||||
png_read_end(read_ptr, end_info_ptr);
|
||||
#if defined(PNG_TEXT_SUPPORTED)
|
||||
{
|
||||
@@ -936,6 +1018,26 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
{
|
||||
png_unknown_chunkp unknowns;
|
||||
int num_unknowns;
|
||||
num_unknowns = (int)png_get_unknown_chunks(read_ptr, end_info_ptr,
|
||||
&unknowns);
|
||||
if (num_unknowns)
|
||||
{
|
||||
png_size_t i;
|
||||
png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns,
|
||||
num_unknowns);
|
||||
/* copy the locations from the read_info_ptr. The automatically
|
||||
generated locations in write_end_info_ptr are wrong because we
|
||||
haven't written the end_info yet */
|
||||
for (i = 0; i < (png_size_t)num_unknowns; i++)
|
||||
png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i,
|
||||
unknowns[i].location);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
png_write_end(write_ptr, write_end_info_ptr);
|
||||
|
||||
@@ -982,16 +1084,17 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
|
||||
if (num_in != num_out)
|
||||
{
|
||||
fprintf(STDERR, "Files %s and %s are of a different size\n",
|
||||
fprintf(STDERR, "\nFiles %s and %s are of a different size\n",
|
||||
inname, outname);
|
||||
if(wrote_question == 0)
|
||||
{
|
||||
fprintf(STDERR,
|
||||
" Was %s written with the same chunk size (8k),",inname);
|
||||
" Was %s written with the same maximum IDAT chunk size (%d bytes),",
|
||||
inname,PNG_ZBUF_SIZE);
|
||||
fprintf(STDERR,
|
||||
" filtering\n heuristic (libpng default), compression");
|
||||
"\n filtering heuristic (libpng default), compression");
|
||||
fprintf(STDERR,
|
||||
" level (zlib default)\n and zlib version (%s)?\n\n",
|
||||
" level (zlib default),\n and zlib version (%s)?\n\n",
|
||||
ZLIB_VERSION);
|
||||
wrote_question=1;
|
||||
}
|
||||
@@ -1009,11 +1112,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
if(wrote_question == 0)
|
||||
{
|
||||
fprintf(STDERR,
|
||||
" Was %s written with the same chunk size (8k),",inname);
|
||||
" Was %s written with the same maximum IDAT chunk size (%d bytes),",
|
||||
inname,PNG_ZBUF_SIZE);
|
||||
fprintf(STDERR,
|
||||
" filtering\n heuristic (libpng default), compression");
|
||||
"\n filtering heuristic (libpng default), compression");
|
||||
fprintf(STDERR,
|
||||
" level (zlib default)\n and zlib version (%s)?\n\n",
|
||||
" level (zlib default),\n and zlib version (%s)?\n\n",
|
||||
ZLIB_VERSION);
|
||||
wrote_question=1;
|
||||
}
|
||||
@@ -1048,9 +1152,13 @@ main(int argc, char *argv[])
|
||||
fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION);
|
||||
fprintf(STDERR,"%s",png_get_copyright(NULL));
|
||||
/* Show the version of libpng used in building the library */
|
||||
fprintf(STDERR," library:%s",png_get_header_version(NULL));
|
||||
fprintf(STDERR," library (%lu):%s", png_access_version_number(),
|
||||
png_get_header_version(NULL));
|
||||
/* Show the version of libpng used in building the application */
|
||||
fprintf(STDERR," pngtest:%s",PNG_HEADER_VERSION_STRING);
|
||||
fprintf(STDERR," pngtest (%lu):%s", PNG_LIBPNG_VER,
|
||||
PNG_HEADER_VERSION_STRING);
|
||||
fprintf(STDERR," sizeof(png_struct)=%d, sizeof(png_info)=%d\n",
|
||||
sizeof(png_struct), sizeof(png_info));
|
||||
|
||||
/* Do some consistency checking on the memory allocation settings, I'm
|
||||
not sure this matters, but it is nice to know, the first of these
|
||||
@@ -1123,7 +1231,10 @@ main(int argc, char *argv[])
|
||||
#endif
|
||||
for (i=2; i<argc; ++i)
|
||||
{
|
||||
int k, kerror;
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
int k;
|
||||
#endif
|
||||
int kerror;
|
||||
fprintf(STDERR, "Testing %s:",argv[i]);
|
||||
kerror = test_one_file(argv[i], outname);
|
||||
if (kerror == 0)
|
||||
@@ -1154,15 +1265,17 @@ main(int argc, char *argv[])
|
||||
if (allocation_now != current_allocation)
|
||||
fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
|
||||
current_allocation-allocation_now);
|
||||
if (current_allocation != 0) {
|
||||
if (current_allocation != 0)
|
||||
{
|
||||
memory_infop pinfo = pinformation;
|
||||
|
||||
fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n",
|
||||
current_allocation);
|
||||
while (pinfo != NULL) {
|
||||
while (pinfo != NULL)
|
||||
{
|
||||
fprintf(STDERR, " %d bytes at %x\n", pinfo->size, pinfo->pointer);
|
||||
pinfo = pinfo->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1176,7 +1289,8 @@ main(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<3; ++i) {
|
||||
for (i=0; i<3; ++i)
|
||||
{
|
||||
int kerror;
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
int allocation_now = current_allocation;
|
||||
@@ -1190,7 +1304,9 @@ main(int argc, char *argv[])
|
||||
{
|
||||
if(verbose == 1 || i == 2)
|
||||
{
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
int k;
|
||||
#endif
|
||||
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
fprintf(STDERR, "\n PASS (%lu zero samples)\n",zero_samples);
|
||||
#else
|
||||
@@ -1219,13 +1335,16 @@ main(int argc, char *argv[])
|
||||
if (allocation_now != current_allocation)
|
||||
fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
|
||||
current_allocation-allocation_now);
|
||||
if (current_allocation != 0) {
|
||||
if (current_allocation != 0)
|
||||
{
|
||||
memory_infop pinfo = pinformation;
|
||||
|
||||
fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n",
|
||||
current_allocation);
|
||||
while (pinfo != NULL) {
|
||||
fprintf(STDERR, " %d bytes at %x\n", pinfo->size, pinfo->pointer);
|
||||
while (pinfo != NULL)
|
||||
{
|
||||
fprintf(STDERR," %d bytes at %x\n",
|
||||
pinfo->size, pinfo->pointer);
|
||||
pinfo = pinfo->next;
|
||||
}
|
||||
}
|
||||
@@ -1261,9 +1380,4 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
void
|
||||
png_check_pngtest_version
|
||||
(version_1_0_5h png_h_is_not_version_1_0_5h)
|
||||
{
|
||||
if(png_h_is_not_version_1_0_5h == NULL) return;
|
||||
}
|
||||
typedef version_1_0_7beta14 your_png_h_is_not_version_1_0_7beta14;
|
||||
|
||||
55
pngtrans.c
55
pngtrans.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* libpng 1.0.5h - December 10, 1999
|
||||
* libpng 1.0.7beta14 - May 17, 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 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
||||
/* turn on BGR-to-RGB mapping */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_bgr(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_bgr\n");
|
||||
@@ -23,7 +23,7 @@ png_set_bgr(png_structp png_ptr)
|
||||
|
||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||
/* turn on 16 bit byte swapping */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_swap(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_swap\n");
|
||||
@@ -34,7 +34,7 @@ png_set_swap(png_structp png_ptr)
|
||||
|
||||
#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
/* turn on pixel packing */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_packing(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_packing\n");
|
||||
@@ -48,7 +48,7 @@ png_set_packing(png_structp png_ptr)
|
||||
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
||||
/* turn on packed pixel swapping */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_packswap(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_packswap\n");
|
||||
@@ -58,7 +58,7 @@ png_set_packswap(png_structp png_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_shift(png_structp png_ptr, png_color_8p true_bits)
|
||||
{
|
||||
png_debug(1, "in png_set_shift\n");
|
||||
@@ -69,7 +69,7 @@ png_set_shift(png_structp png_ptr, png_color_8p true_bits)
|
||||
|
||||
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
|
||||
defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
int
|
||||
int PNGAPI
|
||||
png_set_interlace_handling(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_interlace handling\n");
|
||||
@@ -89,7 +89,7 @@ png_set_interlace_handling(png_structp png_ptr)
|
||||
* for 48-bit input data, as well as to avoid problems with some compilers
|
||||
* that don't like bytes as parameters.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
{
|
||||
png_debug(1, "in png_set_filler\n");
|
||||
@@ -122,7 +122,7 @@ png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
|
||||
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
|
||||
defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_swap_alpha(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_swap_alpha\n");
|
||||
@@ -132,7 +132,7 @@ png_set_swap_alpha(png_structp png_ptr)
|
||||
|
||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
|
||||
defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_invert_alpha(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_invert_alpha\n");
|
||||
@@ -141,7 +141,7 @@ png_set_invert_alpha(png_structp png_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_invert_mono(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_invert_mono\n");
|
||||
@@ -149,7 +149,7 @@ png_set_invert_mono(png_structp png_ptr)
|
||||
}
|
||||
|
||||
/* invert monochrome grayscale data */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_invert(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_invert\n");
|
||||
@@ -174,7 +174,7 @@ png_do_invert(png_row_infop row_info, png_bytep row)
|
||||
|
||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||
/* swaps byte order on 16 bit depth images */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_swap(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_swap\n");
|
||||
@@ -305,7 +305,7 @@ static png_byte fourbppswaptable[256] = {
|
||||
};
|
||||
|
||||
/* swaps pixel packing order within bytes */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_packswap(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_packswap\n");
|
||||
@@ -337,7 +337,7 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
|
||||
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
||||
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||
/* remove filler or alpha byte(s) */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
||||
{
|
||||
png_debug(1, "in png_do_strip_filler\n");
|
||||
@@ -495,7 +495,7 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
||||
|
||||
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
||||
/* swaps red and blue bytes within a pixel */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_bgr\n");
|
||||
@@ -571,25 +571,38 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||
#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
void
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_LEGACY_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_user_transform_info(png_structp png_ptr, png_voidp
|
||||
user_transform_ptr, int user_transform_depth, int user_transform_channels)
|
||||
{
|
||||
png_debug(1, "in png_set_user_transform_info\n");
|
||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
png_ptr->user_transform_ptr = user_transform_ptr;
|
||||
png_ptr->user_transform_depth = (png_byte)user_transform_depth;
|
||||
png_ptr->user_transform_channels = (png_byte)user_transform_channels;
|
||||
#else
|
||||
if(user_transform_ptr || user_transform_depth || user_transform_channels)
|
||||
png_warning(png_ptr,
|
||||
"This version of libpng does not support user transform info");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This function returns a pointer to the user_transform_ptr associated with
|
||||
* the user transform functions. The application should free any memory
|
||||
* associated with this pointer before png_write_destroy and png_read_destroy
|
||||
* are called.
|
||||
*/
|
||||
png_voidp
|
||||
png_voidp PNGAPI
|
||||
png_get_user_transform_ptr(png_structp png_ptr)
|
||||
{
|
||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
return ((png_voidp)png_ptr->user_transform_ptr);
|
||||
}
|
||||
#else
|
||||
if(png_ptr)
|
||||
return (NULL);
|
||||
return (NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
34
pngtypes.h
34
pngtypes.h
@@ -1,34 +0,0 @@
|
||||
/* pngtypes.h - array of chunk-types for libpng
|
||||
*
|
||||
* libpng 1.0.5h - December 10, 1999
|
||||
* 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 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_sPLT;
|
||||
PNG_sRGB;
|
||||
PNG_tEXt;
|
||||
PNG_tIME;
|
||||
PNG_tRNS;
|
||||
PNG_zTXt;
|
||||
|
||||
32
pngvcrd.c
32
pngvcrd.c
@@ -2,10 +2,10 @@
|
||||
*
|
||||
* For Intel x86 CPU and Microsoft Visual C++ compiler
|
||||
*
|
||||
* libpng 1.0.5h - December 10, 1999
|
||||
* libpng 1.0.7beta14 - May 17, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998, Intel Corporation
|
||||
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
*
|
||||
* Contributed by Nirav Chhatrapati, Intel Corporation, 1998
|
||||
* Interface to libpng contributed by Gilles Vollant, 1999
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
static int mmx_supported=2;
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_read_filter_row_c(png_structp png_ptr, png_row_infop row_info,
|
||||
png_bytep row, png_bytep prev_row, int filter);
|
||||
|
||||
@@ -33,6 +33,9 @@ static int mmxsupport()
|
||||
{
|
||||
int mmx_supported_local = 0;
|
||||
_asm {
|
||||
push ebx //CPUID will trash these
|
||||
push ecx
|
||||
push edx
|
||||
pushfd //Save Eflag to stack
|
||||
pop eax //Get Eflag from stack into eax
|
||||
mov ecx, eax //Make another copy of Eflag in ecx
|
||||
@@ -70,7 +73,9 @@ static int mmxsupport()
|
||||
|
||||
NOT_SUPPORTED:
|
||||
mov eax, mmx_supported_local //move return value to eax
|
||||
|
||||
pop edx //CPUID trashed these
|
||||
pop ecx
|
||||
pop ebx
|
||||
}
|
||||
|
||||
//mmx_supported_local=0; // test code for force don't support MMX
|
||||
@@ -93,7 +98,7 @@ NOT_SUPPORTED:
|
||||
/* Use this routine for x86 platform - uses faster MMX routine if machine
|
||||
supports MMX */
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_combine_row(png_structp png_ptr, png_bytep row, int mask)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -965,7 +970,7 @@ end48:
|
||||
|
||||
#if defined(PNG_READ_INTERLACING_SUPPORTED)
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
png_uint_32 transformations)
|
||||
{
|
||||
@@ -1898,7 +1903,7 @@ union uAll {
|
||||
|
||||
|
||||
// Optimized code for PNG Average filter decoder
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_read_filter_row_mmx_avg(png_row_infop row_info, png_bytep row
|
||||
, png_bytep prev_row)
|
||||
{
|
||||
@@ -2331,7 +2336,7 @@ davgend:
|
||||
}
|
||||
|
||||
// Optimized code for PNG Paeth filter decoder
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_read_filter_row_mmx_paeth(png_row_infop row_info, png_bytep row,
|
||||
png_bytep prev_row)
|
||||
{
|
||||
@@ -3227,7 +3232,7 @@ dpthend:
|
||||
}
|
||||
|
||||
// Optimized code for PNG Sub filter decoder
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_read_filter_row_mmx_sub(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
//int test;
|
||||
@@ -3531,7 +3536,7 @@ dsubend:
|
||||
}
|
||||
|
||||
// Optimized code for PNG Up filter decoder
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_read_filter_row_mmx_up(png_row_infop row_info, png_bytep row,
|
||||
png_bytep prev_row)
|
||||
{
|
||||
@@ -3646,14 +3651,14 @@ dupend:
|
||||
|
||||
|
||||
// Optimized png_read_filter_row routines
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep
|
||||
row, png_bytep prev_row, int filter)
|
||||
{
|
||||
#ifdef PNG_DEBUG
|
||||
char filnm[6];
|
||||
#endif
|
||||
#define UseMMX 1
|
||||
#define UseMMX 1
|
||||
|
||||
if (mmx_supported == 2)
|
||||
mmx_supported = mmxsupport();
|
||||
@@ -3841,7 +3846,8 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep
|
||||
break;
|
||||
}
|
||||
default:
|
||||
png_error(png_ptr, "Bad adaptive filter type");
|
||||
png_warning(png_ptr, "Ignoring bad adaptive filter type");
|
||||
*row=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
16
pngwio.c
16
pngwio.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngwio.c - functions for data output
|
||||
*
|
||||
* libpng 1.0.5h - December 10, 1999
|
||||
* libpng 1.0.7beta14 - May 17, 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 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
*
|
||||
* This file provides a location for all output. Users who need
|
||||
* special handling are expected to write functions that have the same
|
||||
@@ -24,7 +24,7 @@
|
||||
buffering if you are using unbuffered writes. This should never be asked
|
||||
to write more than 64K on a 16 bit machine. */
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
if (png_ptr->write_data_fn != NULL )
|
||||
@@ -39,7 +39,7 @@ png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
write_data function and use it at run time with png_set_write_fn(), rather
|
||||
than changing the library. */
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
static void
|
||||
static void /* PRIVATE */
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_uint_32 check;
|
||||
@@ -59,7 +59,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
static void
|
||||
static void /* PRIVATE */
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_uint_32 check;
|
||||
@@ -106,7 +106,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
to disk). After png_flush is called, there should be no data pending
|
||||
writing in any buffers. */
|
||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_flush(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr->output_flush_fn != NULL)
|
||||
@@ -114,7 +114,7 @@ png_flush(png_structp png_ptr)
|
||||
}
|
||||
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
static void
|
||||
static void /* PRIVATE */
|
||||
png_default_flush(png_structp png_ptr)
|
||||
{
|
||||
FILE *io_ptr;
|
||||
@@ -147,7 +147,7 @@ png_default_flush(png_structp png_ptr)
|
||||
PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile
|
||||
time, output_flush_fn will be ignored, although it must be
|
||||
supplied for compatibility. */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
|
||||
{
|
||||
|
||||
399
pngwrite.c
399
pngwrite.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* libpng 1.0.5h - December 10, 1999
|
||||
* libpng 1.0.7beta14 - May 17, 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 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
*/
|
||||
|
||||
/* get internal access to png.h */
|
||||
@@ -21,12 +21,9 @@
|
||||
* write a plain PNG file. If you have long comments, I suggest writing
|
||||
* them in png_write_end(), and compressing them.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_WRITE_sPLT_SUPPORTED)
|
||||
int i;
|
||||
#endif
|
||||
png_debug(1, "in png_write_info_before_PLTE\n");
|
||||
if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
|
||||
{
|
||||
@@ -45,11 +42,11 @@ png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
|
||||
#if defined(PNG_WRITE_gAMA_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_gAMA)
|
||||
{
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_write_gAMA_fixed(png_ptr, info_ptr->int_gamma);
|
||||
#else
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_write_gAMA(png_ptr, info_ptr->gamma);
|
||||
#else
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_write_gAMA_fixed(png_ptr, info_ptr->int_gamma);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
@@ -63,11 +60,6 @@ png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
|
||||
png_write_iCCP(png_ptr, info_ptr->iccp_name, PNG_TEXT_COMPRESSION_NONE,
|
||||
info_ptr->iccp_profile, (int)info_ptr->iccp_proflen);
|
||||
#endif
|
||||
#if defined(PNG_WRITE_sPLT_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_sPLT)
|
||||
for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
|
||||
png_write_sPLT(png_ptr, info_ptr->splt_palettes + i);
|
||||
#endif
|
||||
#if defined(PNG_WRITE_sBIT_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_sBIT)
|
||||
png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type);
|
||||
@@ -75,19 +67,19 @@ png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
|
||||
#if defined(PNG_WRITE_cHRM_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_cHRM)
|
||||
{
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_write_cHRM_fixed(png_ptr,
|
||||
info_ptr->int_x_white, info_ptr->int_y_white,
|
||||
info_ptr->int_x_red, info_ptr->int_y_red,
|
||||
info_ptr->int_x_green, info_ptr->int_y_green,
|
||||
info_ptr->int_x_blue, info_ptr->int_y_blue);
|
||||
#else
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_write_cHRM(png_ptr,
|
||||
info_ptr->x_white, info_ptr->y_white,
|
||||
info_ptr->x_red, info_ptr->y_red,
|
||||
info_ptr->x_green, info_ptr->y_green,
|
||||
info_ptr->x_blue, info_ptr->y_blue);
|
||||
#else
|
||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_write_cHRM_fixed(png_ptr,
|
||||
info_ptr->int_x_white, info_ptr->int_y_white,
|
||||
info_ptr->int_x_red, info_ptr->int_y_red,
|
||||
info_ptr->int_x_green, info_ptr->int_y_green,
|
||||
info_ptr->int_x_blue, info_ptr->int_y_blue);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
@@ -102,18 +94,26 @@ png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
|
||||
for (up = info_ptr->unknown_chunks;
|
||||
up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
|
||||
up++)
|
||||
if (!(up->location & PNG_HAVE_PLTE))
|
||||
{
|
||||
int keep=png_handle_as_unknown(png_ptr, up->name);
|
||||
if (keep != HANDLE_CHUNK_NEVER &&
|
||||
up->location && (!(up->location & PNG_HAVE_PLTE)) &&
|
||||
((up->name[3] & 0x20) || keep == HANDLE_CHUNK_ALWAYS ||
|
||||
(png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
|
||||
{
|
||||
png_write_chunk(png_ptr, up->name, up->data, up->size);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_write_info(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_WRITE_TEXT_SUPPORTED)
|
||||
#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
|
||||
int i;
|
||||
#endif
|
||||
|
||||
@@ -132,7 +132,7 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||
/* invert the alpha channel (in tRNS) */
|
||||
if (png_ptr->transformations & PNG_INVERT_ALPHA &&
|
||||
if ((png_ptr->transformations & PNG_INVERT_ALPHA) &&
|
||||
info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
int j;
|
||||
@@ -165,8 +165,18 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
|
||||
#endif
|
||||
#if defined(PNG_WRITE_sCAL_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_sCAL)
|
||||
png_write_sCAL_s(png_ptr, info_ptr->scal_unit,
|
||||
#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO)
|
||||
png_write_sCAL(png_ptr, (int)info_ptr->scal_unit,
|
||||
info_ptr->scal_pixel_width, info_ptr->scal_pixel_height);
|
||||
#else
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit,
|
||||
info_ptr->scal_s_width, info_ptr->scal_s_height);
|
||||
#else
|
||||
png_warning(png_ptr,
|
||||
"png_write_sCAL not supported; sCAL chunk not written.\n");
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#if defined(PNG_WRITE_pHYs_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_pHYs)
|
||||
@@ -180,6 +190,11 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
|
||||
png_ptr->mode |= PNG_WROTE_tIME;
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_WRITE_sPLT_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_sPLT)
|
||||
for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
|
||||
png_write_sPLT(png_ptr, info_ptr->splt_palettes + i);
|
||||
#endif
|
||||
#if defined(PNG_WRITE_TEXT_SUPPORTED)
|
||||
/* Check to see if we need to write text chunks */
|
||||
for (i = 0; i < info_ptr->num_text; i++)
|
||||
@@ -187,15 +202,15 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
|
||||
png_debug2(2, "Writing header text chunk %d, type %d\n", i,
|
||||
info_ptr->text[i].compression);
|
||||
/* an internationalized chunk? */
|
||||
if (info_ptr->text[i].lang)
|
||||
if (info_ptr->text[i].compression > 0)
|
||||
{
|
||||
#if defined(PNG_WRITE_iTXt_SUPPORTED)
|
||||
/* write international chunk */
|
||||
png_write_iTXt(png_ptr,
|
||||
info_ptr->text[i].compression,
|
||||
info_ptr->text[i].lang,
|
||||
info_ptr->text[i].key,
|
||||
info_ptr->text[i].translated_key,
|
||||
info_ptr->text[i].lang,
|
||||
info_ptr->text[i].lang_key,
|
||||
info_ptr->text[i].text);
|
||||
#else
|
||||
png_warning(png_ptr, "Unable to write international text\n");
|
||||
@@ -204,12 +219,12 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
|
||||
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
|
||||
}
|
||||
/* If we want a compressed text chunk */
|
||||
else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt)
|
||||
else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_zTXt)
|
||||
{
|
||||
#if defined(PNG_WRITE_zTXt_SUPPORTED)
|
||||
/* write compressed chunk */
|
||||
png_write_zTXt(png_ptr, info_ptr->text[i].key,
|
||||
info_ptr->text[i].text, info_ptr->text[i].text_length,
|
||||
info_ptr->text[i].text, 0,
|
||||
info_ptr->text[i].compression);
|
||||
#else
|
||||
png_warning(png_ptr, "Unable to write compressed text\n");
|
||||
@@ -223,7 +238,7 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
|
||||
/* write uncompressed chunk */
|
||||
png_write_tEXt(png_ptr, info_ptr->text[i].key,
|
||||
info_ptr->text[i].text,
|
||||
info_ptr->text[i].text_length);
|
||||
0);
|
||||
#else
|
||||
png_warning(png_ptr, "Unable to write uncompressed text\n");
|
||||
#endif
|
||||
@@ -242,8 +257,17 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
|
||||
for (up = info_ptr->unknown_chunks;
|
||||
up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
|
||||
up++)
|
||||
if ((up->location& PNG_HAVE_PLTE) && !(up->location& PNG_HAVE_IDAT))
|
||||
png_write_chunk(png_ptr, up->name, up->data, up->size);
|
||||
{
|
||||
int keep=png_handle_as_unknown(png_ptr, up->name);
|
||||
if (keep != HANDLE_CHUNK_NEVER &&
|
||||
up->location && (up->location & PNG_HAVE_PLTE) &&
|
||||
!(up->location & PNG_HAVE_IDAT) &&
|
||||
((up->name[3] & 0x20) || keep == HANDLE_CHUNK_ALWAYS ||
|
||||
(png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
|
||||
{
|
||||
png_write_chunk(png_ptr, up->name, up->data, up->size);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -253,7 +277,7 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
|
||||
* in png_write_info(), do not write them again here. If you have long
|
||||
* comments, I suggest writing them here, and compressing them.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_write_end(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_debug(1, "in png_write_end\n");
|
||||
@@ -268,7 +292,7 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
|
||||
#endif
|
||||
#if defined(PNG_WRITE_tIME_SUPPORTED)
|
||||
/* check to see if user has supplied a time chunk */
|
||||
if (info_ptr->valid & PNG_INFO_tIME &&
|
||||
if ((info_ptr->valid & PNG_INFO_tIME) &&
|
||||
!(png_ptr->mode & PNG_WROTE_tIME))
|
||||
png_write_tIME(png_ptr, &(info_ptr->mod_time));
|
||||
#endif
|
||||
@@ -278,12 +302,29 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_debug2(2, "Writing trailer text chunk %d, type %d\n", i,
|
||||
info_ptr->text[i].compression);
|
||||
if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt)
|
||||
/* an internationalized chunk? */
|
||||
if (info_ptr->text[i].compression > 0)
|
||||
{
|
||||
#if defined(PNG_WRITE_iTXt_SUPPORTED)
|
||||
/* write international chunk */
|
||||
png_write_iTXt(png_ptr,
|
||||
info_ptr->text[i].compression,
|
||||
info_ptr->text[i].key,
|
||||
info_ptr->text[i].lang,
|
||||
info_ptr->text[i].lang_key,
|
||||
info_ptr->text[i].text);
|
||||
#else
|
||||
png_warning(png_ptr, "Unable to write international text\n");
|
||||
#endif
|
||||
/* Mark this chunk as written */
|
||||
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
|
||||
}
|
||||
else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt)
|
||||
{
|
||||
#if defined(PNG_WRITE_zTXt_SUPPORTED)
|
||||
/* write compressed chunk */
|
||||
png_write_zTXt(png_ptr, info_ptr->text[i].key,
|
||||
info_ptr->text[i].text, info_ptr->text[i].text_length,
|
||||
info_ptr->text[i].text, 0,
|
||||
info_ptr->text[i].compression);
|
||||
#else
|
||||
png_warning(png_ptr, "Unable to write compressed text\n");
|
||||
@@ -296,7 +337,7 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
|
||||
#if defined(PNG_WRITE_tEXt_SUPPORTED)
|
||||
/* write uncompressed chunk */
|
||||
png_write_tEXt(png_ptr, info_ptr->text[i].key,
|
||||
info_ptr->text[i].text, info_ptr->text[i].text_length);
|
||||
info_ptr->text[i].text, 0);
|
||||
#else
|
||||
png_warning(png_ptr, "Unable to write uncompressed text\n");
|
||||
#endif
|
||||
@@ -316,8 +357,16 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
|
||||
for (up = info_ptr->unknown_chunks;
|
||||
up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
|
||||
up++)
|
||||
if (up->location & PNG_HAVE_IDAT)
|
||||
{
|
||||
int keep=png_handle_as_unknown(png_ptr, up->name);
|
||||
if (keep != HANDLE_CHUNK_NEVER &&
|
||||
up->location && (up->location & PNG_AFTER_IDAT) &&
|
||||
((up->name[3] & 0x20) || keep == HANDLE_CHUNK_ALWAYS ||
|
||||
(png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
|
||||
{
|
||||
png_write_chunk(png_ptr, up->name, up->data, up->size);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -329,7 +378,7 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
|
||||
}
|
||||
|
||||
#if defined(PNG_WRITE_tIME_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime)
|
||||
{
|
||||
png_debug(1, "in png_convert_from_struct_tm\n");
|
||||
@@ -341,7 +390,7 @@ png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime)
|
||||
ptime->second = (png_byte)ttime->tm_sec;
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_convert_from_time_t(png_timep ptime, time_t ttime)
|
||||
{
|
||||
struct tm *tbuf;
|
||||
@@ -353,7 +402,7 @@ png_convert_from_time_t(png_timep ptime, time_t ttime)
|
||||
#endif
|
||||
|
||||
/* Initialize png_ptr structure, and allocate any memory needed */
|
||||
png_structp
|
||||
png_structp PNGAPI
|
||||
png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
png_error_ptr error_fn, png_error_ptr warn_fn)
|
||||
{
|
||||
@@ -363,16 +412,19 @@ png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
}
|
||||
|
||||
/* Alternate initialize png_ptr structure, and allocate any memory needed */
|
||||
png_structp
|
||||
png_structp PNGAPI
|
||||
png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
|
||||
png_malloc_ptr malloc_fn, png_free_ptr free_fn)
|
||||
{
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
png_structp png_ptr;
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
jmp_buf jmpbuf;
|
||||
#endif
|
||||
#endif
|
||||
int i;
|
||||
png_debug(1, "in png_create_write_struct\n");
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
|
||||
@@ -383,6 +435,8 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
{
|
||||
return ((png_structp)NULL);
|
||||
}
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
if (setjmp(jmpbuf))
|
||||
#else
|
||||
@@ -396,21 +450,45 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn);
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
|
||||
|
||||
/* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
|
||||
* we must recompile any applications that use any older library version.
|
||||
* For versions after libpng 1.0, we will be compatible, so we need
|
||||
* only check the first digit.
|
||||
*/
|
||||
if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
|
||||
(png_libpng_ver[0] == '0' && user_png_ver[2] < '9'))
|
||||
i=0;
|
||||
do
|
||||
{
|
||||
png_error(png_ptr,
|
||||
"Incompatible libpng version in application and library");
|
||||
if(user_png_ver[i] != png_libpng_ver[i])
|
||||
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||
} while (png_libpng_ver[i++]);
|
||||
|
||||
if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
|
||||
{
|
||||
/* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
|
||||
* we must recompile any applications that use any older library version.
|
||||
* For versions after libpng 1.0, we will be compatible, so we need
|
||||
* only check the first digit.
|
||||
*/
|
||||
if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
|
||||
(user_png_ver[0] == '0' && user_png_ver[2] < '9'))
|
||||
{
|
||||
png_error(png_ptr,
|
||||
"Incompatible libpng version in application and library");
|
||||
}
|
||||
|
||||
/* Libpng 1.0.6 was not binary compatible, due to insertion of the
|
||||
info_ptr->free_me member. Note to maintainer: this test can be
|
||||
removed from version 2.0.0 and beyond because the previous test
|
||||
would have already rejected it. */
|
||||
|
||||
if (user_png_ver[4] == '6' && user_png_ver[2] == '0' &&
|
||||
user_png_ver[0] == '1' && user_png_ver[5] == '\0')
|
||||
{
|
||||
png_error(png_ptr,
|
||||
"Application must be recompiled; version 1.0.6 was incompatible");
|
||||
}
|
||||
}
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
@@ -429,20 +507,58 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
}
|
||||
|
||||
/* Initialize png_ptr structure, and allocate any memory needed */
|
||||
void
|
||||
#undef png_write_init
|
||||
void PNGAPI
|
||||
png_write_init(png_structp png_ptr)
|
||||
{
|
||||
jmp_buf tmp_jmp; /* to save current jump buffer */
|
||||
/* We only come here via pre-1.0.7-compiled applications */
|
||||
png_write_init_2(png_ptr, "1.0.0", 10000, 10000);
|
||||
}
|
||||
|
||||
png_debug(1, "in png_write_init\n");
|
||||
void PNGAPI
|
||||
png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver,
|
||||
png_size_t png_struct_size, png_size_t png_info_size)
|
||||
{
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
jmp_buf tmp_jmp; /* to save current jump buffer */
|
||||
#endif
|
||||
int i = 0;
|
||||
do
|
||||
{
|
||||
if (user_png_ver[i] != png_libpng_ver[i])
|
||||
{
|
||||
#ifdef PNG_LEGACY_SUPPORTED
|
||||
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||
#else
|
||||
png_ptr->error_fn=(png_error_ptr)NULL;
|
||||
png_error(png_ptr,
|
||||
"Application uses deprecated png_write_init() and must be recompiled.");
|
||||
#endif
|
||||
}
|
||||
} while (png_libpng_ver[i++]);
|
||||
|
||||
if (sizeof(png_struct) > png_struct_size ||
|
||||
sizeof(png_info) > png_info_size)
|
||||
{
|
||||
png_ptr->error_fn=(png_error_ptr)NULL;
|
||||
png_error(png_ptr,
|
||||
"Application and library have different sized structs. Please recompile.");
|
||||
}
|
||||
|
||||
png_debug(1, "in png_write_init_2\n");
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
/* save jump buffer and error functions */
|
||||
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
|
||||
#endif
|
||||
|
||||
/* reset all variables to 0 */
|
||||
png_memset(png_ptr, 0, sizeof (png_struct));
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
/* restore jump buffer */
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
|
||||
#endif
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||
@@ -461,7 +577,7 @@ png_write_init(png_structp png_ptr)
|
||||
* have called png_set_interlace_handling(), you will have to
|
||||
* "write" the image seven times.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_write_rows(png_structp png_ptr, png_bytepp row,
|
||||
png_uint_32 num_rows)
|
||||
{
|
||||
@@ -479,7 +595,7 @@ png_write_rows(png_structp png_ptr, png_bytepp row,
|
||||
/* Write the image. You only need to call this function once, even
|
||||
* if you are writing an interlaced image.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_write_image(png_structp png_ptr, png_bytepp image)
|
||||
{
|
||||
png_uint_32 i; /* row index */
|
||||
@@ -506,7 +622,7 @@ png_write_image(png_structp png_ptr, png_bytepp image)
|
||||
}
|
||||
|
||||
/* called by user to write a row of image data */
|
||||
void
|
||||
void PNGAPI
|
||||
png_write_row(png_structp png_ptr, png_bytep row)
|
||||
{
|
||||
png_debug2(1, "in png_write_row (row %ld, pass %d)\n",
|
||||
@@ -554,49 +670,49 @@ png_write_row(png_structp png_ptr, png_bytep row)
|
||||
switch (png_ptr->pass)
|
||||
{
|
||||
case 0:
|
||||
if (png_ptr->row_number & 7)
|
||||
if (png_ptr->row_number & 0x07)
|
||||
{
|
||||
png_write_finish_row(png_ptr);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if ((png_ptr->row_number & 7) || png_ptr->width < 5)
|
||||
if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)
|
||||
{
|
||||
png_write_finish_row(png_ptr);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if ((png_ptr->row_number & 7) != 4)
|
||||
if ((png_ptr->row_number & 0x07) != 4)
|
||||
{
|
||||
png_write_finish_row(png_ptr);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if ((png_ptr->row_number & 3) || png_ptr->width < 3)
|
||||
if ((png_ptr->row_number & 0x03) || png_ptr->width < 3)
|
||||
{
|
||||
png_write_finish_row(png_ptr);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if ((png_ptr->row_number & 3) != 2)
|
||||
if ((png_ptr->row_number & 0x03) != 2)
|
||||
{
|
||||
png_write_finish_row(png_ptr);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if ((png_ptr->row_number & 1) || png_ptr->width < 2)
|
||||
if ((png_ptr->row_number & 0x01) || png_ptr->width < 2)
|
||||
{
|
||||
png_write_finish_row(png_ptr);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if (!(png_ptr->row_number & 1))
|
||||
if (!(png_ptr->row_number & 0x01))
|
||||
{
|
||||
png_write_finish_row(png_ptr);
|
||||
return;
|
||||
@@ -657,7 +773,7 @@ png_write_row(png_structp png_ptr, png_bytep row)
|
||||
|
||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||
/* Set the automatic flush interval or 0 to turn flushing off */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_flush(png_structp png_ptr, int nrows)
|
||||
{
|
||||
png_debug(1, "in png_set_flush\n");
|
||||
@@ -665,7 +781,7 @@ png_set_flush(png_structp png_ptr, int nrows)
|
||||
}
|
||||
|
||||
/* flush the current output buffers now */
|
||||
void
|
||||
void PNGAPI
|
||||
png_write_flush(png_structp png_ptr)
|
||||
{
|
||||
int wrote_IDAT;
|
||||
@@ -718,7 +834,7 @@ png_write_flush(png_structp png_ptr)
|
||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
|
||||
/* free all memory used by the write */
|
||||
void
|
||||
void PNGAPI
|
||||
png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
|
||||
{
|
||||
png_structp png_ptr = NULL;
|
||||
@@ -741,23 +857,14 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
|
||||
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
#if defined(PNG_WRITE_TEXT_SUPPORTED)
|
||||
png_free_text(png_ptr, info_ptr, -1);
|
||||
#endif
|
||||
#if defined(PNG_WRITE_sCAL_SUPPORTED)
|
||||
png_free_sCAL(png_ptr, info_ptr);
|
||||
#endif
|
||||
#if defined(PNG_WRITE_pCAL_SUPPORTED)
|
||||
png_free_pCAL(png_ptr, info_ptr);
|
||||
#endif
|
||||
#if defined(PNG_WRITE_iCCP_SUPPORTED)
|
||||
png_free_iCCP(png_ptr, info_ptr);
|
||||
#endif
|
||||
#if defined(PNG_WRITE_sPLT_SUPPORTED)
|
||||
png_free_spalette(png_ptr, info_ptr, -1);
|
||||
#endif
|
||||
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
png_free_unknown_chunk(png_ptr, info_ptr, -1);
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
if (png_ptr->num_chunk_list)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->chunk_list);
|
||||
png_ptr->num_chunk_list=0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
@@ -782,10 +889,12 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
|
||||
|
||||
|
||||
/* Free any memory used in png_ptr struct (old method) */
|
||||
void
|
||||
void PNGAPI
|
||||
png_write_destroy(png_structp png_ptr)
|
||||
{
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
jmp_buf tmp_jmp; /* save jump buffer */
|
||||
#endif
|
||||
png_error_ptr error_fn;
|
||||
png_error_ptr warning_fn;
|
||||
png_voidp error_ptr;
|
||||
@@ -818,8 +927,10 @@ png_write_destroy(png_structp png_ptr)
|
||||
png_free(png_ptr, png_ptr->inv_filter_costs);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
/* reset structure */
|
||||
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
|
||||
#endif
|
||||
|
||||
error_fn = png_ptr->error_fn;
|
||||
warning_fn = png_ptr->warning_fn;
|
||||
@@ -837,11 +948,13 @@ png_write_destroy(png_structp png_ptr)
|
||||
png_ptr->free_fn = free_fn;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Allow the application to select one or more row filters to use. */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_filter(png_structp png_ptr, int method, int filters)
|
||||
{
|
||||
png_debug(1, "in png_set_filter\n");
|
||||
@@ -872,14 +985,14 @@ png_set_filter(png_structp png_ptr, int method, int filters)
|
||||
*/
|
||||
if (png_ptr->row_buf != NULL)
|
||||
{
|
||||
if (png_ptr->do_filter & PNG_FILTER_SUB && png_ptr->sub_row == NULL)
|
||||
if ((png_ptr->do_filter & PNG_FILTER_SUB) && png_ptr->sub_row == NULL)
|
||||
{
|
||||
png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
|
||||
}
|
||||
|
||||
if (png_ptr->do_filter & PNG_FILTER_UP && png_ptr->up_row == NULL)
|
||||
if ((png_ptr->do_filter & PNG_FILTER_UP) && png_ptr->up_row == NULL)
|
||||
{
|
||||
if (png_ptr->prev_row == NULL)
|
||||
{
|
||||
@@ -894,7 +1007,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
|
||||
}
|
||||
}
|
||||
|
||||
if (png_ptr->do_filter & PNG_FILTER_AVG && png_ptr->avg_row == NULL)
|
||||
if ((png_ptr->do_filter & PNG_FILTER_AVG) && png_ptr->avg_row == NULL)
|
||||
{
|
||||
if (png_ptr->prev_row == NULL)
|
||||
{
|
||||
@@ -909,7 +1022,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
|
||||
}
|
||||
}
|
||||
|
||||
if (png_ptr->do_filter & PNG_FILTER_PAETH &&
|
||||
if ((png_ptr->do_filter & PNG_FILTER_PAETH) &&
|
||||
png_ptr->paeth_row == NULL)
|
||||
{
|
||||
if (png_ptr->prev_row == NULL)
|
||||
@@ -941,7 +1054,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
|
||||
* better compression.
|
||||
*/
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* GRR 970116 */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
|
||||
int num_weights, png_doublep filter_weights,
|
||||
png_doublep filter_costs)
|
||||
@@ -1058,7 +1171,7 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
|
||||
}
|
||||
#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_compression_level(png_structp png_ptr, int level)
|
||||
{
|
||||
png_debug(1, "in png_set_compression_level\n");
|
||||
@@ -1066,7 +1179,7 @@ png_set_compression_level(png_structp png_ptr, int level)
|
||||
png_ptr->zlib_level = level;
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_compression_mem_level(png_structp png_ptr, int mem_level)
|
||||
{
|
||||
png_debug(1, "in png_set_compression_mem_level\n");
|
||||
@@ -1074,7 +1187,7 @@ png_set_compression_mem_level(png_structp png_ptr, int mem_level)
|
||||
png_ptr->zlib_mem_level = mem_level;
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_compression_strategy(png_structp png_ptr, int strategy)
|
||||
{
|
||||
png_debug(1, "in png_set_compression_strategy\n");
|
||||
@@ -1082,7 +1195,7 @@ png_set_compression_strategy(png_structp png_ptr, int strategy)
|
||||
png_ptr->zlib_strategy = strategy;
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_compression_window_bits(png_structp png_ptr, int window_bits)
|
||||
{
|
||||
if (window_bits > 15)
|
||||
@@ -1101,7 +1214,7 @@ png_set_compression_window_bits(png_structp png_ptr, int window_bits)
|
||||
png_ptr->zlib_window_bits = window_bits;
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_compression_method(png_structp png_ptr, int method)
|
||||
{
|
||||
png_debug(1, "in png_set_compression_method\n");
|
||||
@@ -1111,14 +1224,14 @@ png_set_compression_method(png_structp png_ptr, int method)
|
||||
png_ptr->zlib_method = method;
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn)
|
||||
{
|
||||
png_ptr->write_row_fn = write_row_fn;
|
||||
}
|
||||
|
||||
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
|
||||
write_user_transform_fn)
|
||||
{
|
||||
@@ -1127,3 +1240,87 @@ png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
|
||||
png_ptr->write_user_transform_fn = write_user_transform_fn;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(PNG_INFO_IMAGE_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_write_png(png_structp png_ptr, png_infop info_ptr,
|
||||
int transforms, voidp params)
|
||||
{
|
||||
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||
/* invert the alpha channel from opacity to transparency */
|
||||
if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
|
||||
png_set_invert_alpha(png_ptr);
|
||||
#endif
|
||||
|
||||
/* Write the file header information. */
|
||||
png_write_info(png_ptr, info_ptr);
|
||||
|
||||
/* ------ these transformations don't touch the info structure ------- */
|
||||
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED)
|
||||
/* invert monochrome pixels */
|
||||
if (transforms & PNG_TRANSFORM_INVERT_MONO)
|
||||
png_set_invert_mono(png_ptr);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_SHIFT_SUPPORTED)
|
||||
/* Shift the pixels up to a legal bit depth and fill in
|
||||
* as appropriate to correctly scale the image.
|
||||
*/
|
||||
if ((transforms & PNG_TRANSFORM_SHIFT)
|
||||
&& (info_ptr->valid & PNG_INFO_sBIT))
|
||||
png_set_shift(png_ptr, &info_ptr->sig_bit);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
/* pack pixels into bytes */
|
||||
if (transforms & PNG_TRANSFORM_PACKING)
|
||||
png_set_packing(png_ptr);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
|
||||
/* swap location of alpha bytes from ARGB to RGBA */
|
||||
if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
|
||||
png_set_swap_alpha(png_ptr);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
/* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into
|
||||
* RGB (4 channels -> 3 channels). The second parameter is not used.
|
||||
*/
|
||||
if (transforms & PNG_TRANSFORM_STRIP_FILLER)
|
||||
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_BGR_SUPPORTED)
|
||||
/* flip BGR pixels to RGB */
|
||||
if (transforms & PNG_TRANSFORM_BGR)
|
||||
png_set_bgr(png_ptr);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||
/* swap bytes of 16-bit files to most significant byte first */
|
||||
if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
|
||||
png_set_swap(png_ptr);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
||||
/* swap bits of 1, 2, 4 bit packed pixel formats */
|
||||
if (transforms & PNG_TRANSFORM_PACKSWAP)
|
||||
png_set_packswap(png_ptr);
|
||||
#endif
|
||||
|
||||
/* ----------------------- end of transformations ------------------- */
|
||||
|
||||
/* write the bits */
|
||||
if (info_ptr->valid & PNG_INFO_IDAT)
|
||||
png_write_image(png_ptr, info_ptr->row_pointers);
|
||||
|
||||
/* It is REQUIRED to call this to finish writing the rest of the file */
|
||||
png_write_end(png_ptr, info_ptr);
|
||||
|
||||
if(transforms == 0 || params == (voidp)NULL)
|
||||
/* quiet compiler warnings */ return;
|
||||
}
|
||||
#endif
|
||||
|
||||
18
pngwtran.c
18
pngwtran.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* libpng 1.0.5h - December 10, 1999
|
||||
* libpng 1.0.7beta14 - May 17, 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 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@@ -14,7 +14,7 @@
|
||||
/* Transform the data according to the user's wishes. The order of
|
||||
* transformations is significant.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_write_transformations(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_do_write_transformations\n");
|
||||
@@ -82,7 +82,7 @@ png_do_write_transformations(png_structp png_ptr)
|
||||
* row_info bit depth should be 8 (one pixel per byte). The channels
|
||||
* should be 1 (this only happens on grayscale and paletted images).
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
{
|
||||
png_debug(1, "in png_do_pack\n");
|
||||
@@ -140,7 +140,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
{
|
||||
png_byte value;
|
||||
|
||||
value = (png_byte)(*sp & 0x3);
|
||||
value = (png_byte)(*sp & 0x03);
|
||||
v |= (value << shift);
|
||||
if (shift == 0)
|
||||
{
|
||||
@@ -172,7 +172,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
{
|
||||
png_byte value;
|
||||
|
||||
value = (png_byte)(*sp & 0xf);
|
||||
value = (png_byte)(*sp & 0x0f);
|
||||
v |= (value << shift);
|
||||
|
||||
if (shift == 0)
|
||||
@@ -208,7 +208,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
* would pass 3 as bit_depth, and this routine would translate the
|
||||
* data to 0 to 15.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
||||
{
|
||||
png_debug(1, "in png_do_shift\n");
|
||||
@@ -332,7 +332,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_write_swap_alpha\n");
|
||||
@@ -420,7 +420,7 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_write_invert_alpha\n");
|
||||
|
||||
247
pngwutil.c
247
pngwutil.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* libpng 1.0.5h - December 10, 1999
|
||||
* libpng 1.0.7beta14 - May 17, 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 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@@ -15,7 +15,7 @@
|
||||
* with unsigned numbers for convenience, although one supported
|
||||
* ancillary chunk uses signed (two's complement) numbers.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_save_uint_32(png_bytep buf, png_uint_32 i)
|
||||
{
|
||||
buf[0] = (png_byte)((i >> 24) & 0xff);
|
||||
@@ -29,7 +29,7 @@ png_save_uint_32(png_bytep buf, png_uint_32 i)
|
||||
* complement format. If this isn't the case, then this routine needs to
|
||||
* be modified to write data in two's complement format.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_save_int_32(png_bytep buf, png_int_32 i)
|
||||
{
|
||||
buf[0] = (png_byte)((i >> 24) & 0xff);
|
||||
@@ -43,7 +43,7 @@ png_save_int_32(png_bytep buf, png_int_32 i)
|
||||
* The parameter is declared unsigned int, not png_uint_16,
|
||||
* just to avoid potential problems on pre-ANSI C compilers.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_save_uint_16(png_bytep buf, unsigned int i)
|
||||
{
|
||||
buf[0] = (png_byte)((i >> 8) & 0xff);
|
||||
@@ -59,7 +59,7 @@ png_save_uint_16(png_bytep buf, unsigned int i)
|
||||
* png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end()
|
||||
* functions instead.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_write_chunk(png_structp png_ptr, png_bytep chunk_name,
|
||||
png_bytep data, png_size_t length)
|
||||
{
|
||||
@@ -72,7 +72,7 @@ png_write_chunk(png_structp png_ptr, png_bytep chunk_name,
|
||||
* The total_length is the sum of the lengths of all the data you will be
|
||||
* passing in png_write_chunk_data().
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name,
|
||||
png_uint_32 length)
|
||||
{
|
||||
@@ -95,7 +95,7 @@ png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name,
|
||||
* sum of the lengths from these calls *must* add up to the total_length
|
||||
* given to png_write_chunk_start().
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
/* write the data, and run the CRC over it */
|
||||
@@ -107,7 +107,7 @@ png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
}
|
||||
|
||||
/* Finish a chunk started with png_write_chunk_start(). */
|
||||
void
|
||||
void PNGAPI
|
||||
png_write_chunk_end(png_structp png_ptr)
|
||||
{
|
||||
png_byte buf[4];
|
||||
@@ -124,7 +124,7 @@ png_write_chunk_end(png_structp png_ptr)
|
||||
* we should call png_set_sig_bytes() to tell libpng how many of the
|
||||
* bytes have already been written.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_sig(png_structp png_ptr)
|
||||
{
|
||||
png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
@@ -133,7 +133,7 @@ png_write_sig(png_structp png_ptr)
|
||||
(png_size_t)8 - png_ptr->sig_bytes);
|
||||
}
|
||||
|
||||
#if defined(PNG_WRITE_TEXT_SUPPORTED)
|
||||
#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_iCCP_SUPPORTED)
|
||||
/*
|
||||
* This pair of functions encapsulates the operation of (a) compressing a
|
||||
* text string, and (b) issuing it later as a series of chunk data writes.
|
||||
@@ -151,7 +151,7 @@ typedef struct
|
||||
} compression_state;
|
||||
|
||||
/* compress given text into storage in the png_ptr structure */
|
||||
static int
|
||||
static int /* PRIVATE */
|
||||
png_text_compress(png_structp png_ptr,
|
||||
png_charp text, png_size_t text_len, int compression,
|
||||
compression_state *comp)
|
||||
@@ -167,7 +167,7 @@ png_text_compress(png_structp png_ptr,
|
||||
{
|
||||
comp->input = text;
|
||||
comp->input_len = text_len;
|
||||
return(text_len);
|
||||
return((int)text_len);
|
||||
}
|
||||
|
||||
if (compression >= PNG_TEXT_COMPRESSION_LAST)
|
||||
@@ -179,7 +179,6 @@ png_text_compress(png_structp png_ptr,
|
||||
#else
|
||||
png_warning(png_ptr, "Unknown compression type");
|
||||
#endif
|
||||
compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||
}
|
||||
|
||||
/* We can't write the chunk until we find out how much data we have,
|
||||
@@ -315,11 +314,11 @@ png_text_compress(png_structp png_ptr,
|
||||
if (png_ptr->zstream.avail_out < png_ptr->zbuf_size)
|
||||
text_len += png_ptr->zbuf_size - (png_size_t)png_ptr->zstream.avail_out;
|
||||
|
||||
return(text_len);
|
||||
return((int)text_len);
|
||||
}
|
||||
|
||||
/* ship the compressed text out via chunk writes */
|
||||
static void
|
||||
static void /* PRIVATE */
|
||||
png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
|
||||
{
|
||||
int i;
|
||||
@@ -334,7 +333,8 @@ png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
|
||||
/* write saved output buffers, if any */
|
||||
for (i = 0; i < comp->num_output_ptr; i++)
|
||||
{
|
||||
png_write_chunk_data(png_ptr,(png_bytep)comp->output_ptr[i],png_ptr->zbuf_size);
|
||||
png_write_chunk_data(png_ptr,(png_bytep)comp->output_ptr[i],
|
||||
png_ptr->zbuf_size);
|
||||
png_free(png_ptr, comp->output_ptr[i]);
|
||||
}
|
||||
if (comp->max_output_ptr != 0)
|
||||
@@ -354,7 +354,7 @@ png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
|
||||
* information. Note that the rest of this code depends upon this
|
||||
* information being correct.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
|
||||
int bit_depth, int color_type, int compression_type, int filter_type,
|
||||
int interlace_type)
|
||||
@@ -497,7 +497,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
|
||||
* correct order for PNG, so people can redefine it to any convenient
|
||||
* structure.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -541,7 +541,7 @@ png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)
|
||||
}
|
||||
|
||||
/* write an IDAT chunk */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -553,7 +553,7 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
}
|
||||
|
||||
/* write an IEND chunk */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_IEND(png_structp png_ptr)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -567,7 +567,7 @@ png_write_IEND(png_structp png_ptr)
|
||||
#if defined(PNG_WRITE_gAMA_SUPPORTED)
|
||||
/* write a gAMA chunk */
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_gAMA(png_structp png_ptr, double file_gamma)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -577,15 +577,15 @@ png_write_gAMA(png_structp png_ptr, double file_gamma)
|
||||
png_byte buf[4];
|
||||
|
||||
png_debug(1, "in png_write_gAMA\n");
|
||||
/* file_gamma is saved in 1/1000000ths */
|
||||
/* file_gamma is saved in 1/100,000ths */
|
||||
igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5);
|
||||
png_save_uint_32(buf, igamma);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);
|
||||
}
|
||||
#endif
|
||||
void
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_write_gAMA_fixed(png_structp png_ptr, png_uint_32 file_gamma)
|
||||
void /* PRIVATE */
|
||||
png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
PNG_gAMA;
|
||||
@@ -593,7 +593,7 @@ png_write_gAMA_fixed(png_structp png_ptr, png_uint_32 file_gamma)
|
||||
png_byte buf[4];
|
||||
|
||||
png_debug(1, "in png_write_gAMA\n");
|
||||
/* file_gamma is saved in 1/1000000ths */
|
||||
/* file_gamma is saved in 1/100,000ths */
|
||||
png_save_uint_32(buf, file_gamma);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);
|
||||
}
|
||||
@@ -602,7 +602,7 @@ png_write_gAMA_fixed(png_structp png_ptr, png_uint_32 file_gamma)
|
||||
|
||||
#if defined(PNG_WRITE_sRGB_SUPPORTED)
|
||||
/* write a sRGB chunk */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_sRGB(png_structp png_ptr, int srgb_intent)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -621,7 +621,7 @@ png_write_sRGB(png_structp png_ptr, int srgb_intent)
|
||||
|
||||
#if defined(PNG_WRITE_iCCP_SUPPORTED)
|
||||
/* write an iCCP chunk */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
|
||||
png_charp profile, int profile_len)
|
||||
{
|
||||
@@ -641,14 +641,14 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
|
||||
}
|
||||
|
||||
if (compression_type)
|
||||
/* ignore */ ;
|
||||
png_warning(png_ptr, "Unknown compression type in iCCP chunk");
|
||||
|
||||
if (profile == NULL || *profile == '\0')
|
||||
profile_len = 0;
|
||||
|
||||
if (profile_len)
|
||||
profile_len = png_text_compress(png_ptr, profile, profile_len,
|
||||
PNG_TEXT_COMPRESSION_zTXt, &comp);
|
||||
profile_len = png_text_compress(png_ptr, profile, (png_size_t)profile_len,
|
||||
PNG_TEXT_COMPRESSION_zTXt, &comp);
|
||||
|
||||
/* make sure we include the NULL after the name and the compression type */
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_iCCP,
|
||||
@@ -665,8 +665,8 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
|
||||
|
||||
#if defined(PNG_WRITE_sPLT_SUPPORTED)
|
||||
/* write a sPLT chunk */
|
||||
void
|
||||
png_write_sPLT(png_structp png_ptr, png_spalette_p spalette)
|
||||
void /* PRIVATE */
|
||||
png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
PNG_sPLT;
|
||||
@@ -676,10 +676,11 @@ png_write_sPLT(png_structp png_ptr, png_spalette_p spalette)
|
||||
png_byte entrybuf[10];
|
||||
int entry_size = (spalette->depth == 8 ? 6 : 10);
|
||||
int palette_size = entry_size * spalette->nentries;
|
||||
png_spalette_entryp ep;
|
||||
png_sPLT_entryp ep;
|
||||
|
||||
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");
|
||||
return;
|
||||
@@ -687,8 +688,9 @@ png_write_sPLT(png_structp png_ptr, png_spalette_p spalette)
|
||||
|
||||
/* make sure we include the NULL after the name */
|
||||
png_write_chunk_start(png_ptr, (png_bytep) png_sPLT,
|
||||
(png_uint_32)(name_len + 1 + palette_size));
|
||||
(png_uint_32)(name_len + 2 + palette_size));
|
||||
png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 1);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1);
|
||||
|
||||
/* loop through each palette entry, writing appropriately */
|
||||
for (ep = spalette->entries; ep<spalette->entries+spalette->nentries; ep++)
|
||||
@@ -719,7 +721,7 @@ png_write_sPLT(png_structp png_ptr, png_spalette_p spalette)
|
||||
|
||||
#if defined(PNG_WRITE_sBIT_SUPPORTED)
|
||||
/* write the sBIT chunk */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -776,7 +778,7 @@ png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type)
|
||||
#if defined(PNG_WRITE_cHRM_SUPPORTED)
|
||||
/* write the cHRM chunk */
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_cHRM(png_structp png_ptr, double white_x, double white_y,
|
||||
double red_x, double red_y, double green_x, double green_y,
|
||||
double blue_x, double blue_y)
|
||||
@@ -784,15 +786,18 @@ png_write_cHRM(png_structp png_ptr, double white_x, double white_y,
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
PNG_cHRM;
|
||||
#endif
|
||||
png_uint_32 itemp;
|
||||
png_byte buf[32];
|
||||
png_uint_32 itemp;
|
||||
|
||||
png_debug(1, "in png_write_cHRM\n");
|
||||
/* each value is saved in 1/1000000ths */
|
||||
/* each value is saved in 1/100,000ths */
|
||||
if (white_x < 0 || white_x > 0.8 || white_y < 0 || white_y > 0.8 ||
|
||||
white_x + white_y > 1.0)
|
||||
{
|
||||
png_warning(png_ptr, "Invalid cHRM white point specified");
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
printf("white_x=%f, white_y=%f\n",white_x, white_y);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
itemp = (png_uint_32)(white_x * 100000.0 + 0.5);
|
||||
@@ -837,23 +842,25 @@ png_write_cHRM(png_structp png_ptr, double white_x, double white_y,
|
||||
}
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
void
|
||||
png_write_cHRM_fixed(png_structp png_ptr, png_uint_32 white_x,
|
||||
png_uint_32 white_y, png_uint_32 red_x, png_uint_32 red_y,
|
||||
png_uint_32 green_x, png_uint_32 green_y, png_uint_32 blue_x,
|
||||
png_uint_32 blue_y)
|
||||
void /* PRIVATE */
|
||||
png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
|
||||
png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y,
|
||||
png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x,
|
||||
png_fixed_point blue_y)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
PNG_cHRM;
|
||||
#endif
|
||||
png_uint_32 itemp;
|
||||
png_byte buf[32];
|
||||
|
||||
png_debug(1, "in png_write_cHRM\n");
|
||||
/* each value is saved int 1/1000000ths */
|
||||
/* each value is saved in 1/100,000ths */
|
||||
if (white_x > 80000L || white_y > 80000L || white_x + white_y > 100000L)
|
||||
{
|
||||
png_warning(png_ptr, "Invalid cHRM white point specified");
|
||||
png_warning(png_ptr, "Invalid fixed cHRM white point specified");
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
printf("white_x=%ld, white_y=%ld\n",white_x, white_y);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
png_save_uint_32(buf, white_x);
|
||||
@@ -861,7 +868,7 @@ png_write_cHRM_fixed(png_structp png_ptr, png_uint_32 white_x,
|
||||
|
||||
if (red_x > 80000L || red_y > 80000L || red_x + red_y > 100000L)
|
||||
{
|
||||
png_warning(png_ptr, "Invalid cHRM red point specified");
|
||||
png_warning(png_ptr, "Invalid cHRM fixed red point specified");
|
||||
return;
|
||||
}
|
||||
png_save_uint_32(buf + 8, red_x);
|
||||
@@ -869,7 +876,7 @@ png_write_cHRM_fixed(png_structp png_ptr, png_uint_32 white_x,
|
||||
|
||||
if (green_x > 80000L || green_y > 80000L || green_x + green_y > 100000L)
|
||||
{
|
||||
png_warning(png_ptr, "Invalid cHRM green point specified");
|
||||
png_warning(png_ptr, "Invalid fixed cHRM green point specified");
|
||||
return;
|
||||
}
|
||||
png_save_uint_32(buf + 16, green_x);
|
||||
@@ -877,7 +884,7 @@ png_write_cHRM_fixed(png_structp png_ptr, png_uint_32 white_x,
|
||||
|
||||
if (blue_x > 80000L || blue_y > 80000L || blue_x + blue_y > 100000L)
|
||||
{
|
||||
png_warning(png_ptr, "Invalid cHRM blue point specified");
|
||||
png_warning(png_ptr, "Invalid fixed cHRM blue point specified");
|
||||
return;
|
||||
}
|
||||
png_save_uint_32(buf + 24, blue_x);
|
||||
@@ -890,7 +897,7 @@ png_write_cHRM_fixed(png_structp png_ptr, png_uint_32 white_x,
|
||||
|
||||
#if defined(PNG_WRITE_tRNS_SUPPORTED)
|
||||
/* write the tRNS chunk */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
|
||||
int num_trans, int color_type)
|
||||
{
|
||||
@@ -933,7 +940,7 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
|
||||
|
||||
#if defined(PNG_WRITE_bKGD_SUPPORTED)
|
||||
/* write the background chunk */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -974,7 +981,7 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
|
||||
|
||||
#if defined(PNG_WRITE_hIST_SUPPORTED)
|
||||
/* write the histogram */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -1014,7 +1021,7 @@ png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)
|
||||
* by the calling routine. This avoids problems with trying to write to
|
||||
* static keywords without having to have duplicate copies of the strings.
|
||||
*/
|
||||
png_size_t
|
||||
png_size_t /* PRIVATE */
|
||||
png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
||||
{
|
||||
png_size_t key_len;
|
||||
@@ -1108,7 +1115,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
||||
{
|
||||
png_free(png_ptr, *new_key);
|
||||
*new_key=NULL;
|
||||
png_chunk_warning(png_ptr, "zero length keyword");
|
||||
png_chunk_warning(png_ptr, "Zero length keyword");
|
||||
}
|
||||
|
||||
if (key_len > 79)
|
||||
@@ -1124,7 +1131,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
||||
|
||||
#if defined(PNG_WRITE_tEXt_SUPPORTED)
|
||||
/* write a tEXt chunk */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
png_size_t text_len)
|
||||
{
|
||||
@@ -1143,6 +1150,8 @@ png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
|
||||
if (text == NULL || *text == '\0')
|
||||
text_len = 0;
|
||||
else
|
||||
text_len = png_strlen(text);
|
||||
|
||||
/* make sure we include the 0 after the key */
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_tEXt, (png_uint_32)key_len+text_len+1);
|
||||
@@ -1163,7 +1172,7 @@ png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
|
||||
#if defined(PNG_WRITE_zTXt_SUPPORTED)
|
||||
/* write a compressed text chunk */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
png_size_t text_len, int compression)
|
||||
{
|
||||
@@ -1190,10 +1199,13 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
return;
|
||||
}
|
||||
|
||||
text_len = png_strlen(text);
|
||||
|
||||
png_free(png_ptr, new_key);
|
||||
|
||||
/* compute the compressed data; do it now for the length */
|
||||
text_len = png_text_compress(png_ptr, text, text_len, compression, &comp);
|
||||
text_len = png_text_compress(png_ptr, text, text_len, compression,
|
||||
&comp);
|
||||
|
||||
/* write start of chunk */
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_zTXt, (png_uint_32)
|
||||
@@ -1213,59 +1225,51 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
|
||||
#if defined(PNG_WRITE_iTXt_SUPPORTED)
|
||||
/* write an iTXt chunk */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
|
||||
png_charp lang, png_charp translated_key, png_charp text)
|
||||
png_charp lang, png_charp lang_key, png_charp text)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
PNG_iTXt;
|
||||
#endif
|
||||
png_size_t lang_len, key_len, translated_key_len, text_len;
|
||||
png_size_t lang_len, key_len, lang_key_len, text_len;
|
||||
png_charp new_lang, new_key;
|
||||
png_byte cbuf[2];
|
||||
compression_state comp;
|
||||
|
||||
png_debug(1, "in png_write_iTXt\n");
|
||||
|
||||
translated_key_len = png_strlen(translated_key);
|
||||
text_len = png_strlen(text);
|
||||
|
||||
if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0)
|
||||
{
|
||||
png_warning(png_ptr, "Empty keyword in iTXt chunk");
|
||||
return;
|
||||
}
|
||||
if (lang == NULL || (lang_len = png_check_keyword(png_ptr, lang,
|
||||
&new_lang))==0)
|
||||
{
|
||||
png_warning(png_ptr, "Empty language field in iTXt chunk");
|
||||
return;
|
||||
}
|
||||
if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0)
|
||||
{
|
||||
png_warning(png_ptr, "Empty keyword in iTXt chunk");
|
||||
return;
|
||||
}
|
||||
lang_key_len = png_strlen(lang_key);
|
||||
text_len = png_strlen(text);
|
||||
|
||||
if (text == NULL || *text == '\0')
|
||||
text_len = 0;
|
||||
|
||||
/* compute the compressed data; do it now for the length */
|
||||
text_len = png_text_compress(png_ptr, text, text_len, compression, &comp);
|
||||
text_len = png_text_compress(png_ptr, text, text_len, compression-2,
|
||||
&comp);
|
||||
|
||||
/* make sure we include the compression flag, the compression byte,
|
||||
* and the NULs after the key, lang, and translated_key parts */
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_iTXt,
|
||||
(png_uint_32)(2 + lang_len+1 + key_len+1 + translated_key_len +
|
||||
text_len));
|
||||
* and the NULs after the key, lang, and lang_key parts */
|
||||
|
||||
/* set the compression bits */
|
||||
if (compression == PNG_TEXT_COMPRESSION_NONE)
|
||||
{
|
||||
cbuf[0] = 0;
|
||||
cbuf[1] = 0;
|
||||
}
|
||||
else /* compression == PNG_TEXT_COMPRESSION_zTXt */
|
||||
{
|
||||
cbuf[0] = 1;
|
||||
cbuf[1] = 0;
|
||||
}
|
||||
png_write_chunk_data(png_ptr, cbuf, 2);
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_iTXt,
|
||||
(png_uint_32)(
|
||||
5 /* comp byte, comp flag, terminators for key, lang and lang_key */
|
||||
+ key_len
|
||||
+ lang_len
|
||||
+ lang_key_len
|
||||
+ text_len));
|
||||
|
||||
/*
|
||||
* We leave it to the application to meet PNG-1.0 requirements on the
|
||||
@@ -1274,9 +1278,19 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
|
||||
* The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG.
|
||||
*/
|
||||
png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1);
|
||||
|
||||
/* set the compression flag */
|
||||
if (compression == PNG_ITXT_COMPRESSION_NONE || \
|
||||
compression == PNG_TEXT_COMPRESSION_NONE)
|
||||
cbuf[0] = 0;
|
||||
else /* compression == PNG_ITXT_COMPRESSION_zTXt */
|
||||
cbuf[0] = 1;
|
||||
/* set the compression method */
|
||||
cbuf[1] = 0;
|
||||
png_write_chunk_data(png_ptr, cbuf, 2);
|
||||
|
||||
png_write_chunk_data(png_ptr, (png_bytep)new_lang, lang_len + 1);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)translated_key,
|
||||
translated_key_len);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)lang_key, lang_key_len+1);
|
||||
png_write_chunk_data(png_ptr, '\0', 1);
|
||||
|
||||
png_write_compressed_data_out(png_ptr, &comp);
|
||||
@@ -1289,7 +1303,7 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
|
||||
|
||||
#if defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||
/* write the oFFs chunk */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_oFFs(png_structp png_ptr, png_uint_32 x_offset,
|
||||
png_uint_32 y_offset,
|
||||
int unit_type)
|
||||
@@ -1313,7 +1327,7 @@ png_write_oFFs(png_structp png_ptr, png_uint_32 x_offset,
|
||||
|
||||
#if defined(PNG_WRITE_pCAL_SUPPORTED)
|
||||
/* write the pCAL chunk (png-scivis-19970203) */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
|
||||
png_int_32 X1, int type, int nparams, png_charp units, png_charpp params)
|
||||
{
|
||||
@@ -1373,9 +1387,9 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
|
||||
|
||||
#if defined(PNG_WRITE_sCAL_SUPPORTED)
|
||||
/* write the sCAL chunk */
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
void
|
||||
png_write_sCAL(png_structp png_ptr, png_charp unit, double width,double height)
|
||||
#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO)
|
||||
void /* PRIVATE */
|
||||
png_write_sCAL(png_structp png_ptr, int unit, double width,double height)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
PNG_sCAL;
|
||||
@@ -1387,19 +1401,20 @@ png_write_sCAL(png_structp png_ptr, png_charp unit, double width,double height)
|
||||
|
||||
sprintf(wbuf, "%12.12e", width);
|
||||
sprintf(hbuf, "%12.12e", height);
|
||||
total_len = png_strlen(unit)+1 + png_strlen(wbuf)+1 + png_strlen(hbuf);
|
||||
total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf);
|
||||
|
||||
png_debug1(3, "sCAL total length = %d\n", total_len);
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)unit, png_strlen(unit)+1);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)&unit, 1);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)wbuf, strlen(wbuf)+1);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)hbuf, strlen(hbuf));
|
||||
|
||||
png_write_chunk_end(png_ptr);
|
||||
}
|
||||
#endif
|
||||
void
|
||||
png_write_sCAL_s(png_structp png_ptr, png_charp unit, png_charp width,
|
||||
#else
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width,
|
||||
png_charp height)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -1408,25 +1423,27 @@ png_write_sCAL_s(png_structp png_ptr, png_charp unit, png_charp width,
|
||||
png_size_t total_len;
|
||||
char wbuf[32], hbuf[32];
|
||||
|
||||
png_debug(1, "in png_write_sCAL\n");
|
||||
png_debug(1, "in png_write_sCAL_s\n");
|
||||
|
||||
sprintf(wbuf, "%s", width);
|
||||
sprintf(hbuf, "%s", height);
|
||||
total_len = png_strlen(unit)+1 + png_strlen(wbuf)+1 + png_strlen(hbuf);
|
||||
strcpy(wbuf,(const char *)width);
|
||||
strcpy(hbuf,(const char *)height);
|
||||
total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf);
|
||||
|
||||
png_debug1(3, "sCAL total length = %d\n", total_len);
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)unit, png_strlen(unit)+1);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)&unit, 1);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)wbuf, strlen(wbuf)+1);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)hbuf, strlen(hbuf));
|
||||
|
||||
png_write_chunk_end(png_ptr);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_pHYs_SUPPORTED)
|
||||
/* write the pHYs chunk */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit,
|
||||
png_uint_32 y_pixels_per_unit,
|
||||
int unit_type)
|
||||
@@ -1452,7 +1469,7 @@ png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit,
|
||||
/* Write the tIME chunk. Use either png_convert_from_struct_tm()
|
||||
* or png_convert_from_time_t(), or fill in the structure yourself.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_tIME(png_structp png_ptr, png_timep mod_time)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -1481,7 +1498,7 @@ png_write_tIME(png_structp png_ptr, png_timep mod_time)
|
||||
#endif
|
||||
|
||||
/* initializes the row writing capability of libpng */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_start_row(png_structp png_ptr)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -1575,7 +1592,7 @@ png_write_start_row(png_structp png_ptr)
|
||||
}
|
||||
|
||||
/* Internal use only. Called when finished processing a row of data. */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_finish_row(png_structp png_ptr)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -1689,7 +1706,7 @@ png_write_finish_row(png_structp png_ptr)
|
||||
* sp will always be >= dp, so we should never overwrite anything.
|
||||
* See the default: case for the easiest code to understand.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -1730,7 +1747,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
i += png_pass_inc[pass])
|
||||
{
|
||||
sp = row + (png_size_t)(i >> 3);
|
||||
value = (int)(*sp >> (7 - (int)(i & 7))) & 0x1;
|
||||
value = (int)(*sp >> (7 - (int)(i & 0x07))) & 0x01;
|
||||
d |= (value << shift);
|
||||
|
||||
if (shift == 0)
|
||||
@@ -1764,7 +1781,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
i += png_pass_inc[pass])
|
||||
{
|
||||
sp = row + (png_size_t)(i >> 2);
|
||||
value = (*sp >> ((3 - (int)(i & 3)) << 1)) & 0x3;
|
||||
value = (*sp >> ((3 - (int)(i & 0x03)) << 1)) & 0x03;
|
||||
d |= (value << shift);
|
||||
|
||||
if (shift == 0)
|
||||
@@ -1797,7 +1814,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
i += png_pass_inc[pass])
|
||||
{
|
||||
sp = row + (png_size_t)(i >> 1);
|
||||
value = (*sp >> ((1 - (int)(i & 1)) << 2)) & 0xf;
|
||||
value = (*sp >> ((1 - (int)(i & 0x01)) << 2)) & 0x0f;
|
||||
d |= (value << shift);
|
||||
|
||||
if (shift == 0)
|
||||
@@ -1860,7 +1877,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
#define PNG_HISHIFT 10
|
||||
#define PNG_LOMASK ((png_uint_32)0xffffL)
|
||||
#define PNG_HIMASK ((png_uint_32)(~PNG_LOMASK >> PNG_HISHIFT))
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
{
|
||||
png_bytep prev_row, best_row, row_buf;
|
||||
@@ -1904,7 +1921,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
/* We don't need to test the 'no filter' case if this is the only filter
|
||||
* that has been chosen, as it doesn't actually do anything to the data.
|
||||
*/
|
||||
if (filter_to_do & PNG_FILTER_NONE &&
|
||||
if ((filter_to_do & PNG_FILTER_NONE) &&
|
||||
filter_to_do != PNG_FILTER_NONE)
|
||||
{
|
||||
png_bytep rp;
|
||||
@@ -2472,7 +2489,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
|
||||
|
||||
/* Do the actual writing of a previously filtered row. */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row)
|
||||
{
|
||||
png_debug(1, "in png_write_filtered_row\n");
|
||||
|
||||
@@ -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
|
||||
43
scripts/libpng.icc
Normal file
43
scripts/libpng.icc
Normal file
@@ -0,0 +1,43 @@
|
||||
// Project file for libpng (static)
|
||||
// IBM VisualAge/C++ version 4.0 or later
|
||||
// Copyright (C) 2000 Cosmin Truta
|
||||
// Notes:
|
||||
// All modules are compiled in C mode
|
||||
// Tested with IBM VAC++ 4.0 under Win32
|
||||
// Expected to work with IBM VAC++ 4.0 or later under OS/2 and Win32
|
||||
// Can be easily adapted for IBM VAC++ 4.0 or later under AIX
|
||||
// For conditions of distribution and use, see copyright notice in png.h
|
||||
|
||||
option incl(searchpath, "../zlib"), opt(level, "2"),
|
||||
link(libsearchpath, "../zlib")
|
||||
{
|
||||
target type(lib) "libpng.lib"
|
||||
{
|
||||
source type(c) "png.c"
|
||||
source type(c) "pngerror.c"
|
||||
source type(c) "pngget.c"
|
||||
source type(c) "pngmem.c"
|
||||
source type(c) "pngpread.c"
|
||||
source type(c) "pngread.c"
|
||||
source type(c) "pngrio.c"
|
||||
source type(c) "pngrtran.c"
|
||||
source type(c) "pngrutil.c"
|
||||
source type(c) "pngset.c"
|
||||
source type(c) "pngtrans.c"
|
||||
source type(c) "pngwio.c"
|
||||
source type(c) "pngwrite.c"
|
||||
source type(c) "pngwtran.c"
|
||||
source type(c) "pngwutil.c"
|
||||
}
|
||||
}
|
||||
|
||||
option incl(searchpath, "../zlib"), opt(level, "2"),
|
||||
link(libsearchpath, "../zlib")
|
||||
{
|
||||
target type(exe) "pngtest.exe"
|
||||
{
|
||||
source type(c) "pngtest.c"
|
||||
source type(lib) "libpng.lib"
|
||||
source type(lib) "zlib.lib"
|
||||
}
|
||||
}
|
||||
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
|
||||
# ------------- Borland C++ 4.5 -------------
|
||||
# ------------- 32-bit Borland C++ -------------
|
||||
|
||||
# This makefile expects to find zlib.h and zlib32bd.lib in the
|
||||
# $(ZLIBDIR) directory.
|
||||
@@ -12,42 +12,65 @@
|
||||
# compress and uncompress functions, nor any of the gz... functions,
|
||||
# since libpng does not call them.
|
||||
|
||||
ZLIBDIR=..\zlib112
|
||||
.AUTODEPEND
|
||||
|
||||
ZLIBDIR=..\zlib
|
||||
ZLIB=zlib32bd.lib
|
||||
PNGDLL=png32bd.dll
|
||||
PNGLIB=png32bd.lib
|
||||
|
||||
CFLAGS= -ps -O2 -C -K -N- -k- -d -3 -r- -w-par -w-aus -WDE -I$(ZLIBDIR)
|
||||
CC=f:\bc45\bin\bcc32
|
||||
LINKFLAGS= -Tpd -aa -c
|
||||
LINK=f:\bc45\bin\tlink32
|
||||
LIBDIR=f:\bc45\lib
|
||||
IMPLIB=f:\bc45\bin\implib
|
||||
CC=bcc32
|
||||
CFLAGS= -ps -O2 -N- -k- -d -r- -w-par -w-aus -I$(ZLIBDIR) \
|
||||
-DPNG_NO_GLOBAL_ARRAYS #-DPNG_DEBUG=5
|
||||
#LINK=tlink32
|
||||
#LINK=ilink32
|
||||
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:
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
|
||||
OBJ1=png.obj pngerror.obj pngget.obj pngmem.obj pngpread.obj
|
||||
OBJ2=pngread.obj pngrio.obj pngrtran.obj pngrutil.obj pngset.obj
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
|
||||
.c.exe:
|
||||
$(CC) $(CFLAGS) $< $(PNGLIB) $(NOEHLIB)
|
||||
|
||||
|
||||
OBJ1=png.obj pngerror.obj pngget.obj pngmem.obj pngpread.obj
|
||||
OBJ2=pngread.obj pngrio.obj pngrtran.obj pngrutil.obj pngset.obj
|
||||
OBJ3=pngtrans.obj pngwio.obj pngwrite.obj pngwtran.obj pngwutil.obj
|
||||
|
||||
all: $(PNGDLL)
|
||||
|
||||
test: pngtest.exe
|
||||
pngtest
|
||||
|
||||
|
||||
$(PNGDLL): $(OBJ1) $(OBJ2) $(OBJ3) $(ZLIBDIR)\$(ZLIB)
|
||||
$(LINK) @&&|
|
||||
$(LINKFLAGS) $(LIBDIR)\c0d32 +
|
||||
$(OBJ1) +
|
||||
$(OBJ2) +
|
||||
$(LINK) @&&|
|
||||
$(LINKFLAGS)
|
||||
-e$(PNGDLL)
|
||||
$(OBJ1)
|
||||
$(OBJ2)
|
||||
$(OBJ3)
|
||||
$@
|
||||
-x
|
||||
$(ZLIBDIR)\$(ZLIB) $(LIBDIR)\import32 $(LIBDIR)\cw32
|
||||
|,&&|
|
||||
LIBRARY $(@B)
|
||||
EXETYPE WINDOWS
|
||||
CODE PRELOAD MOVEABLE DISCARDABLE
|
||||
DATA PRELOAD MOVEABLE MULTIPLE
|
||||
$(ZLIBDIR)\$(ZLIB)
|
||||
$(NOEHLIB)
|
||||
|
|
||||
$(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
|
||||
@@ -31,7 +31,7 @@ RANLIB=ranlib
|
||||
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
||||
# have to change it.
|
||||
PNGMAJ = 2
|
||||
PNGMIN = 1.0.5h
|
||||
PNGMIN = 1.0.7beta14
|
||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||
|
||||
# where make install puts libpng.a, libpng.so*, and png.h
|
||||
|
||||
@@ -1,39 +1,38 @@
|
||||
# Makefile for libpng
|
||||
# Borland C++ 4.5 (Note: All modules are compiled in C mode)
|
||||
# Will work with C++ 4.02 also
|
||||
# To build the library, do:
|
||||
# "make -fmakefile.borland -DMODEL=m"
|
||||
# or: "make -fmakefile.borland -DMODEL=l"
|
||||
# 16-bit Borland C++ (Note: All modules are compiled in C mode)
|
||||
# To build the library, do:
|
||||
# "make -fmakefile.bor -DMODEL=c"
|
||||
# or: "make -fmakefile.bor -DMODEL=l"
|
||||
#
|
||||
# ------------- Borland C++ 4.5 -------------
|
||||
# ------------ Borland C++ ------------
|
||||
|
||||
### Absolutely necessary for this makefile to work
|
||||
.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
|
||||
ZLIB_PATH=..\zlib
|
||||
## Compiler, linker and lib stuff
|
||||
CC=bcc
|
||||
LD=bcc
|
||||
LIB=tlib
|
||||
|
||||
!ifndef MODEL
|
||||
MODEL=l
|
||||
!endif
|
||||
|
||||
MODEL_ARG=-m$(MODEL)
|
||||
|
||||
#TARGET_CPU=3
|
||||
# 2 = 286, 3 = 386, etc.
|
||||
!ifndef TARGET_CPU
|
||||
TARGET_CPU=2
|
||||
!endif
|
||||
|
||||
|
||||
# Use this if you don't want Borland's fancy exception handling.
|
||||
NOEHLIB=noeh$(MODEL).lib
|
||||
# Use this if you don't want Borland's fancy exception handling
|
||||
# (for Borland C++ 4.0 or later)
|
||||
#NOEHLIB=noeh$(MODEL).lib
|
||||
|
||||
!ifdef DEBUG
|
||||
CDEBUG=-v
|
||||
@@ -49,59 +48,50 @@ CDEBUG=$(CDEBUG) -N
|
||||
LDEBUG=$(LDEBUG) -N
|
||||
!endif
|
||||
|
||||
|
||||
## Compiler, linker, and lib stuff
|
||||
CC=bcc
|
||||
LD=bcc
|
||||
LIB=tlib
|
||||
|
||||
MODELARG=-m$(MODEL)
|
||||
|
||||
# -X- turns on dependency generation in the object file
|
||||
# -w sets all warnings on
|
||||
# -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_PATH) -$(TARGET_CPU) $(MODELARG) $(CDEBUG)
|
||||
CFLAGS=-O2 -Z -X- -w -I$(ZLIB_DIR) -$(TARGET_CPU) $(MODEL_ARG) $(CDEBUG)
|
||||
|
||||
# -M generate map file
|
||||
LDFLAGS=-M $(LDEBUG)
|
||||
LDFLAGS=-M -L$(ZLIB_DIR) $(MODEL_ARG) $(LDEBUG)
|
||||
|
||||
O=obj
|
||||
|
||||
## variables
|
||||
## Variables
|
||||
OBJS = \
|
||||
png.$(O) \
|
||||
pngerror.$(O) \
|
||||
pngmem.$(O) \
|
||||
pngpread.$(O) \
|
||||
pngset.$(O) \
|
||||
pngget.$(O) \
|
||||
pngread.$(O) \
|
||||
pngrio.$(O) \
|
||||
pngrtran.$(O) \
|
||||
pngrutil.$(O) \
|
||||
pngtrans.$(O) \
|
||||
pngwrite.$(O) \
|
||||
pngwtran.$(O) \
|
||||
pngwio.$(O) \
|
||||
pngwutil.$(O)
|
||||
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.$(O) \
|
||||
+pngerror.$(O) \
|
||||
+pngmem.$(O) \
|
||||
+pngpread.$(O) \
|
||||
+pngread.$(O) \
|
||||
+pngset.$(O) \
|
||||
+pngget.$(O) \
|
||||
+pngrio.$(O) \
|
||||
+pngrtran.$(O) \
|
||||
+pngrutil.$(O) \
|
||||
+pngtrans.$(O) \
|
||||
+pngwrite.$(O) \
|
||||
+pngwtran.$(O) \
|
||||
+pngwio.$(O) \
|
||||
+pngwutil.$(O)
|
||||
+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$(MODEL).lib
|
||||
|
||||
@@ -113,10 +103,12 @@ LIBNAME=libpng$(MODEL).lib
|
||||
$(CC) $(CFLAGS) -c {$*.c }
|
||||
|
||||
.c.exe:
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $*.c
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $*.c $(LIBNAME) zlib_$(MODEL).lib $(NOEHLIB)
|
||||
|
||||
|
||||
## Major targets
|
||||
all: libpng pngtest
|
||||
|
||||
libpng: $(LIBNAME)
|
||||
|
||||
pngtest: pngtest$(MODEL).exe
|
||||
@@ -128,17 +120,17 @@ test: pngtest$(MODEL).exe
|
||||
## Minor Targets
|
||||
|
||||
png.obj: png.c
|
||||
pngset.obj: pngset.c
|
||||
pngerror.obj: pngerror.c
|
||||
pngget.obj: pngget.c
|
||||
pngread.obj: pngread.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
|
||||
pngerror.obj: pngerror.c
|
||||
pngmem.obj: pngmem.c
|
||||
pngrio.obj: pngrio.c
|
||||
pngwio.obj: pngwio.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
|
||||
@@ -155,14 +147,16 @@ pngtest$(MODEL).obj: pngtest.c
|
||||
$(CC) $(CFLAGS) -opngtest$(MODEL) -c pngtest.c
|
||||
|
||||
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:
|
||||
-del *.obj
|
||||
-del *.exe
|
||||
-del *.lib
|
||||
-del *.lst
|
||||
-del *.map
|
||||
|
||||
|
||||
# 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
|
||||
# have to change it.
|
||||
PNGMAJ = 2
|
||||
PNGMIN = 1.0.5h
|
||||
PNGMIN = 1.0.7beta14
|
||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||
|
||||
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
|
||||
|
||||
126
scripts/makefile.gcmmx
Normal file
126
scripts/makefile.gcmmx
Normal file
@@ -0,0 +1,126 @@
|
||||
# makefile for libpng on Linux ELF with gcc using MMX assembler code
|
||||
# Copyright (C) 1996, 1997 Andreas Dilger
|
||||
# Copyright (C) 1998-2000 Greg Roelofs
|
||||
# For conditions of distribution and use, see copyright notice in png.h
|
||||
|
||||
CC=gcc
|
||||
|
||||
# where "make install" puts libpng.a, libpng.so*, png.h and pngconf.h
|
||||
prefix=/usr/local
|
||||
|
||||
# Where the zlib library and include files are located
|
||||
#ZLIBLIB=/usr/local/lib
|
||||
#ZLIBINC=/usr/local/include
|
||||
ZLIBLIB=../zlib
|
||||
ZLIBINC=../zlib
|
||||
|
||||
ALIGN=
|
||||
# for i386:
|
||||
#ALIGN=-malign-loops=2 -malign-functions=2
|
||||
|
||||
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
|
||||
-Wmissing-declarations -Wtraditional -Wcast-align \
|
||||
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
|
||||
|
||||
# for pgcc version 2.95.1, -O3 is buggy; don't use it.
|
||||
|
||||
CFLAGS=-DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 $(ALIGN) -funroll-loops \
|
||||
-fomit-frame-pointer # $(WARNMORE) -g -DPNG_DEBUG=5
|
||||
LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz -lm
|
||||
|
||||
RANLIB=ranlib
|
||||
#RANLIB=echo
|
||||
|
||||
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
||||
# have to change it.
|
||||
PNGMAJ = 2
|
||||
PNGMIN = 1.0.7beta14
|
||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||
|
||||
INCPATH=$(prefix)/include
|
||||
LIBPATH=$(prefix)/lib
|
||||
|
||||
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 pnggccrd.o
|
||||
|
||||
OBJSDLL = $(OBJS:.o=.pic.o)
|
||||
|
||||
.SUFFIXES: .c .o .pic.o
|
||||
|
||||
.c.pic.o:
|
||||
$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
|
||||
|
||||
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)
|
||||
ar rc $@ $(OBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
libpng.so: libpng.so.$(PNGMAJ)
|
||||
ln -sf libpng.so.$(PNGMAJ) libpng.so
|
||||
|
||||
libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
|
||||
ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
|
||||
|
||||
libpng.so.$(PNGVER): $(OBJSDLL)
|
||||
$(CC) -shared -Wl,-soname,libpng.so.$(PNGMAJ) -o libpng.so.$(PNGVER) \
|
||||
$(OBJSDLL) -L$(ZLIBLIB) -lz -lm -lc
|
||||
|
||||
pngtest: pngtest.o libpng.so
|
||||
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
|
||||
|
||||
test: pngtest
|
||||
./pngtest
|
||||
|
||||
install: libpng.a libpng.so.$(PNGVER)
|
||||
-@if [ ! -d $(INCPATH) ]; then mkdir $(INCPATH); fi
|
||||
-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
|
||||
cp png.h pngconf.h $(INCPATH)
|
||||
chmod 644 $(INCPATH)/png.h $(INCPATH)/pngconf.h
|
||||
cp libpng.a libpng.so.$(PNGVER) $(LIBPATH)
|
||||
chmod 755 $(LIBPATH)/libpng.so.$(PNGVER)
|
||||
-@/bin/rm -f $(LIBPATH)/libpng.so.$(PNGMAJ) $(LIBPATH)/libpng.so
|
||||
(cd $(LIBPATH); ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
|
||||
ln -sf libpng.so.$(PNGMAJ) libpng.so)
|
||||
|
||||
clean:
|
||||
/bin/rm -f *.o libpng.a libpng.so* pngtest pngout.png
|
||||
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
|
||||
writelock:
|
||||
chmod a-w *.[ch35] $(DOCS) scripts/*
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
png.o png.pic.o: png.h pngconf.h
|
||||
pngerror.o pngerror.pic.o: png.h pngconf.h
|
||||
pngrio.o pngrio.pic.o: png.h pngconf.h
|
||||
pngwio.o pngwio.pic.o: png.h pngconf.h
|
||||
pngmem.o pngmem.pic.o: png.h pngconf.h
|
||||
pngset.o pngset.pic.o: png.h pngconf.h
|
||||
pngget.o pngget.pic.o: png.h pngconf.h
|
||||
pngread.o pngread.pic.o: png.h pngconf.h
|
||||
pngrtran.o pngrtran.pic.o: png.h pngconf.h
|
||||
pngrutil.o pngrutil.pic.o: png.h pngconf.h
|
||||
pngtrans.o pngtrans.pic.o: png.h pngconf.h
|
||||
pngwrite.o pngwrite.pic.o: png.h pngconf.h
|
||||
pngwtran.o pngwtran.pic.o: png.h pngconf.h
|
||||
pngwutil.o pngwutil.pic.o: png.h pngconf.h
|
||||
pngpread.o pngpread.pic.o: png.h pngconf.h
|
||||
|
||||
pngtest.o: png.h pngconf.h
|
||||
71
scripts/makefile.ibmc
Normal file
71
scripts/makefile.ibmc
Normal file
@@ -0,0 +1,71 @@
|
||||
# Makefile for libpng (static)
|
||||
# IBM C version 3.x for Win32 and OS/2
|
||||
# Copyright (C) 2000 Cosmin Truta
|
||||
# Notes:
|
||||
# Derived from makefile.std
|
||||
# All modules are compiled in C mode
|
||||
# Tested with IBM C 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
|
||||
114
scripts/makefile.intel
Normal file
114
scripts/makefile.intel
Normal file
@@ -0,0 +1,114 @@
|
||||
# Makefile for libpng
|
||||
# Microsoft Visual C++ with Intel C/C++ Compiler 4.0 and later
|
||||
|
||||
# Copyright (C) 2000, Pawel Mrochen, based on makefile.msc which is
|
||||
# copyright 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
# For conditions of distribution and use, see copyright notice in png.h
|
||||
|
||||
# To use, do "nmake /f scripts\makefile.intel"
|
||||
|
||||
|
||||
# ------------------- Intel C/C++ Compiler 4.0 and later -------------------
|
||||
|
||||
# Caution: the assembler code was introduced at libpng version 1.0.4 and has
|
||||
# not yet been thoroughly tested.
|
||||
|
||||
# Use assembler code
|
||||
ASMCODE=-DPNG_USE_PNGVCRD
|
||||
|
||||
# Where the zlib library and include files are located
|
||||
ZLIBLIB=..\zlib
|
||||
ZLIBINC=..\zlib
|
||||
|
||||
# Target CPU
|
||||
CPU=6 # Pentium II
|
||||
#CPU=5 # Pentium
|
||||
|
||||
# Calling convention
|
||||
CALLING=r # __fastcall
|
||||
#CALLING=z # __stdcall
|
||||
#CALLING=d # __cdecl
|
||||
|
||||
# Uncomment next to put error messages in a file
|
||||
#ERRFILE=>>pngerrs
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
|
||||
CC=icl -c
|
||||
CFLAGS=-O2 -G$(CPU)$(CALLING) -Qip -Qunroll4 -I$(ZLIBINC) $(ASMCODE) -nologo
|
||||
LD=link
|
||||
LDFLAGS=/SUBSYSTEM:CONSOLE /NOLOGO
|
||||
|
||||
O=.obj
|
||||
|
||||
OBJS=png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O)\
|
||||
pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O)\
|
||||
pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) pngvcrd$(O)
|
||||
|
||||
|
||||
all: test
|
||||
|
||||
png$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngset$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngget$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngread$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngpread$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngrtran$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngrutil$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngvcrd$(O): png.h pngconf.h pngasmrd.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngerror$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngmem$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngrio$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngwio$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngtest$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngtrans$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngwrite$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngwtran$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngwutil$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
libpng.lib: $(OBJS)
|
||||
if exist libpng.lib del libpng.lib
|
||||
lib /NOLOGO /OUT:libpng.lib $(OBJS)
|
||||
|
||||
pngtest.exe: pngtest.obj libpng.lib
|
||||
$(LD) $(LDFLAGS) /OUT:pngtest.exe pngtest.obj libpng.lib $(ZLIBLIB)\zlib.lib
|
||||
|
||||
test: pngtest.exe
|
||||
pngtest.exe
|
||||
|
||||
|
||||
# End of makefile for libpng
|
||||
@@ -34,7 +34,7 @@ RANLIB=ranlib
|
||||
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
||||
# have to change it.
|
||||
PNGMAJ = 2
|
||||
PNGMIN = 1.0.5h
|
||||
PNGMIN = 1.0.7beta14
|
||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||
|
||||
INCPATH=$(prefix)/include
|
||||
@@ -74,7 +74,8 @@ test: pngtest
|
||||
./pngtest
|
||||
|
||||
install: libpng.a libpng.so.$(PNGVER)
|
||||
-@mkdir $(INCPATH) $(LIBPATH)
|
||||
-@if [ ! -d $(INCPATH) ]; then mkdir $(INCPATH); fi
|
||||
-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
|
||||
cp png.h pngconf.h $(INCPATH)
|
||||
chmod 644 $(INCPATH)/png.h $(INCPATH)/pngconf.h
|
||||
cp libpng.a libpng.so.$(PNGVER) $(LIBPATH)
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
# 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 -----
|
||||
MODEL=-AL
|
||||
CFLAGS=-Oait -Gs -nologo -W3 $(MODEL) -I..\zlib
|
||||
MODEL=L
|
||||
CFLAGS=-Oait -Gs -nologo -W3 -A$(MODEL) -I..\zlib
|
||||
#-Ox generates bad code with MSC 5.1
|
||||
CC=cl
|
||||
LD=link
|
||||
|
||||
@@ -25,7 +25,7 @@ RANLIB=echo
|
||||
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
||||
# have to change it.
|
||||
PNGMAJ = 2
|
||||
PNGMIN = 1.0.5h
|
||||
PNGMIN = 1.0.7beta14
|
||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||
|
||||
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.7beta14
|
||||
LIBS=libpng.so.1.0.7beta14
|
||||
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
|
||||
|
||||
@@ -6,17 +6,6 @@
|
||||
|
||||
CC=gcc
|
||||
|
||||
case "`type ld`" in *ucb*) echo "
|
||||
# WARNING:
|
||||
# The commands "CC" and "LD" must NOT refer to /usr/ucb/cc and
|
||||
# /usr/ucb/ld. If they do, you need to adjust your PATH environment
|
||||
# variable to put /usr/ccs/bin ahead of /usr/ucb. The environment
|
||||
# variable LD_LIBRARY_PATH should not be set at all. If it is,
|
||||
# things are likely to break because of the libucb dependency that
|
||||
# is created.
|
||||
" ;;
|
||||
esac
|
||||
|
||||
# Where make install puts libpng.a, libpng.so*, and png.h
|
||||
prefix=/usr/local
|
||||
|
||||
@@ -42,7 +31,7 @@ RANLIB=echo
|
||||
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
||||
# have to change it.
|
||||
PNGMAJ = 2
|
||||
PNGMIN = 1.0.5h
|
||||
PNGMIN = 1.0.7beta14
|
||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||
|
||||
INCPATH=$(prefix)/include
|
||||
@@ -72,6 +61,18 @@ libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
|
||||
ln -f -s libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
|
||||
|
||||
libpng.so.$(PNGVER): $(OBJSDLL)
|
||||
@case "`type ld`" in *ucb*) \
|
||||
echo; \
|
||||
echo '## WARNING:'; \
|
||||
echo '## The commands "CC" and "LD" must NOT refer to /usr/ucb/cc'; \
|
||||
echo '## and /usr/ucb/ld. If they do, you need to adjust your PATH'; \
|
||||
echo '## environment variable to put /usr/ccs/bin ahead of /usr/ucb.'; \
|
||||
echo '## The environment variable LD_LIBRARY_PATH should not be set'; \
|
||||
echo '## at all. If it is, things are likely to break because of'; \
|
||||
echo '## the libucb dependency that is created.'; \
|
||||
echo; \
|
||||
;; \
|
||||
esac
|
||||
$(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h libpng.so.$(PNGMAJ) \
|
||||
-o libpng.so.$(PNGVER) $(OBJSDLL) -lz
|
||||
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
# 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 -------------
|
||||
MODEL=-ml
|
||||
CFLAGS=-O2 -Z $(MODEL) -I..\zlib
|
||||
# ------ Turbo C 3.00 (can be modified to work with earlier versions)------
|
||||
|
||||
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
|
||||
LD=tcc
|
||||
LIB=tlib
|
||||
LDFLAGS=$(MODEL) -L..\zlib
|
||||
LDFLAGS=-m$(MODEL) -L..\zlib
|
||||
O=.obj
|
||||
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)
|
||||
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
|
||||
$(CC) -c $(CFLAGS) $*.c
|
||||
@@ -71,12 +78,12 @@ pngwtran$(O): png.h pngconf.h
|
||||
pngwutil$(O): png.h pngconf.h
|
||||
$(CC) -c $(CFLAGS) $*.c
|
||||
|
||||
libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3)
|
||||
$(LIB) libpng +$(OBJSL1)
|
||||
$(LIB) libpng +$(OBJSL2)
|
||||
$(LIB) libpng +$(OBJSL3)
|
||||
libpng$(MODEL).lib: $(OBJS1) $(OBJS2) $(OBJS3)
|
||||
$(LIB) libpng$(MODEL) +$(OBJSL1)
|
||||
$(LIB) libpng$(MODEL) +$(OBJSL2)
|
||||
$(LIB) libpng$(MODEL) +$(OBJSL3)
|
||||
|
||||
pngtest$(E): pngtest$(O) libpng.lib
|
||||
$(CC) $(LDFLAGS) pngtest.obj libpng.lib zlib.lib
|
||||
pngtest$(E): pngtest$(O) libpng$(MODEL).lib
|
||||
$(LD) $(LDFLAGS) pngtest.obj libpng$(MODEL).lib zlib_$(MODEL).lib
|
||||
|
||||
# End of makefile for libpng
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
# If you don't want to use assembler code, use makefile.vcwin32 instead.
|
||||
|
||||
MODEL=-
|
||||
CFLAGS=-DPNG_USE_PNGVCRD -Ox -GA3s -nologo -W3 -I..\zlib
|
||||
|
||||
CC=cl
|
||||
@@ -81,6 +80,7 @@ pngwutil$(O): png.h pngconf.h
|
||||
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3)
|
||||
echo something to del > libpng.lib
|
||||
del libpng.lib
|
||||
lib /OUT:libpng.lib $(OBJS1) $(OBJS2) $(OBJS3)
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
# ---------- Microsoft Visual C++ 4.0 and later, no assembler code------
|
||||
# If you want to use assembler code, use makefile.vcawin32 instead.
|
||||
|
||||
MODEL=-
|
||||
CFLAGS= -Ox -GA3s -nologo -W3 -I..\zlib
|
||||
|
||||
CC=cl
|
||||
@@ -74,6 +73,7 @@ pngwutil$(O): png.h pngconf.h
|
||||
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3)
|
||||
echo something to del > libpng.lib
|
||||
del libpng.lib
|
||||
lib /OUT:libpng.lib $(OBJS1) $(OBJS2) $(OBJS3)
|
||||
|
||||
|
||||
@@ -1,28 +1,48 @@
|
||||
# Makefile for libpng
|
||||
# Watcom 10.0 and later 32-bit protected mode flat memory model
|
||||
# Watcom C/C++ 10.0 and later, 32-bit protected mode, flat memory model
|
||||
|
||||
# Adapted by Pawel Mrochen, based on makefile.msc
|
||||
# Copyright (C) 2000, Pawel Mrochen, based on makefile.msc which is
|
||||
# copyright 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
# For conditions of distribution and use, see copyright notice in png.h
|
||||
# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib
|
||||
|
||||
# To use, do "wmake /f scripts\makefile.watcom"
|
||||
|
||||
# ------------- Watcom 10.0 and later -------------
|
||||
MODEL=-mf
|
||||
CFLAGS= $(MODEL) -5r -fp5 -fpi87 -oneatx -i=..\zlib
|
||||
|
||||
# ---------------------- Watcom C/C++ 10.0 and later -----------------------
|
||||
|
||||
# Where the zlib library and include files are located
|
||||
ZLIBLIB=..\zlib
|
||||
ZLIBINC=..\zlib
|
||||
|
||||
# Target OS
|
||||
OS=DOS
|
||||
#OS=NT
|
||||
|
||||
# Target CPU
|
||||
CPU=6 # Pentium Pro
|
||||
#CPU=5 # Pentium
|
||||
|
||||
# Calling convention
|
||||
CALLING=r # registers
|
||||
#CALLING=s # stack
|
||||
|
||||
# Uncomment next to put error messages in a file
|
||||
#ERRFILE=>>pngerrs
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
|
||||
CC=wcc386
|
||||
CFLAGS=-$(CPU)$(CALLING) -fp$(CPU) -fpi87 -oneatx -mf -bt=$(OS) -i=$(ZLIBINC) -zq
|
||||
LD=wcl386
|
||||
LIB=wlib -b -c
|
||||
LDFLAGS=
|
||||
LDFLAGS=-zq
|
||||
|
||||
O=.obj
|
||||
|
||||
#uncomment next to put error messages in a file
|
||||
#ERRFILE= >> pngerrs
|
||||
OBJS1=png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O)
|
||||
OBJS2=pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O)
|
||||
OBJS3=pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O)
|
||||
|
||||
# variables
|
||||
OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O)
|
||||
OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O)
|
||||
OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O)
|
||||
|
||||
all: test
|
||||
|
||||
@@ -75,14 +95,15 @@ pngwutil$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3)
|
||||
$(LIB) -n libpng.lib $(OBJS1)
|
||||
$(LIB) libpng.lib $(OBJS2)
|
||||
$(LIB) libpng.lib $(OBJS3)
|
||||
wlib -b -c -n -q libpng.lib $(OBJS1)
|
||||
wlib -b -c -q libpng.lib $(OBJS2)
|
||||
wlib -b -c -q libpng.lib $(OBJS3)
|
||||
|
||||
pngtest.exe: pngtest.obj libpng.lib
|
||||
$(LD) $(LDFLAGS) pngtest.obj libpng.lib ..\zlib\zlib.lib
|
||||
$(LD) $(LDFLAGS) pngtest.obj libpng.lib $(ZLIBLIB)\zlib.lib
|
||||
|
||||
test: pngtest.exe .symbolic
|
||||
pngtest
|
||||
pngtest.exe
|
||||
|
||||
|
||||
# End of makefile for libpng
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
unit pngdef;
|
||||
|
||||
// Caution: this file is probably out of date.
|
||||
|
||||
interface
|
||||
|
||||
const
|
||||
PNG_LIBPNG_VER_STRING = '1.0.5h';
|
||||
PNG_LIBPNG_VER = 10006;
|
||||
PNG_LIBPNG_VER_STRING = '1.0.7beta14';
|
||||
PNG_LIBPNG_VER = 10007;
|
||||
|
||||
type
|
||||
png_uint_32 = Cardinal;
|
||||
@@ -56,6 +58,9 @@ type
|
||||
png_write_status_ptr = procedure(png_ptr: Pointer;
|
||||
row_number: png_uint_32; pass: int);
|
||||
stdcall;
|
||||
png_user_chunk_ptr = procedure(png_ptr: Pointer;
|
||||
data: png_unknown_chunkp);
|
||||
stdcall;
|
||||
png_user_transform_ptr = procedure(png_ptr: Pointer;
|
||||
row_info: Pointer; data: png_bytep);
|
||||
stdcall;
|
||||
@@ -360,6 +365,9 @@ function png_get_rgb_to_gray_status(png_ptr: png_structp);
|
||||
function png_get_rowbytes(png_ptr: png_structp; info_ptr: png_infop):
|
||||
png_uint_32;
|
||||
stdcall;
|
||||
function png_get_rows(png_ptr: png_structp; info_ptr: png_infop):
|
||||
png_bytepp;
|
||||
stdcall;
|
||||
function png_get_sBIT(png_ptr: png_structp; info_ptr: png_infop;
|
||||
var sig_bits: png_color_8p): png_uint_32;
|
||||
stdcall;
|
||||
@@ -380,6 +388,9 @@ function png_get_text(png_ptr: png_structp; info_ptr: png_infop;
|
||||
var text_ptr: png_textp; var num_text: int):
|
||||
png_uint_32;
|
||||
stdcall;
|
||||
function png_get_user_chunk_ptr(png_ptr: png_structp):
|
||||
png_voidp;
|
||||
stdcall;
|
||||
function png_get_valid(png_ptr: png_structp; info_ptr: png_infop;
|
||||
flag: png_uint_32): png_uint_32;
|
||||
stdcall;
|
||||
@@ -441,6 +452,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,
|
||||
blue_x, blue_y: double);
|
||||
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);
|
||||
stdcall;
|
||||
procedure png_set_compression_mem_level(png_ptr: png_structp;
|
||||
@@ -480,6 +495,9 @@ procedure png_set_flush(png_ptr: png_structp; nrows: int);
|
||||
procedure png_set_gAMA(png_ptr: png_structp; info_ptr: png_infop;
|
||||
file_gamma: double);
|
||||
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,
|
||||
default_file_gamma: double);
|
||||
stdcall;
|
||||
@@ -492,6 +510,9 @@ procedure png_set_hIST(png_ptr: png_structp; info_ptr: png_infop;
|
||||
stdcall;
|
||||
function png_set_interlace_handling(png_ptr: png_structp): int;
|
||||
stdcall;
|
||||
procedure png_set_invalid(png_ptr: png_structp; info_ptr:png_infop;
|
||||
mask: int);
|
||||
stdcall;
|
||||
procedure png_set_invert_alpha(png_ptr: png_structp);
|
||||
stdcall;
|
||||
procedure png_set_invert_mono(png_ptr: png_structp);
|
||||
@@ -525,10 +546,20 @@ procedure png_set_read_fn(png_ptr: png_structp;
|
||||
procedure png_set_read_status_fn(png_ptr: png_structp;
|
||||
read_row_fn: png_read_status_ptr);
|
||||
stdcall;
|
||||
procedure png_set_read_user_chunk_fn(png_ptr: png_structp;
|
||||
read_user_chunk_fn: png_user_chunk_ptr);
|
||||
stdcall;
|
||||
procedure png_set_read_user_transform_fn(png_ptr: png_structp;
|
||||
read_user_transform_fn: png_user_transform_ptr);
|
||||
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;
|
||||
procedure png_set_rows(png_ptr: png_structp; info_ptr: png_infop;
|
||||
row_pointers: png_bytepp);
|
||||
stdcall;
|
||||
procedure png_set_sBIT(png_ptr: png_structp; info_ptr: png_infop;
|
||||
sig_bits: png_color_8p);
|
||||
@@ -608,24 +639,18 @@ procedure png_get_iCCP(png_ptr: png_structp; info_ptr: png_infop;
|
||||
name: png_charpp; compression_type: int *; profile: png_charpp;
|
||||
proflen: png_int_32): png_bytep;
|
||||
stdcall;
|
||||
procedure png_get_spalettes(png_ptr: png_structp;
|
||||
procedure png_get_sPLT(png_ptr: png_structp;
|
||||
info_ptr: png_infop; entries: png_spalette_pp): png_uint_32;
|
||||
stdcall;
|
||||
procedure png_free_pCAL(png_ptr: png_structp; info_ptr: png_infop);
|
||||
stdcall;
|
||||
procedure png_set_iCCP(png_ptr: png_structp; info_ptr: png_infop;
|
||||
name: png_charp; compression_type: int; profile: png_charp;
|
||||
proflen: int);
|
||||
stdcall;
|
||||
procedure png_free_iCCP(png_ptr: png_structp; info_ptr: png_infop);
|
||||
procedure png_free_data(png_ptr: png_structp; info_ptr: png_infop; num: int);
|
||||
stdcall;
|
||||
procedure png_free_text(png_ptr: png_structp; info_ptr: png_infop);
|
||||
stdcall;
|
||||
procedure png_set_spalettes(png_ptr: png_structp; info_ptr: png_infop;
|
||||
procedure png_set_sPLT(png_ptr: png_structp; info_ptr: png_infop;
|
||||
entries: png_spalette_p; nentries: int);
|
||||
stdcall;
|
||||
procedure png_free_sPLT(png_ptr: png_structp; info_ptr: png_infop);
|
||||
stdcall;
|
||||
|
||||
implementation
|
||||
|
||||
@@ -667,12 +692,14 @@ function png_get_pixel_aspect_ratio; external pngDLL;
|
||||
function png_get_pixels_per_meter; external pngDLL;
|
||||
function png_get_progressive_ptr; external pngDLL;
|
||||
function png_get_rowbytes; external pngDLL;
|
||||
function png_get_rows; external pngDLL;
|
||||
function png_get_sBIT; external pngDLL;
|
||||
function png_get_sRGB; external pngDLL;
|
||||
function png_get_signature; external pngDLL;
|
||||
function png_get_tIME; external pngDLL;
|
||||
function png_get_tRNS; external pngDLL;
|
||||
function png_get_text; external pngDLL;
|
||||
function png_get_user_chunk_ptr; external pngDLL;
|
||||
function png_get_valid; external pngDLL;
|
||||
function png_get_x_offset_microns; external pngDLL;
|
||||
function png_get_x_offset_pixels; external pngDLL;
|
||||
@@ -694,6 +721,7 @@ procedure png_set_bKGD; external pngDLL;
|
||||
procedure png_set_background; external pngDLL;
|
||||
procedure png_set_bgr; 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_mem_level; external pngDLL;
|
||||
procedure png_set_compression_method; external pngDLL;
|
||||
@@ -708,6 +736,7 @@ procedure png_set_filter; external pngDLL;
|
||||
procedure png_set_filter_heuristics; external pngDLL;
|
||||
procedure png_set_flush; external pngDLL;
|
||||
procedure png_set_gAMA; external pngDLL;
|
||||
procedure png_set_gAMA_fixed; external pngDLL;
|
||||
procedure png_set_gamma; external pngDLL;
|
||||
procedure png_set_gray_to_rgb; external pngDLL;
|
||||
procedure png_set_hIST; external pngDLL;
|
||||
@@ -723,6 +752,9 @@ procedure png_set_progressive_read_fn; external pngDLL;
|
||||
procedure png_set_read_fn; external pngDLL;
|
||||
procedure png_set_read_status_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_sBIT; external pngDLL;
|
||||
procedure png_set_sRGB; external pngDLL;
|
||||
procedure png_set_sRGB_gAMA_and_cHRM; external pngDLL;
|
||||
@@ -735,6 +767,7 @@ procedure png_set_swap_alpha; external pngDLL;
|
||||
procedure png_set_tIME; external pngDLL;
|
||||
procedure png_set_tRNS; external pngDLL;
|
||||
procedure png_set_text; external pngDLL;
|
||||
procedure png_set_user_chunk_fn; external pngDLL;
|
||||
procedure png_set_write_fn; external pngDLL;
|
||||
procedure png_set_write_status_fn; external pngDLL;
|
||||
procedure png_set_write_user_transform_fn; external pngDLL;
|
||||
@@ -752,12 +785,9 @@ procedure png_write_info_before_PLTE; external pngDLL;
|
||||
procedure png_write_row; external pngDLL;
|
||||
procedure png_write_rows; external pngDLL;
|
||||
procedure png_get_iCCP; external pngDLL;
|
||||
procedure png_get_spalettes; external pngDLL;
|
||||
procedure png_free_pCAL; external pngDLL;
|
||||
procedure png_get_sPLT; external pngDLL;
|
||||
procedure png_set_iCCP; external pngDLL;
|
||||
procedure png_free_iCCP; external pngDLL;
|
||||
procedure png_free_text; external pngDLL;
|
||||
procedure png_set_spalettes; external pngDLL;
|
||||
procedure png_free_sPLT; external pngDLL;
|
||||
procedure png_set_sPLT; external pngDLL;
|
||||
procedure png_free_data; external pngDLL;
|
||||
|
||||
end.
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
; PNGLIB module definition file for OS/2
|
||||
;----------------------------------------
|
||||
|
||||
; Caution: This file is probably out of date.
|
||||
|
||||
LIBRARY PNG
|
||||
DESCRIPTION "PNG image compression library for OS/2"
|
||||
CODE PRELOAD MOVEABLE DISCARDABLE
|
||||
@@ -31,9 +33,12 @@ EXPORTS
|
||||
png_set_bgr
|
||||
png_set_gray_to_rgb
|
||||
png_set_rgb_to_gray
|
||||
png_set_rgb_to_gray_fixed
|
||||
png_set_rows
|
||||
png_build_grayscale_palette
|
||||
png_set_strip_alpha
|
||||
png_set_swap_alpha
|
||||
png_set_invalid
|
||||
png_set_invert_alpha
|
||||
png_set_filler
|
||||
png_set_swap
|
||||
@@ -47,6 +52,7 @@ EXPORTS
|
||||
png_set_dither
|
||||
png_set_gamma
|
||||
png_set_flush
|
||||
png_set_user_chunk_fn
|
||||
png_write_flush
|
||||
png_start_read_image
|
||||
png_read_update_info
|
||||
@@ -79,6 +85,7 @@ EXPORTS
|
||||
png_get_header_ver
|
||||
png_get_header_version
|
||||
png_get_libpng_ver
|
||||
png_get_user_chunk_ptr
|
||||
; png_get_mem_fn
|
||||
; png_set_mem_fn
|
||||
png_set_write_fn
|
||||
@@ -118,6 +125,7 @@ EXPORTS
|
||||
png_get_pixels_per_meter
|
||||
png_get_pixel_aspect_ratio
|
||||
png_get_rgb_to_gray_status
|
||||
png_get_rows
|
||||
png_get_x_offset_pixels
|
||||
png_get_y_offset_pixels
|
||||
png_get_x_offset_microns
|
||||
@@ -127,8 +135,10 @@ EXPORTS
|
||||
png_set_bKGD
|
||||
png_get_cHRM
|
||||
png_set_cHRM
|
||||
png_set_cHRM_fixed
|
||||
png_get_gAMA
|
||||
png_set_gAMA
|
||||
png_set_gAMA_fixed
|
||||
png_get_hIST
|
||||
png_set_hIST
|
||||
png_get_IHDR
|
||||
@@ -177,20 +187,24 @@ EXPORTS
|
||||
png_write_PLTE
|
||||
png_write_IDAT
|
||||
png_write_IEND
|
||||
png_write_gAMA
|
||||
png_write_sBIT
|
||||
png_write_cHRM
|
||||
png_write_sRGB
|
||||
png_write_tRNS
|
||||
png_write_bKGD
|
||||
png_write_cHRM
|
||||
png_write_gAMA
|
||||
png_write_hIST
|
||||
png_check_keyword
|
||||
png_write_tEXt
|
||||
png_write_zTXt
|
||||
png_write_iCCP
|
||||
png_write_iTXt
|
||||
png_write_oFFs
|
||||
png_write_pCAL
|
||||
png_write_pHYs
|
||||
png_write_sBIT
|
||||
png_write_sCAL
|
||||
png_write_sPLT
|
||||
png_write_sRGB
|
||||
png_check_keyword
|
||||
png_write_tEXt
|
||||
png_write_tIME
|
||||
png_write_tRNS
|
||||
png_write_zTXt
|
||||
png_write_finish_row
|
||||
png_write_start_row
|
||||
png_build_gamma_table
|
||||
@@ -229,18 +243,22 @@ EXPORTS
|
||||
png_handle_IHDR
|
||||
png_handle_PLTE
|
||||
png_handle_IEND
|
||||
png_handle_gAMA
|
||||
png_handle_sBIT
|
||||
png_handle_cHRM
|
||||
png_handle_sRGB
|
||||
png_handle_tRNS
|
||||
png_handle_bKGD
|
||||
png_handle_cHRM
|
||||
png_handle_gAMA
|
||||
png_handle_hIST
|
||||
png_handle_iCCP
|
||||
png_handle_iTXt
|
||||
png_handle_oFFs
|
||||
png_handle_pCAL
|
||||
png_handle_pHYs
|
||||
png_handle_tIME
|
||||
png_handle_sBIT
|
||||
png_handle_sCAL
|
||||
png_handle_sPLT
|
||||
png_handle_sRGB
|
||||
png_handle_tEXt
|
||||
png_handle_tIME
|
||||
png_handle_tRNS
|
||||
png_handle_zTXt
|
||||
png_handle_unknown
|
||||
png_check_chunk_name
|
||||
@@ -281,14 +299,10 @@ EXPORTS
|
||||
; png_pass_height
|
||||
png_get_iCCP
|
||||
png_get_sCAL
|
||||
png_get_spalettes
|
||||
png_free_pCAL
|
||||
png_get_sPLT
|
||||
png_set_iCCP
|
||||
png_free_iCCP
|
||||
png_free_text
|
||||
png_free_sCAL
|
||||
png_set_spalettes
|
||||
png_free_sPLT
|
||||
png_set_sPLT
|
||||
png_free_data
|
||||
|
||||
png_IHDR
|
||||
png_IDAT
|
||||
|
||||
Reference in New Issue
Block a user