mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c944229859 | ||
|
|
5c6aeb25c1 | ||
|
|
345bc27e70 | ||
|
|
f7d1a17033 | ||
|
|
8686fff347 | ||
|
|
d0dce40075 | ||
|
|
1d96361273 | ||
|
|
896239be20 | ||
|
|
f9f2fe0ce7 | ||
|
|
d12aa50322 | ||
|
|
8f8fb6ae7a | ||
|
|
0f7202f074 | ||
|
|
397100eb8a | ||
|
|
4922b1b6e9 | ||
|
|
38d73aff67 | ||
|
|
7cd899c707 | ||
|
|
ea3bcd7087 | ||
|
|
983ec160b4 | ||
|
|
08a3343e05 | ||
|
|
cbe52d8720 | ||
|
|
a357b99113 | ||
|
|
0f881d62b3 | ||
|
|
b212002101 | ||
|
|
46f61e2398 | ||
|
|
c4a2ae6cac | ||
|
|
2687fcc7b5 | ||
|
|
70e3f543f1 | ||
|
|
b6ce43d6ff |
45
ANNOUNCE
Normal file
45
ANNOUNCE
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
|
||||||
|
Libpng 1.0.2b - January 6, 1999
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
Changes since the last public release:
|
||||||
|
|
||||||
|
version 1.0.2a [December 30, 1998]
|
||||||
|
Replaced and extended code that was removed from png_set_filler() in 1.0.1a.
|
||||||
|
Fixed a bug in png_do_filler() that made it fail to write filler bytes in
|
||||||
|
the left-most pixel of each row (Kevin Bracey).
|
||||||
|
Changed "static pngcharp tIME_string" to "static char tIME_string[30]"
|
||||||
|
in pngtest.c (Duncan Simpson).
|
||||||
|
Fixed a bug in pngtest.c that caused pngtest to try to write a tIME chunk
|
||||||
|
even when no tIME chunk was present in the source file.
|
||||||
|
Fixed a problem in pngrutil.c: gray_to_rgb didn't always work with 16-bit.
|
||||||
|
Fixed a problem in png_read_push_finish_row(), which would not skip some
|
||||||
|
passes that it should skip, for images that are less than 3 pixels high.
|
||||||
|
Interchanged the order of calls to png_do_swap() and png_do_shift()
|
||||||
|
in pngwtran.c (John Cromer).
|
||||||
|
Added #ifdef PNG_DEBUG/#endif surrounding use of PNG_DEBUG in png.h .
|
||||||
|
Changed "bad adaptive filter type" from error to warning in pngrutil.c .
|
||||||
|
Fixed a documentation error about default filtering with 8-bit indexed-color.
|
||||||
|
Separated the PNG_NO_STDIO macro into PNG_NO_STDIO and PNG_NO_CONSOLE_IO
|
||||||
|
(L. Peter Deutsch).
|
||||||
|
Added png_set_rgb_to_gray() and png_get_rgb_to_gray_status() functions.
|
||||||
|
Added png_get_copyright() and png_get_header_version() functions.
|
||||||
|
Revised comments on png_set_progressive_read_fn() in libpng.txt and example.c
|
||||||
|
Added information about debugging in libpng.txt and libpng.3 .
|
||||||
|
Changed "ln -sf" to "ln -s -f" in makefile.s2x, makefile.lnx, and makefile.sco.
|
||||||
|
Removed lines after Dynamic Dependencies" in makefile.aco .
|
||||||
|
Revised makefile.dec to make a shared library (Jeremie Petit).
|
||||||
|
Removed trailing blanks from all files.
|
||||||
|
version 1.0.2b [January 6, 1999]
|
||||||
|
Removed misplaced #endif and #ifdef PNG_NO_EXTERN near the end of png.h
|
||||||
|
Added "if" tests to silence complaints about unused png_ptr in png.h and png.c
|
||||||
|
Changed "check_if_png" function in example.c to return true (nonzero) if PNG.
|
||||||
|
Changed libpng.txt to demonstrate png_sig_cmp() instead of png_check_sig()
|
||||||
|
which is obsolete.
|
||||||
|
|
||||||
|
Send comments/corrections/commendations to
|
||||||
|
png-implement@dworkin.wustl.edu or to randeg@alumni.rpi.edu
|
||||||
|
|
||||||
|
Glenn R-P
|
||||||
517
CHANGES
517
CHANGES
@@ -1,169 +1,386 @@
|
|||||||
pngchange.txt - changes for libpng
|
CHANGES - changes for libpng
|
||||||
|
|
||||||
version 0.2
|
version 0.2
|
||||||
added reader into png.h
|
added reader into png.h
|
||||||
fixed small problems in stub file
|
fixed small problems in stub file
|
||||||
version 0.3
|
version 0.3
|
||||||
added pull reader
|
added pull reader
|
||||||
split up pngwrite.c to several files
|
split up pngwrite.c to several files
|
||||||
added pnglib.txt
|
added pnglib.txt
|
||||||
added example.c
|
added example.c
|
||||||
cleaned up writer, adding a few new tranformations
|
cleaned up writer, adding a few new tranformations
|
||||||
fixed some bugs in writer
|
fixed some bugs in writer
|
||||||
interfaced with zlib 0.5
|
interfaced with zlib 0.5
|
||||||
added K&R support
|
added K&R support
|
||||||
added check for 64 KB blocks for 16 bit machines
|
added check for 64 KB blocks for 16 bit machines
|
||||||
version 0.4
|
version 0.4
|
||||||
cleaned up code and commented code
|
cleaned up code and commented code
|
||||||
simplified time handling into png_time
|
simplified time handling into png_time
|
||||||
created png_color_16 and png_color_8 to handle color needs
|
created png_color_16 and png_color_8 to handle color needs
|
||||||
cleaned up color type defines
|
cleaned up color type defines
|
||||||
fixed various bugs
|
fixed various bugs
|
||||||
made various names more consistant
|
made various names more consistant
|
||||||
interfaced with zlib 0.71
|
interfaced with zlib 0.71
|
||||||
cleaned up zTXt reader and writer (using zlib's Reset functions)
|
cleaned up zTXt reader and writer (using zlib's Reset functions)
|
||||||
split transformations into pngrtran.c and pngwtran.c
|
split transformations into pngrtran.c and pngwtran.c
|
||||||
version 0.5
|
version 0.5
|
||||||
interfaced with zlib 0.8
|
interfaced with zlib 0.8
|
||||||
fixed many reading and writing bugs
|
fixed many reading and writing bugs
|
||||||
saved using 3 spaces instead of tabs
|
saved using 3 spaces instead of tabs
|
||||||
version 0.6
|
version 0.6
|
||||||
added png_large_malloc() and png_large_free()
|
added png_large_malloc() and png_large_free()
|
||||||
added png_size_t
|
added png_size_t
|
||||||
cleaned up some compiler warnings
|
cleaned up some compiler warnings
|
||||||
added png_start_read_image()
|
added png_start_read_image()
|
||||||
version 0.7
|
version 0.7
|
||||||
cleaned up lots of bugs
|
cleaned up lots of bugs
|
||||||
finished dithering and other stuff
|
finished dithering and other stuff
|
||||||
added test program
|
added test program
|
||||||
changed name from pnglib to libpng
|
changed name from pnglib to libpng
|
||||||
version 0.71 [June, 1995]
|
version 0.71 [June, 1995]
|
||||||
changed pngtest.png for zlib 0.93
|
changed pngtest.png for zlib 0.93
|
||||||
fixed error in libpng.txt and example.c
|
fixed error in libpng.txt and example.c
|
||||||
version 0.8
|
version 0.8
|
||||||
cleaned up some bugs
|
cleaned up some bugs
|
||||||
added png_set_filler()
|
added png_set_filler()
|
||||||
split up pngstub.c into pngmem.c, pngio.c, and pngerror.c
|
split up pngstub.c into pngmem.c, pngio.c, and pngerror.c
|
||||||
added #define's to remove unwanted code
|
added #define's to remove unwanted code
|
||||||
moved png_info_init() to png.c
|
moved png_info_init() to png.c
|
||||||
added old_size into png_realloc()
|
added old_size into png_realloc()
|
||||||
added functions to manually set filtering and compression info
|
added functions to manually set filtering and compression info
|
||||||
changed compression parameters based on image type
|
changed compression parameters based on image type
|
||||||
optimized filter selection code
|
optimized filter selection code
|
||||||
added version info
|
added version info
|
||||||
changed external functions passing floats to doubles (k&r problems?)
|
changed external functions passing floats to doubles (k&r problems?)
|
||||||
put all the configurable stuff in pngconf.h
|
put all the configurable stuff in pngconf.h
|
||||||
enabled png_set_shift to work with paletted images on read
|
enabled png_set_shift to work with paletted images on read
|
||||||
added png_read_update_info() - updates info structure with
|
added png_read_update_info() - updates info structure with
|
||||||
transformations
|
transformations
|
||||||
version 0.81 [August, 1995]
|
version 0.81 [August, 1995]
|
||||||
incorporated Tim Wegner's medium model code (thanks, Tim)
|
incorporated Tim Wegner's medium model code (thanks, Tim)
|
||||||
version 0.82 [September, 1995]
|
version 0.82 [September, 1995]
|
||||||
[unspecified changes]
|
[unspecified changes]
|
||||||
version 0.85 [December, 1995]
|
version 0.85 [December, 1995]
|
||||||
added more medium model code (almost everything's a far)
|
added more medium model code (almost everything's a far)
|
||||||
added i/o, error, and memory callback functions
|
added i/o, error, and memory callback functions
|
||||||
fixed some bugs (16 bit, 4 bit interlaced, etc.)
|
fixed some bugs (16 bit, 4 bit interlaced, etc.)
|
||||||
added first run progressive reader (barely tested)
|
added first run progressive reader (barely tested)
|
||||||
version 0.86 [January, 1996]
|
version 0.86 [January, 1996]
|
||||||
fixed bugs
|
fixed bugs
|
||||||
improved documentation
|
improved documentation
|
||||||
version 0.87 [January, 1996]
|
version 0.87 [January, 1996]
|
||||||
fixed medium model bugs
|
fixed medium model bugs
|
||||||
fixed other bugs introduced in 0.85 and 0.86
|
fixed other bugs introduced in 0.85 and 0.86
|
||||||
added some minor documentation
|
added some minor documentation
|
||||||
version 0.88 [January, 1996]
|
version 0.88 [January, 1996]
|
||||||
fixed progressive bugs
|
fixed progressive bugs
|
||||||
replaced tabs with spaces
|
replaced tabs with spaces
|
||||||
cleaned up documentation
|
cleaned up documentation
|
||||||
added callbacks for read/write and warning/error functions
|
added callbacks for read/write and warning/error functions
|
||||||
version 0.89 [July, 1996]
|
version 0.89 [July, 1996]
|
||||||
added new initialization API to make libpng work better with shared libs
|
added new initialization API to make libpng work better with shared libs
|
||||||
we now have png_create_read_struct(), png_create_write_struct(),
|
we now have png_create_read_struct(), png_create_write_struct(),
|
||||||
png_create_info_struct(), png_destroy_read_struct(), and
|
png_create_info_struct(), png_destroy_read_struct(), and
|
||||||
png_destroy_write_struct() instead of the separate calls to
|
png_destroy_write_struct() instead of the separate calls to
|
||||||
malloc and png_read_init(), png_info_init(), and png_write_init()
|
malloc and png_read_init(), png_info_init(), and png_write_init()
|
||||||
changed warning/error callback functions to fix bug - this means you
|
changed warning/error callback functions to fix bug - this means you
|
||||||
should use the new initialization API if you were using the old
|
should use the new initialization API if you were using the old
|
||||||
png_set_message_fn() calls, and that the old API no longer exists
|
png_set_message_fn() calls, and that the old API no longer exists
|
||||||
so that people are aware that they need to change their code
|
so that people are aware that they need to change their code
|
||||||
changed filter selection API to allow selection of multiple filters
|
changed filter selection API to allow selection of multiple filters
|
||||||
since it didn't work in previous versions of libpng anyways
|
since it didn't work in previous versions of libpng anyways
|
||||||
optimized filter selection code
|
optimized filter selection code
|
||||||
fixed png_set_background() to allow using an arbitrary RGB color for
|
fixed png_set_background() to allow using an arbitrary RGB color for
|
||||||
paletted images
|
paletted images
|
||||||
fixed gamma and background correction for paletted images, so
|
fixed gamma and background correction for paletted images, so
|
||||||
png_correct_palette is not needed unless you are correcting an
|
png_correct_palette is not needed unless you are correcting an
|
||||||
external palette (you will need to #define PNG_CORRECT_PALETTE_SUPPORTED
|
external palette (you will need to #define PNG_CORRECT_PALETTE_SUPPORTED
|
||||||
in pngconf.h) - if nobody uses this, it may disappear in the future.
|
in pngconf.h) - if nobody uses this, it may disappear in the future.
|
||||||
fixed bug with Borland 64K memory allocation (Alexander Lehmann)
|
fixed bug with Borland 64K memory allocation (Alexander Lehmann)
|
||||||
fixed bug in interlace handling (Smarasderagd, I think)
|
fixed bug in interlace handling (Smarasderagd, I think)
|
||||||
added more error checking for writing and image to reduce invalid files
|
added more error checking for writing and image to reduce invalid files
|
||||||
separated read and write functions so that they won't both be linked
|
separated read and write functions so that they won't both be linked
|
||||||
into a binary when only reading or writing functionality is used
|
into a binary when only reading or writing functionality is used
|
||||||
new pngtest image also has interlacing and zTXt
|
new pngtest image also has interlacing and zTXt
|
||||||
updated documentation to reflect new API
|
updated documentation to reflect new API
|
||||||
version 0.90 [January, 1997]
|
version 0.90 [January, 1997]
|
||||||
made CRC errors/warnings on critical and ancillary chunks configurable
|
made CRC errors/warnings on critical and ancillary chunks configurable
|
||||||
libpng will use the zlib CRC routines by (compile-time) default
|
libpng will use the zlib CRC routines by (compile-time) default
|
||||||
changed DOS small/medium model memory support - needs zlib 1.04 (Tim Wegner)
|
changed DOS small/medium model memory support - needs zlib 1.04 (Tim Wegner)
|
||||||
added external C++ wrapper statements to png.h (Gilles Dauphin)
|
added external C++ wrapper statements to png.h (Gilles Dauphin)
|
||||||
allow PNG file to be read when some or all of file signature has already
|
allow PNG file to be read when some or all of file signature has already
|
||||||
been read from the beginning of the stream. ****This affects the size
|
been read from the beginning of the stream. ****This affects the size
|
||||||
of info_struct and invalidates all programs that use a shared libpng****
|
of info_struct and invalidates all programs that use a shared libpng****
|
||||||
fixed png_filler() declarations
|
fixed png_filler() declarations
|
||||||
fixed? background color conversions
|
fixed? background color conversions
|
||||||
fixed order of error function pointers to match documentation
|
fixed order of error function pointers to match documentation
|
||||||
current chunk name is now available in png_struct to reduce the number
|
current chunk name is now available in png_struct to reduce the number
|
||||||
of nearly identical error messages (will simplify multi-lingual
|
of nearly identical error messages (will simplify multi-lingual
|
||||||
support when available)
|
support when available)
|
||||||
try to get ready for unknown-chunk callback functions:
|
try to get ready for unknown-chunk callback functions:
|
||||||
- previously read critical chunks are flagged, so the chunk handling
|
- previously read critical chunks are flagged, so the chunk handling
|
||||||
routines can determine if the chunk is in the right place
|
routines can determine if the chunk is in the right place
|
||||||
- all chunk handling routines have the same prototypes, so we will
|
- all chunk handling routines have the same prototypes, so we will
|
||||||
be able to handle all chunks via a callback mechanism
|
be able to handle all chunks via a callback mechanism
|
||||||
try to fix Linux "setjmp" buffer size problems
|
try to fix Linux "setjmp" buffer size problems
|
||||||
version 0.95 [March, 1997]
|
version 0.95 [March, 1997]
|
||||||
fixed bug in pngwutil.c allocating "up_row" twice and "avg_row" never
|
fixed bug in pngwutil.c allocating "up_row" twice and "avg_row" never
|
||||||
fixed bug in PNG file signature compares when start != 0
|
fixed bug in PNG file signature compares when start != 0
|
||||||
changed parameter type of png_set_filler(...filler...) from png_byte
|
changed parameter type of png_set_filler(...filler...) from png_byte
|
||||||
to png_uint_32
|
to png_uint_32
|
||||||
added test for MACOS to ensure that both math.h and fp.h are not #included
|
added test for MACOS to ensure that both math.h and fp.h are not #included
|
||||||
added macros for libpng to be compiled as a Windows DLL (Andreas Kupries)
|
added macros for libpng to be compiled as a Windows DLL (Andreas Kupries)
|
||||||
added "packswap" transformation, which changes the endianness of
|
added "packswap" transformation, which changes the endianness of
|
||||||
packed-pixel bytes (Kevin Bracey)
|
packed-pixel bytes (Kevin Bracey)
|
||||||
added "strip_alpha" transformation, which removes the alpha channel of
|
added "strip_alpha" transformation, which removes the alpha channel of
|
||||||
input images without using it (not neccesarily a good idea)
|
input images without using it (not neccesarily a good idea)
|
||||||
added "swap_alpha" transformation, which puts the alpha channel in front
|
added "swap_alpha" transformation, which puts the alpha channel in front
|
||||||
of the color bytes instead of after
|
of the color bytes instead of after
|
||||||
removed all implicit variable tests which assume NULL == 0 (I think)
|
removed all implicit variable tests which assume NULL == 0 (I think)
|
||||||
changed several variables to "png_size_t" to show 16/32-bit limitations
|
changed several variables to "png_size_t" to show 16/32-bit limitations
|
||||||
added new pCAL chunk read/write support
|
added new pCAL chunk read/write support
|
||||||
added experimental filter selection weighting (Greg Roelofs)
|
added experimental filter selection weighting (Greg Roelofs)
|
||||||
removed old png_set_rgbx() and png_set_xrgb() functions that have been
|
removed old png_set_rgbx() and png_set_xrgb() functions that have been
|
||||||
obsolete for about 2 years now (use png_set_filler() instead)
|
obsolete for about 2 years now (use png_set_filler() instead)
|
||||||
added macros to read 16- and 32-bit ints directly from buffer, to be
|
added macros to read 16- and 32-bit ints directly from buffer, to be
|
||||||
used only on those systems that support it (namely PowerPC and 680x0)
|
used only on those systems that support it (namely PowerPC and 680x0)
|
||||||
With some testing, this may become the default for MACOS/PPC systems.
|
With some testing, this may become the default for MACOS/PPC systems.
|
||||||
only calculate CRC on data if we are going to use it
|
only calculate CRC on data if we are going to use it
|
||||||
added macros for zTXt compression type PNG_zTXt_COMPRESSION_???
|
added macros for zTXt compression type PNG_zTXt_COMPRESSION_???
|
||||||
added macros for simple libpng debugging output selectable at compile time
|
added macros for simple libpng debugging output selectable at compile time
|
||||||
removed PNG_READ_END_MODE in progressive reader (Smarasderagd)
|
removed PNG_READ_END_MODE in progressive reader (Smarasderagd)
|
||||||
more description of info_struct in libpng.txt and png.h
|
more description of info_struct in libpng.txt and png.h
|
||||||
more instructions in example.c
|
more instructions in example.c
|
||||||
more chunk types tested in pngtest.c
|
more chunk types tested in pngtest.c
|
||||||
renamed pngrcb.c to pngset.c, and all png_read_<chunk> functions to be
|
renamed pngrcb.c to pngset.c, and all png_read_<chunk> functions to be
|
||||||
png_set_<chunk>. We now have corresponding png_get_<chunk>
|
png_set_<chunk>. We now have corresponding png_get_<chunk>
|
||||||
functions in pngget.c to get infomation in info_ptr. This isolates
|
functions in pngget.c to get infomation in info_ptr. This isolates
|
||||||
the application from the internal organization of png_info_struct
|
the application from the internal organization of png_info_struct
|
||||||
(good for shared library implementations).
|
(good for shared library implementations).
|
||||||
version 0.96 [May, 1997]
|
version 0.96 [May, 1997]
|
||||||
fixed serious bug with < 8bpp images introduced in 0.95
|
fixed serious bug with < 8bpp images introduced in 0.95
|
||||||
fixed 256-color transparency bug (Greg Roelofs)
|
fixed 256-color transparency bug (Greg Roelofs)
|
||||||
fixed up documentation (Greg Roelofs, Laszlo Nyul)
|
fixed up documentation (Greg Roelofs, Laszlo Nyul)
|
||||||
fixed "error" in pngconf.h for Linux setjmp() behaviour
|
fixed "error" in pngconf.h for Linux setjmp() behaviour
|
||||||
fixed DOS medium model support (Tim Wegner)
|
fixed DOS medium model support (Tim Wegner)
|
||||||
fixed png_check_keyword() for case with error in static string text
|
fixed png_check_keyword() for case with error in static string text
|
||||||
added read of CRC after IEND chunk for embedded PNGs (Laszlo Nyul)
|
added read of CRC after IEND chunk for embedded PNGs (Laszlo Nyul)
|
||||||
added typecasts to quiet compiler errors
|
added typecasts to quiet compiler errors
|
||||||
added more debugging info
|
added more debugging info
|
||||||
|
version 0.97 [January, 1998]
|
||||||
|
removed PNG_USE_OWN_CRC capability
|
||||||
|
relocated png_set_crc_action from pngrutil.c to pngrtran.c
|
||||||
|
fixed typecasts of "new_key", etc. (Andreas Dilger)
|
||||||
|
added RFC 1152 [sic] date support
|
||||||
|
fixed bug in gamma handling of 4-bit grayscale
|
||||||
|
added 2-bit grayscale gamma handling (Glenn R-P)
|
||||||
|
added more typecasts. 65536L becomes (png_uint_32)65536L, etc. (Glenn R-P)
|
||||||
|
minor corrections in libpng.txt
|
||||||
|
added simple sRGB support (Glenn R-P)
|
||||||
|
easier conditional compiling, e.g. define PNG_READ/WRITE_NOT_FULLY_SUPPORTED;
|
||||||
|
all configurable options can be selected from command-line instead
|
||||||
|
of having to edit pngconf.h (Glenn R-P)
|
||||||
|
fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P)
|
||||||
|
added more conditions for png_do_background, to avoid changing
|
||||||
|
black pixels to background when a background is supplied and
|
||||||
|
no pixels are transparent
|
||||||
|
repaired PNG_NO_STDIO behaviour
|
||||||
|
tested NODIV support and made it default behaviour (Greg Roelofs)
|
||||||
|
added "-m" option and PNGTEST_DEBUG_MEMORY to pngtest (John Bowler)
|
||||||
|
regularized version numbering scheme and bumped shared-library major
|
||||||
|
version number to 2 to avoid problems with libpng 0.89 apps (Greg Roelofs)
|
||||||
|
version 0.98 [January, 1998]
|
||||||
|
cleaned up some typos in libpng.txt and in code documentation
|
||||||
|
fixed memory leaks in pCAL chunk processing (Glenn R-P and John Bowler)
|
||||||
|
cosmetic change "display_gamma" to "screen_gamma" in pngrtran.c
|
||||||
|
changed recommendation about file_gamma for PC images to .51 from .45,
|
||||||
|
in example.c and libpng.txt, added comments to distinguish between
|
||||||
|
screen_gamma, viewing_gamma, and display_gamma.
|
||||||
|
changed all references to RFC1152 to read RFC1123 and changed the
|
||||||
|
PNG_TIME_RFC1152_SUPPORTED macro to PNG_TIME_RFC1123_SUPPORTED
|
||||||
|
added png_invert_alpha capability (Glenn R-P -- suggestion by Jon Vincent)
|
||||||
|
changed srgb_intent from png_byte to int to avoid compiler bugs
|
||||||
|
version 0.99 [January 30, 1998]
|
||||||
|
free info_ptr->text instead of end_info_ptr->text in pngread.c (John Bowler)
|
||||||
|
fixed a longstanding "packswap" bug in pngtrans.c
|
||||||
|
fixed some inconsistencies in pngconf.h that prevented compiling with
|
||||||
|
PNG_READ_GAMMA_SUPPORTED and PNG_READ_hIST_SUPPORTED undefined
|
||||||
|
fixed some typos and made other minor rearrangement of libpng.txt (Andreas)
|
||||||
|
changed recommendation about file_gamma for PC images to .50 from .51 in
|
||||||
|
example.c and libpng.txt, and changed file_gamma for sRGB images to .45
|
||||||
|
added a number of functions to access information from the png structure
|
||||||
|
png_get_image_height(), etc. (Glenn R-P, suggestion by Brad Pettit)
|
||||||
|
added TARGET_MACOS similar to zlib-1.0.8
|
||||||
|
define PNG_ALWAYS_EXTERN when __MWERKS__ && WIN32 are defined
|
||||||
|
added type casting to all png_malloc() function calls
|
||||||
|
version 0.99a [January 31, 1998]
|
||||||
|
Added type casts and parentheses to all returns that return a value.(Tim W.)
|
||||||
|
version 0.99b [February 4, 1998]
|
||||||
|
Added type cast png_uint_32 on malloc function calls where needed.
|
||||||
|
Changed type of num_hist from png_uint_32 to int (same as num_palette).
|
||||||
|
Added checks for rowbytes overflow, in case png_size_t is less than 32 bits.
|
||||||
|
Renamed makefile.elf to makefile.lnx.
|
||||||
|
version 0.99c [February 7, 1998]
|
||||||
|
More type casting. Removed erroneous overflow test in pngmem.c.
|
||||||
|
Added png_buffered_memcpy() and png_buffered_memset(), apply them to rowbytes.
|
||||||
|
Added UNIX manual pages libpng.3 (incorporating libpng.txt) and png.5.
|
||||||
|
version 0.99d [February 11, 1998]
|
||||||
|
Renamed "far_to_near()" "png_far_to_near()"
|
||||||
|
Revised libpng.3
|
||||||
|
Version 99c "buffered" operations didn't work as intended. Replaced them
|
||||||
|
with png_memcpy_check() and png_memset_check().
|
||||||
|
Added many "if (png_ptr == NULL) return" to quell compiler warnings about
|
||||||
|
unused png_ptr, mostly in pngget.c and pngset.c.
|
||||||
|
Check for overlength tRNS chunk present when indexed-color PLTE is read.
|
||||||
|
Cleaned up spelling errors in libpng.3/libpng.txt
|
||||||
|
Corrected a problem with png_get_tRNS() which returned undefined trans array
|
||||||
|
version 0.99e [February 28, 1998]
|
||||||
|
Corrected png_get_tRNS() again.
|
||||||
|
Add parentheses for easier reading of pngget.c, fixed "||" should be "&&".
|
||||||
|
Touched up example.c to make more of it compileable, although the entire
|
||||||
|
file still can't be compiled (Willem van Schaik)
|
||||||
|
Fixed a bug in png_do_shift() (Bryan Tsai)
|
||||||
|
Added a space in png.h prototype for png_write_chunk_start()
|
||||||
|
Replaced pngtest.png with one created with zlib 1.1.1
|
||||||
|
Changed pngtest to report PASS even when file size is different (Jean-loup G.)
|
||||||
|
Corrected some logic errors in png_do_invert_alpha() (Chris Patterson)
|
||||||
|
version 0.99f [March 5, 1998]
|
||||||
|
Corrected a bug in pngpread() introduced in version 99c (Kevin Bracey)
|
||||||
|
Moved makefiles into a "scripts" directory, and added INSTALL instruction file
|
||||||
|
Added makefile.os2 and pngos2.def (A. Zabolotny) and makefile.s2x (W. Sebok)
|
||||||
|
Added pointers to "note on libpng versions" in makefile.lnx and README
|
||||||
|
Added row callback feature when reading and writing nonprogressive rows
|
||||||
|
and added a test of this feature in pngtest.c
|
||||||
|
Added user transform callbacks, with test of the feature in pngtest.c
|
||||||
|
version 0.99g [March 6, 1998, morning]
|
||||||
|
Minor changes to pngtest.c to suppress compiler warnings.
|
||||||
|
Removed "beta" language from documentation.
|
||||||
|
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
|
||||||
|
version 1.00 [March 7, 1998]
|
||||||
|
Changed several typedefs in pngrutil.c
|
||||||
|
Added makefile.wat (Pawel Mrochen), updated makefile.tc3 (Willem van Schaik)
|
||||||
|
replaced "while(1)" with "for(;;)"
|
||||||
|
added PNGARG() to prototypes in pngtest.c and removed some prototypes
|
||||||
|
updated some of the makefiles (Tom Lane)
|
||||||
|
changed some typedefs (s_start, etc.) in pngrutil.c
|
||||||
|
fixed dimensions of "short_months" array in pngwrite.c
|
||||||
|
Replaced ansi2knr.c with the one from jpeg-v6
|
||||||
|
version 1.0.0 [March 8, 1998]
|
||||||
|
Changed name from 1.00 to 1.0.0 (Adam Costello)
|
||||||
|
Added smakefile.ppc (with SCOPTIONS.ppc) for Amiga PPC (Andreas Kleinert)
|
||||||
|
version 1.0.0a [March 9, 1998]
|
||||||
|
Fixed three bugs in pngrtran.c to make gamma+background handling consistent
|
||||||
|
(Greg Roelofs)
|
||||||
|
Changed format of the PNG_LIBPNG_VER integer to xyyzz instead of xyz
|
||||||
|
for major, minor, and bugfix releases. This is 10001. (Adam Costello,
|
||||||
|
Tom Lane)
|
||||||
|
Make months range from 1-12 in png_convert_to_rfc1123
|
||||||
|
version 1.0.0b [March 13, 1998]
|
||||||
|
Quieted compiler complaints about two empty "for" loops in pngrutil.c
|
||||||
|
Minor changes to makefile.s2x
|
||||||
|
Removed #ifdef/#endif around a png_free() in pngread.c
|
||||||
|
version 1.0.1 [March 14, 1998]
|
||||||
|
Changed makefile.s2x to reduce security risk of using a relative pathname
|
||||||
|
Fixed some typos in the documentation (Greg).
|
||||||
|
Fixed a problem with value of "channels" returned by png_read_update_info()
|
||||||
|
version 1.0.1a [April 21, 1998]
|
||||||
|
Optimized Paeth calculations by replacing abs() function calls with intrinsics
|
||||||
|
plus other loop optimizations. Improves avg decoding speed by about 20%.
|
||||||
|
Commented out i386istic "align" compiler flags in makefile.lnx.
|
||||||
|
Reduced the default warning level in some makefiles, to make them consistent.
|
||||||
|
Removed references to IJG and JPEG in the ansi2knr.c copyright statement.
|
||||||
|
Fixed a bug in png_do_strip_filler with XXRRGGBB => RRGGBB transformation.
|
||||||
|
Added grayscale and 16-bit capability to png_do_read_filler().
|
||||||
|
Fixed a bug in pngset.c, introduced in version 0.99c, that sets rowbytes
|
||||||
|
too large when writing an image with bit_depth < 8 (Bob Dellaca).
|
||||||
|
Corrected some bugs in the experimental weighted filtering heuristics.
|
||||||
|
Moved a misplaced pngrutil code block that truncates tRNS if it has more
|
||||||
|
than num_palette entries -- test was done before num_palette was defined.
|
||||||
|
Fixed a png_convert_to_rfc1123() bug that converts day 31 to 0 (Steve Eddins).
|
||||||
|
Changed compiler flags in makefile.wat for better optimization (Pawel Mrochen).
|
||||||
|
version 1.0.1b [May 2, 1998]
|
||||||
|
Relocated png_do_gray_to_rgb() within png_do_read_transformations() (Greg).
|
||||||
|
Relocated the png_composite macros from pngrtran.c to png.h (Greg).
|
||||||
|
Added makefile.sco (contributed by Mike Hopkirk).
|
||||||
|
Fixed two bugs (missing definitions of "istop") introduced in libpng-1.0.1a.
|
||||||
|
Fixed a bug in pngrtran.c that would set channels=5 under some circumstances.
|
||||||
|
More work on the Paeth-filtering, achieving imperceptible speedup (A Kleinert).
|
||||||
|
More work on loop optimization which may help when compiled with C++ compilers.
|
||||||
|
Added warnings when people try to use transforms they've defined out.
|
||||||
|
Collapsed 4 "i" and "c" loops into single "i" loops in pngrtran and pngwtran.
|
||||||
|
Revised paragraph about png_set_expand() in libpng.txt and libpng.3 (Greg)
|
||||||
|
version 1.0.1c [May 11, 1998]
|
||||||
|
Fixed a bug in pngrtran.c (introduced in libpng-1.0.1a) where the masks for
|
||||||
|
filler bytes should have been 0xff instead of 0xf.
|
||||||
|
Added max_pixel_depth=32 in pngrutil.c when using FILLER with palette images.
|
||||||
|
Moved PNG_WRITE_WEIGHTED_FILTER_SUPPORTED and PNG_WRITE_FLUSH_SUPPORTED
|
||||||
|
out of the PNG_WRITE_TRANSFORMS_NOT_SUPPORTED block of pngconf.h
|
||||||
|
Added "PNG_NO_WRITE_TRANSFORMS" etc., as alternatives for *_NOT_SUPPORTED,
|
||||||
|
for consistency, in pngconf.h
|
||||||
|
Added individual "ifndef PNG_NO_[CAPABILITY]" in pngconf.h to make it easier
|
||||||
|
to remove unwanted capabilities via the compile line
|
||||||
|
Made some corrections to grammar (which, it's) in documentation (Greg).
|
||||||
|
Corrected example.c, use of row_pointers in png_write_image().
|
||||||
|
version 1.0.1d [May 24, 1998]
|
||||||
|
Corrected several statements that used side effects illegally in pngrutil.c
|
||||||
|
and pngtrans.c, that were introduced in version 1.0.1b
|
||||||
|
Revised png_read_rows() to avoid repeated if-testing for NULL (A Kleinert)
|
||||||
|
More corrections to example.c, use of row_pointers in png_write_image()
|
||||||
|
and png_read_rows().
|
||||||
|
Added pngdll.mak and pngdef.pas to scripts directory, contributed by
|
||||||
|
Bob Dellaca, to make a png32bd.dll with Borland C++ 4.5
|
||||||
|
Fixed error in example.c with png_set_text: num_text is 3, not 2 (Guido V.)
|
||||||
|
Changed several loops from count-down to count-up, for consistency.
|
||||||
|
version 1.0.1e [June 6, 1998]
|
||||||
|
Revised libpng.txt and libpng.3 description of png_set_read|write_fn(), and
|
||||||
|
added warnings when people try to set png_read_fn and png_write_fn in
|
||||||
|
the same structure.
|
||||||
|
Added a test such that png_do_gamma will be done when num_trans==0
|
||||||
|
for truecolor images that have defined a background. This corrects an
|
||||||
|
error that was introduced in libpng-0.90 that can cause gamma processing
|
||||||
|
to be skipped.
|
||||||
|
Added tests in png.h to include "trans" and "trans_values" in structures
|
||||||
|
when PNG_READ_BACKGROUND_SUPPORTED or PNG_READ_EXPAND_SUPPORTED is defined.
|
||||||
|
Add png_free(png_ptr->time_buffer) in png_destroy_read_struct()
|
||||||
|
Moved png_convert_to_rfc_1123() from pngwrite.c to png.c
|
||||||
|
Added capability for user-provided malloc_fn() and free_fn() functions,
|
||||||
|
and revised pngtest.c to demonstrate their use, replacing the
|
||||||
|
PNGTEST_DEBUG_MEM feature.
|
||||||
|
Added makefile.w32, for Microsoft C++ 4.0 and later (Tim Wegner).
|
||||||
|
version 1.0.2 [June 14, 1998]
|
||||||
|
Fixed two bugs in makefile.bor .
|
||||||
|
version 1.0.2a [December 30, 1998]
|
||||||
|
Replaced and extended code that was removed from png_set_filler() in 1.0.1a.
|
||||||
|
Fixed a bug in png_do_filler() that made it fail to write filler bytes in
|
||||||
|
the left-most pixel of each row (Kevin Bracey).
|
||||||
|
Changed "static pngcharp tIME_string" to "static char tIME_string[30]"
|
||||||
|
in pngtest.c (Duncan Simpson).
|
||||||
|
Fixed a bug in pngtest.c that caused pngtest to try to write a tIME chunk
|
||||||
|
even when no tIME chunk was present in the source file.
|
||||||
|
Fixed a problem in pngrutil.c: gray_to_rgb didn't always work with 16-bit.
|
||||||
|
Fixed a problem in png_read_push_finish_row(), which would not skip some
|
||||||
|
passes that it should skip, for images that are less than 3 pixels high.
|
||||||
|
Interchanged the order of calls to png_do_swap() and png_do_shift()
|
||||||
|
in pngwtran.c (John Cromer).
|
||||||
|
Added #ifdef PNG_DEBUG/#endif surrounding use of PNG_DEBUG in png.h .
|
||||||
|
Changed "bad adaptive filter type" from error to warning in pngrutil.c .
|
||||||
|
Fixed a documentation error about default filtering with 8-bit indexed-color.
|
||||||
|
Separated the PNG_NO_STDIO macro into PNG_NO_STDIO and PNG_NO_CONSOLE_IO
|
||||||
|
(L. Peter Deutsch).
|
||||||
|
Added png_set_rgb_to_gray() and png_get_rgb_to_gray_status() functions.
|
||||||
|
Added png_get_copyright() and png_get_header_version() functions.
|
||||||
|
Revised comments on png_set_progressive_read_fn() in libpng.txt and example.c
|
||||||
|
Added information about debugging in libpng.txt and libpng.3 .
|
||||||
|
Changed "ln -sf" to "ln -s -f" in makefile.s2x, makefile.lnx, and makefile.sco.
|
||||||
|
Removed lines after Dynamic Dependencies" in makefile.aco .
|
||||||
|
Revised makefile.dec to make a shared library (Jeremie Petit).
|
||||||
|
Removed trailing blanks from all files.
|
||||||
|
version 1.0.2b [January 6, 1999]
|
||||||
|
Removed misplaced #endif and #ifdef PNG_NO_EXTERN near the end of png.h
|
||||||
|
Added "if" tests to silence complaints about unused png_ptr in png.h and png.c
|
||||||
|
Changed "check_if_png" function in example.c to return true (nonzero) if PNG.
|
||||||
|
Changed libpng.txt to demonstrate png_sig_cmp() instead of png_check_sig()
|
||||||
|
which is obsolete.
|
||||||
|
|||||||
90
INSTALL
Normal file
90
INSTALL
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
|
||||||
|
Installing libpng version 1.0.2b - January 6, 1999
|
||||||
|
|
||||||
|
Before installing libpng, you must first install zlib. zlib
|
||||||
|
can usually be found wherever you got libpng. zlib can be
|
||||||
|
placed in another directory, at the same level as libpng.
|
||||||
|
Note that your system might already have a preinstalled
|
||||||
|
zlib, but you will still need to have access to the
|
||||||
|
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.2b" or "lpng103" and "zlib-1.1.3"
|
||||||
|
or "zlib113") so that you have directories called "zlib" and "libpng".
|
||||||
|
|
||||||
|
Your directory structure should look like this:
|
||||||
|
|
||||||
|
.. (the parent directory)
|
||||||
|
libpng (this directory)
|
||||||
|
INSTALL (this file)
|
||||||
|
README
|
||||||
|
*.h
|
||||||
|
*.c
|
||||||
|
scripts
|
||||||
|
makefile.*
|
||||||
|
pngtest.png
|
||||||
|
etc.
|
||||||
|
zlib
|
||||||
|
README
|
||||||
|
*.h
|
||||||
|
*.c
|
||||||
|
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.
|
||||||
|
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.knr => Archaic UNIX Makefile that converts files with ansi2knr
|
||||||
|
makefile.dec => DEC Alpha UNIX makefile
|
||||||
|
makefile.sgi => Silicon Graphics IRIX makefile
|
||||||
|
makefile.sun => Sun makefile
|
||||||
|
makefile.s2x => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0)
|
||||||
|
makefile.lnx => Linux/ELF makefile (gcc, creates libpng.so.2.1.0)
|
||||||
|
makefile.mip => MIPS makefile
|
||||||
|
makefile.aco => Acorn makefile
|
||||||
|
makefile.ama => Amiga makefile
|
||||||
|
smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC compiler
|
||||||
|
(Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc)
|
||||||
|
makefile.atr => Atari makefile
|
||||||
|
makefile.bor => Borland makefile
|
||||||
|
build.bat => MS-DOS batch file for Borland compiler
|
||||||
|
makefile.dj2 => DJGPP 2 makefile
|
||||||
|
makefile.msc => Microsoft C makefile
|
||||||
|
makefile.w32 => makefile for Microsoft Visual C++ 4.0 and later
|
||||||
|
makefile.tc3 => 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.wat => 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
|
||||||
|
|
||||||
|
Copy the file (or files) that you need from the
|
||||||
|
scripts directory into this directory, for example
|
||||||
|
|
||||||
|
MSDOS example: copy scripts\makefile.msd makefile
|
||||||
|
UNIX example: cp scripts/makefile.std makefile
|
||||||
|
|
||||||
|
Read the makefile to see if you need to change any source or
|
||||||
|
target directories to match your preferences.
|
||||||
|
|
||||||
|
Then read pngconf.h to see if you want to make any configuration
|
||||||
|
changes.
|
||||||
|
|
||||||
|
Then just run "make test" which will create the libpng library in
|
||||||
|
this directory and run a quick test that reads the "pngtest.png"
|
||||||
|
file and writes a "pngout.png" file that should be identical to it.
|
||||||
|
|
||||||
|
Most of the makefiles will allow you to run "make install" to
|
||||||
|
put the library in its final resting place (if you want to
|
||||||
|
do that, run "make install" in the zlib directory first if necessary).
|
||||||
|
|
||||||
|
Further information can be found in the README and libpng.txt
|
||||||
|
files, in the individual makefiles, and in png.h, and the manual
|
||||||
|
pages libpng.3 and png.5.
|
||||||
90
KNOWNBUG
Normal file
90
KNOWNBUG
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
|
||||||
|
Known bugs and suggested enhancements in libpng-1.0.2
|
||||||
|
|
||||||
|
|
||||||
|
1. March 15, 1998 -- OPTIMIZATION -- Kevin Bracey
|
||||||
|
|
||||||
|
Loops need to be optimized everywhere
|
||||||
|
|
||||||
|
Make them count down instead of up -- Kevin Bracey
|
||||||
|
|
||||||
|
Optimizing compilers don't need this, and making
|
||||||
|
the change would be error prone -- Tom Lane, Glenn R-P
|
||||||
|
|
||||||
|
Question whether i-- or --i is better.
|
||||||
|
|
||||||
|
STATUS: Under investigation, postponed until after
|
||||||
|
libpng-1.0.2. About 160 loops will be turned around
|
||||||
|
in libpng-1.0.Nn, for testing.
|
||||||
|
|
||||||
|
2. June 15, 1998 -- BUG -- Evan Light
|
||||||
|
|
||||||
|
Under some conditions, 16-bit grayscale images aren't properly
|
||||||
|
expanded to rgb, because png_read_start_row() returns too small a
|
||||||
|
value of max_pixel_depth when png_set_filler() has also been called.
|
||||||
|
|
||||||
|
STATUS: Fixed in libpng-1.0.2a
|
||||||
|
|
||||||
|
3. June 16, 1998 -- BUG -- Matt McConnell
|
||||||
|
|
||||||
|
When reading interlaced images with a progressive reader, in some
|
||||||
|
cases (interlaced images less than 3 pixels high) some passes are
|
||||||
|
not skipped that should be.
|
||||||
|
|
||||||
|
STATUS: Fixed in libpng-1.0.2a
|
||||||
|
|
||||||
|
4. July 3, 1998 -- ENHANCEMENT -- Glenn R-P
|
||||||
|
|
||||||
|
Added png_set_rgb_to_gray() and png_get_rgb_to_gray_status() functions.
|
||||||
|
|
||||||
|
STATUS: Done in libpng-1.0.2a, awaiting comment on resulting test
|
||||||
|
images.
|
||||||
|
|
||||||
|
5. July 4, 1998 -- ENHANCEMENT -- Glenn R-P
|
||||||
|
|
||||||
|
libpng-1.0.2 and earlier transform colors to gamma=1.0 space for
|
||||||
|
merging with background, and then back to the image's gamma. The
|
||||||
|
bit_depth of the intermediate (gamma=1.0) representation is probably
|
||||||
|
not sufficient. In the typical gamma=1/2.2 situation, the linear
|
||||||
|
pixels need about 4 more bits than the gamma-encoded ones, to avoid
|
||||||
|
loss of precision. A similar situation exists with the rgb_to_gray
|
||||||
|
operation.
|
||||||
|
|
||||||
|
STATUS: under development.
|
||||||
|
|
||||||
|
6. August 20, 1998 -- BUG -- Kevin Bracey
|
||||||
|
|
||||||
|
When using the filler transformation, the filler isn't written
|
||||||
|
into the leftmost pixel of each row.
|
||||||
|
|
||||||
|
Also, the filler operation isn't being done right when writing
|
||||||
|
files. Some code that was removed from png_set_filler() in
|
||||||
|
libpng 1.0.1a shouldn't have been removed.
|
||||||
|
|
||||||
|
STATUS: Fixed in libpng-1.0.2a
|
||||||
|
|
||||||
|
7. August 23, 1998 -- BUG -- Duncan Simpson
|
||||||
|
|
||||||
|
"static pngcharp tIME_string" should be changed to
|
||||||
|
"static char tIME_string[30]" in pngtest.c
|
||||||
|
|
||||||
|
Also -- December 30, 1998 -- there are some misplaced brackets in
|
||||||
|
pngtest.c that cause pngtest to try to write a tIME chunk
|
||||||
|
even when no tIME chunk was present in the source file.
|
||||||
|
|
||||||
|
STATUS: Fixed in libpng-1.0.2a
|
||||||
|
|
||||||
|
8. August 24, 1998 -- BUG -- John Cromer
|
||||||
|
|
||||||
|
Order of byte-swap and shift operations seems to be incorrect in
|
||||||
|
png_do_write_transformations()
|
||||||
|
|
||||||
|
STATUS: Under investigation.
|
||||||
|
|
||||||
|
9. September 11, 1998 -- ENHANCEMENT -- L. Peter Deutsch
|
||||||
|
|
||||||
|
The PNG_NO_STDIO macro should be split into PNG_NO_STDIO
|
||||||
|
and PNG_NO_CONSOLE_STDIO.
|
||||||
|
|
||||||
|
STATUS: Done in libpng-1.0.2a
|
||||||
|
|
||||||
99
README
99
README
@@ -1,16 +1,21 @@
|
|||||||
README for libpng 0.96
|
README for libpng 1.0.2b - January 6, 1999 (shared library 2.1)
|
||||||
|
See the note about version numbers near the top of png.h
|
||||||
|
|
||||||
This is the sixth (and hopefully last) beta release of libpng 1.0.
|
See INSTALL for instructions on how to install libpng.
|
||||||
The changes from libpng-0.90 include bug fixes, a C++ wrapper for
|
|
||||||
png.h, some additions to the API, as well as internal changes to
|
This is the first official release of libpng. Don't let the fact that
|
||||||
the library. See "CHANGES" for a detailed list of differences.
|
it's the first release fool you. The libpng library has been in
|
||||||
|
extensive use and testing for about two and a half years. However, it's
|
||||||
|
finally gotten to the stage where there haven't been significant
|
||||||
|
changes to the API in some time, and people have a bad feeling about
|
||||||
|
libraries with versions < 1.0.
|
||||||
|
|
||||||
****
|
****
|
||||||
Note that some of the changes to the png_info structure render this
|
Note that some of the changes to the png_info structure render this
|
||||||
version of the library binary incompatible with libpng-0.89 or
|
version of the library binary incompatible with libpng-0.89 or
|
||||||
earlier versions if you are using a shared library. The type of the
|
earlier versions if you are using a shared library. The type of the
|
||||||
"filler" parameter for png_set_filler() has changed from png_byte to
|
"filler" parameter for png_set_filler() has changed from png_byte to
|
||||||
png_uint_32, which will affect shared-library applications which use
|
png_uint_32, which will affect shared-library applications that use
|
||||||
this function.
|
this function.
|
||||||
|
|
||||||
To avoid problems with changes to the internals of png_info_struct,
|
To avoid problems with changes to the internals of png_info_struct,
|
||||||
@@ -19,6 +24,12 @@ access to info_ptr. These functions are the png_set_<chunk> and
|
|||||||
png_get_<chunk> functions. These functions should be used when
|
png_get_<chunk> functions. These functions should be used when
|
||||||
accessing/storing the info_struct data, rather than manipulating it
|
accessing/storing the info_struct data, rather than manipulating it
|
||||||
directly, to avoid such problems in the future.
|
directly, to avoid such problems in the future.
|
||||||
|
|
||||||
|
It is important to note that the APIs do not make current programs
|
||||||
|
that access the info struct directly incompatible with the new
|
||||||
|
library. However, it is strongly suggested that new programs use
|
||||||
|
the new APIs (as shown in example.c), and older programs be converted
|
||||||
|
to the new format, to facilitate upgrades in the future.
|
||||||
****
|
****
|
||||||
|
|
||||||
Additions since 0.90 include the ability to compile libpng as a
|
Additions since 0.90 include the ability to compile libpng as a
|
||||||
@@ -65,7 +76,7 @@ If not, it should be at ftp.uu.net in /graphics/png
|
|||||||
Eventually, it will be at ftp.uu.net in /pub/archiving/zip/zlib
|
Eventually, it will be at ftp.uu.net in /pub/archiving/zip/zlib
|
||||||
|
|
||||||
You may also want a copy of the PNG specification. It is available
|
You may also want a copy of the PNG specification. It is available
|
||||||
as an Internet Draft, and RFC, and a W3C Recommendation. Failing
|
as an RFC and a W3C Recommendation. Failing
|
||||||
these resources you can try ftp.uu.net in the /graphics/png directory.
|
these resources you can try ftp.uu.net in the /graphics/png directory.
|
||||||
|
|
||||||
This code is currently being archived at ftp.uu.net in the
|
This code is currently being archived at ftp.uu.net in the
|
||||||
@@ -85,19 +96,19 @@ Finally, if you get any warning messages when compiling libpng
|
|||||||
fix. Please mention "libpng" somewhere in the subject line. Thanks.
|
fix. Please mention "libpng" somewhere in the subject line. Thanks.
|
||||||
|
|
||||||
This release was created and will be supported by myself (of course
|
This release was created and will be supported by myself (of course
|
||||||
based in a large way on Guy's earlier work), and the PNG group.
|
based in a large way on Guy's and Andreas' earlier work), and the PNG group.
|
||||||
|
|
||||||
adilger@enel.ucalgary.ca
|
randeg@alumni.rpi.edu
|
||||||
png-implement@dworkin.wustl.edu
|
png-implement@dworkin.wustl.edu
|
||||||
|
|
||||||
You can reach Guy, the original libpng author, at (internet preferred):
|
You can't reach Guy, the original libpng author, at the addresses
|
||||||
|
given in previous versions of this document. He and Andreas will read mail
|
||||||
internet: schalnat@group42.com
|
addressed to the png-implement list, however.
|
||||||
CompuServe: 75501,1625
|
|
||||||
|
|
||||||
Please do not send general questions about PNG. Send them to
|
Please do not send general questions about PNG. Send them to
|
||||||
the address in the specification. At the same time, please do
|
the address in the specification (png-group@w3.org). At the same
|
||||||
not send libpng questions to that address, send them to me. I'll
|
time, please do not send libpng questions to that address, send them to me
|
||||||
|
or to png-implement@dworkin.wustl.edu. I'll
|
||||||
get them in the end anyway. If you have a question about something
|
get them in the end anyway. If you have a question about something
|
||||||
in the PNG specification that is related to using libpng, send it
|
in the PNG specification that is related to using libpng, send it
|
||||||
to me. Send me any questions that start with "I was using libpng,
|
to me. Send me any questions that start with "I was using libpng,
|
||||||
@@ -105,7 +116,7 @@ and ...". If in doubt, send questions to me. I'll bounce them
|
|||||||
to others, if necessary.
|
to others, if necessary.
|
||||||
|
|
||||||
Please do not send suggestions on how to change PNG. We have
|
Please do not send suggestions on how to change PNG. We have
|
||||||
been discussing PNG for a couple years now, and it is official and
|
been discussing PNG for three years now, and it is official and
|
||||||
finished. If you have suggestions for libpng, however, I'll
|
finished. If you have suggestions for libpng, however, I'll
|
||||||
gladly listen. Even if your suggestion is not used for version
|
gladly listen. Even if your suggestion is not used for version
|
||||||
1.0, it may be used later.
|
1.0, it may be used later.
|
||||||
@@ -115,28 +126,20 @@ Files in this distribution:
|
|||||||
CHANGES => Description of changes between libpng versions
|
CHANGES => Description of changes between libpng versions
|
||||||
README => This file
|
README => This file
|
||||||
TODO => Things not implemented in the current library
|
TODO => Things not implemented in the current library
|
||||||
|
ansi2knr.1 => Manual page for ansi2knr
|
||||||
ansi2knr.c => Converts files to K&R style function declarations
|
ansi2knr.c => Converts files to K&R style function declarations
|
||||||
build.bat => MS-DOS batch file for Borland compiler
|
build.bat => MS-DOS batch file for Borland compiler
|
||||||
descrip.mms => VMS project file
|
descrip.mms => VMS project file
|
||||||
example.c => Example code for using libpng functions
|
example.c => Example code for using libpng functions
|
||||||
|
libpng.3 => manual page for libpng
|
||||||
libpng.txt => Description of libpng and its functions
|
libpng.txt => Description of libpng and its functions
|
||||||
makefile => Default Unixish makefile
|
libpngpf.3 => manual page for libpng's private functions
|
||||||
makefile.aco => ACORN makefile
|
png.5 => manual page for the PNG format
|
||||||
makefile.ama => Amiga makefile
|
|
||||||
makefile.atr => Atari makefile
|
|
||||||
makefile.bor => Borland makefile
|
|
||||||
makefile.dj2 => DJGPP 2 makefile
|
|
||||||
makefile.elf => Unix ELF makefile
|
|
||||||
makefile.knr => Makefile which calls ansi2knr to convert files
|
|
||||||
makefile.mip => MIPS makefile
|
|
||||||
makefile.msc => Microsoft C makefile
|
|
||||||
makefile.std => Standard Unix makefile
|
|
||||||
makefile.tc => Turbo C makefile
|
|
||||||
makevms.com => VMS make program
|
|
||||||
png.c => Basic interface functions common to library
|
png.c => Basic interface functions common to library
|
||||||
png.h => Library function and interface declarations
|
png.h => Library function and interface declarations
|
||||||
pngconf.h => System specific library configuration
|
pngconf.h => System specific library configuration
|
||||||
pngerror.c => Error/warning message I/O functions
|
pngerror.c => Error/warning message I/O functions
|
||||||
|
pngget.c => Functions for retrieving info from struct
|
||||||
pngmem.c => Memory handling functions
|
pngmem.c => Memory handling functions
|
||||||
pngpread.c => Progressive reading functions
|
pngpread.c => Progressive reading functions
|
||||||
pngread.c => Read data/helper high-level functions
|
pngread.c => Read data/helper high-level functions
|
||||||
@@ -151,16 +154,44 @@ Files in this distribution:
|
|||||||
pngwrite.c => High-level write functions
|
pngwrite.c => High-level write functions
|
||||||
pngwtran.c => Write data transformations
|
pngwtran.c => Write data transformations
|
||||||
pngwutil.c => Write utility functions
|
pngwutil.c => Write utility functions
|
||||||
|
scripts => Directory containing scripts for building libpng:
|
||||||
|
descrip.mms => VMS makefile for MMS or MMK
|
||||||
|
makefile.std => Generic UNIX makefile
|
||||||
|
makefile.knr => Archaic UNIX Makefile that converts files with ansi2knr
|
||||||
|
makefile.dec => DEC Alpha UNIX makefile
|
||||||
|
makefile.sgi => Silicon Graphics IRIX makefile
|
||||||
|
makefile.sun => Sun makefile
|
||||||
|
makefile.s2x => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0)
|
||||||
|
makefile.lnx => Linux/ELF makefile (gcc, creates libpng.so.2.1.0)
|
||||||
|
makefile.mip => MIPS makefile
|
||||||
|
makefile.aco => Acorn makefile
|
||||||
|
makefile.ama => Amiga makefile
|
||||||
|
smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC compiler
|
||||||
|
(Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc)
|
||||||
|
makefile.atr => Atari makefile
|
||||||
|
makefile.bor => Borland makefile
|
||||||
|
build.bat => MS-DOS batch file for Borland compiler
|
||||||
|
makefile.dj2 => DJGPP 2 makefile
|
||||||
|
makefile.msc => Microsoft C makefile
|
||||||
|
makefile.w32 => makefile for Microsoft Visual C++ 4.0 and later
|
||||||
|
makefile.tc3 => Turbo C 3.0 makefile
|
||||||
|
makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def)
|
||||||
|
makefile.wat => Watcom 10a+ Makefile, 32-bit flat memory model
|
||||||
|
pngos2.def => OS/2 module definition file used by makefile.os2
|
||||||
|
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
|
||||||
|
|
||||||
Good luck, and happy coding.
|
Good luck, and happy coding.
|
||||||
|
|
||||||
|
-Glenn Randers-Pehrson
|
||||||
|
Internet: randeg@alumni.rpi.edu
|
||||||
|
Web: http://www.rpi.edu/~randeg/index.html
|
||||||
|
|
||||||
-Andreas Eric Dilger
|
-Andreas Eric Dilger
|
||||||
Internet: adilger@enel.ucalgary.ca
|
Internet: adilger@enel.ucalgary.ca
|
||||||
Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/
|
Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/
|
||||||
|
|
||||||
-Guy Eric Schalnat
|
-Guy Eric Schalnat
|
||||||
Group 42, Inc.
|
(formerly of Group 42, Inc)
|
||||||
Internet: schalnat@group42.com
|
Internet: gschal@infinet.com
|
||||||
CompuServe: 75501,1625
|
|
||||||
Web: http://www.group42.com/
|
|
||||||
|
|
||||||
|
|||||||
41
TODO
41
TODO
@@ -1,19 +1,24 @@
|
|||||||
pngtodo.txt - list of things to do for libpng
|
TODO - list of things to do for libpng:
|
||||||
|
|
||||||
add "grayscale->palette" transformation and "palette->grayscale" detection
|
Final bug fixes.
|
||||||
improved dithering
|
Fix problem with C++ and EXTERN "C".
|
||||||
multi-lingual error and warning message support
|
Better C++ wrapper/full C++ implementation?
|
||||||
cHRM transformation
|
Keep up with public chunks.
|
||||||
sRGB chunk handling
|
sPLT chunk handling.
|
||||||
man pages for function calls
|
cHRM transformation.
|
||||||
high-level API for reading images
|
Support for application-defined chunk handlers.
|
||||||
final bug fixes
|
Improve setjmp/longjmp usage or remove it in favor of returning error codes.
|
||||||
better documentation
|
High-level API for reading images.
|
||||||
better filter selection
|
Add "grayscale->palette" transformation and "palette->grayscale" detection.
|
||||||
(counting huffman bits/precompression? filter inertia? filter costs?)
|
Color to gray transformation.
|
||||||
optional palette creation
|
Improved dithering.
|
||||||
histogram creation
|
Multi-lingual error and warning message support.
|
||||||
support for application-defined chunk handlers
|
Complete sRGB transformation (presently it simply uses gamma=0.45455).
|
||||||
keep up with public chunks
|
Man pages for function calls.
|
||||||
better C++ wrapper/full C++ implementation?
|
Better documentation.
|
||||||
text conversion between different code pages (Latin-1 -> Mac and DOS)
|
Better filter selection
|
||||||
|
(counting huffman bits/precompression? filter inertia? filter costs?).
|
||||||
|
Optional palette (sPLT) creation.
|
||||||
|
Histogram creation.
|
||||||
|
Text conversion between different code pages (Latin-1 -> Mac and DOS).
|
||||||
|
Improve API by hiding the info_ptr.
|
||||||
|
|||||||
36
ansi2knr.1
Normal file
36
ansi2knr.1
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
.TH ANSI2KNR 1 "19 Jan 1996"
|
||||||
|
.SH NAME
|
||||||
|
ansi2knr \- convert ANSI C to Kernighan & Ritchie C
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.I ansi2knr
|
||||||
|
[--varargs] input_file [output_file]
|
||||||
|
.SH DESCRIPTION
|
||||||
|
If no output_file is supplied, output goes to stdout.
|
||||||
|
.br
|
||||||
|
There are no error messages.
|
||||||
|
.sp
|
||||||
|
.I ansi2knr
|
||||||
|
recognizes function definitions by seeing a non-keyword identifier at the left
|
||||||
|
margin, followed by a left parenthesis, with a right parenthesis as the last
|
||||||
|
character on the line, and with a left brace as the first token on the
|
||||||
|
following line (ignoring possible intervening comments). It will recognize a
|
||||||
|
multi-line header provided that no intervening line ends with a left or right
|
||||||
|
brace or a semicolon. These algorithms ignore whitespace and comments, except
|
||||||
|
that the function name must be the first thing on the line.
|
||||||
|
.sp
|
||||||
|
The following constructs will confuse it:
|
||||||
|
.br
|
||||||
|
- Any other construct that starts at the left margin and follows the
|
||||||
|
above syntax (such as a macro or function call).
|
||||||
|
.br
|
||||||
|
- Some macros that tinker with the syntax of the function header.
|
||||||
|
.sp
|
||||||
|
The --varargs switch is obsolete, and is recognized only for
|
||||||
|
backwards compatibility. The present version of
|
||||||
|
.I ansi2knr
|
||||||
|
will always attempt to convert a ... argument to va_alist and va_dcl.
|
||||||
|
.SH AUTHOR
|
||||||
|
L. Peter Deutsch <ghost@aladdin.com> wrote the original ansi2knr and
|
||||||
|
continues to maintain the current version; most of the code in the current
|
||||||
|
version is his work. ansi2knr also includes contributions by Francois
|
||||||
|
Pinard <pinard@iro.umontreal.ca> and Jim Avera <jima@netcom.com>.
|
||||||
427
ansi2knr.c
427
ansi2knr.c
@@ -1,27 +1,35 @@
|
|||||||
/* Copyright (C) 1989, 1991, 1993 Aladdin Enterprises. All rights reserved. */
|
|
||||||
|
|
||||||
/* ansi2knr.c */
|
/* ansi2knr.c */
|
||||||
/* Convert ANSI function declarations to K&R syntax */
|
|
||||||
|
|
||||||
/*
|
/* Convert ANSI C function definitions to K&R ("traditional C") syntax
|
||||||
ansi2knr is distributed in the hope that it will be useful, but
|
Copyright (C) 1989 Aladdin Enterprises. All rights reserved.
|
||||||
WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
|
Copyright (C) 1988 Richard M. Stallman
|
||||||
to anyone for the consequences of using it or for whether it serves any
|
|
||||||
particular purpose or works at all, unless he says so in writing. Refer
|
|
||||||
to the GNU General Public License for full details.
|
|
||||||
|
|
||||||
Everyone is granted permission to copy, modify and redistribute
|
ansi2knr is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
ansi2knr, but only under the conditions described in the GNU
|
WARRANTY. No author or distributor accepts responsibility to anyone for the
|
||||||
General Public License. A copy of this license is supposed to have been
|
consequences of using it or for whether it serves any particular purpose or
|
||||||
given to you along with ansi2knr so you can know your rights and
|
works at all, unless he says so in writing. Refer to the GNU General Public
|
||||||
responsibilities. It should be in a file named COPYING. Among other
|
License (the "GPL") for full details.
|
||||||
things, the copyright notice and this notice must be preserved on all
|
|
||||||
copies.
|
Everyone is granted permission to copy, modify and redistribute ansi2knr,
|
||||||
|
but only under the conditions described in the GPL. A copy of this license
|
||||||
|
is supposed to have been given to you along with ansi2knr so you can know
|
||||||
|
your rights and responsibilities. It should be in a file named COPYLEFT.
|
||||||
|
[In the LIBPNG distribution, the GPL appears below, not in a separate file.]
|
||||||
|
Among other things, the copyright notice and this notice must be preserved
|
||||||
|
on all copies.
|
||||||
|
|
||||||
|
We explicitly state here what we believe is already implied by the GPL: if
|
||||||
|
the ansi2knr program is distributed as a separate source file and a
|
||||||
|
separate executable file which are aggregated on a storage medium together
|
||||||
|
with another program, this in itself does not bring the other program under
|
||||||
|
the GPL, nor does the mere fact that such a program or the procedures for
|
||||||
|
constructing it invoke the ansi2knr executable bring any other part of the
|
||||||
|
program under the GPL.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
---------- Here is the GNU GPL file COPYING, referred to above ----------
|
---------- Here is the GNU GPL file COPYLEFT, referred to above ----------
|
||||||
----- These terms do NOT apply to the JPEG software itself; see README ------
|
----- These terms do NOT apply to the LIBPNG software itself; see README ------
|
||||||
|
|
||||||
GHOSTSCRIPT GENERAL PUBLIC LICENSE
|
GHOSTSCRIPT GENERAL PUBLIC LICENSE
|
||||||
(Clarified 11 Feb 1988)
|
(Clarified 11 Feb 1988)
|
||||||
@@ -166,59 +174,142 @@ PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) GHOSTSCRIPT, EVEN IF YOU
|
|||||||
HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM
|
HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM
|
||||||
BY ANY OTHER PARTY.
|
BY ANY OTHER PARTY.
|
||||||
|
|
||||||
-------------------- End of file COPYING ------------------------------
|
-------------------- End of file COPYLEFT ------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
#include <stdio.h>
|
* Usage:
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#ifdef BSD
|
|
||||||
#include <strings.h>
|
|
||||||
#else
|
|
||||||
#ifdef VMS
|
|
||||||
extern int strlen(), strncmp();
|
|
||||||
#else
|
|
||||||
#include <string.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* malloc and free should be declared in stdlib.h, */
|
|
||||||
/* but if you've got a K&R compiler, they probably aren't. */
|
|
||||||
#ifdef MSDOS
|
|
||||||
#include <malloc.h>
|
|
||||||
#else
|
|
||||||
#ifdef VMS
|
|
||||||
extern char *malloc();
|
|
||||||
extern void free();
|
|
||||||
#else
|
|
||||||
extern char *malloc();
|
|
||||||
extern int free();
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Usage:
|
|
||||||
ansi2knr input_file [output_file]
|
ansi2knr input_file [output_file]
|
||||||
* If no output_file is supplied, output goes to stdout.
|
* If no output_file is supplied, output goes to stdout.
|
||||||
* There are no error messages.
|
* There are no error messages.
|
||||||
*
|
*
|
||||||
* ansi2knr recognizes functions by seeing a non-keyword identifier
|
* ansi2knr recognizes function definitions by seeing a non-keyword
|
||||||
* at the left margin, followed by a left parenthesis,
|
* identifier at the left margin, followed by a left parenthesis,
|
||||||
* with a right parenthesis as the last character on the line.
|
* with a right parenthesis as the last character on the line,
|
||||||
* It will recognize a multi-line header provided that the last character
|
* and with a left brace as the first token on the following line
|
||||||
* of the last line of the header is a right parenthesis,
|
* (ignoring possible intervening comments).
|
||||||
* and no intervening line ends with a left brace or a semicolon.
|
* It will recognize a multi-line header provided that no intervening
|
||||||
|
* line ends with a left or right brace or a semicolon.
|
||||||
* These algorithms ignore whitespace and comments, except that
|
* These algorithms ignore whitespace and comments, except that
|
||||||
* the function name must be the first thing on the line.
|
* the function name must be the first thing on the line.
|
||||||
* The following constructs will confuse it:
|
* The following constructs will confuse it:
|
||||||
* - Any other construct that starts at the left margin and
|
* - Any other construct that starts at the left margin and
|
||||||
* follows the above syntax (such as a macro or function call).
|
* follows the above syntax (such as a macro or function call).
|
||||||
* - Macros that tinker with the syntax of the function header.
|
* - Some macros that tinker with the syntax of the function header.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The original and principal author of ansi2knr is L. Peter Deutsch
|
||||||
|
* <ghost@aladdin.com>. Other authors are noted in the change history
|
||||||
|
* that follows (in reverse chronological order):
|
||||||
|
lpd 96-01-21 added code to cope with not HAVE_CONFIG_H and with
|
||||||
|
compilers that don't understand void, as suggested by
|
||||||
|
Tom Lane
|
||||||
|
lpd 96-01-15 changed to require that the first non-comment token
|
||||||
|
on the line following a function header be a left brace,
|
||||||
|
to reduce sensitivity to macros, as suggested by Tom Lane
|
||||||
|
<tgl@sss.pgh.pa.us>
|
||||||
|
lpd 95-06-22 removed #ifndefs whose sole purpose was to define
|
||||||
|
undefined preprocessor symbols as 0; changed all #ifdefs
|
||||||
|
for configuration symbols to #ifs
|
||||||
|
lpd 95-04-05 changed copyright notice to make it clear that
|
||||||
|
including ansi2knr in a program does not bring the entire
|
||||||
|
program under the GPL
|
||||||
|
lpd 94-12-18 added conditionals for systems where ctype macros
|
||||||
|
don't handle 8-bit characters properly, suggested by
|
||||||
|
Francois Pinard <pinard@iro.umontreal.ca>;
|
||||||
|
removed --varargs switch (this is now the default)
|
||||||
|
lpd 94-10-10 removed CONFIG_BROKETS conditional
|
||||||
|
lpd 94-07-16 added some conditionals to help GNU `configure',
|
||||||
|
suggested by Francois Pinard <pinard@iro.umontreal.ca>;
|
||||||
|
properly erase prototype args in function parameters,
|
||||||
|
contributed by Jim Avera <jima@netcom.com>;
|
||||||
|
correct error in writeblanks (it shouldn't erase EOLs)
|
||||||
|
lpd 89-xx-xx original version
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Most of the conditionals here are to make ansi2knr work with */
|
||||||
|
/* or without the GNU configure machinery. */
|
||||||
|
|
||||||
|
#if HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#if HAVE_CONFIG_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
For properly autoconfiguring ansi2knr, use AC_CONFIG_HEADER(config.h).
|
||||||
|
This will define HAVE_CONFIG_H and so, activate the following lines.
|
||||||
|
*/
|
||||||
|
|
||||||
|
# if STDC_HEADERS || HAVE_STRING_H
|
||||||
|
# include <string.h>
|
||||||
|
# else
|
||||||
|
# include <strings.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#else /* not HAVE_CONFIG_H */
|
||||||
|
|
||||||
|
/* Otherwise do it the hard way */
|
||||||
|
|
||||||
|
# ifdef BSD
|
||||||
|
# include <strings.h>
|
||||||
|
# else
|
||||||
|
# ifdef VMS
|
||||||
|
extern int strlen(), strncmp();
|
||||||
|
# else
|
||||||
|
# include <string.h>
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif /* not HAVE_CONFIG_H */
|
||||||
|
|
||||||
|
#if STDC_HEADERS
|
||||||
|
# include <stdlib.h>
|
||||||
|
#else
|
||||||
|
/*
|
||||||
|
malloc and free should be declared in stdlib.h,
|
||||||
|
but if you've got a K&R compiler, they probably aren't.
|
||||||
|
*/
|
||||||
|
# ifdef MSDOS
|
||||||
|
# include <malloc.h>
|
||||||
|
# else
|
||||||
|
# ifdef VMS
|
||||||
|
extern char *malloc();
|
||||||
|
extern void free();
|
||||||
|
# else
|
||||||
|
extern char *malloc();
|
||||||
|
extern int free();
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The ctype macros don't always handle 8-bit characters correctly.
|
||||||
|
* Compensate for this here.
|
||||||
|
*/
|
||||||
|
#ifdef isascii
|
||||||
|
# undef HAVE_ISASCII /* just in case */
|
||||||
|
# define HAVE_ISASCII 1
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
#if STDC_HEADERS || !HAVE_ISASCII
|
||||||
|
# define is_ascii(c) 1
|
||||||
|
#else
|
||||||
|
# define is_ascii(c) isascii(c)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define is_space(c) (is_ascii(c) && isspace(c))
|
||||||
|
#define is_alpha(c) (is_ascii(c) && isalpha(c))
|
||||||
|
#define is_alnum(c) (is_ascii(c) && isalnum(c))
|
||||||
|
|
||||||
/* Scanning macros */
|
/* Scanning macros */
|
||||||
#define isidchar(ch) (isalnum(ch) || (ch) == '_')
|
#define isidchar(ch) (is_alnum(ch) || (ch) == '_')
|
||||||
#define isidfirstchar(ch) (isalpha(ch) || (ch) == '_')
|
#define isidfirstchar(ch) (is_alpha(ch) || (ch) == '_')
|
||||||
|
|
||||||
/* Forward references */
|
/* Forward references */
|
||||||
char *skipspace();
|
char *skipspace();
|
||||||
@@ -227,6 +318,7 @@ int test1();
|
|||||||
int convert1();
|
int convert1();
|
||||||
|
|
||||||
/* The main program */
|
/* The main program */
|
||||||
|
int
|
||||||
main(argc, argv)
|
main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
char *argv[];
|
char *argv[];
|
||||||
@@ -234,46 +326,99 @@ main(argc, argv)
|
|||||||
#define bufsize 5000 /* arbitrary size */
|
#define bufsize 5000 /* arbitrary size */
|
||||||
char *buf;
|
char *buf;
|
||||||
char *line;
|
char *line;
|
||||||
|
char *more;
|
||||||
|
/*
|
||||||
|
* In previous versions, ansi2knr recognized a --varargs switch.
|
||||||
|
* If this switch was supplied, ansi2knr would attempt to convert
|
||||||
|
* a ... argument to va_alist and va_dcl; if this switch was not
|
||||||
|
* supplied, ansi2knr would simply drop any such arguments.
|
||||||
|
* Now, ansi2knr always does this conversion, and we only
|
||||||
|
* check for this switch for backward compatibility.
|
||||||
|
*/
|
||||||
|
int convert_varargs = 1;
|
||||||
|
|
||||||
|
if ( argc > 1 && argv[1][0] == '-' )
|
||||||
|
{ if ( !strcmp(argv[1], "--varargs") )
|
||||||
|
{ convert_varargs = 1;
|
||||||
|
argc--;
|
||||||
|
argv++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ fprintf(stderr, "Unrecognized switch: %s\n", argv[1]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
switch ( argc )
|
switch ( argc )
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
printf("Usage: ansi2knr input_file [output_file]\n");
|
printf("Usage: ansi2knr input_file [output_file]\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
case 2:
|
case 2:
|
||||||
out = stdout; break;
|
out = stdout;
|
||||||
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
out = fopen(argv[2], "w");
|
out = fopen(argv[2], "w");
|
||||||
if ( out == NULL )
|
if ( out == NULL )
|
||||||
{ fprintf(stderr, "Cannot open %s\n", argv[2]);
|
{ fprintf(stderr, "Cannot open output file %s\n", argv[2]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
in = fopen(argv[1], "r");
|
in = fopen(argv[1], "r");
|
||||||
if ( in == NULL )
|
if ( in == NULL )
|
||||||
{ fprintf(stderr, "Cannot open %s\n", argv[1]);
|
{ fprintf(stderr, "Cannot open input file %s\n", argv[1]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
fprintf(out, "#line 1 \"%s\"\n", argv[1]);
|
fprintf(out, "#line 1 \"%s\"\n", argv[1]);
|
||||||
buf = malloc(bufsize);
|
buf = malloc(bufsize);
|
||||||
line = buf;
|
line = buf;
|
||||||
while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL )
|
while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL )
|
||||||
{ switch ( test1(buf) )
|
{
|
||||||
|
test: line += strlen(line);
|
||||||
|
switch ( test1(buf) )
|
||||||
{
|
{
|
||||||
|
case 2: /* a function header */
|
||||||
|
convert1(buf, out, 1, convert_varargs);
|
||||||
|
break;
|
||||||
case 1: /* a function */
|
case 1: /* a function */
|
||||||
convert1(buf, out);
|
/* Check for a { at the start of the next line. */
|
||||||
|
more = ++line;
|
||||||
|
f: if ( line >= buf + (bufsize - 1) ) /* overflow check */
|
||||||
|
goto wl;
|
||||||
|
if ( fgets(line, (unsigned)(buf + bufsize - line), in) == NULL )
|
||||||
|
goto wl;
|
||||||
|
switch ( *skipspace(more, 1) )
|
||||||
|
{
|
||||||
|
case '{':
|
||||||
|
/* Definitely a function header. */
|
||||||
|
convert1(buf, out, 0, convert_varargs);
|
||||||
|
fputs(more, out);
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
/* The next line was blank or a comment: */
|
||||||
|
/* keep scanning for a non-comment. */
|
||||||
|
line += strlen(line);
|
||||||
|
goto f;
|
||||||
|
default:
|
||||||
|
/* buf isn't a function header, but */
|
||||||
|
/* more might be. */
|
||||||
|
fputs(buf, out);
|
||||||
|
strcpy(buf, more);
|
||||||
|
line = buf;
|
||||||
|
goto test;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case -1: /* maybe the start of a function */
|
case -1: /* maybe the start of a function */
|
||||||
line = buf + strlen(buf);
|
|
||||||
if ( line != buf + (bufsize - 1) ) /* overflow check */
|
if ( line != buf + (bufsize - 1) ) /* overflow check */
|
||||||
continue;
|
continue;
|
||||||
/* falls through */
|
/* falls through */
|
||||||
default: /* not a function */
|
default: /* not a function */
|
||||||
fputs(buf, out);
|
wl: fputs(buf, out);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
line = buf;
|
line = buf;
|
||||||
}
|
}
|
||||||
if ( line != buf ) fputs(buf, out);
|
if ( line != buf )
|
||||||
|
fputs(buf, out);
|
||||||
free(buf);
|
free(buf);
|
||||||
fclose(out);
|
fclose(out);
|
||||||
fclose(in);
|
fclose(in);
|
||||||
@@ -286,11 +431,14 @@ skipspace(p, dir)
|
|||||||
register char *p;
|
register char *p;
|
||||||
register int dir; /* 1 for forward, -1 for backward */
|
register int dir; /* 1 for forward, -1 for backward */
|
||||||
{ for ( ; ; )
|
{ for ( ; ; )
|
||||||
{ while ( isspace(*p) ) p += dir;
|
{ while ( is_space(*p) )
|
||||||
if ( !(*p == '/' && p[dir] == '*') ) break;
|
p += dir;
|
||||||
|
if ( !(*p == '/' && p[dir] == '*') )
|
||||||
|
break;
|
||||||
p += dir; p += dir;
|
p += dir; p += dir;
|
||||||
while ( !(*p == '*' && p[dir] == '/') )
|
while ( !(*p == '*' && p[dir] == '/') )
|
||||||
{ if ( *p == 0 ) return p; /* multi-line comment?? */
|
{ if ( *p == 0 )
|
||||||
|
return p; /* multi-line comment?? */
|
||||||
p += dir;
|
p += dir;
|
||||||
}
|
}
|
||||||
p += dir; p += dir;
|
p += dir; p += dir;
|
||||||
@@ -300,13 +448,16 @@ skipspace(p, dir)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Write blanks over part of a string.
|
* Write blanks over part of a string.
|
||||||
|
* Don't overwrite end-of-line characters.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
writeblanks(start, end)
|
writeblanks(start, end)
|
||||||
char *start;
|
char *start;
|
||||||
char *end;
|
char *end;
|
||||||
{ char *p;
|
{ char *p;
|
||||||
for ( p = start; p < end; p++ ) *p = ' ';
|
for ( p = start; p < end; p++ )
|
||||||
|
if ( *p != '\r' && *p != '\n' )
|
||||||
|
*p = ' ';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,8 +467,12 @@ writeblanks(start, end)
|
|||||||
* Return as follows:
|
* Return as follows:
|
||||||
* 0 - definitely not a function definition;
|
* 0 - definitely not a function definition;
|
||||||
* 1 - definitely a function definition;
|
* 1 - definitely a function definition;
|
||||||
|
* 2 - definitely a function prototype (NOT USED);
|
||||||
* -1 - may be the beginning of a function definition,
|
* -1 - may be the beginning of a function definition,
|
||||||
* append another line and look again.
|
* append another line and look again.
|
||||||
|
* The reason we don't attempt to convert function prototypes is that
|
||||||
|
* Ghostscript's declaration-generating macros look too much like
|
||||||
|
* prototypes, and confuse the algorithms.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
test1(buf)
|
test1(buf)
|
||||||
@@ -326,24 +481,27 @@ test1(buf)
|
|||||||
char *bend;
|
char *bend;
|
||||||
char *endfn;
|
char *endfn;
|
||||||
int contin;
|
int contin;
|
||||||
|
|
||||||
if ( !isidfirstchar(*p) )
|
if ( !isidfirstchar(*p) )
|
||||||
return 0; /* no name at left margin */
|
return 0; /* no name at left margin */
|
||||||
bend = skipspace(buf + strlen(buf) - 1, -1);
|
bend = skipspace(buf + strlen(buf) - 1, -1);
|
||||||
switch ( *bend )
|
switch ( *bend )
|
||||||
{
|
{
|
||||||
case ')': contin = 1; break;
|
case ';': contin = 0 /*2*/; break;
|
||||||
case '{':
|
case ')': contin = 1; break;
|
||||||
case ';': return 0; /* not a function */
|
case '{': return 0; /* not a function */
|
||||||
default: contin = -1;
|
case '}': return 0; /* not a function */
|
||||||
|
default: contin = -1;
|
||||||
}
|
}
|
||||||
while ( isidchar(*p) ) p++;
|
while ( isidchar(*p) )
|
||||||
|
p++;
|
||||||
endfn = p;
|
endfn = p;
|
||||||
p = skipspace(p, 1);
|
p = skipspace(p, 1);
|
||||||
if ( *p++ != '(' )
|
if ( *p++ != '(' )
|
||||||
return 0; /* not a function */
|
return 0; /* not a function */
|
||||||
p = skipspace(p, 1);
|
p = skipspace(p, 1);
|
||||||
if ( *p == ')' )
|
if ( *p == ')' )
|
||||||
return 0; /* no parameters */
|
return 0; /* no parameters */
|
||||||
/* Check that the apparent function name isn't a keyword. */
|
/* Check that the apparent function name isn't a keyword. */
|
||||||
/* We only need to check for keywords that could be followed */
|
/* We only need to check for keywords that could be followed */
|
||||||
/* by a left parenthesis (which, unfortunately, is most of them). */
|
/* by a left parenthesis (which, unfortunately, is most of them). */
|
||||||
@@ -357,19 +515,23 @@ test1(buf)
|
|||||||
char **key = words;
|
char **key = words;
|
||||||
char *kp;
|
char *kp;
|
||||||
int len = endfn - buf;
|
int len = endfn - buf;
|
||||||
|
|
||||||
while ( (kp = *key) != 0 )
|
while ( (kp = *key) != 0 )
|
||||||
{ if ( strlen(kp) == len && !strncmp(kp, buf, len) )
|
{ if ( strlen(kp) == len && !strncmp(kp, buf, len) )
|
||||||
return 0; /* name is a keyword */
|
return 0; /* name is a keyword */
|
||||||
key++;
|
key++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return contin;
|
return contin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Convert a recognized function definition or header to K&R syntax. */
|
||||||
int
|
int
|
||||||
convert1(buf, out)
|
convert1(buf, out, header, convert_varargs)
|
||||||
char *buf;
|
char *buf;
|
||||||
FILE *out;
|
FILE *out;
|
||||||
|
int header; /* Boolean */
|
||||||
|
int convert_varargs; /* Boolean */
|
||||||
{ char *endfn;
|
{ char *endfn;
|
||||||
register char *p;
|
register char *p;
|
||||||
char **breaks;
|
char **breaks;
|
||||||
@@ -377,9 +539,12 @@ convert1(buf, out)
|
|||||||
char **btop;
|
char **btop;
|
||||||
char **bp;
|
char **bp;
|
||||||
char **ap;
|
char **ap;
|
||||||
|
char *vararg = 0;
|
||||||
|
|
||||||
/* Pre-ANSI implementations don't agree on whether strchr */
|
/* Pre-ANSI implementations don't agree on whether strchr */
|
||||||
/* is called strchr or index, so we open-code it here. */
|
/* is called strchr or index, so we open-code it here. */
|
||||||
for ( endfn = buf; *(endfn++) != '('; ) ;
|
for ( endfn = buf; *(endfn++) != '('; )
|
||||||
|
;
|
||||||
top: p = endfn;
|
top: p = endfn;
|
||||||
breaks = (char **)malloc(sizeof(char *) * num_breaks * 2);
|
breaks = (char **)malloc(sizeof(char *) * num_breaks * 2);
|
||||||
if ( breaks == 0 )
|
if ( breaks == 0 )
|
||||||
@@ -393,7 +558,10 @@ top: p = endfn;
|
|||||||
/* Parse the argument list */
|
/* Parse the argument list */
|
||||||
do
|
do
|
||||||
{ int level = 0;
|
{ int level = 0;
|
||||||
|
char *lp = NULL;
|
||||||
|
char *rp;
|
||||||
char *end = NULL;
|
char *end = NULL;
|
||||||
|
|
||||||
if ( bp >= btop )
|
if ( bp >= btop )
|
||||||
{ /* Filled up break table. */
|
{ /* Filled up break table. */
|
||||||
/* Allocate a bigger one and start over. */
|
/* Allocate a bigger one and start over. */
|
||||||
@@ -406,13 +574,27 @@ top: p = endfn;
|
|||||||
for ( ; end == NULL; p++ )
|
for ( ; end == NULL; p++ )
|
||||||
{ switch(*p)
|
{ switch(*p)
|
||||||
{
|
{
|
||||||
case ',': if ( !level ) end = p; break;
|
case ',':
|
||||||
case '(': level++; break;
|
if ( !level ) end = p;
|
||||||
case ')': if ( --level < 0 ) end = p; break;
|
break;
|
||||||
case '/': p = skipspace(p, 1) - 1; break;
|
case '(':
|
||||||
default: ;
|
if ( !level ) lp = p;
|
||||||
|
level++;
|
||||||
|
break;
|
||||||
|
case ')':
|
||||||
|
if ( --level < 0 ) end = p;
|
||||||
|
else rp = p;
|
||||||
|
break;
|
||||||
|
case '/':
|
||||||
|
p = skipspace(p, 1) - 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Erase any embedded prototype parameters. */
|
||||||
|
if ( lp )
|
||||||
|
writeblanks(lp + 1, rp);
|
||||||
p--; /* back up over terminator */
|
p--; /* back up over terminator */
|
||||||
/* Find the name being declared. */
|
/* Find the name being declared. */
|
||||||
/* This is complicated because of procedure and */
|
/* This is complicated because of procedure and */
|
||||||
@@ -421,35 +603,42 @@ top: p = endfn;
|
|||||||
{ p = skipspace(p - 1, -1);
|
{ p = skipspace(p - 1, -1);
|
||||||
switch ( *p )
|
switch ( *p )
|
||||||
{
|
{
|
||||||
case ']': /* skip array dimension(s) */
|
case ']': /* skip array dimension(s) */
|
||||||
case ')': /* skip procedure args OR name */
|
case ')': /* skip procedure args OR name */
|
||||||
{ int level = 1;
|
{ int level = 1;
|
||||||
while ( level )
|
while ( level )
|
||||||
switch ( *--p )
|
switch ( *--p )
|
||||||
{
|
{
|
||||||
case ']': case ')': level++; break;
|
case ']': case ')': level++; break;
|
||||||
case '[': case '(': level--; break;
|
case '[': case '(': level--; break;
|
||||||
case '/': p = skipspace(p, -1) + 1; break;
|
case '/': p = skipspace(p, -1) + 1; break;
|
||||||
default: ;
|
default: ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( *p == '(' && *skipspace(p + 1, 1) == '*' )
|
if ( *p == '(' && *skipspace(p + 1, 1) == '*' )
|
||||||
{ /* We found the name being declared */
|
{ /* We found the name being declared */
|
||||||
while ( !isidfirstchar(*p) )
|
while ( !isidfirstchar(*p) )
|
||||||
p = skipspace(p, 1) + 1;
|
p = skipspace(p, 1) + 1;
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: goto found;
|
default:
|
||||||
|
goto found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' )
|
found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' )
|
||||||
{ p++;
|
{ if ( convert_varargs )
|
||||||
if ( bp == breaks + 1 ) /* sole argument */
|
{ *bp++ = "va_alist";
|
||||||
writeblanks(breaks[0], p);
|
vararg = p-2;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
writeblanks(bp[-1] - 1, p);
|
{ p++;
|
||||||
bp--;
|
if ( bp == breaks + 1 ) /* sole argument */
|
||||||
|
writeblanks(breaks[0], p);
|
||||||
|
else
|
||||||
|
writeblanks(bp[-1] - 1, p);
|
||||||
|
bp--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ while ( isidchar(*p) ) p--;
|
{ while ( isidchar(*p) ) p--;
|
||||||
@@ -470,19 +659,37 @@ found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Put out the function name */
|
/* Put out the function name and left parenthesis. */
|
||||||
p = buf;
|
p = buf;
|
||||||
while ( p != endfn ) putc(*p, out), p++;
|
while ( p != endfn ) putc(*p, out), p++;
|
||||||
/* Put out the declaration */
|
/* Put out the declaration. */
|
||||||
for ( ap = breaks+1; ap < bp; ap += 2 )
|
if ( header )
|
||||||
{ p = *ap;
|
{ fputs(");", out);
|
||||||
while ( isidchar(*p) ) putc(*p, out), p++;
|
for ( p = breaks[0]; *p; p++ )
|
||||||
if ( ap < bp - 1 ) fputs(", ", out);
|
if ( *p == '\r' || *p == '\n' )
|
||||||
}
|
putc(*p, out);
|
||||||
fputs(") ", out);
|
}
|
||||||
/* Put out the argument declarations */
|
else
|
||||||
for ( ap = breaks+2; ap <= bp; ap += 2 ) (*ap)[-1] = ';';
|
{ for ( ap = breaks+1; ap < bp; ap += 2 )
|
||||||
fputs(breaks[0], out);
|
{ p = *ap;
|
||||||
|
while ( isidchar(*p) )
|
||||||
|
putc(*p, out), p++;
|
||||||
|
if ( ap < bp - 1 )
|
||||||
|
fputs(", ", out);
|
||||||
|
}
|
||||||
|
fputs(") ", out);
|
||||||
|
/* Put out the argument declarations */
|
||||||
|
for ( ap = breaks+2; ap <= bp; ap += 2 )
|
||||||
|
(*ap)[-1] = ';';
|
||||||
|
if ( vararg != 0 )
|
||||||
|
{ *vararg = 0;
|
||||||
|
fputs(breaks[0], out); /* any prior args */
|
||||||
|
fputs("va_dcl", out); /* the final arg */
|
||||||
|
fputs(bp[0], out);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fputs(breaks[0], out);
|
||||||
|
}
|
||||||
free((char *)breaks);
|
free((char *)breaks);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
251
example.c
251
example.c
@@ -1,36 +1,40 @@
|
|||||||
|
|
||||||
/* example.c - an example of using libpng */
|
/* example.c - an example of using libpng */
|
||||||
|
|
||||||
/* This is an example of how to use libpng to read and write PNG files.
|
/* This is an example of how to use libpng to read and write PNG files.
|
||||||
The file libpng.txt is much more verbose then this. If you have not
|
* The file libpng.txt is much more verbose then this. If you have not
|
||||||
read it, do so first. This was designed to be a starting point of an
|
* read it, do so first. This was designed to be a starting point of an
|
||||||
implementation. This is not officially part of libpng, and therefore
|
* implementation. This is not officially part of libpng, and therefore
|
||||||
does not require a copyright notice.
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
This file does not currently compile, because it is missing certain
|
#include "png.h"
|
||||||
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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <png.h>
|
/* 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.
|
||||||
/* Check to see if a file is a PNG file using png_check_sig(). Returns
|
*
|
||||||
non-zero if the image is a PNG, and 0 if it isn't a PNG.
|
* The function check_if_png() shown here, but not used, returns nonzero (true)
|
||||||
|
* if the file can be opened and is a PNG, 0 (false) otherwise.
|
||||||
If this call is successful, and you are going to keep the file open,
|
*
|
||||||
you should call png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); once
|
* If this call is successful, and you are going to keep the file open,
|
||||||
you have created the png_ptr, so that libpng knows your application
|
* you should call png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); once
|
||||||
has read that many bytes from the start of the file. Make sure you
|
* you have created the png_ptr, so that libpng knows your application
|
||||||
don't call png_set_sig_bytes() with more than 8 bytes read or give it
|
* has read that many bytes from the start of the file. Make sure you
|
||||||
an incorrect number of bytes read, or you will either have read too
|
* don't call png_set_sig_bytes() with more than 8 bytes read or give it
|
||||||
many bytes (your fault), or you are telling libpng to read the wrong
|
* an incorrect number of bytes read, or you will either have read too
|
||||||
number of magic bytes (also your fault).
|
* many bytes (your fault), or you are telling libpng to read the wrong
|
||||||
|
* number of magic bytes (also your fault).
|
||||||
Many applications already read the first 2 or 4 bytes from the start
|
*
|
||||||
of the image to determine the file type, so it would be easiest just
|
* Many applications already read the first 2 or 4 bytes from the start
|
||||||
to pass the bytes to png_check_sig() or even skip that if you know
|
* of the image to determine the file type, so it would be easiest just
|
||||||
you have a PNG file, and call png_set_sig_bytes().
|
* to pass the bytes to png_sig_cmp() or even skip that if you know
|
||||||
*/
|
* you have a PNG file, and call png_set_sig_bytes().
|
||||||
|
*/
|
||||||
#define PNG_BYTES_TO_CHECK 4
|
#define PNG_BYTES_TO_CHECK 4
|
||||||
int check_if_png(char *file_name, FILE **fp)
|
int check_if_png(char *file_name, FILE **fp)
|
||||||
{
|
{
|
||||||
@@ -40,20 +44,23 @@ int check_if_png(char *file_name, FILE **fp)
|
|||||||
if ((*fp = fopen(file_name, "rb")) != NULL);
|
if ((*fp = fopen(file_name, "rb")) != NULL);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Read in the signature bytes */
|
/* Read in some of the signature bytes */
|
||||||
if (fread(buf, 1, PNG_BYTES_TO_CHECK, *fp) != PNG_BYTES_TO_CHECK)
|
if (fread(buf, 1, PNG_BYTES_TO_CHECK, *fp) != PNG_BYTES_TO_CHECK)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Compare the first PNG_BYTES_TO_CHECK bytes of the signature. */
|
/* Compare the first PNG_BYTES_TO_CHECK bytes of the signature.
|
||||||
return(png_check_sig(buf, PNG_BYTES_TO_CHECK));
|
Return nonzero (true) if they match */
|
||||||
|
|
||||||
|
return(!png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read a PNG file. You may want to return an error code if the read
|
/* Read a PNG file. You may want to return an error code if the read
|
||||||
fails (depending upon the failure). There are two "prototypes" given
|
* fails (depending upon the failure). There are two "prototypes" given
|
||||||
here - one where we are given the filename, and we need to open the
|
* here - one where we are given the filename, and we need to open the
|
||||||
file, and the other where we are given an open file (possibly with
|
* file, and the other where we are given an open file (possibly with
|
||||||
some or all of the magic bytes read - see comments above). */
|
* some or all of the magic bytes read - see comments above).
|
||||||
**** prototype 1 ****
|
*/
|
||||||
|
#ifdef open_file /* prototype 1 */
|
||||||
void read_png(char *file_name) /* We need to open the file */
|
void read_png(char *file_name) /* We need to open the file */
|
||||||
{
|
{
|
||||||
png_structp png_ptr;
|
png_structp png_ptr;
|
||||||
@@ -65,14 +72,14 @@ void read_png(char *file_name) /* We need to open the file */
|
|||||||
|
|
||||||
if ((fp = fopen(file_name, "rb")) == NULL)
|
if ((fp = fopen(file_name, "rb")) == NULL)
|
||||||
return;
|
return;
|
||||||
**** prototype 2 ****
|
#else no_open_file /* prototype 2 */
|
||||||
void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||||
{
|
{
|
||||||
png_structp png_ptr;
|
png_structp png_ptr;
|
||||||
png_infop info_ptr;
|
png_infop info_ptr;
|
||||||
png_uint_32 width, height;
|
png_uint_32 width, height;
|
||||||
int bit_depth, color_type, interlace_type;
|
int bit_depth, color_type, interlace_type;
|
||||||
**** only use one prototype! ****
|
#endif no_open_file /* only use one prototype! */
|
||||||
|
|
||||||
/* Create and initialize the png_struct with the desired error handler
|
/* Create and initialize the png_struct with the desired error handler
|
||||||
* functions. If you want to use the default stderr and longjump method,
|
* functions. If you want to use the default stderr and longjump method,
|
||||||
@@ -81,7 +88,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
|||||||
* was compiled with a compatible version of the library. REQUIRED
|
* was compiled with a compatible version of the library. REQUIRED
|
||||||
*/
|
*/
|
||||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
||||||
(void *)user_error_ptr, user_error_fn, user_warning_fn);
|
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
{
|
{
|
||||||
@@ -90,7 +97,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate/initialize the memory for image information. REQUIRED. */
|
/* Allocate/initialize the memory for image information. REQUIRED. */
|
||||||
info_ptr = png_create_info_struct();
|
info_ptr = png_create_info_struct(png_ptr);
|
||||||
if (info_ptr == NULL)
|
if (info_ptr == NULL)
|
||||||
{
|
{
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
@@ -112,19 +119,20 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* One of the following I/O initialization methods is REQUIRED */
|
/* One of the following I/O initialization methods is REQUIRED */
|
||||||
**** PNG file I/O method 1 ****
|
#ifdef streams /* PNG file I/O method 1 */
|
||||||
/* Set up the input control if you are using standard C streams */
|
/* Set up the input control if you are using standard C streams */
|
||||||
png_init_io(png_ptr, fp);
|
png_init_io(png_ptr, fp);
|
||||||
|
|
||||||
**** PNG file I/O method 2 ****
|
#else no_streams /* PNG file I/O method 2 */
|
||||||
/* If you are using replacement read functions, instead of calling
|
/* If you are using replacement read functions, instead of calling
|
||||||
* png_init_io() here you would call */
|
* png_init_io() here you would call:
|
||||||
|
*/
|
||||||
png_set_read_fn(png_ptr, (void *)user_io_ptr, user_read_fn);
|
png_set_read_fn(png_ptr, (void *)user_io_ptr, user_read_fn);
|
||||||
/* where user_io_ptr is a structure you want available to the callbacks */
|
/* where user_io_ptr is a structure you want available to the callbacks */
|
||||||
**** Use only one I/O method! ****
|
#endif no_streams /* Use only one I/O method! */
|
||||||
|
|
||||||
/* If we have already read some of the signature */
|
/* If we have already read some of the signature */
|
||||||
png_set_sig_bytes_read(png_ptr, sig_read);
|
png_set_sig_bytes(png_ptr, sig_read);
|
||||||
|
|
||||||
/* The call to png_read_info() gives us all of the information from the
|
/* The call to png_read_info() gives us all of the information from the
|
||||||
* PNG file before the first IDAT (image data chunk). REQUIRED
|
* PNG file before the first IDAT (image data chunk). REQUIRED
|
||||||
@@ -143,29 +151,31 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
|||||||
/* tell libpng to strip 16 bit/color files down to 8 bits/color */
|
/* tell libpng to strip 16 bit/color files down to 8 bits/color */
|
||||||
png_set_strip_16(png_ptr);
|
png_set_strip_16(png_ptr);
|
||||||
|
|
||||||
/* strip alpha bytes from the input data without combining with th
|
/* Strip alpha bytes from the input data without combining with th
|
||||||
* background (not recommended) */
|
* background (not recommended).
|
||||||
|
*/
|
||||||
png_set_strip_alpha(png_ptr);
|
png_set_strip_alpha(png_ptr);
|
||||||
|
|
||||||
/* extract multiple pixels with bit depths of 1, 2, and 4 from a single
|
/* Extract multiple pixels with bit depths of 1, 2, and 4 from a single
|
||||||
* byte into separate bytes (useful for paletted and grayscale images).
|
* byte into separate bytes (useful for paletted and grayscale images).
|
||||||
*/
|
*/
|
||||||
png_set_packing(png_ptr);
|
png_set_packing(png_ptr);
|
||||||
|
|
||||||
/* change the order of packed pixels to least significant bit first
|
/* Change the order of packed pixels to least significant bit first
|
||||||
* (not useful if you are using png_set_packing). */
|
* (not useful if you are using png_set_packing). */
|
||||||
png_set_packswap(png_ptr);
|
png_set_packswap(png_ptr);
|
||||||
|
|
||||||
/* expand paletted colors into true RGB triplets */
|
/* Expand paletted colors into true RGB triplets */
|
||||||
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
png_set_expand(png_ptr);
|
png_set_expand(png_ptr);
|
||||||
|
|
||||||
/* expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */
|
/* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */
|
||||||
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
|
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
|
||||||
png_set_expand(png_ptr);
|
png_set_expand(png_ptr);
|
||||||
|
|
||||||
/* expand paletted or RGB images with transparency to full alpha channels
|
/* Expand paletted or RGB images with transparency to full alpha channels
|
||||||
* so the data will be available as RGBA quartets */
|
* so the data will be available as RGBA quartets.
|
||||||
|
*/
|
||||||
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
|
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
|
||||||
png_set_expand(png_ptr);
|
png_set_expand(png_ptr);
|
||||||
|
|
||||||
@@ -176,29 +186,32 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
|||||||
* use it - you should use the (solid) application background if it has one.
|
* use it - you should use the (solid) application background if it has one.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
png_color_16 my_background, *image_background);
|
png_color_16 my_background, *image_background;
|
||||||
|
|
||||||
if (png_get_bKGD(png_ptr, info_ptr, &image_background);
|
if (png_get_bKGD(png_ptr, info_ptr, &image_background))
|
||||||
png_set_background(png_ptr, image_background),
|
png_set_background(png_ptr, image_background,
|
||||||
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
|
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
|
||||||
else
|
else
|
||||||
png_set_background(png_ptr, &my_background,
|
png_set_background(png_ptr, &my_background,
|
||||||
PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
|
PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
|
||||||
|
|
||||||
/* Some suggestions as to how to get a screen gamma value */
|
/* Some suggestions as to how to get a screen gamma value */
|
||||||
|
|
||||||
|
/* Note that screen gamma is (display_gamma/viewing_gamma) */
|
||||||
if (/* We have a user-defined screen gamma value */)
|
if (/* We have a user-defined screen gamma value */)
|
||||||
{
|
{
|
||||||
screen_gamma = user-defined screen_gamma;
|
screen_gamma = user-defined screen_gamma;
|
||||||
}
|
}
|
||||||
/* This is one way that applications share the same screen gamma value */
|
/* This is one way that applications share the same screen gamma value */
|
||||||
else if ((gamma_str = getenv("DISPLAY_GAMMA")) != NULL)
|
else if ((gamma_str = getenv("SCREEN_GAMMA")) != NULL)
|
||||||
{
|
{
|
||||||
screen_gamma = atof(gamma_str);
|
screen_gamma = atof(gamma_str);
|
||||||
}
|
}
|
||||||
/* If we don't have another value */
|
/* If we don't have another value */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
screen_gamma = 2.2; /* A good guess for PC monitors */
|
screen_gamma = 2.2; /* A good guess for a PC monitors in a dimly
|
||||||
|
lit room */
|
||||||
screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */
|
screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,20 +220,30 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
|||||||
* by the user at run time by the user. It is strongly suggested that
|
* by the user at run time by the user. It is strongly suggested that
|
||||||
* your application support gamma correction.
|
* your application support gamma correction.
|
||||||
*/
|
*/
|
||||||
if (png_get_gAMA(png_ptr, info_ptr, &image_gamma);
|
|
||||||
png_set_gamma(png_ptr, screen_gamma, image_gamma);
|
int intent;
|
||||||
|
|
||||||
|
if (png_get_sRGB(png_ptr, info_ptr, &intent))
|
||||||
|
png_set_sRGB(png_ptr, intent, 0);
|
||||||
else
|
else
|
||||||
png_set_gamma(png_ptr, screen_gamma, 0.45);
|
{
|
||||||
|
double image_gamma;
|
||||||
|
if (png_get_gAMA(png_ptr, info_ptr, &image_gamma))
|
||||||
|
png_set_gamma(png_ptr, screen_gamma, image_gamma);
|
||||||
|
else
|
||||||
|
png_set_gamma(png_ptr, screen_gamma, 0.45455);
|
||||||
|
}
|
||||||
|
|
||||||
/* Dither RGB files down to 8 bit palette or reduce palettes
|
/* Dither RGB files down to 8 bit palette or reduce palettes
|
||||||
to the number of colors available on your screen */
|
* to the number of colors available on your screen.
|
||||||
|
*/
|
||||||
if (color_type & PNG_COLOR_MASK_COLOR)
|
if (color_type & PNG_COLOR_MASK_COLOR)
|
||||||
{
|
{
|
||||||
png_uint_32 num_palette;
|
png_uint_32 num_palette;
|
||||||
png_colorp palette;
|
png_colorp palette;
|
||||||
|
|
||||||
/* This reduces the image to the application supplied palette */
|
/* This reduces the image to the application supplied palette */
|
||||||
if (we have our own palette)
|
if (/* we have our own palette */)
|
||||||
{
|
{
|
||||||
/* An array of colors to which the image should be dithered */
|
/* An array of colors to which the image should be dithered */
|
||||||
png_color std_color_cube[MAX_SCREEN_COLORS];
|
png_color std_color_cube[MAX_SCREEN_COLORS];
|
||||||
@@ -229,7 +252,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
|||||||
MAX_SCREEN_COLORS, NULL, 0);
|
MAX_SCREEN_COLORS, NULL, 0);
|
||||||
}
|
}
|
||||||
/* This reduces the image to the palette supplied in the file */
|
/* This reduces the image to the palette supplied in the file */
|
||||||
else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)))
|
else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette))
|
||||||
{
|
{
|
||||||
png_color16p histogram;
|
png_color16p histogram;
|
||||||
|
|
||||||
@@ -241,7 +264,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* invert monocrome files to have 0 as white and 1 as black */
|
/* invert monocrome files to have 0 as white and 1 as black */
|
||||||
png_set_invert(png_ptr);
|
png_set_invert_mono(png_ptr);
|
||||||
|
|
||||||
/* If you want to shift the pixel values from the range [0,255] or
|
/* If you want to shift the pixel values from the range [0,255] or
|
||||||
* [0,65535] to the original [0,7] or [0,31], or whatever range the
|
* [0,65535] to the original [0,7] or [0,31], or whatever range the
|
||||||
@@ -269,19 +292,19 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
|||||||
|
|
||||||
/* Turn on interlace handling. REQUIRED if you are not using
|
/* Turn on interlace handling. REQUIRED if you are not using
|
||||||
* png_read_image(). To see how to handle interlacing passes,
|
* png_read_image(). To see how to handle interlacing passes,
|
||||||
* see the png_read_row() method below.
|
* see the png_read_row() method below:
|
||||||
*/
|
*/
|
||||||
number_passes = png_set_interlace_handling(png_ptr);
|
number_passes = png_set_interlace_handling(png_ptr);
|
||||||
|
|
||||||
/* optional call to gamma correct and add the background to the palette
|
/* Optional call to gamma correct and add the background to the palette
|
||||||
* and update info structure. REQUIRED if you are expecting libpng to
|
* and update info structure. REQUIRED if you are expecting libpng to
|
||||||
* update the palette for you (ie you selected such a transform above).
|
* update the palette for you (ie you selected such a transform above).
|
||||||
*/
|
*/
|
||||||
png_read_update_info(png_ptr, info_ptr);
|
png_read_update_info(png_ptr, info_ptr);
|
||||||
|
|
||||||
/* allocate the memory to hold the image using the fields of info_ptr. */
|
/* Allocate the memory to hold the image using the fields of info_ptr. */
|
||||||
|
|
||||||
/* the easiest way to read the image */
|
/* The easiest way to read the image: */
|
||||||
png_bytep row_pointers[height];
|
png_bytep row_pointers[height];
|
||||||
|
|
||||||
for (row = 0; row < height; row++)
|
for (row = 0; row < height; row++)
|
||||||
@@ -290,37 +313,37 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Now it's time to read the image. One of these methods is REQUIRED */
|
/* Now it's time to read the image. One of these methods is REQUIRED */
|
||||||
**** Read the entire image in one go ****
|
#ifdef entire /* Read the entire image in one go */
|
||||||
png_read_image(png_ptr, row_pointers);
|
png_read_image(png_ptr, row_pointers);
|
||||||
|
|
||||||
**** Read the image one or more scanlines at a time ****
|
#else no_entire /* Read the image one or more scanlines at a time */
|
||||||
/* the other way to read images - deal with interlacing */
|
/* The other way to read images - deal with interlacing: */
|
||||||
|
|
||||||
for (pass = 0; pass < number_passes; pass++)
|
for (pass = 0; pass < number_passes; pass++)
|
||||||
{
|
{
|
||||||
[[[[[[[ Read the image a single row at a time ]]]]]]]
|
#ifdef single /* Read the image a single row at a time */
|
||||||
for (y = 0; y < height; y++)
|
for (y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
png_bytep row_pointers = row[y];
|
png_read_rows(png_ptr, &row_pointers[y], NULL, 1);
|
||||||
png_read_rows(png_ptr, &row_pointers, NULL, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[[[[[[[ Read the image several rows at a time ]]]]]]]
|
#else no_single /* Read the image several rows at a time */
|
||||||
for (y = 0; y < height; y += number_of_rows)
|
for (y = 0; y < height; y += number_of_rows)
|
||||||
{
|
{
|
||||||
<<<<<<<<<< Read the image using the "sparkle" effect. >>>>>>>>>>
|
#ifdef sparkle /* Read the image using the "sparkle" effect. */
|
||||||
png_read_rows(png_ptr, row_pointers, NULL, number_of_rows);
|
png_read_rows(png_ptr, &row_pointers[y], NULL, number_of_rows);
|
||||||
|
|
||||||
<<<<<<<<<< Read the image using the "rectangle" effect >>>>>>>>>>
|
png_read_rows(png_ptr, NULL, row_pointers[y], number_of_rows);
|
||||||
png_read_rows(png_ptr, NULL, row_pointers, number_of_rows);
|
#else no_sparkle /* Read the image using the "rectangle" effect */
|
||||||
<<<<<<<<<< use only one of these two methods >>>>>>>>>>
|
png_read_rows(png_ptr, NULL, &row_pointers[y], number_of_rows);
|
||||||
|
#endif no_sparkle /* use only one of these two methods */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if you want to display the image after every pass, do
|
/* if you want to display the image after every pass, do
|
||||||
so here */
|
so here */
|
||||||
[[[[[[[ use only one of these two methods ]]]]]]]
|
#endif no_single /* use only one of these two methods */
|
||||||
}
|
}
|
||||||
**** use only one of these two methods ****
|
#endif no_entire /* use only one of these two methods */
|
||||||
|
|
||||||
/* read rest of file, and get additional chunks in info_ptr - REQUIRED */
|
/* read rest of file, and get additional chunks in info_ptr - REQUIRED */
|
||||||
png_read_end(png_ptr, info_ptr);
|
png_read_end(png_ptr, info_ptr);
|
||||||
@@ -347,7 +370,7 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
|
|||||||
* linked libraries.
|
* linked libraries.
|
||||||
*/
|
*/
|
||||||
*png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
*png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
||||||
(void *)user_error_ptr, user_error_fn, user_warning_fn);
|
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
|
||||||
|
|
||||||
if (*png_ptr == NULL)
|
if (*png_ptr == NULL)
|
||||||
{
|
{
|
||||||
@@ -369,8 +392,11 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
|
|||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this one's new. You will need to provide all three
|
/* This one's new. You will need to provide all three
|
||||||
* function callbacks, even if you aren't using them all.
|
* function callbacks, even if you aren't using them all.
|
||||||
|
* If you aren't using all functions, you can specify NULL
|
||||||
|
* parameters. Even when all three functions are NULL,
|
||||||
|
* you need to call png_set_progressive_read_fn().
|
||||||
* These functions shouldn't be dependent on global or
|
* These functions shouldn't be dependent on global or
|
||||||
* static variables if you are decoding several images
|
* static variables if you are decoding several images
|
||||||
* simultaneously. You should store stream specific data
|
* simultaneously. You should store stream specific data
|
||||||
@@ -465,7 +491,7 @@ end_callback(png_structp png_ptr, png_infop info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* write a png file */
|
/* write a png file */
|
||||||
void write_png(char *file_name, ... other image information ...)
|
void write_png(char *file_name /* , ... other image information ... */)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
png_structp png_ptr;
|
png_structp png_ptr;
|
||||||
@@ -483,7 +509,7 @@ void write_png(char *file_name, ... other image information ...)
|
|||||||
* in case we are using dynamically linked libraries. REQUIRED.
|
* in case we are using dynamically linked libraries. REQUIRED.
|
||||||
*/
|
*/
|
||||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||||
(void *)user_error_ptr, user_error_fn, user_warning_fn);
|
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
{
|
{
|
||||||
@@ -512,16 +538,16 @@ void write_png(char *file_name, ... other image information ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* One of the following I/O initialization functions is REQUIRED */
|
/* One of the following I/O initialization functions is REQUIRED */
|
||||||
**** I/O initialization method 1 ****
|
#ifdef streams /* I/O initialization method 1 */
|
||||||
/* set up the output control if you are using standard C streams */
|
/* set up the output control if you are using standard C streams */
|
||||||
png_init_io(png_ptr, fp);
|
png_init_io(png_ptr, fp);
|
||||||
**** I/O initialization method 2 ****
|
#else no_streams /* I/O initialization method 2 */
|
||||||
/* If you are using replacement read functions, instead of calling
|
/* If you are using replacement read functions, instead of calling
|
||||||
* png_init_io() here you would call */
|
* png_init_io() here you would call */
|
||||||
png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn,
|
png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn,
|
||||||
user_IO_flush_function);
|
user_IO_flush_function);
|
||||||
/* where user_io_ptr is a structure you want available to the callbacks */
|
/* where user_io_ptr is a structure you want available to the callbacks */
|
||||||
**** only use 1 initialization method ****
|
#endif no_streams /* only use one initialization method */
|
||||||
|
|
||||||
/* Set the image information here. Width and height are up to 2^31,
|
/* 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
|
* bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
|
||||||
@@ -535,8 +561,8 @@ void write_png(char *file_name, ... other image information ...)
|
|||||||
PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||||
|
|
||||||
/* set the palette if there is one. REQUIRED for indexed-color images */
|
/* set the palette if there is one. REQUIRED for indexed-color images */
|
||||||
palette = png_malloc(png_ptr, 256 * sizeof (png_color));
|
palette = (png_colorp)png_malloc(png_ptr, 256 * sizeof (png_color));
|
||||||
... set palette colors ...
|
/* ... set palette colors ... */
|
||||||
png_set_PLTE(png_ptr, info_ptr, palette, 256);
|
png_set_PLTE(png_ptr, info_ptr, palette, 256);
|
||||||
|
|
||||||
/* optional significant bit chunk */
|
/* optional significant bit chunk */
|
||||||
@@ -550,9 +576,10 @@ void write_png(char *file_name, ... other image information ...)
|
|||||||
sig_bit.alpha = true_alpha_bit_depth;
|
sig_bit.alpha = true_alpha_bit_depth;
|
||||||
png_set_sBIT(png_ptr, info_ptr, sig_bit);
|
png_set_sBIT(png_ptr, info_ptr, sig_bit);
|
||||||
|
|
||||||
|
|
||||||
/* Optional gamma chunk is strongly suggested if you have any guess
|
/* Optional gamma chunk is strongly suggested if you have any guess
|
||||||
* as to the correct gamma of the image. */
|
* as to the correct gamma of the image.
|
||||||
|
*/
|
||||||
png_set_gAMA(png_ptr, info_ptr, gamma);
|
png_set_gAMA(png_ptr, info_ptr, gamma);
|
||||||
|
|
||||||
/* Optionally write comments into the image */
|
/* Optionally write comments into the image */
|
||||||
@@ -565,9 +592,11 @@ void write_png(char *file_name, ... other image information ...)
|
|||||||
text_ptr[2].key = "Description";
|
text_ptr[2].key = "Description";
|
||||||
text_ptr[2].text = "<long text>";
|
text_ptr[2].text = "<long text>";
|
||||||
text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt;
|
text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||||
png_set_text(png_ptr, info_ptr, text_ptr, 2);
|
png_set_text(png_ptr, info_ptr, text_ptr, 3);
|
||||||
|
|
||||||
/* other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs, */
|
/* other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs, */
|
||||||
|
/* note that if sRGB is present the cHRM chunk must be ignored
|
||||||
|
* on read and must be written in accordance with the sRGB profile */
|
||||||
|
|
||||||
/* Write the file header information. REQUIRED */
|
/* Write the file header information. REQUIRED */
|
||||||
png_write_info(png_ptr, info_ptr);
|
png_write_info(png_ptr, info_ptr);
|
||||||
@@ -579,13 +608,15 @@ void write_png(char *file_name, ... other image information ...)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* set up the transformations you want. Note that these are
|
/* set up the transformations you want. Note that these are
|
||||||
* all optional. Only call them if you want them. */
|
* all optional. Only call them if you want them.
|
||||||
|
*/
|
||||||
|
|
||||||
/* invert monocrome pixels */
|
/* invert monocrome pixels */
|
||||||
png_set_invert(png_ptr);
|
png_set_invert_mono(png_ptr);
|
||||||
|
|
||||||
/* Shift the pixels up to a legal bit depth and fill in
|
/* Shift the pixels up to a legal bit depth and fill in
|
||||||
* as appropriate to correctly scale the image */
|
* as appropriate to correctly scale the image.
|
||||||
|
*/
|
||||||
png_set_shift(png_ptr, &sig_bit);
|
png_set_shift(png_ptr, &sig_bit);
|
||||||
|
|
||||||
/* pack pixels into bytes */
|
/* pack pixels into bytes */
|
||||||
@@ -595,7 +626,8 @@ void write_png(char *file_name, ... other image information ...)
|
|||||||
png_set_swap_alpha(png_ptr);
|
png_set_swap_alpha(png_ptr);
|
||||||
|
|
||||||
/* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into
|
/* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into
|
||||||
* RGB (4 channels -> 3 channels). The second parameter is not used. */
|
* RGB (4 channels -> 3 channels). The second parameter is not used.
|
||||||
|
*/
|
||||||
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
|
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
|
||||||
|
|
||||||
/* flip BGR pixels to RGB */
|
/* flip BGR pixels to RGB */
|
||||||
@@ -617,31 +649,34 @@ void write_png(char *file_name, ... other image information ...)
|
|||||||
* layout, however, so choose what fits your needs best). You need to
|
* layout, however, so choose what fits your needs best). You need to
|
||||||
* use the first method if you aren't handling interlacing yourself.
|
* use the first method if you aren't handling interlacing yourself.
|
||||||
*/
|
*/
|
||||||
png_byte row_pointers[height][width];
|
png_uint_32 k, height, width;
|
||||||
|
png_byte image[height][width];
|
||||||
|
png_bytep row_pointers[height];
|
||||||
|
for (k = 0; k < height; k++)
|
||||||
|
row_pointers[k] = image + k*width;
|
||||||
|
|
||||||
/* One of the following output methods is REQUIRED */
|
/* One of the following output methods is REQUIRED */
|
||||||
**** write out the entire image data in one call ***
|
#ifdef entire /* write out the entire image data in one call */
|
||||||
png_write_image(png_ptr, row_pointers);
|
png_write_image(png_ptr, row_pointers);
|
||||||
|
|
||||||
/* the other way to write the image - deal with interlacing */
|
/* the other way to write the image - deal with interlacing */
|
||||||
|
|
||||||
**** write out the image data by one or more scanlines ****
|
#else no_entire /* write out the image data by one or more scanlines */
|
||||||
/* The number of passes is either 1 for non-interlaced images,
|
/* The number of passes is either 1 for non-interlaced images,
|
||||||
* or 7 for interlaced images.
|
* or 7 for interlaced images.
|
||||||
*/
|
*/
|
||||||
for (pass = 0; pass < number_passes; pass++)
|
for (pass = 0; pass < number_passes; pass++)
|
||||||
{
|
{
|
||||||
/* Write a few rows at a time. */
|
/* Write a few rows at a time. */
|
||||||
png_write_rows(png_ptr, row_pointers, number_of_rows);
|
png_write_rows(png_ptr, &row_pointers[first_row], number_of_rows);
|
||||||
|
|
||||||
/* If you are only writing one row at a time, this works */
|
/* If you are only writing one row at a time, this works */
|
||||||
for (y = 0; y < height; y++)
|
for (y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
png_bytep row_pointers = row[y];
|
png_write_rows(png_ptr, &row_pointers[y], 1);
|
||||||
png_write_rows(png_ptr, &row_pointers, 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
**** use only one output method ****
|
#endif no_entire /* use only one output method */
|
||||||
|
|
||||||
/* You can write optional chunks like tEXt, zTXt, and tIME at the end
|
/* You can write optional chunks like tEXt, zTXt, and tIME at the end
|
||||||
* as well.
|
* as well.
|
||||||
|
|||||||
1298
libpng.txt
1298
libpng.txt
File diff suppressed because it is too large
Load Diff
347
libpngpf.3
Normal file
347
libpngpf.3
Normal file
@@ -0,0 +1,347 @@
|
|||||||
|
.TH LIBPNGPF 3 "January 6, 1999"
|
||||||
|
.SH NAME
|
||||||
|
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.2b - January 6, 1999
|
||||||
|
(private functions)
|
||||||
|
.SH SYNOPSIS
|
||||||
|
#include <png.h>
|
||||||
|
|
||||||
|
void png_build_gamma_table (png_structp png_ptr);
|
||||||
|
|
||||||
|
void png_build_grayscale_palette (int bit_depth, png_colorp
|
||||||
|
palette);
|
||||||
|
|
||||||
|
void png_calculate_crc (png_structp png_ptr, png_bytep ptr,
|
||||||
|
png_size_t length);
|
||||||
|
void png_check_chunk_name (png_structp png_ptr, png_bytep
|
||||||
|
chunk_name);
|
||||||
|
|
||||||
|
png_size_t png_check_keyword (png_structp png_ptr, png_charp
|
||||||
|
key, png_charpp new_key);
|
||||||
|
|
||||||
|
void png_combine_row (png_structp png_ptr, png_bytep row, int
|
||||||
|
mask);
|
||||||
|
|
||||||
|
void png_correct_palette (png_structp png_ptr, png_colorp
|
||||||
|
palette, int num_palette);
|
||||||
|
|
||||||
|
int png_crc_error (png_structp png_ptr);
|
||||||
|
|
||||||
|
int png_crc_finish (png_structp png_ptr, png_uint_32 skip);
|
||||||
|
|
||||||
|
void png_crc_read (png_structp png_ptr, png_bytep buf,
|
||||||
|
png_size_t length);
|
||||||
|
|
||||||
|
png_voidp png_create_struct (int type, png_malloc_ptr malloc_fn);
|
||||||
|
|
||||||
|
png_voidp png_create_struct_2 (int type);
|
||||||
|
|
||||||
|
void png_destroy_struct (png_voidp struct_ptr);
|
||||||
|
|
||||||
|
void png_destroy_struct_2 (png_voidp struct_ptr, png_free_ptr
|
||||||
|
free_fn);
|
||||||
|
|
||||||
|
void 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, png_bytep gamma_table, png_bytep
|
||||||
|
gamma_from_1, png_bytep gamma_to_1, png_uint_16pp gamma_16,
|
||||||
|
png_uint_16pp gamma_16_from_1, png_uint_16pp gamma_16_to_1, int
|
||||||
|
gamma_shift);
|
||||||
|
|
||||||
|
void png_do_bgr (png_row_infop row_info, png_bytep row);
|
||||||
|
|
||||||
|
void png_do_chop (png_row_infop row_info, png_bytep row);
|
||||||
|
|
||||||
|
void png_do_dither (png_row_infop row_info, png_bytep row,
|
||||||
|
png_bytep palette_lookup, png_bytep dither_lookup);
|
||||||
|
|
||||||
|
void png_do_expand (png_row_infop row_info, png_bytep row,
|
||||||
|
png_color_16p trans_value);
|
||||||
|
|
||||||
|
void png_do_expand_palette (png_row_infop row_info, png_bytep
|
||||||
|
row, png_colorp palette, png_bytep trans, int num_trans);
|
||||||
|
|
||||||
|
void png_do_gamma (png_row_infop row_info, png_bytep row,
|
||||||
|
png_bytep gamma_table, png_uint_16pp gamma_16_table, int
|
||||||
|
gamma_shift);
|
||||||
|
|
||||||
|
void png_do_gray_to_rgb (png_row_infop row_info, png_bytep
|
||||||
|
row);
|
||||||
|
|
||||||
|
void png_do_invert (png_row_infop row_info, png_bytep row);
|
||||||
|
|
||||||
|
void png_do_pack (png_row_infop row_info, png_bytep row,
|
||||||
|
png_uint_32 bit_depth);
|
||||||
|
|
||||||
|
void png_do_packswap (png_row_infop row_info, png_bytep row);
|
||||||
|
|
||||||
|
void png_do_read_filler (png_row_infop row_info, png_bytep row,
|
||||||
|
png_uint_32 filler, png_uint_32 flags);
|
||||||
|
|
||||||
|
void png_do_read_interlace (png_row_infop row_info, png_bytep
|
||||||
|
row, int pass, png_uint_32 transformations);
|
||||||
|
|
||||||
|
void png_do_read_invert_alpha (png_row_infop row_info,
|
||||||
|
png_bytep row);
|
||||||
|
|
||||||
|
void png_do_read_swap_alpha (png_row_infop row_info, png_bytep
|
||||||
|
row);
|
||||||
|
|
||||||
|
void png_do_read_transformations (png_structp png_ptr);
|
||||||
|
|
||||||
|
int png_do_rgb_to_gray (png_row_infop row_info, png_bytep
|
||||||
|
row);
|
||||||
|
|
||||||
|
void png_do_shift (png_row_infop row_info, png_bytep row,
|
||||||
|
png_color_8p bit_depth);
|
||||||
|
|
||||||
|
void png_do_strip_filler (png_row_infop row_info, png_bytep
|
||||||
|
row, png_uint_32 flags);
|
||||||
|
|
||||||
|
void png_do_swap (png_row_infop row_info, png_bytep row);
|
||||||
|
|
||||||
|
void png_do_unpack (png_row_infop row_info, png_bytep row);
|
||||||
|
|
||||||
|
void png_do_unshift (png_row_infop row_info, png_bytep row,
|
||||||
|
png_color_8p sig_bits);
|
||||||
|
|
||||||
|
void png_do_write_interlace (png_row_infop row_info, png_bytep
|
||||||
|
row, int pass);
|
||||||
|
|
||||||
|
void png_do_write_invert_alpha (png_row_infop row_info,
|
||||||
|
png_bytep row);
|
||||||
|
|
||||||
|
void png_do_write_swap_alpha (png_row_infop row_info, png_bytep
|
||||||
|
row);
|
||||||
|
|
||||||
|
void png_do_write_transformations (png_structp png_ptr);
|
||||||
|
|
||||||
|
void *png_far_to_near (png_structp png_ptr,png_voidp ptr,
|
||||||
|
int check);
|
||||||
|
|
||||||
|
void png_flush (png_structp png_ptr);
|
||||||
|
|
||||||
|
png_int_32 png_get_int_32 (png_bytep buf);
|
||||||
|
|
||||||
|
png_uint_16 png_get_uint_16 (png_bytep buf);
|
||||||
|
|
||||||
|
png_uint_32 png_get_uint_32 (png_bytep buf);
|
||||||
|
|
||||||
|
void png_handle_bKGD (png_structp png_ptr, png_infop info_ptr,
|
||||||
|
png_uint_32 length);
|
||||||
|
|
||||||
|
void png_handle_cHRM (png_structp png_ptr, png_infop info_ptr,
|
||||||
|
png_uint_32 length);
|
||||||
|
|
||||||
|
void png_handle_gAMA (png_structp png_ptr, png_infop info_ptr,
|
||||||
|
png_uint_32 length);
|
||||||
|
|
||||||
|
void png_handle_hIST (png_structp png_ptr, png_infop info_ptr,
|
||||||
|
png_uint_32 length);
|
||||||
|
|
||||||
|
void png_handle_IEND (png_structp png_ptr, png_infop info_ptr,
|
||||||
|
png_uint_32 length);
|
||||||
|
|
||||||
|
void png_handle_IHDR (png_structp png_ptr, png_infop info_ptr,
|
||||||
|
png_uint_32 length);
|
||||||
|
|
||||||
|
void png_handle_oFFs (png_structp png_ptr, png_infop info_ptr,
|
||||||
|
png_uint_32 length);
|
||||||
|
|
||||||
|
void png_handle_pCAL (png_structp png_ptr, png_infop info_ptr,
|
||||||
|
png_uint_32 length);
|
||||||
|
|
||||||
|
void png_handle_pHYs (png_structp png_ptr, png_infop info_ptr,
|
||||||
|
png_uint_32 length);
|
||||||
|
|
||||||
|
void png_handle_PLTE (png_structp png_ptr, png_infop info_ptr,
|
||||||
|
png_uint_32 length);
|
||||||
|
|
||||||
|
void png_handle_sBIT (png_structp png_ptr, png_infop info_ptr,
|
||||||
|
png_uint_32 length);
|
||||||
|
|
||||||
|
void png_handle_sRGB (png_structp png_ptr, png_infop info_ptr,
|
||||||
|
png_uint_32 length);
|
||||||
|
|
||||||
|
void png_handle_tEXt (png_structp png_ptr, png_infop info_ptr,
|
||||||
|
png_uint_32 length);
|
||||||
|
|
||||||
|
void png_handle_tIME (png_structp png_ptr, png_infop info_ptr,
|
||||||
|
png_uint_32 length);
|
||||||
|
|
||||||
|
void png_handle_tRNS (png_structp png_ptr, png_infop info_ptr,
|
||||||
|
png_uint_32 length);
|
||||||
|
|
||||||
|
void png_handle_unknown (png_structp png_ptr, png_infop
|
||||||
|
info_ptr, png_uint_32 length);
|
||||||
|
|
||||||
|
void png_handle_zTXt (png_structp png_ptr, png_infop info_ptr,
|
||||||
|
png_uint_32 length);
|
||||||
|
|
||||||
|
void png_info_destroy (png_structp png_ptr, png_infop
|
||||||
|
info_ptr);
|
||||||
|
|
||||||
|
void png_init_read_transformations (png_structp png_ptr);
|
||||||
|
|
||||||
|
void png_process_IDAT_data (png_structp png_ptr, png_bytep
|
||||||
|
buffer, png_size_t buffer_length);
|
||||||
|
|
||||||
|
void png_process_some_data (png_structp png_ptr, png_infop
|
||||||
|
info_ptr);
|
||||||
|
|
||||||
|
void png_push_check_crc (png_structp png_ptr);
|
||||||
|
|
||||||
|
void png_push_crc_finish (png_structp png_ptr);
|
||||||
|
|
||||||
|
void png_push_crc_skip (png_structp png_ptr, png_uint_32
|
||||||
|
length);
|
||||||
|
|
||||||
|
void png_push_fill_buffer (png_structp png_ptr, png_bytep
|
||||||
|
buffer, png_size_t length);
|
||||||
|
|
||||||
|
void png_push_handle_tEXt (png_structp png_ptr, png_infop
|
||||||
|
info_ptr, png_uint_32 length);
|
||||||
|
|
||||||
|
void png_push_handle_unknown (png_structp png_ptr, png_infop
|
||||||
|
info_ptr, png_uint_32 length);
|
||||||
|
|
||||||
|
void png_push_handle_zTXt (png_structp png_ptr, png_infop
|
||||||
|
info_ptr, png_uint_32 length);
|
||||||
|
|
||||||
|
void png_push_have_end (png_structp png_ptr, png_infop
|
||||||
|
info_ptr);
|
||||||
|
|
||||||
|
void png_push_have_info (png_structp png_ptr, png_infop
|
||||||
|
info_ptr);
|
||||||
|
|
||||||
|
void png_push_have_row (png_structp png_ptr, png_bytep row);
|
||||||
|
|
||||||
|
void png_push_process_row (png_structp png_ptr);
|
||||||
|
|
||||||
|
void png_push_read_chunk (png_structp png_ptr, png_infop
|
||||||
|
info_ptr);
|
||||||
|
|
||||||
|
void png_push_read_end (png_structp png_ptr, png_infop
|
||||||
|
info_ptr);
|
||||||
|
|
||||||
|
void png_push_read_IDAT (png_structp png_ptr);
|
||||||
|
|
||||||
|
void png_push_read_sig (png_structp png_ptr, png_infop
|
||||||
|
info_ptr);
|
||||||
|
|
||||||
|
void png_push_read_tEXt (png_structp png_ptr, png_infop
|
||||||
|
info_ptr);
|
||||||
|
|
||||||
|
void png_push_read_zTXt (png_structp png_ptr, png_infop
|
||||||
|
info_ptr);
|
||||||
|
|
||||||
|
void png_push_restore_buffer (png_structp png_ptr, png_bytep
|
||||||
|
buffer, png_size_t buffer_length);
|
||||||
|
|
||||||
|
void png_push_save_buffer (png_structp png_ptr);
|
||||||
|
|
||||||
|
void png_read_data (png_structp png_ptr, png_bytep data,
|
||||||
|
png_size_t length);
|
||||||
|
|
||||||
|
void png_read_filter_row (png_structp png_ptr, png_row_infop
|
||||||
|
row_info, png_bytep row, png_bytep prev_row, int filter);
|
||||||
|
|
||||||
|
void png_read_finish_row (png_structp png_ptr);
|
||||||
|
|
||||||
|
void png_read_init (png_structp png_ptr);
|
||||||
|
|
||||||
|
void png_read_push_finish_row (png_structp png_ptr);
|
||||||
|
|
||||||
|
void png_read_start_row (png_structp png_ptr);
|
||||||
|
|
||||||
|
void png_read_transform_info (png_structp png_ptr, png_infop
|
||||||
|
info_ptr);
|
||||||
|
|
||||||
|
void png_reset_crc (png_structp png_ptr);
|
||||||
|
|
||||||
|
void png_save_int_32 (png_bytep buf, png_int_32 i);
|
||||||
|
|
||||||
|
void png_save_uint_16 (png_bytep buf, unsigned int i);
|
||||||
|
|
||||||
|
void png_save_uint_32 (png_bytep buf, png_uint_32 i);
|
||||||
|
|
||||||
|
void png_write_bKGD (png_structp png_ptr, png_color_16p values,
|
||||||
|
int color_type);
|
||||||
|
|
||||||
|
void 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);
|
||||||
|
|
||||||
|
void png_write_data (png_structp png_ptr, png_bytep data,
|
||||||
|
png_size_t length);
|
||||||
|
void png_write_filtered_row (png_structp png_ptr, png_bytep
|
||||||
|
filtered_row);
|
||||||
|
|
||||||
|
void png_write_find_filter (png_structp png_ptr, png_row_infop
|
||||||
|
row_info);
|
||||||
|
|
||||||
|
void png_write_finish_row (png_structp png_ptr);
|
||||||
|
|
||||||
|
void png_write_gAMA (png_structp png_ptr, double file_gamma);
|
||||||
|
|
||||||
|
void png_write_hIST (png_structp png_ptr, png_uint_16p hist,
|
||||||
|
int num_hist);
|
||||||
|
|
||||||
|
void png_write_init (png_structp png_ptr);
|
||||||
|
|
||||||
|
void png_write_IDAT (png_structp png_ptr, png_bytep data,
|
||||||
|
png_size_t length);
|
||||||
|
|
||||||
|
void png_write_IEND (png_structp png_ptr);
|
||||||
|
|
||||||
|
void 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);
|
||||||
|
|
||||||
|
void png_write_oFFs (png_structp png_ptr, png_uint_32 x_offset,
|
||||||
|
png_uint_32 y_offset, int unit_type);
|
||||||
|
|
||||||
|
void 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);
|
||||||
|
|
||||||
|
void png_write_pHYs (png_structp png_ptr, png_uint_32
|
||||||
|
x_pixels_per_unit, png_uint_32 y_pixels_per_unit, int
|
||||||
|
unit_type);
|
||||||
|
|
||||||
|
void png_write_PLTE (png_structp png_ptr, png_colorp palette,
|
||||||
|
png_uint_32 num_pal);
|
||||||
|
|
||||||
|
void png_write_sBIT (png_structp png_ptr, png_color_8p sbit,
|
||||||
|
int color_type);
|
||||||
|
|
||||||
|
void png_write_sig (png_structp png_ptr);
|
||||||
|
|
||||||
|
void png_write_sRGB (png_structp png_ptr, int intent);
|
||||||
|
|
||||||
|
void png_write_start_row (png_structp png_ptr);
|
||||||
|
|
||||||
|
void png_write_tEXt (png_structp png_ptr, png_charp key,
|
||||||
|
png_charp text, png_size_t text_len);
|
||||||
|
|
||||||
|
void png_write_tIME (png_structp png_ptr, png_timep mod_time);
|
||||||
|
|
||||||
|
void png_write_tRNS (png_structp png_ptr, png_bytep trans,
|
||||||
|
png_color_16p values, int number, int color_type);
|
||||||
|
|
||||||
|
void png_write_zTXt (png_structp png_ptr, png_charp key,
|
||||||
|
png_charp text, png_size_t text_len, int compression);
|
||||||
|
|
||||||
|
voidpf png_zalloc (voidpf png_ptr, uInt items, uInt size);
|
||||||
|
|
||||||
|
void png_zfree (voidpf png_ptr, voidpf ptr);
|
||||||
|
|
||||||
|
.SH DESCRIPTION
|
||||||
|
The functions listed above are used privately by libpng
|
||||||
|
and are not recommended for use by applications. They
|
||||||
|
are listed alphabetically here as an aid to libpng maintainers.
|
||||||
|
See png.h for more information on these functions.
|
||||||
|
|
||||||
|
.SH SEE ALSO
|
||||||
|
libpng(3), png(5)
|
||||||
|
.SH AUTHOR
|
||||||
|
Glenn Randers-Pehrson
|
||||||
221
makefile.aco
221
makefile.aco
@@ -1,221 +0,0 @@
|
|||||||
# Project: libpng
|
|
||||||
|
|
||||||
|
|
||||||
# Toolflags:
|
|
||||||
CCflags = -c -depend !Depend -IC:,Zlib: -g -throwback -DRISCOS -fnah
|
|
||||||
C++flags = -c -depend !Depend -IC: -throwback
|
|
||||||
Linkflags = -aif -c++ -o $@
|
|
||||||
ObjAsmflags = -throwback -NoCache -depend !Depend
|
|
||||||
CMHGflags =
|
|
||||||
LibFileflags = -c -l -o $@
|
|
||||||
Squeezeflags = -o $@
|
|
||||||
|
|
||||||
|
|
||||||
# Final targets:
|
|
||||||
@.libpng-lib: @.o.png @.o.pngerror @.o.pngrio @.o.pngwio @.o.pngmem \
|
|
||||||
@.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngrtran \
|
|
||||||
@.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil
|
|
||||||
LibFile $(LibFileflags) @.o.png @.o.pngerror @.o.pngrio @.o.pngrtran \
|
|
||||||
@.o.pngmem @.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngwio \
|
|
||||||
@.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil
|
|
||||||
@.mm-libpng-lib: @.mm.png @.mm.pngerror @.mm.pngrio @.mm.pngwio @.mm.pngmem \
|
|
||||||
@.mm.pngpread @.mm.pngset @.mm.pngget @.mm.pngread @.mm.pngrtran \
|
|
||||||
@.mm.pngrutil @.mm.pngtrans @.mm.pngwrite @.mm.pngwtran @.mm.pngwutil
|
|
||||||
LibFile $(LibFileflags) @.mm.png @.mm.pngerror @.mm.pngrio \
|
|
||||||
@.mm.pngwio @.mm.pngmem @.mm.pngpread @.mm.pngset @.mm.pngget \
|
|
||||||
@.mm.pngread @.mm.pngrtran @.mm.pngrutil @.mm.pngtrans @.mm.pngwrite \
|
|
||||||
@.mm.pngwtran @.mm.pngwutil
|
|
||||||
|
|
||||||
|
|
||||||
# User-editable dependencies:
|
|
||||||
# (C) Copyright 1997 Tom Tanner
|
|
||||||
Test: @.pngtest
|
|
||||||
<Prefix$Dir>.pngtest
|
|
||||||
@remove <Prefix$Dir>.pngtest
|
|
||||||
|
|
||||||
#It would be nice if you could stop "make" listing from here on!
|
|
||||||
@.pngtest: @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib
|
|
||||||
Link $(Linkflags) @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib
|
|
||||||
|
|
||||||
.SUFFIXES: .o .mm .c
|
|
||||||
|
|
||||||
.c.mm:
|
|
||||||
MemCheck.CC cc $(ccflags) -o $@ LibPng:$<
|
|
||||||
.c.o:
|
|
||||||
cc $(ccflags) -o $@ $<
|
|
||||||
|
|
||||||
|
|
||||||
# Static dependencies:
|
|
||||||
|
|
||||||
|
|
||||||
# Dynamic dependencies:
|
|
||||||
o.pngtest: c.pngtest
|
|
||||||
o.pngtest: h.png
|
|
||||||
o.pngtest: Zlib:h.zlib
|
|
||||||
o.pngtest: Zlib:h.zconf
|
|
||||||
o.pngtest: h.pngconf
|
|
||||||
mm.png: LibPng:c.png
|
|
||||||
mm.png: LibPng:h.png
|
|
||||||
mm.png: Zlib:h.zlib
|
|
||||||
mm.png: Zlib:h.zconf
|
|
||||||
mm.png: LibPng:h.pngconf
|
|
||||||
mm.png: MemCheck:ANSI.h.stdio
|
|
||||||
mm.pngerror: LibPng:c.pngerror
|
|
||||||
mm.pngerror: LibPng:h.png
|
|
||||||
mm.pngerror: Zlib:h.zlib
|
|
||||||
mm.pngerror: Zlib:h.zconf
|
|
||||||
mm.pngerror: LibPng:h.pngconf
|
|
||||||
mm.pngerror: MemCheck:ANSI.h.stdio
|
|
||||||
mm.pngrio: LibPng:c.pngrio
|
|
||||||
mm.pngrio: LibPng:h.png
|
|
||||||
mm.pngrio: Zlib:h.zlib
|
|
||||||
mm.pngrio: Zlib:h.zconf
|
|
||||||
mm.pngrio: LibPng:h.pngconf
|
|
||||||
mm.pngrio: MemCheck:ANSI.h.stdio
|
|
||||||
mm.pngwio: LibPng:c.pngwio
|
|
||||||
mm.pngwio: LibPng:h.png
|
|
||||||
mm.pngwio: Zlib:h.zlib
|
|
||||||
mm.pngwio: Zlib:h.zconf
|
|
||||||
mm.pngwio: LibPng:h.pngconf
|
|
||||||
mm.pngwio: MemCheck:ANSI.h.stdio
|
|
||||||
mm.pngmem: LibPng:c.pngmem
|
|
||||||
mm.pngmem: LibPng:h.png
|
|
||||||
mm.pngmem: Zlib:h.zlib
|
|
||||||
mm.pngmem: Zlib:h.zconf
|
|
||||||
mm.pngmem: LibPng:h.pngconf
|
|
||||||
mm.pngmem: MemCheck:ANSI.h.stdio
|
|
||||||
mm.pngpread: LibPng:c.pngpread
|
|
||||||
mm.pngpread: LibPng:h.png
|
|
||||||
mm.pngpread: Zlib:h.zlib
|
|
||||||
mm.pngpread: Zlib:h.zconf
|
|
||||||
mm.pngpread: LibPng:h.pngconf
|
|
||||||
mm.pngpread: MemCheck:ANSI.h.stdio
|
|
||||||
mm.pngset: LibPng:c.pngset
|
|
||||||
mm.pngset: LibPng:h.png
|
|
||||||
mm.pngset: Zlib:h.zlib
|
|
||||||
mm.pngset: Zlib:h.zconf
|
|
||||||
mm.pngset: LibPng:h.pngconf
|
|
||||||
mm.pngset: MemCheck:ANSI.h.stdio
|
|
||||||
mm.pngget: LibPng:c.pngget
|
|
||||||
mm.pngget: LibPng:h.png
|
|
||||||
mm.pngget: Zlib:h.zlib
|
|
||||||
mm.pngget: Zlib:h.zconf
|
|
||||||
mm.pngget: LibPng:h.pngconf
|
|
||||||
mm.pngget: MemCheck:ANSI.h.stdio
|
|
||||||
mm.pngread: LibPng:c.pngread
|
|
||||||
mm.pngread: LibPng:h.png
|
|
||||||
mm.pngread: Zlib:h.zlib
|
|
||||||
mm.pngread: Zlib:h.zconf
|
|
||||||
mm.pngread: LibPng:h.pngconf
|
|
||||||
mm.pngread: MemCheck:ANSI.h.stdio
|
|
||||||
mm.pngrtran: LibPng:c.pngrtran
|
|
||||||
mm.pngrtran: LibPng:h.png
|
|
||||||
mm.pngrtran: Zlib:h.zlib
|
|
||||||
mm.pngrtran: Zlib:h.zconf
|
|
||||||
mm.pngrtran: LibPng:h.pngconf
|
|
||||||
mm.pngrtran: MemCheck:ANSI.h.stdio
|
|
||||||
mm.pngrutil: LibPng:c.pngrutil
|
|
||||||
mm.pngrutil: LibPng:h.png
|
|
||||||
mm.pngrutil: Zlib:h.zlib
|
|
||||||
mm.pngrutil: Zlib:h.zconf
|
|
||||||
mm.pngrutil: LibPng:h.pngconf
|
|
||||||
mm.pngrutil: MemCheck:ANSI.h.stdio
|
|
||||||
mm.pngtrans: LibPng:c.pngtrans
|
|
||||||
mm.pngtrans: LibPng:h.png
|
|
||||||
mm.pngtrans: Zlib:h.zlib
|
|
||||||
mm.pngtrans: Zlib:h.zconf
|
|
||||||
mm.pngtrans: LibPng:h.pngconf
|
|
||||||
mm.pngtrans: MemCheck:ANSI.h.stdio
|
|
||||||
mm.pngwrite: LibPng:c.pngwrite
|
|
||||||
mm.pngwrite: LibPng:h.png
|
|
||||||
mm.pngwrite: Zlib:h.zlib
|
|
||||||
mm.pngwrite: Zlib:h.zconf
|
|
||||||
mm.pngwrite: LibPng:h.pngconf
|
|
||||||
mm.pngwrite: MemCheck:ANSI.h.stdio
|
|
||||||
mm.pngwtran: LibPng:c.pngwtran
|
|
||||||
mm.pngwtran: LibPng:h.png
|
|
||||||
mm.pngwtran: Zlib:h.zlib
|
|
||||||
mm.pngwtran: Zlib:h.zconf
|
|
||||||
mm.pngwtran: LibPng:h.pngconf
|
|
||||||
mm.pngwtran: MemCheck:ANSI.h.stdio
|
|
||||||
mm.pngwutil: LibPng:c.pngwutil
|
|
||||||
mm.pngwutil: LibPng:h.png
|
|
||||||
mm.pngwutil: Zlib:h.zlib
|
|
||||||
mm.pngwutil: Zlib:h.zconf
|
|
||||||
mm.pngwutil: LibPng:h.pngconf
|
|
||||||
mm.pngwutil: MemCheck:ANSI.h.stdio
|
|
||||||
o.png: c.png
|
|
||||||
o.png: h.png
|
|
||||||
o.png: Zlib:h.zlib
|
|
||||||
o.png: Zlib:h.zconf
|
|
||||||
o.png: h.pngconf
|
|
||||||
o.pngerror: c.pngerror
|
|
||||||
o.pngerror: h.png
|
|
||||||
o.pngerror: Zlib:h.zlib
|
|
||||||
o.pngerror: Zlib:h.zconf
|
|
||||||
o.pngerror: h.pngconf
|
|
||||||
o.pngrio: c.pngrio
|
|
||||||
o.pngrio: h.png
|
|
||||||
o.pngrio: Zlib:h.zlib
|
|
||||||
o.pngrio: Zlib:h.zconf
|
|
||||||
o.pngrio: h.pngconf
|
|
||||||
o.pngwio: c.pngwio
|
|
||||||
o.pngwio: h.png
|
|
||||||
o.pngwio: Zlib:h.zlib
|
|
||||||
o.pngwio: Zlib:h.zconf
|
|
||||||
o.pngwio: h.pngconf
|
|
||||||
o.pngmem: c.pngmem
|
|
||||||
o.pngmem: h.png
|
|
||||||
o.pngmem: Zlib:h.zlib
|
|
||||||
o.pngmem: Zlib:h.zconf
|
|
||||||
o.pngmem: h.pngconf
|
|
||||||
o.pngpread: c.pngpread
|
|
||||||
o.pngpread: h.png
|
|
||||||
o.pngpread: Zlib:h.zlib
|
|
||||||
o.pngpread: Zlib:h.zconf
|
|
||||||
o.pngpread: h.pngconf
|
|
||||||
o.pngset: c.pngset
|
|
||||||
o.pngset: h.png
|
|
||||||
o.pngset: Zlib:h.zlib
|
|
||||||
o.pngset: Zlib:h.zconf
|
|
||||||
o.pngset: h.pngconf
|
|
||||||
o.pngget: c.pngget
|
|
||||||
o.pngget: h.png
|
|
||||||
o.pngget: Zlib:h.zlib
|
|
||||||
o.pngget: Zlib:h.zconf
|
|
||||||
o.pngget: h.pngconf
|
|
||||||
o.pngread: c.pngread
|
|
||||||
o.pngread: h.png
|
|
||||||
o.pngread: Zlib:h.zlib
|
|
||||||
o.pngread: Zlib:h.zconf
|
|
||||||
o.pngread: h.pngconf
|
|
||||||
o.pngrtran: c.pngrtran
|
|
||||||
o.pngrtran: h.png
|
|
||||||
o.pngrtran: Zlib:h.zlib
|
|
||||||
o.pngrtran: Zlib:h.zconf
|
|
||||||
o.pngrtran: h.pngconf
|
|
||||||
o.pngrutil: c.pngrutil
|
|
||||||
o.pngrutil: h.png
|
|
||||||
o.pngrutil: Zlib:h.zlib
|
|
||||||
o.pngrutil: Zlib:h.zconf
|
|
||||||
o.pngrutil: h.pngconf
|
|
||||||
o.pngtrans: c.pngtrans
|
|
||||||
o.pngtrans: h.png
|
|
||||||
o.pngtrans: Zlib:h.zlib
|
|
||||||
o.pngtrans: Zlib:h.zconf
|
|
||||||
o.pngtrans: h.pngconf
|
|
||||||
o.pngwrite: c.pngwrite
|
|
||||||
o.pngwrite: h.png
|
|
||||||
o.pngwrite: Zlib:h.zlib
|
|
||||||
o.pngwrite: Zlib:h.zconf
|
|
||||||
o.pngwrite: h.pngconf
|
|
||||||
o.pngwtran: c.pngwtran
|
|
||||||
o.pngwtran: h.png
|
|
||||||
o.pngwtran: Zlib:h.zlib
|
|
||||||
o.pngwtran: Zlib:h.zconf
|
|
||||||
o.pngwtran: h.pngconf
|
|
||||||
o.pngwutil: c.pngwutil
|
|
||||||
o.pngwutil: h.png
|
|
||||||
o.pngwutil: Zlib:h.zlib
|
|
||||||
o.pngwutil: Zlib:h.zconf
|
|
||||||
o.pngwutil: h.pngconf
|
|
||||||
86
makefile.elf
86
makefile.elf
@@ -1,86 +0,0 @@
|
|||||||
# makefile for libpng on (linux) ELF
|
|
||||||
# Copyright (C) 1996, 1997 Andreas Dilger
|
|
||||||
# For conditions of distribution and use, see copyright notice in png.h
|
|
||||||
|
|
||||||
CC=gcc
|
|
||||||
|
|
||||||
# Where the zlib library and include files are located
|
|
||||||
#ZLIBLIB=/usr/local/lib
|
|
||||||
#ZLIBINC=/usr/local/include
|
|
||||||
ZLIBLIB=../zlib
|
|
||||||
ZLIBINC=../zlib
|
|
||||||
|
|
||||||
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
|
|
||||||
-Wmissing-declarations -Wtraditional -Wcast-align \
|
|
||||||
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
|
|
||||||
CFLAGS=-I$(ZLIBINC) -Wall -O2 -fPIC # $(WARNMORE) # -g -DPNG_DEBUG=3
|
|
||||||
LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz -lm
|
|
||||||
|
|
||||||
RANLIB=ranlib
|
|
||||||
#RANLIB=echo
|
|
||||||
|
|
||||||
PNGMAJ = 0
|
|
||||||
PNGMIN = 96
|
|
||||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
|
||||||
|
|
||||||
# where make install puts libpng.a, libpng.so*, and png.h
|
|
||||||
prefix=/usr/local
|
|
||||||
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
|
|
||||||
|
|
||||||
all: libpng.so pngtest
|
|
||||||
|
|
||||||
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): $(OBJS)
|
|
||||||
gcc -shared -Wl,-soname,libpng.so.$(PNGMAJ) -o libpng.so.$(PNGVER) $(OBJS)
|
|
||||||
|
|
||||||
pngtest: pngtest.o libpng.so
|
|
||||||
$(CC) -o pngtest pngtest.o $(LDFLAGS)
|
|
||||||
|
|
||||||
test: pngtest
|
|
||||||
./pngtest
|
|
||||||
|
|
||||||
install: libpng.so.$(PNGVER)
|
|
||||||
-@mkdir $(INCPATH) $(LIBPATH)
|
|
||||||
cp png.h pngconf.h $(INCPATH)
|
|
||||||
chmod 644 $(INCPATH)/png.h $(INCPATH)/pngconf.h
|
|
||||||
cp libpng.so.$(PNGVER) $(LIBPATH)
|
|
||||||
chmod 755 $(LIBPATH)/libpng.so.$(PNGVER)
|
|
||||||
-@/bin/rm $(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:
|
|
||||||
rm -f *.o libpng.a libpng.so* 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
|
|
||||||
44
png.5
Normal file
44
png.5
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
.TH PNG 5 "January 6, 1999"
|
||||||
|
.SH NAME
|
||||||
|
png \- Portable Network Graphics (PNG) format
|
||||||
|
.SH DESCRIPTION
|
||||||
|
PNG (Portable Network Graphics) is an extensible file format for the
|
||||||
|
lossless, portable, well-compressed storage of raster images. PNG provides
|
||||||
|
a patent-free replacement for GIF and can also replace many
|
||||||
|
common uses of TIFF. Indexed-color, grayscale, and truecolor images are
|
||||||
|
supported, plus an optional alpha channel. Sample depths range from
|
||||||
|
1 to 16 bits.
|
||||||
|
.br
|
||||||
|
|
||||||
|
PNG is designed to work well in online viewing applications, such as the
|
||||||
|
World Wide Web, so it is fully streamable with a progressive display
|
||||||
|
option. PNG is robust, providing both full file integrity checking and
|
||||||
|
fast, simple detection of common transmission errors. Also, PNG can store
|
||||||
|
gamma and chromaticity data for improved color matching on heterogeneous
|
||||||
|
platforms.
|
||||||
|
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
.IR libpng(3), zlib(3), deflate(5), and zlib(5)
|
||||||
|
.LP
|
||||||
|
PNG specification:
|
||||||
|
RFC 2083
|
||||||
|
.IP
|
||||||
|
.br
|
||||||
|
ftp://ds.internic.net/rfc/rfc2083.txt
|
||||||
|
.br
|
||||||
|
or (as a W3C Recommendation) at
|
||||||
|
.br
|
||||||
|
http://www.w3.org/TR/REC-png.html
|
||||||
|
.SH AUTHORS
|
||||||
|
This man page: Glenn Randers-Pehrson
|
||||||
|
.LP
|
||||||
|
Portable Network Graphics (PNG) Specification Version 1.0 (October 1, 1996):
|
||||||
|
Thomas Boutell and others (png-list@dworkin.wustl.edu).
|
||||||
|
.LP
|
||||||
|
|
||||||
|
.SH COPYRIGHT NOTICE
|
||||||
|
The PNG specification is copyright (c) 1996 Massachussets Institute of
|
||||||
|
Technology. See the specification for conditions of use and distribution.
|
||||||
|
.LP
|
||||||
|
.\" end of man page
|
||||||
|
|
||||||
245
png.c
245
png.c
@@ -1,27 +1,30 @@
|
|||||||
|
|
||||||
/* png.c - location for general purpose png functions
|
/* png.c - location for general purpose libpng functions
|
||||||
|
*
|
||||||
libpng 1.0 beta 6 - version 0.96
|
* libpng version 1.0.2b - January 6, 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) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1998, 1999, Glenn Randers-Pehrson
|
||||||
May 12, 1997
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#define PNG_NO_EXTERN
|
#define PNG_NO_EXTERN
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
|
||||||
/* Version information for C files. This had better match the version
|
/* Version information for C files. This had better match the version
|
||||||
string defined in png.h */
|
* string defined in png.h.
|
||||||
char png_libpng_ver[] = "0.95";
|
*/
|
||||||
|
|
||||||
/* Place to hold the signiture string for a PNG file. */
|
char png_libpng_ver[12] = "1.0.2b";
|
||||||
|
|
||||||
|
/* Place to hold the signature string for a PNG file. */
|
||||||
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||||
|
|
||||||
/* constant strings for known chunk types. If you need to add a chunk,
|
/* Constant strings for known chunk types. If you need to add a chunk,
|
||||||
add a string holding the name here. If you want to make the code
|
* add a string holding the name here. If you want to make the code
|
||||||
portable to EBCDIC machines, use ASCII numbers, not characters. */
|
* portable to EBCDIC machines, use ASCII numbers, not characters.
|
||||||
|
*/
|
||||||
png_byte FARDATA png_IHDR[5] = { 73, 72, 68, 82, '\0'};
|
png_byte FARDATA png_IHDR[5] = { 73, 72, 68, 82, '\0'};
|
||||||
png_byte FARDATA png_IDAT[5] = { 73, 68, 65, 84, '\0'};
|
png_byte FARDATA png_IDAT[5] = { 73, 68, 65, 84, '\0'};
|
||||||
png_byte FARDATA png_IEND[5] = { 73, 69, 78, 68, '\0'};
|
png_byte FARDATA png_IEND[5] = { 73, 69, 78, 68, '\0'};
|
||||||
@@ -34,6 +37,7 @@ png_byte FARDATA png_oFFs[5] = {111, 70, 70, 115, '\0'};
|
|||||||
png_byte FARDATA png_pCAL[5] = {112, 67, 65, 76, '\0'};
|
png_byte FARDATA png_pCAL[5] = {112, 67, 65, 76, '\0'};
|
||||||
png_byte FARDATA png_pHYs[5] = {112, 72, 89, 115, '\0'};
|
png_byte FARDATA png_pHYs[5] = {112, 72, 89, 115, '\0'};
|
||||||
png_byte FARDATA png_sBIT[5] = {115, 66, 73, 84, '\0'};
|
png_byte FARDATA png_sBIT[5] = {115, 66, 73, 84, '\0'};
|
||||||
|
png_byte FARDATA png_sRGB[5] = {115, 82, 71, 66, '\0'};
|
||||||
png_byte FARDATA png_tEXt[5] = {116, 69, 88, 116, '\0'};
|
png_byte FARDATA png_tEXt[5] = {116, 69, 88, 116, '\0'};
|
||||||
png_byte FARDATA png_tIME[5] = {116, 73, 77, 69, '\0'};
|
png_byte FARDATA png_tIME[5] = {116, 73, 77, 69, '\0'};
|
||||||
png_byte FARDATA png_tRNS[5] = {116, 82, 78, 83, '\0'};
|
png_byte FARDATA png_tRNS[5] = {116, 82, 78, 83, '\0'};
|
||||||
@@ -53,22 +57,20 @@ int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
|
|||||||
/* offset to next interlace block in the y direction */
|
/* offset to next interlace block in the y direction */
|
||||||
int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
||||||
|
|
||||||
/* width of interlace block */
|
/* Width of interlace block. This is not currently used - if you need
|
||||||
/* this is not currently used - if you need it, uncomment it here and
|
* it, uncomment it here and in png.h
|
||||||
in png.h
|
|
||||||
int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1};
|
int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* height of interlace block */
|
/* Height of interlace block. This is not currently used - if you need
|
||||||
/* this is not currently used - if you need it, uncomment it here and
|
* it, uncomment it here and in png.h
|
||||||
in png.h
|
|
||||||
int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
|
int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* mask to determine which pixels are valid in a pass */
|
/* Mask to determine which pixels are valid in a pass */
|
||||||
int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
||||||
|
|
||||||
/* mask to determine which pixels to overwrite while displaying */
|
/* Mask to determine which pixels to overwrite while displaying */
|
||||||
int FARDATA png_pass_dsp_mask[] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
int FARDATA png_pass_dsp_mask[] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
||||||
|
|
||||||
|
|
||||||
@@ -101,36 +103,35 @@ png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
|
|||||||
if (num_to_check > 8)
|
if (num_to_check > 8)
|
||||||
num_to_check = 8;
|
num_to_check = 8;
|
||||||
else if (num_to_check < 1)
|
else if (num_to_check < 1)
|
||||||
return 0;
|
return (0);
|
||||||
|
|
||||||
if (start > 7)
|
if (start > 7)
|
||||||
return 0;
|
return (0);
|
||||||
|
|
||||||
if (start + num_to_check > 8)
|
if (start + num_to_check > 8)
|
||||||
num_to_check = 8 - start;
|
num_to_check = 8 - start;
|
||||||
|
|
||||||
return (png_memcmp(&sig[start], &png_sig[start], num_to_check));
|
return ((int)(png_memcmp(&sig[start], &png_sig[start], num_to_check)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (Obsolete) function to check signature bytes. It does not allow one
|
/* (Obsolete) function to check signature bytes. It does not allow one
|
||||||
to check a partial signature. This function will be removed in the
|
* to check a partial signature. This function might be removed in the
|
||||||
future - use png_sig_cmp(). */
|
* future - use png_sig_cmp(). Returns true (nonzero) if the file is a PNG.
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
png_check_sig(png_bytep sig, int num)
|
png_check_sig(png_bytep sig, int num)
|
||||||
{
|
{
|
||||||
return !png_sig_cmp(sig, (png_size_t)0, (png_size_t)num);
|
return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Function to allocate memory for zlib. */
|
/* Function to allocate memory for zlib. */
|
||||||
voidpf
|
voidpf
|
||||||
png_zalloc(voidpf png_ptr, uInt items, uInt size)
|
png_zalloc(voidpf png_ptr, uInt items, uInt size)
|
||||||
{
|
{
|
||||||
png_voidp ptr;
|
png_uint_32 num_bytes = (png_uint_32)items * size;
|
||||||
png_uint_32 num_bytes;
|
png_voidp ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes);
|
||||||
|
|
||||||
num_bytes = (png_uint_32)items * size;
|
if (num_bytes > (png_uint_32)0x8000L)
|
||||||
ptr = png_malloc((png_structp)png_ptr, num_bytes);
|
|
||||||
if (num_bytes > (png_uint_32)0x8000)
|
|
||||||
{
|
{
|
||||||
png_memset(ptr, 0, (png_size_t)0x8000L);
|
png_memset(ptr, 0, (png_size_t)0x8000L);
|
||||||
png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0,
|
png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0,
|
||||||
@@ -140,7 +141,7 @@ png_zalloc(voidpf png_ptr, uInt items, uInt size)
|
|||||||
{
|
{
|
||||||
png_memset(ptr, 0, (png_size_t)num_bytes);
|
png_memset(ptr, 0, (png_size_t)num_bytes);
|
||||||
}
|
}
|
||||||
return (voidpf)(ptr);
|
return ((voidpf)ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* function to free memory for zlib */
|
/* function to free memory for zlib */
|
||||||
@@ -151,78 +152,19 @@ png_zfree(voidpf png_ptr, voidpf ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Reset the CRC variable to 32 bits of 1's. Care must be taken
|
/* Reset the CRC variable to 32 bits of 1's. Care must be taken
|
||||||
in case CRC is > 32 bits to leave the top bits 0. */
|
* in case CRC is > 32 bits to leave the top bits 0.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
png_reset_crc(png_structp png_ptr)
|
png_reset_crc(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
/* set CRC to all 1's */
|
|
||||||
#ifdef PNG_USE_OWN_CRC
|
|
||||||
png_ptr->crc = 0xffffffffL;
|
|
||||||
#else
|
|
||||||
png_ptr->crc = crc32(0, Z_NULL, 0);
|
png_ptr->crc = crc32(0, Z_NULL, 0);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_USE_OWN_CRC
|
|
||||||
/* Table of CRCs of all 8-bit messages. By default, we use the tables made
|
|
||||||
by zlib, to save some memory. If you wish to png_malloc() this
|
|
||||||
table, turn this into a pointer, and png_malloc() it in make_crc_table().
|
|
||||||
You may then want to hook it into png_struct and free it with the
|
|
||||||
destroy functions. Another alternative is to pre-fill the table. */
|
|
||||||
static png_uint_32 crc_table[256];
|
|
||||||
|
|
||||||
/* Flag: has the table been computed? Initially false. */
|
|
||||||
static int crc_table_computed = 0;
|
|
||||||
|
|
||||||
/* make the table for a fast crc */
|
|
||||||
static void
|
|
||||||
make_crc_table(void)
|
|
||||||
{
|
|
||||||
png_uint_32 c;
|
|
||||||
int n, k;
|
|
||||||
|
|
||||||
for (n = 0; n < 256; n++)
|
|
||||||
{
|
|
||||||
c = (png_uint_32)n;
|
|
||||||
for (k = 0; k < 8; k++)
|
|
||||||
c = c & 1 ? 0xedb88320L ^ (c >> 1) : c >> 1;
|
|
||||||
crc_table[n] = c;
|
|
||||||
}
|
|
||||||
crc_table_computed = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Update a running CRC with the bytes buf[0..len-1] - the CRC should be
|
|
||||||
initialized to all 1's, and the transmitted value is the 1's complement
|
|
||||||
of the final running CRC. */
|
|
||||||
static png_uint_32
|
|
||||||
update_crc(png_uint_32 crc, png_bytep buf, png_size_t len)
|
|
||||||
{
|
|
||||||
png_uint_32 c;
|
|
||||||
png_bytep p;
|
|
||||||
png_uint_32 n;
|
|
||||||
|
|
||||||
c = crc;
|
|
||||||
p = buf;
|
|
||||||
n = len;
|
|
||||||
|
|
||||||
if (!crc_table_computed)
|
|
||||||
{
|
|
||||||
make_crc_table();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (n > 0) do
|
|
||||||
{
|
|
||||||
c = crc_table[(png_byte)((c ^ (*p++)) & 0xff)] ^ (c >> 8);
|
|
||||||
} while (--n);
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
#endif /* PNG_USE_OWN_CRC */
|
|
||||||
|
|
||||||
/* Calculate the CRC over a section of data. We can only pass as
|
/* Calculate the CRC over a section of data. We can only pass as
|
||||||
much data to this routine as the largest single buffer size. We
|
* much data to this routine as the largest single buffer size. We
|
||||||
also check that this data will actually be used before going to the
|
* also check that this data will actually be used before going to the
|
||||||
trouble of calculating it. */
|
* trouble of calculating it.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length)
|
png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length)
|
||||||
{
|
{
|
||||||
@@ -241,36 +183,40 @@ png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (need_crc)
|
if (need_crc)
|
||||||
#ifdef PNG_USE_OWN_CRC
|
png_ptr->crc = crc32(png_ptr->crc, ptr, (uInt)length);
|
||||||
png_ptr->crc = update_crc(png_ptr->crc, ptr, length);
|
|
||||||
#else
|
|
||||||
png_ptr->crc = crc32(png_ptr->crc, ptr, length);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate the memory for an info_struct for the application. We don't
|
/* Allocate the memory for an info_struct for the application. We don't
|
||||||
really need the png_ptr, but it could potentially be useful in the
|
* really need the png_ptr, but it could potentially be useful in the
|
||||||
future. This should be used in favour of malloc(sizeof(png_info))
|
* future. This should be used in favour of malloc(sizeof(png_info))
|
||||||
and png_info_init() so that applications that want to use a shared
|
* and png_info_init() so that applications that want to use a shared
|
||||||
libpng don't have to be recompiled if png_info changes size. */
|
* libpng don't have to be recompiled if png_info changes size.
|
||||||
|
*/
|
||||||
png_infop
|
png_infop
|
||||||
png_create_info_struct(png_structp png_ptr)
|
png_create_info_struct(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_infop info_ptr;
|
png_infop info_ptr;
|
||||||
|
|
||||||
png_debug(1, "in png_create_info_struct\n");
|
png_debug(1, "in png_create_info_struct\n");
|
||||||
|
if(png_ptr == NULL) return (NULL);
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
if ((info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO,
|
||||||
|
png_ptr->malloc_fn)) != NULL)
|
||||||
|
#else
|
||||||
if ((info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO)) != NULL)
|
if ((info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO)) != NULL)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
png_info_init(info_ptr);
|
png_info_init(info_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return info_ptr;
|
return (info_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function frees the memory associated with a single info struct.
|
/* This function frees the memory associated with a single info struct.
|
||||||
Normally, one would use either png_destroy_read_struct() or
|
* Normally, one would use either png_destroy_read_struct() or
|
||||||
png_destroy_write_struct() to free an info struct, but this may be
|
* png_destroy_write_struct() to free an info struct, but this may be
|
||||||
useful for some applications. */
|
* useful for some applications.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
|
png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
|
||||||
{
|
{
|
||||||
@@ -284,14 +230,19 @@ png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
|
|||||||
{
|
{
|
||||||
png_info_destroy(png_ptr, info_ptr);
|
png_info_destroy(png_ptr, info_ptr);
|
||||||
|
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn);
|
||||||
|
#else
|
||||||
png_destroy_struct((png_voidp)info_ptr);
|
png_destroy_struct((png_voidp)info_ptr);
|
||||||
|
#endif
|
||||||
*info_ptr_ptr = (png_infop)NULL;
|
*info_ptr_ptr = (png_infop)NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the info structure. This is now an internal function (0.89)
|
/* Initialize the info structure. This is now an internal function (0.89)
|
||||||
and applications using it are urged to use png_create_info_struct()
|
* and applications using it are urged to use png_create_info_struct()
|
||||||
instead. */
|
* instead.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
png_info_init(png_infop info_ptr)
|
png_info_init(png_infop info_ptr)
|
||||||
{
|
{
|
||||||
@@ -308,11 +259,10 @@ void
|
|||||||
png_info_destroy(png_structp png_ptr, png_infop info_ptr)
|
png_info_destroy(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
|
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
|
||||||
int i;
|
|
||||||
|
|
||||||
png_debug(1, "in png_info_destroy\n");
|
png_debug(1, "in png_info_destroy\n");
|
||||||
if (info_ptr->text != NULL)
|
if (info_ptr->text != NULL)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
for (i = 0; i < info_ptr->num_text; i++)
|
for (i = 0; i < info_ptr->num_text; i++)
|
||||||
{
|
{
|
||||||
png_free(png_ptr, info_ptr->text[i].key);
|
png_free(png_ptr, info_ptr->text[i].key);
|
||||||
@@ -325,7 +275,8 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
|
|||||||
png_free(png_ptr, info_ptr->pcal_units);
|
png_free(png_ptr, info_ptr->pcal_units);
|
||||||
if (info_ptr->pcal_params != NULL)
|
if (info_ptr->pcal_params != NULL)
|
||||||
{
|
{
|
||||||
for (i = 0; i < info_ptr->pcal_nparams; i++)
|
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[i]);
|
||||||
}
|
}
|
||||||
@@ -337,18 +288,20 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* This function returns a pointer to the io_ptr associated with the user
|
/* This function returns a pointer to the io_ptr associated with the user
|
||||||
functions. The application should free any memory associated with this
|
* functions. The application should free any memory associated with this
|
||||||
pointer before png_write_destroy() or png_read_destroy() are called. */
|
* pointer before png_write_destroy() or png_read_destroy() are called.
|
||||||
|
*/
|
||||||
png_voidp
|
png_voidp
|
||||||
png_get_io_ptr(png_structp png_ptr)
|
png_get_io_ptr(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
return png_ptr->io_ptr;
|
return (png_ptr->io_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(PNG_NO_STDIO)
|
#if !defined(PNG_NO_STDIO)
|
||||||
/* Initialize the default input/output functions for the PNG file. If you
|
/* 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()
|
* 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().
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
png_init_io(png_structp png_ptr, FILE *fp)
|
png_init_io(png_structp png_ptr, FILE *fp)
|
||||||
{
|
{
|
||||||
@@ -356,3 +309,51 @@ png_init_io(png_structp png_ptr, FILE *fp)
|
|||||||
png_ptr->io_ptr = (png_voidp)fp;
|
png_ptr->io_ptr = (png_voidp)fp;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||||
|
/* 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_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
||||||
|
{
|
||||||
|
static PNG_CONST char short_months[12][4] =
|
||||||
|
{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||||
|
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||||
|
|
||||||
|
if (png_ptr->time_buffer == NULL)
|
||||||
|
{
|
||||||
|
png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29*
|
||||||
|
sizeof(char)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef USE_FAR_KEYWORD
|
||||||
|
{
|
||||||
|
char near_time_buf[29];
|
||||||
|
sprintf(near_time_buf, "%d %s %d %02d:%02d:%02d +0000",
|
||||||
|
ptime->day % 32, short_months[(ptime->month - 1) % 12],
|
||||||
|
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
||||||
|
ptime->second % 61);
|
||||||
|
png_memcpy(png_ptr->time_buffer, near_time_buf,
|
||||||
|
29*sizeof(char));
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
sprintf(png_ptr->time_buffer, "%d %s %d %02d:%02d:%02d +0000",
|
||||||
|
ptime->day % 32, short_months[(ptime->month - 1) % 12],
|
||||||
|
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
||||||
|
ptime->second % 61);
|
||||||
|
#endif
|
||||||
|
return ((png_charp)png_ptr->time_buffer);
|
||||||
|
}
|
||||||
|
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||||
|
|
||||||
|
png_charp
|
||||||
|
png_get_copyright(png_structp png_ptr)
|
||||||
|
{
|
||||||
|
if(png_ptr == NULL)
|
||||||
|
/* silence compiler warning about unused png_ptr */ ;
|
||||||
|
return("\n libpng version 1.0.2b - January 6, 1999\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");
|
||||||
|
}
|
||||||
|
|||||||
510
pngconf.h
510
pngconf.h
@@ -1,66 +1,86 @@
|
|||||||
|
|
||||||
/* pngconf.c - machine configurable file for libpng
|
/* pngconf.h - machine configurable file for libpng
|
||||||
|
*
|
||||||
libpng 1.0 beta 6 - version 0.96
|
* libpng 1.0.2b - January 6, 1999
|
||||||
For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
May 12, 1997
|
* Copyright (c) 1998, 1999, Glenn Randers-Pehrson
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Any machine specific code is near the front of this file, so if you
|
/* Any machine specific code is near the front of this file, so if you
|
||||||
are configuring libpng for a machine, you may want to read the section
|
* are configuring libpng for a machine, you may want to read the section
|
||||||
starting here down to where it starts to typedef png_color, png_text,
|
* starting here down to where it starts to typedef png_color, png_text,
|
||||||
and png_info */
|
* and png_info.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef PNGCONF_H
|
#ifndef PNGCONF_H
|
||||||
#define PNGCONF_H
|
#define PNGCONF_H
|
||||||
|
|
||||||
/* This is the size of the compression buffer, and thus the size of
|
|
||||||
an IDAT chunk. Make this whatever size you feel is best for your
|
|
||||||
machine. One of these will be allocated per png_struct. When this
|
|
||||||
is full, it writes the data to the disk, and does some other
|
|
||||||
calculations. Making this an extreamly small size will slow
|
|
||||||
the library down, but you may want to experiment to determine
|
|
||||||
where it becomes significant, if you are concerned with memory
|
|
||||||
usage. Note that zlib allocates at least 32Kb also. For readers,
|
|
||||||
this describes the size of the buffer available to read the data in.
|
|
||||||
Unless this gets smaller then the size of a row (compressed),
|
|
||||||
it should not make much difference how big this is. */
|
|
||||||
|
|
||||||
|
/* This is the size of the compression buffer, and thus the size of
|
||||||
|
* an IDAT chunk. Make this whatever size you feel is best for your
|
||||||
|
* machine. One of these will be allocated per png_struct. When this
|
||||||
|
* is full, it writes the data to the disk, and does some other
|
||||||
|
* calculations. Making this an extremely small size will slow
|
||||||
|
* the library down, but you may want to experiment to determine
|
||||||
|
* where it becomes significant, if you are concerned with memory
|
||||||
|
* usage. Note that zlib allocates at least 32Kb also. For readers,
|
||||||
|
* this describes the size of the buffer available to read the data in.
|
||||||
|
* Unless this gets smaller than the size of a row (compressed),
|
||||||
|
* it should not make much difference how big this is.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PNG_ZBUF_SIZE
|
||||||
#define PNG_ZBUF_SIZE 8192
|
#define PNG_ZBUF_SIZE 8192
|
||||||
|
#endif
|
||||||
|
|
||||||
/* If you are running on a machine where you cannot allocate more
|
/* If you are running on a machine where you cannot allocate more
|
||||||
than 64K of memory at once, uncomment this. While libpng will not
|
* than 64K of memory at once, uncomment this. While libpng will not
|
||||||
normally need that much memory in a chunk (unless you load up a very
|
* normally need that much memory in a chunk (unless you load up a very
|
||||||
large file), zlib needs to know how big of a chunk it can use, and
|
* large file), zlib needs to know how big of a chunk it can use, and
|
||||||
libpng thus makes sure to check any memory allocation to verify it
|
* libpng thus makes sure to check any memory allocation to verify it
|
||||||
will fit into memory.
|
* will fit into memory.
|
||||||
#define PNG_MAX_MALLOC_64K
|
#define PNG_MAX_MALLOC_64K
|
||||||
*/
|
*/
|
||||||
#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
|
#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
|
||||||
#define PNG_MAX_MALLOC_64K
|
#define PNG_MAX_MALLOC_64K
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This protects us against compilers which run on a windowing system
|
/* This protects us against compilers that run on a windowing system
|
||||||
and thus don't have or would rather us not use the stdio types:
|
* and thus don't have or would rather us not use the stdio types:
|
||||||
stdin, stdout, and stderr. The only one currently used is stderr
|
* stdin, stdout, and stderr. The only one currently used is stderr
|
||||||
in png_error() and png_warning(). #defining PNG_NO_STDIO will
|
* in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will
|
||||||
prevent these from being compiled and used. */
|
* prevent these from being compiled and used. #defining PNG_NO_STDIO
|
||||||
|
* will also prevent these, plus will prevent the entire set of stdio
|
||||||
|
* macros and functions (FILE *, printf, etc.) from being compiled and used,
|
||||||
|
* unless PNG_DEBUG has been #defined.
|
||||||
|
*
|
||||||
|
* #define PNG_NO_CONSOLE_IO
|
||||||
|
* #define PNG_NO_STDIO
|
||||||
|
*/
|
||||||
|
|
||||||
/* #define PNG_NO_STDIO */
|
#ifdef PNG_DEBUG
|
||||||
|
# if (PNG_DEBUG > 0)
|
||||||
/* for FILE. If you are not using standard io, you don't need this */
|
# include <stdio.h>
|
||||||
#ifndef PNG_NO_STDIO
|
# endif
|
||||||
#include <stdio.h>
|
#else
|
||||||
|
# ifdef PNG_NO_STDIO
|
||||||
|
# ifndef PNG_NO_CONSOLE_IO
|
||||||
|
# define PNG_NO_CONSOLE_IO
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# include <stdio.h>
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This macro protects us against machines that don't have function
|
/* This macro protects us against machines that don't have function
|
||||||
prototypes (ie K&R style headers). If your compiler does not handle
|
* prototypes (ie K&R style headers). If your compiler does not handle
|
||||||
function prototypes, define this macro and use the included ansi2knr.
|
* function prototypes, define this macro and use the included ansi2knr.
|
||||||
I've always been able to use _NO_PROTO as the indicator, but you may
|
* I've always been able to use _NO_PROTO as the indicator, but you may
|
||||||
need to drag the empty declaration out in front of here, or change the
|
* need to drag the empty declaration out in front of here, or change the
|
||||||
ifdef to suit your own needs. */
|
* ifdef to suit your own needs.
|
||||||
|
*/
|
||||||
#ifndef PNGARG
|
#ifndef PNGARG
|
||||||
|
|
||||||
#ifdef OF /* zlib prototype munger */
|
#ifdef OF /* zlib prototype munger */
|
||||||
@@ -77,10 +97,16 @@
|
|||||||
|
|
||||||
#endif /* PNGARG */
|
#endif /* PNGARG */
|
||||||
|
|
||||||
/* Try to determine if we are compiling on a Mac */
|
/* Try to determine if we are compiling on a Mac. Note that testing for
|
||||||
#if defined(__MWERKS__) ||defined(applec) ||defined(THINK_C) ||defined(__SC__)
|
* just __MWERKS__ is not good enough, because the Codewarrior is now used
|
||||||
|
* on non-Mac platforms.
|
||||||
|
*/
|
||||||
|
#ifndef MACOS
|
||||||
|
#if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
|
||||||
|
defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
|
||||||
#define MACOS
|
#define MACOS
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* enough people need this for various reasons to include it here */
|
/* enough people need this for various reasons to include it here */
|
||||||
#if !defined(MACOS) && !defined(RISCOS)
|
#if !defined(MACOS) && !defined(RISCOS)
|
||||||
@@ -88,27 +114,28 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This is an attempt to force a single setjmp behaviour on Linux. If
|
/* This is an attempt to force a single setjmp behaviour on Linux. If
|
||||||
the X config stuff didn't define _BSD_SOURCE we wouldn't need this. */
|
* the X config stuff didn't define _BSD_SOURCE we wouldn't need this.
|
||||||
#ifdef linux
|
*/
|
||||||
|
#ifdef __linux__
|
||||||
#ifdef _BSD_SOURCE
|
#ifdef _BSD_SOURCE
|
||||||
#define _PNG_SAVE_BSD_SOURCE
|
#define _PNG_SAVE_BSD_SOURCE
|
||||||
#undef _BSD_SOURCE
|
#undef _BSD_SOURCE
|
||||||
#endif
|
#endif
|
||||||
#ifdef _SETJMP_H
|
#ifdef _SETJMP_H
|
||||||
#error __png_h_already_includes_setjmp_h__
|
__png.h__ already includes setjmp.h
|
||||||
#error __dont_include_it_again__
|
__dont__ include it again
|
||||||
#endif
|
#endif
|
||||||
#endif /* linux */
|
#endif /* __linux__ */
|
||||||
|
|
||||||
/* include setjmp.h for error handling */
|
/* include setjmp.h for error handling */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
|
|
||||||
#ifdef linux
|
#ifdef __linux__
|
||||||
#ifdef _PNG_SAVE_BSD_SOURCE
|
#ifdef _PNG_SAVE_BSD_SOURCE
|
||||||
#define _BSD_SOURCE
|
#define _BSD_SOURCE
|
||||||
#undef _PNG_SAVE_BSD_SOURCE
|
#undef _PNG_SAVE_BSD_SOURCE
|
||||||
#endif
|
#endif
|
||||||
#endif /* linux */
|
#endif /* __linux__ */
|
||||||
|
|
||||||
#ifdef BSD
|
#ifdef BSD
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
@@ -119,9 +146,6 @@
|
|||||||
/* Other defines for things like memory and the like can go here. */
|
/* Other defines for things like memory and the like can go here. */
|
||||||
#ifdef PNG_INTERNAL
|
#ifdef PNG_INTERNAL
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
/* Where do we need this???
|
|
||||||
#include <ctype.h>
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which
|
/* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which
|
||||||
* aren't usually used outside the library (as far as I know), so it is
|
* aren't usually used outside the library (as far as I know), so it is
|
||||||
@@ -133,12 +157,14 @@
|
|||||||
#define PNG_EXTERN
|
#define PNG_EXTERN
|
||||||
|
|
||||||
/* Other defines specific to compilers can go here. Try to keep
|
/* Other defines specific to compilers can go here. Try to keep
|
||||||
them inside an appropriate ifdef/endif pair for portability */
|
* them inside an appropriate ifdef/endif pair for portability.
|
||||||
|
*/
|
||||||
|
|
||||||
#if defined(MACOS)
|
#if defined(MACOS)
|
||||||
/* We need to check that <math.h> hasn't already been included earlier
|
/* We need to check that <math.h> hasn't already been included earlier
|
||||||
as it seems it doesn't agree with <fp.h>, yet we should really use
|
* as it seems it doesn't agree with <fp.h>, yet we should really use
|
||||||
<fp.h> if possible. */
|
* <fp.h> if possible.
|
||||||
|
*/
|
||||||
#if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)
|
#if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)
|
||||||
#include <fp.h>
|
#include <fp.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -146,9 +172,15 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Codewarrior on NT has linking problems without this. */
|
||||||
|
#if defined(__MWERKS__) && defined(WIN32)
|
||||||
|
#define PNG_ALWAYS_EXTERN
|
||||||
|
#endif
|
||||||
|
|
||||||
/* For some reason, Borland C++ defines memcmp, etc. in mem.h, not
|
/* For some reason, Borland C++ defines memcmp, etc. in mem.h, not
|
||||||
stdlib.h like it should (I think). Or perhaps this is a C++
|
* stdlib.h like it should (I think). Or perhaps this is a C++
|
||||||
"feature"? */
|
* "feature"?
|
||||||
|
*/
|
||||||
#ifdef __TURBOC__
|
#ifdef __TURBOC__
|
||||||
#include <mem.h>
|
#include <mem.h>
|
||||||
#include "alloc.h"
|
#include "alloc.h"
|
||||||
@@ -159,130 +191,344 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This controls how fine the dithering gets. As this allocates
|
/* This controls how fine the dithering gets. As this allocates
|
||||||
a largish chunk of memory (32K), those who are not as concerned
|
* a largish chunk of memory (32K), those who are not as concerned
|
||||||
with dithering quality can decrease some or all of these. */
|
* with dithering quality can decrease some or all of these.
|
||||||
|
*/
|
||||||
|
#ifndef PNG_DITHER_RED_BITS
|
||||||
#define PNG_DITHER_RED_BITS 5
|
#define PNG_DITHER_RED_BITS 5
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_DITHER_GREEN_BITS
|
||||||
#define PNG_DITHER_GREEN_BITS 5
|
#define PNG_DITHER_GREEN_BITS 5
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_DITHER_BLUE_BITS
|
||||||
#define PNG_DITHER_BLUE_BITS 5
|
#define PNG_DITHER_BLUE_BITS 5
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This controls how fine the gamma correction becomes when you
|
/* This controls how fine the gamma correction becomes when you
|
||||||
are only interested in 8 bits anyway. Increasing this value
|
* are only interested in 8 bits anyway. Increasing this value
|
||||||
results in more memory being used, and more pow() functions
|
* results in more memory being used, and more pow() functions
|
||||||
being called to fill in the gamma tables. Don't set this
|
* being called to fill in the gamma tables. Don't set this value
|
||||||
value less then 8, and even that may not work (I haven't tested
|
* less then 8, and even that may not work (I haven't tested it).
|
||||||
it). */
|
*/
|
||||||
|
|
||||||
|
#ifndef PNG_MAX_GAMMA_8
|
||||||
#define PNG_MAX_GAMMA_8 11
|
#define PNG_MAX_GAMMA_8 11
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This controls how much a difference in gamma we can tolerate before
|
/* This controls how much a difference in gamma we can tolerate before
|
||||||
we actually start doing gamma conversion. */
|
* we actually start doing gamma conversion.
|
||||||
|
*/
|
||||||
|
#ifndef PNG_GAMMA_THRESHOLD
|
||||||
#define PNG_GAMMA_THRESHOLD 0.05
|
#define PNG_GAMMA_THRESHOLD 0.05
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* PNG_INTERNAL */
|
#endif /* PNG_INTERNAL */
|
||||||
|
|
||||||
/* The following uses const char * instead of char * for error
|
/* The following uses const char * instead of char * for error
|
||||||
and warning message functions, so some compilers won't complain.
|
* and warning message functions, so some compilers won't complain.
|
||||||
If you want to use const, define PNG_USE_CONST here. It is not
|
* If you do not want to use const, define PNG_NO_CONST here.
|
||||||
normally defined to make configuration easier, as it is not a
|
*/
|
||||||
critical part of the code.
|
|
||||||
*/
|
|
||||||
#undef PNG_USE_CONST
|
|
||||||
|
|
||||||
#ifdef PNG_USE_CONST
|
#ifndef PNG_NO_CONST
|
||||||
# define PNG_CONST const
|
# define PNG_CONST const
|
||||||
#else
|
#else
|
||||||
# define PNG_CONST
|
# define PNG_CONST
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The following defines give you the ability to remove code from the
|
/* The following defines give you the ability to remove code from the
|
||||||
library that you will not be using. I wish I could figure out how to
|
* library that you will not be using. I wish I could figure out how to
|
||||||
automate this, but I can't do that without making it seriously hard
|
* automate this, but I can't do that without making it seriously hard
|
||||||
on the users. So if you are not using an ability, change the #define
|
* on the users. So if you are not using an ability, change the #define
|
||||||
to and #undef, and that part of the library will not be compiled. If
|
* to and #undef, and that part of the library will not be compiled. If
|
||||||
your linker can't find a function, you may want to make sure the
|
* your linker can't find a function, you may want to make sure the
|
||||||
ability is defined here. Some of these depend upon some others being
|
* ability is defined here. Some of these depend upon some others being
|
||||||
defined. I haven't figured out all the interactions here, so you may
|
* defined. I haven't figured out all the interactions here, so you may
|
||||||
have to experiment awhile to get everything to compile. If you are
|
* have to experiment awhile to get everything to compile. If you are
|
||||||
creating or using a shared library, you probably shouldn't touch this,
|
* creating or using a shared library, you probably shouldn't touch this,
|
||||||
as it will affect the size of the structures, and this will cause bad
|
* as it will affect the size of the structures, and this will cause bad
|
||||||
things to happen if the library and/or application ever change. */
|
* things to happen if the library and/or application ever change.
|
||||||
|
*/
|
||||||
|
|
||||||
/* Any transformations you will not be using can be undef'ed here */
|
/* Any transformations you will not be using can be undef'ed here */
|
||||||
#define PNG_PROGRESSIVE_READ_SUPPORTED
|
|
||||||
#define PNG_READ_OPT_PLTE_SUPPORTED
|
/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user
|
||||||
#define PNG_READ_INTERLACING_SUPPORTED
|
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)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
|
||||||
|
!defined(PNG_NO_READ_TRANSFORMS)
|
||||||
|
#define PNG_READ_TRANSFORMS_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \
|
||||||
|
!defined(PNG_NO_WRITE_TRANSFORMS)
|
||||||
|
#define PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||||
|
#ifndef PNG_NO_READ_EXPAND
|
||||||
#define PNG_READ_EXPAND_SUPPORTED
|
#define PNG_READ_EXPAND_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_SHIFT
|
||||||
#define PNG_READ_SHIFT_SUPPORTED
|
#define PNG_READ_SHIFT_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_PACK
|
||||||
#define PNG_READ_PACK_SUPPORTED
|
#define PNG_READ_PACK_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_BGR
|
||||||
#define PNG_READ_BGR_SUPPORTED
|
#define PNG_READ_BGR_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_SWAP
|
||||||
#define PNG_READ_SWAP_SUPPORTED
|
#define PNG_READ_SWAP_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_PACKSWAP
|
||||||
#define PNG_READ_PACKSWAP_SUPPORTED
|
#define PNG_READ_PACKSWAP_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_INVERT
|
||||||
#define PNG_READ_INVERT_SUPPORTED
|
#define PNG_READ_INVERT_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_DITHER
|
||||||
#define PNG_READ_DITHER_SUPPORTED
|
#define PNG_READ_DITHER_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_BACKGROUND
|
||||||
#define PNG_READ_BACKGROUND_SUPPORTED
|
#define PNG_READ_BACKGROUND_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_16_TO_8
|
||||||
#define PNG_READ_16_TO_8_SUPPORTED
|
#define PNG_READ_16_TO_8_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_FILLER
|
||||||
#define PNG_READ_FILLER_SUPPORTED
|
#define PNG_READ_FILLER_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_GAMMA
|
||||||
#define PNG_READ_GAMMA_SUPPORTED
|
#define PNG_READ_GAMMA_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_GRAY_TO_RGB
|
||||||
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
|
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_SWAP_ALPHA
|
||||||
#define PNG_READ_SWAP_ALPHA_SUPPORTED
|
#define PNG_READ_SWAP_ALPHA_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_INVERT_ALPHA
|
||||||
|
#define PNG_READ_INVERT_ALPHA_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_STRIP_ALPHA
|
||||||
#define PNG_READ_STRIP_ALPHA_SUPPORTED
|
#define PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_USER_TRANSFORM
|
||||||
|
#define PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_RGB_TO_GRAY
|
||||||
|
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
|
||||||
|
|
||||||
#define PNG_WRITE_INTERLACING_SUPPORTED
|
#if !defined(PNG_NO_PROGRESSIVE_READ) && \
|
||||||
|
!defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */
|
||||||
|
#define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */
|
||||||
|
#endif /* about interlacing capability! You'll */
|
||||||
|
/* 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
|
||||||
|
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel and SGI */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||||
|
#ifndef PNG_NO_WRITE_SHIFT
|
||||||
#define PNG_WRITE_SHIFT_SUPPORTED
|
#define PNG_WRITE_SHIFT_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_WRITE_PACK
|
||||||
#define PNG_WRITE_PACK_SUPPORTED
|
#define PNG_WRITE_PACK_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_WRITE_BGR
|
||||||
#define PNG_WRITE_BGR_SUPPORTED
|
#define PNG_WRITE_BGR_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_WRITE_SWAP
|
||||||
#define PNG_WRITE_SWAP_SUPPORTED
|
#define PNG_WRITE_SWAP_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_WRITE_PACKSWAP
|
||||||
#define PNG_WRITE_PACKSWAP_SUPPORTED
|
#define PNG_WRITE_PACKSWAP_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_WRITE_INVERT
|
||||||
#define PNG_WRITE_INVERT_SUPPORTED
|
#define PNG_WRITE_INVERT_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_WRITE_FILLER
|
||||||
#define PNG_WRITE_FILLER_SUPPORTED /* This is the same as WRITE_STRIP_ALPHA */
|
#define PNG_WRITE_FILLER_SUPPORTED /* This is the same as WRITE_STRIP_ALPHA */
|
||||||
#define PNG_WRITE_FLUSH_SUPPORTED
|
#endif
|
||||||
|
#ifndef PNG_NO_WRITE_SWAP_ALPHA
|
||||||
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||||
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
#endif
|
||||||
|
#ifndef PNG_NO_WRITE_INVERT_ALPHA
|
||||||
|
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_WRITE_USER_TRANSFORM
|
||||||
|
#define PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
|
||||||
|
|
||||||
/* These are currently experimental features */
|
#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant
|
||||||
#undef PNG_READ_16_TO_8_ACCURATE_SHIFT_SUPPORTED /* very little testing */
|
encoders, but can cause trouble
|
||||||
#undef PNG_READ_COMPOSITE_NODIV_SUPPORTED /* very little testing */
|
if left undefined */
|
||||||
|
|
||||||
|
#ifndef PNG_NO_WRITE_WEIGHTED_FILTER
|
||||||
|
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PNG_NO_WRITE_FLUSH
|
||||||
|
#define PNG_WRITE_FLUSH_SUPPORTED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PNG_NO_STDIO
|
||||||
|
#define PNG_TIME_RFC1123_SUPPORTED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* This adds extra functions in pngget.c for accessing data from the
|
||||||
|
* info pointer (added in version 0.99)
|
||||||
|
* png_get_image_width()
|
||||||
|
* png_get_image_height()
|
||||||
|
* png_get_bit_depth()
|
||||||
|
* png_get_color_type()
|
||||||
|
* png_get_compression_type()
|
||||||
|
* png_get_filter_type()
|
||||||
|
* png_get_interlace_type()
|
||||||
|
* png_get_pixel_aspect_ratio()
|
||||||
|
* png_get_pixels_per_meter()
|
||||||
|
* png_get_x_offset_pixels()
|
||||||
|
* png_get_y_offset_pixels()
|
||||||
|
* png_get_x_offset_microns()
|
||||||
|
* png_get_y_offset_microns()
|
||||||
|
*/
|
||||||
|
#ifndef PNG_NO_EASY_ACCESS
|
||||||
|
#define PNG_EASY_ACCESS_SUPPORTED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* These are currently experimental features, define them if you want */
|
||||||
|
|
||||||
|
/* very little testing */
|
||||||
|
/*
|
||||||
|
#define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
|
||||||
|
#define PNG_USER_MEM_SUPPORTED
|
||||||
|
*/
|
||||||
|
|
||||||
/* This is only for PowerPC big-endian and 680x0 systems */
|
/* This is only for PowerPC big-endian and 680x0 systems */
|
||||||
#undef PNG_READ_BIG_ENDIAN_SUPPORTED /* some testing */
|
/* some testing */
|
||||||
|
/*
|
||||||
|
#define PNG_READ_BIG_ENDIAN_SUPPORTED
|
||||||
|
*/
|
||||||
|
|
||||||
/* These functions are turned off by default, as they will be phased out. */
|
/* These functions are turned off by default, as they will be phased out. */
|
||||||
#undef PNG_USE_OWN_CRC
|
/*
|
||||||
#undef PNG_USELESS_TESTS_SUPPORTED
|
#define PNG_USELESS_TESTS_SUPPORTED
|
||||||
#undef PNG_CORRECT_PALETTE_SUPPORTED
|
#define PNG_CORRECT_PALETTE_SUPPORTED
|
||||||
|
*/
|
||||||
|
|
||||||
/* Any chunks you are not interested in, you can undef here. The
|
/* Any chunks you are not interested in, you can undef here. The
|
||||||
* ones that allocate memory may be expecially important (hIST,
|
* ones that allocate memory may be expecially important (hIST,
|
||||||
* tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info
|
* tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info
|
||||||
* a bit smaller. OPT_PLTE only disables the optional palette in RGB
|
* a bit smaller.
|
||||||
* and RGBA images.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PNG_READ_bKGD_SUPPORTED
|
#if !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
|
||||||
#define PNG_READ_cHRM_SUPPORTED
|
!defined(PNG_NO_READ_ANCILLARY_CHUNKS)
|
||||||
#define PNG_READ_gAMA_SUPPORTED
|
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
|
||||||
#define PNG_READ_hIST_SUPPORTED
|
#endif
|
||||||
#define PNG_READ_oFFs_SUPPORTED
|
#if !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
|
||||||
#define PNG_READ_pCAL_SUPPORTED
|
!defined(PNG_NO_WRITE_ANCILLARY_CHUNKS)
|
||||||
#define PNG_READ_pHYs_SUPPORTED
|
#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
|
||||||
#define PNG_READ_sBIT_SUPPORTED
|
#endif
|
||||||
#define PNG_READ_tEXt_SUPPORTED
|
|
||||||
#define PNG_READ_tIME_SUPPORTED
|
|
||||||
#define PNG_READ_tRNS_SUPPORTED
|
|
||||||
#define PNG_READ_zTXt_SUPPORTED
|
|
||||||
|
|
||||||
|
#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
|
||||||
|
#ifndef PNG_NO_READ_bKGD
|
||||||
|
#define PNG_READ_bKGD_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_cHRM
|
||||||
|
#define PNG_READ_cHRM_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_gAMA
|
||||||
|
#define PNG_READ_gAMA_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_hIST
|
||||||
|
#define PNG_READ_hIST_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_oFFs
|
||||||
|
#define PNG_READ_oFFs_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_pCAL
|
||||||
|
#define PNG_READ_pCAL_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_pHYs
|
||||||
|
#define PNG_READ_pHYs_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_sBIT
|
||||||
|
#define PNG_READ_sBIT_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_sRGB
|
||||||
|
#define PNG_READ_sRGB_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_tEXt
|
||||||
|
#define PNG_READ_tEXt_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_tIME
|
||||||
|
#define PNG_READ_tIME_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_tRNS
|
||||||
|
#define PNG_READ_tRNS_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_zTXt
|
||||||
|
#define PNG_READ_zTXt_SUPPORTED
|
||||||
|
#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 */
|
||||||
|
#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
|
||||||
|
#ifndef PNG_NO_WRITE_bKGD
|
||||||
#define PNG_WRITE_bKGD_SUPPORTED
|
#define PNG_WRITE_bKGD_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_WRITE_cHRM
|
||||||
#define PNG_WRITE_cHRM_SUPPORTED
|
#define PNG_WRITE_cHRM_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_WRITE_gAMA
|
||||||
#define PNG_WRITE_gAMA_SUPPORTED
|
#define PNG_WRITE_gAMA_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_WRITE_hIST
|
||||||
#define PNG_WRITE_hIST_SUPPORTED
|
#define PNG_WRITE_hIST_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_WRITE_oFFs
|
||||||
#define PNG_WRITE_oFFs_SUPPORTED
|
#define PNG_WRITE_oFFs_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_WRITE_pCAL
|
||||||
#define PNG_WRITE_pCAL_SUPPORTED
|
#define PNG_WRITE_pCAL_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_WRITE_pHYs
|
||||||
#define PNG_WRITE_pHYs_SUPPORTED
|
#define PNG_WRITE_pHYs_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_WRITE_sBIT
|
||||||
#define PNG_WRITE_sBIT_SUPPORTED
|
#define PNG_WRITE_sBIT_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_WRITE_sRGB
|
||||||
|
#define PNG_WRITE_sRGB_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_WRITE_tEXt
|
||||||
#define PNG_WRITE_tEXt_SUPPORTED
|
#define PNG_WRITE_tEXt_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_WRITE_tIME
|
||||||
#define PNG_WRITE_tIME_SUPPORTED
|
#define PNG_WRITE_tIME_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_WRITE_tRNS
|
||||||
#define PNG_WRITE_tRNS_SUPPORTED
|
#define PNG_WRITE_tRNS_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NO_WRITE_zTXt
|
||||||
#define PNG_WRITE_zTXt_SUPPORTED
|
#define PNG_WRITE_zTXt_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
|
||||||
|
|
||||||
/* need the time information for reading tIME chunks */
|
/* need the time information for reading tIME chunks */
|
||||||
#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
|
#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
|
||||||
@@ -336,18 +582,19 @@ typedef size_t png_size_t;
|
|||||||
#endif /* LDATA != 1 */
|
#endif /* LDATA != 1 */
|
||||||
|
|
||||||
/* Possibly useful for moving data out of default segment.
|
/* Possibly useful for moving data out of default segment.
|
||||||
Uncomment it if you want. Could also define FARDATA as
|
* Uncomment it if you want. Could also define FARDATA as
|
||||||
const if your compiler supports it. (SJT)
|
* const if your compiler supports it. (SJT)
|
||||||
# define FARDATA FAR
|
# define FARDATA FAR
|
||||||
*/
|
*/
|
||||||
#endif /* __WIN32__, __FLAT__ */
|
#endif /* __WIN32__, __FLAT__ */
|
||||||
|
|
||||||
#endif /* __BORLANDC__ */
|
#endif /* __BORLANDC__ */
|
||||||
|
|
||||||
|
|
||||||
/* Suggest testing for specific compiler first before testing for
|
/* Suggest testing for specific compiler first before testing for
|
||||||
FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
|
* FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
|
||||||
making reliance oncertain keywords suspect. (SJT) */
|
* making reliance oncertain keywords suspect. (SJT)
|
||||||
|
*/
|
||||||
|
|
||||||
/* MSC Medium model */
|
/* MSC Medium model */
|
||||||
#if defined(FAR)
|
#if defined(FAR)
|
||||||
@@ -398,27 +645,39 @@ typedef char FAR * FAR * FAR * png_charppp;
|
|||||||
*/
|
*/
|
||||||
typedef charf * png_zcharp;
|
typedef charf * png_zcharp;
|
||||||
typedef charf * FAR * png_zcharpp;
|
typedef charf * FAR * png_zcharpp;
|
||||||
typedef z_stream FAR * png_zstreamp;
|
typedef z_stream FAR * png_zstreamp;
|
||||||
|
|
||||||
/* allow for compilation as dll under windows */
|
/* allow for compilation as dll under MS Windows */
|
||||||
#ifdef __WIN32DLL__
|
#ifdef __WIN32DLL__
|
||||||
#define PNG_EXPORT(type,symbol) __declspec(dllexport) type symbol
|
#define PNG_EXPORT(type,symbol) __declspec(dllexport) type symbol
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* 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
|
||||||
|
|
||||||
|
/* allow for compilation as shared lib under BeOS */
|
||||||
|
#ifdef __BEOSDLL__
|
||||||
|
#define PNG_EXPORT(type,symbol) __declspec(export) type symbol
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef PNG_EXPORT
|
#ifndef PNG_EXPORT
|
||||||
#define PNG_EXPORT(t,s) t s
|
#define PNG_EXPORT(type,symbol) type symbol
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* User may want to use these so not in PNG_INTERNAL. Any library functions
|
/* User may want to use these so not in PNG_INTERNAL. Any library functions
|
||||||
that are passed far data must be model independent. */
|
* that are passed far data must be model independent.
|
||||||
|
*/
|
||||||
|
|
||||||
#if defined(USE_FAR_KEYWORD) /* memory model independent fns */
|
#if defined(USE_FAR_KEYWORD) /* memory model independent fns */
|
||||||
/* use this to make far-to-near assignments */
|
/* use this to make far-to-near assignments */
|
||||||
# define CHECK 1
|
# define CHECK 1
|
||||||
# define NOCHECK 0
|
# define NOCHECK 0
|
||||||
# define CVT_PTR(ptr) (far_to_near(png_ptr,ptr,CHECK))
|
# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
|
||||||
# define CVT_PTR_NOCHECK(ptr) (far_to_near(png_ptr,ptr,NOCHECK))
|
# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
|
||||||
|
# define png_strcpy _fstrcpy
|
||||||
# define png_strlen _fstrlen
|
# define png_strlen _fstrlen
|
||||||
# define png_memcmp _fmemcmp /* SJT: added */
|
# define png_memcmp _fmemcmp /* SJT: added */
|
||||||
# define png_memcpy _fmemcpy
|
# define png_memcpy _fmemcpy
|
||||||
@@ -426,6 +685,7 @@ typedef z_stream FAR * png_zstreamp;
|
|||||||
#else /* use the usual functions */
|
#else /* use the usual functions */
|
||||||
# define CVT_PTR(ptr) (ptr)
|
# define CVT_PTR(ptr) (ptr)
|
||||||
# define CVT_PTR_NOCHECK(ptr) (ptr)
|
# define CVT_PTR_NOCHECK(ptr) (ptr)
|
||||||
|
# define png_strcpy strcpy
|
||||||
# define png_strlen strlen
|
# define png_strlen strlen
|
||||||
# define png_memcmp memcmp /* SJT: added */
|
# define png_memcmp memcmp /* SJT: added */
|
||||||
# define png_memcpy memcpy
|
# define png_memcpy memcpy
|
||||||
@@ -434,7 +694,7 @@ typedef z_stream FAR * png_zstreamp;
|
|||||||
/* End of memory model independent support */
|
/* End of memory model independent support */
|
||||||
|
|
||||||
/* Just a double check that someone hasn't tried to define something
|
/* Just a double check that someone hasn't tried to define something
|
||||||
* contradictory.
|
* contradictory.
|
||||||
*/
|
*/
|
||||||
#if (PNG_ZBUF_SIZE > 65536) && defined(PNG_MAX_MALLOC_64K)
|
#if (PNG_ZBUF_SIZE > 65536) && defined(PNG_MAX_MALLOC_64K)
|
||||||
#undef PNG_ZBUF_SIZE
|
#undef PNG_ZBUF_SIZE
|
||||||
|
|||||||
128
pngerror.c
128
pngerror.c
@@ -1,16 +1,17 @@
|
|||||||
|
|
||||||
/* pngerror.c - stub functions for i/o and memory allocation
|
/* pngerror.c - stub functions for i/o and memory allocation
|
||||||
|
*
|
||||||
libpng 1.0 beta 6 - version 0.96
|
* libpng 1.0.2b - January 6, 1999
|
||||||
For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
May 12, 1997
|
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||||
|
*
|
||||||
This file provides a location for all error handling. Users which
|
* This file provides a location for all error handling. Users who
|
||||||
need special error handling are expected to write replacement functions
|
* need special error handling are expected to write replacement functions
|
||||||
and use png_set_error_fn() to use those functions. See the instructions
|
* and use png_set_error_fn() to use those functions. See the instructions
|
||||||
at each function. */
|
* at each function.
|
||||||
|
*/
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
@@ -21,9 +22,10 @@ static void png_default_warning PNGARG((png_structp png_ptr,
|
|||||||
png_const_charp message));
|
png_const_charp message));
|
||||||
|
|
||||||
/* This function is called whenever there is a fatal error. This function
|
/* This function is called whenever there is a fatal error. This function
|
||||||
should not be changed. If there is a need to handle errors differently,
|
* should not be changed. If there is a need to handle errors differently,
|
||||||
you should supply a replacement error function and use png_set_error_fn()
|
* you should supply a replacement error function and use png_set_error_fn()
|
||||||
to replace the error function at run-time. */
|
* to replace the error function at run-time.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
png_error(png_structp png_ptr, png_const_charp message)
|
png_error(png_structp png_ptr, png_const_charp message)
|
||||||
{
|
{
|
||||||
@@ -36,9 +38,10 @@ png_error(png_structp png_ptr, png_const_charp message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* This function is called whenever there is a non-fatal error. This function
|
/* This function is called whenever there is a non-fatal error. This function
|
||||||
should not be changed. If there is a need to handle warnings differently,
|
* should not be changed. If there is a need to handle warnings differently,
|
||||||
you should supply a replacement warning function and use
|
* you should supply a replacement warning function and use
|
||||||
png_set_error_fn() to replace the warning function at run-time. */
|
* png_set_error_fn() to replace the warning function at run-time.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
png_warning(png_structp png_ptr, png_const_charp message)
|
png_warning(png_structp png_ptr, png_const_charp message)
|
||||||
{
|
{
|
||||||
@@ -48,14 +51,69 @@ png_warning(png_structp png_ptr, png_const_charp message)
|
|||||||
png_default_warning(png_ptr, message);
|
png_default_warning(png_ptr, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* These utilities are used internally to build an error message that relates
|
||||||
|
* to the current chunk. The chunk name comes from png_ptr->chunk_name,
|
||||||
|
* this is used to prefix the message. The message is limited in length
|
||||||
|
* to 63 bytes, the name characters are output as hex digits wrapped in []
|
||||||
|
* if the character is invalid.
|
||||||
|
*/
|
||||||
|
#define isnonalpha(c) ((c) < 41 || (c) > 122 || ((c) > 90 && (c) < 97))
|
||||||
|
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
|
||||||
|
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp message)
|
||||||
|
{
|
||||||
|
int iout = 0, iin = 0;
|
||||||
|
|
||||||
|
while (iin < 4) {
|
||||||
|
int c = png_ptr->chunk_name[iin++];
|
||||||
|
if (isnonalpha(c)) {
|
||||||
|
buffer[iout++] = '[';
|
||||||
|
buffer[iout++] = png_digit[(c & 0xf0) >> 4];
|
||||||
|
buffer[iout++] = png_digit[c & 0xf];
|
||||||
|
buffer[iout++] = ']';
|
||||||
|
} else {
|
||||||
|
buffer[iout++] = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message == NULL)
|
||||||
|
buffer[iout] = 0;
|
||||||
|
else {
|
||||||
|
buffer[iout++] = ':';
|
||||||
|
buffer[iout++] = ' ';
|
||||||
|
png_memcpy(buffer+iout, message, 64);
|
||||||
|
buffer[iout+63] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
png_chunk_error(png_structp png_ptr, png_const_charp message)
|
||||||
|
{
|
||||||
|
char msg[16+64];
|
||||||
|
png_format_buffer(png_ptr, msg, message);
|
||||||
|
png_error(png_ptr, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
png_chunk_warning(png_structp png_ptr, png_const_charp message)
|
||||||
|
{
|
||||||
|
char msg[16+64];
|
||||||
|
png_format_buffer(png_ptr, msg, message);
|
||||||
|
png_warning(png_ptr, msg);
|
||||||
|
}
|
||||||
|
|
||||||
/* This is the default error handling function. Note that replacements for
|
/* This is the default error handling function. Note that replacements for
|
||||||
this function MUST NOT RETURN, or the program will likely crash. This
|
* this function MUST NOT RETURN, or the program will likely crash. This
|
||||||
function is used by default, or if the program supplies NULL for the
|
* function is used by default, or if the program supplies NULL for the
|
||||||
error function pointer in png_set_error_fn(). */
|
* error function pointer in png_set_error_fn().
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
png_default_error(png_structp png_ptr, png_const_charp message)
|
png_default_error(png_structp png_ptr, png_const_charp message)
|
||||||
{
|
{
|
||||||
#ifndef PNG_NO_STDIO
|
#ifndef PNG_NO_CONSOLE_IO
|
||||||
fprintf(stderr, "libpng error: %s\n", message);
|
fprintf(stderr, "libpng error: %s\n", message);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -71,24 +129,25 @@ png_default_error(png_structp png_ptr, png_const_charp message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* This function is called when there is a warning, but the library thinks
|
/* This function is called when there is a warning, but the library thinks
|
||||||
it can continue anyway. Replacement functions don't have to do anything
|
* it can continue anyway. Replacement functions don't have to do anything
|
||||||
here if you don't want to. In the default configuration, png_ptr is
|
* here if you don't want them to. In the default configuration, png_ptr is
|
||||||
not used, but it is passed in case it may be useful. */
|
* not used, but it is passed in case it may be useful.
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
png_default_warning(png_structp png_ptr, png_const_charp message)
|
png_default_warning(png_structp png_ptr, png_const_charp message)
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL)
|
#ifndef PNG_NO_CONSOLE_IO
|
||||||
return;
|
|
||||||
|
|
||||||
#ifndef PNG_NO_STDIO
|
|
||||||
fprintf(stderr, "libpng warning: %s\n", message);
|
fprintf(stderr, "libpng warning: %s\n", message);
|
||||||
#endif
|
#endif
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function is called when the application wants to use another method
|
/* This function is called when the application wants to use another method
|
||||||
of handling errors and warnings. Note that the error function MUST NOT
|
* of handling errors and warnings. Note that the error function MUST NOT
|
||||||
return to the calling routine or serious problems will occur. The return
|
* return to the calling routine or serious problems will occur. The return
|
||||||
method used in the default routine calls longjmp(png_ptr->jmpbuf, 1) */
|
* method used in the default routine calls longjmp(png_ptr->jmpbuf, 1)
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
||||||
png_error_ptr error_fn, png_error_ptr warning_fn)
|
png_error_ptr error_fn, png_error_ptr warning_fn)
|
||||||
@@ -100,12 +159,13 @@ png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
|||||||
|
|
||||||
|
|
||||||
/* This function returns a pointer to the error_ptr associated with the user
|
/* This function returns a pointer to the error_ptr associated with the user
|
||||||
functions. The application should free any memory associated with this
|
* functions. The application should free any memory associated with this
|
||||||
pointer before png_write_destroy and png_read_destroy are called. */
|
* pointer before png_write_destroy and png_read_destroy are called.
|
||||||
|
*/
|
||||||
png_voidp
|
png_voidp
|
||||||
png_get_error_ptr(png_structp png_ptr)
|
png_get_error_ptr(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
return png_ptr->error_ptr;
|
return ((png_voidp)png_ptr->error_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
444
pngget.c
444
pngget.c
@@ -1,12 +1,12 @@
|
|||||||
|
|
||||||
/* pngget.c - retrieval of values from info struct
|
/* pngget.c - retrieval of values from info struct
|
||||||
|
*
|
||||||
libpng 1.0 beta 6 - version 0.96
|
* libpng 1.0.2b - January 6, 1999
|
||||||
For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
May 12, 1997
|
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
png_uint_32
|
png_uint_32
|
||||||
png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
|
png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
|
||||||
{
|
{
|
||||||
if (info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
return(info_ptr->valid & flag);
|
return(info_ptr->valid & flag);
|
||||||
else
|
else
|
||||||
return(0);
|
return(0);
|
||||||
@@ -23,28 +23,307 @@ png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
|
|||||||
png_uint_32
|
png_uint_32
|
||||||
png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
|
png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
if (info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
return(info_ptr->rowbytes);
|
return(info_ptr->rowbytes);
|
||||||
else
|
else
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_EASY_ACCESS_SUPPORTED
|
||||||
|
/* easy access to info, added in libpng-0.99 */
|
||||||
|
png_uint_32
|
||||||
|
png_get_image_width(png_structp png_ptr, png_infop info_ptr)
|
||||||
|
{
|
||||||
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
|
{
|
||||||
|
return info_ptr->width;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
png_uint_32
|
||||||
|
png_get_image_height(png_structp png_ptr, png_infop info_ptr)
|
||||||
|
{
|
||||||
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
|
{
|
||||||
|
return info_ptr->height;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
png_byte
|
||||||
|
png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
|
||||||
|
{
|
||||||
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
|
{
|
||||||
|
return info_ptr->bit_depth;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
png_byte
|
||||||
|
png_get_color_type(png_structp png_ptr, png_infop info_ptr)
|
||||||
|
{
|
||||||
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
|
{
|
||||||
|
return info_ptr->color_type;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
png_byte
|
||||||
|
png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
|
||||||
|
{
|
||||||
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
|
{
|
||||||
|
return info_ptr->filter_type;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
png_byte
|
||||||
|
png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
|
||||||
|
{
|
||||||
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
|
{
|
||||||
|
return info_ptr->interlace_type;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
png_byte
|
||||||
|
png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
|
||||||
|
{
|
||||||
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
|
{
|
||||||
|
return info_ptr->compression_type;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
png_uint_32
|
||||||
|
png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||||
|
{
|
||||||
|
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
|
||||||
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||||
|
{
|
||||||
|
png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter");
|
||||||
|
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
|
||||||
|
return (0);
|
||||||
|
else return (info_ptr->x_pixels_per_unit);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
png_uint_32
|
||||||
|
png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||||
|
{
|
||||||
|
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
|
||||||
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||||
|
{
|
||||||
|
png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter");
|
||||||
|
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
|
||||||
|
return (0);
|
||||||
|
else return (info_ptr->y_pixels_per_unit);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
png_uint_32
|
||||||
|
png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||||
|
{
|
||||||
|
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
|
||||||
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||||
|
{
|
||||||
|
png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter");
|
||||||
|
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
|
||||||
|
info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
|
||||||
|
return (0);
|
||||||
|
else return (info_ptr->x_pixels_per_unit);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
float
|
||||||
|
png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
|
||||||
|
{
|
||||||
|
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
|
||||||
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||||
|
{
|
||||||
|
png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio");
|
||||||
|
if (info_ptr->x_pixels_per_unit == 0)
|
||||||
|
return ((float)0.0);
|
||||||
|
else
|
||||||
|
return ((float)info_ptr->y_pixels_per_unit
|
||||||
|
/(float)info_ptr->x_pixels_per_unit);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
return ((float)0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
png_uint_32
|
||||||
|
png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
||||||
|
{
|
||||||
|
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||||
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||||
|
{
|
||||||
|
png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
|
||||||
|
if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
||||||
|
return (0);
|
||||||
|
else return (info_ptr->x_offset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
png_uint_32
|
||||||
|
png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
||||||
|
{
|
||||||
|
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||||
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||||
|
{
|
||||||
|
png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
|
||||||
|
if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
||||||
|
return (0);
|
||||||
|
else return (info_ptr->y_offset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
png_uint_32
|
||||||
|
png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
||||||
|
{
|
||||||
|
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||||
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||||
|
{
|
||||||
|
png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
|
||||||
|
if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
||||||
|
return (0);
|
||||||
|
else return (info_ptr->x_offset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
png_uint_32
|
||||||
|
png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
||||||
|
{
|
||||||
|
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||||
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||||
|
{
|
||||||
|
png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
|
||||||
|
if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
||||||
|
return (0);
|
||||||
|
else return (info_ptr->y_offset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_INCH_CONVERSIONS
|
||||||
|
png_uint_32
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
png_uint_32
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
png_uint_32
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
float
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
float
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(PNG_READ_pHYs_SUPPORTED)
|
||||||
|
png_uint_32
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
png_debug1(1, "in %s retrieval function\n", "pHYs");
|
||||||
|
if (res_x != NULL)
|
||||||
|
{
|
||||||
|
*res_x = info_ptr->x_pixels_per_unit;
|
||||||
|
retval |= PNG_INFO_pHYs;
|
||||||
|
}
|
||||||
|
if (res_y != NULL)
|
||||||
|
{
|
||||||
|
*res_y = info_ptr->y_pixels_per_unit;
|
||||||
|
retval |= PNG_INFO_pHYs;
|
||||||
|
}
|
||||||
|
if (unit_type != NULL)
|
||||||
|
{
|
||||||
|
*unit_type = (int)info_ptr->phys_unit_type;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (retval);
|
||||||
|
}
|
||||||
|
#endif /* PNG_READ_pHYs_SUPPORTED */
|
||||||
|
#endif /* PNG_INCH_CONVERSIONS */
|
||||||
|
|
||||||
|
/* png_get_channels really belongs in here, too, but it's been around longer */
|
||||||
|
|
||||||
|
#endif /* PNG_EASY_ACCESS_SUPPORTED */
|
||||||
|
|
||||||
png_byte
|
png_byte
|
||||||
png_get_channels(png_structp png_ptr, png_infop info_ptr)
|
png_get_channels(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
if (info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
return(info_ptr->channels);
|
return(info_ptr->channels);
|
||||||
else
|
else
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
png_bytep
|
png_bytep
|
||||||
png_get_signature(png_structp png_ptr, png_infop info_ptr)
|
png_get_signature(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
if (info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
return(info_ptr->signature);
|
return(info_ptr->signature);
|
||||||
else
|
else
|
||||||
return(NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PNG_READ_bKGD_SUPPORTED)
|
#if defined(PNG_READ_bKGD_SUPPORTED)
|
||||||
@@ -52,8 +331,8 @@ png_uint_32
|
|||||||
png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
|
png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
|
||||||
png_color_16p *background)
|
png_color_16p *background)
|
||||||
{
|
{
|
||||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_bKGD &&
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
|
||||||
background != NULL)
|
&& background != NULL)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function\n", "bKGD");
|
png_debug1(1, "in %s retrieval function\n", "bKGD");
|
||||||
*background = &(info_ptr->background);
|
*background = &(info_ptr->background);
|
||||||
@@ -69,7 +348,7 @@ png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
|
|||||||
double *white_x, double *white_y, double *red_x, double *red_y,
|
double *white_x, double *white_y, double *red_x, double *red_y,
|
||||||
double *green_x, double *green_y, double *blue_x, double *blue_y)
|
double *green_x, double *green_y, double *blue_x, double *blue_y)
|
||||||
{
|
{
|
||||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_cHRM)
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function\n", "cHRM");
|
png_debug1(1, "in %s retrieval function\n", "cHRM");
|
||||||
if (white_x != NULL)
|
if (white_x != NULL)
|
||||||
@@ -98,8 +377,8 @@ png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
|
|||||||
png_uint_32
|
png_uint_32
|
||||||
png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
|
png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
|
||||||
{
|
{
|
||||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_gAMA &&
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
|
||||||
file_gamma != NULL)
|
&& file_gamma != NULL)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function\n", "gAMA");
|
png_debug1(1, "in %s retrieval function\n", "gAMA");
|
||||||
*file_gamma = (double)info_ptr->gamma;
|
*file_gamma = (double)info_ptr->gamma;
|
||||||
@@ -109,11 +388,27 @@ png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||||
|
png_uint_32
|
||||||
|
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)
|
||||||
|
&& file_srgb_intent != NULL)
|
||||||
|
{
|
||||||
|
png_debug1(1, "in %s retrieval function\n", "sRGB");
|
||||||
|
*file_srgb_intent = (int)info_ptr->srgb_intent;
|
||||||
|
return (PNG_INFO_sRGB);
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||||
png_uint_32
|
png_uint_32
|
||||||
png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
|
png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
|
||||||
{
|
{
|
||||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_hIST && hist != NULL)
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
|
||||||
|
&& hist != NULL)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function\n", "hIST");
|
png_debug1(1, "in %s retrieval function\n", "hIST");
|
||||||
*hist = info_ptr->hist;
|
*hist = info_ptr->hist;
|
||||||
@@ -128,11 +423,14 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
|
|||||||
png_uint_32 *width, png_uint_32 *height, int *bit_depth,
|
png_uint_32 *width, png_uint_32 *height, int *bit_depth,
|
||||||
int *color_type, int *interlace_type, int *compression_type,
|
int *color_type, int *interlace_type, int *compression_type,
|
||||||
int *filter_type)
|
int *filter_type)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (info_ptr != NULL && width != NULL && height != NULL &&
|
if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL &&
|
||||||
bit_depth != NULL && color_type != NULL)
|
bit_depth != NULL && color_type != NULL)
|
||||||
{
|
{
|
||||||
|
int pixel_depth, channels;
|
||||||
|
png_uint_32 rowbytes_per_pixel;
|
||||||
|
|
||||||
png_debug1(1, "in %s retrieval function\n", "IHDR");
|
png_debug1(1, "in %s retrieval function\n", "IHDR");
|
||||||
*width = info_ptr->width;
|
*width = info_ptr->width;
|
||||||
*height = info_ptr->height;
|
*height = info_ptr->height;
|
||||||
@@ -144,6 +442,23 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
|
|||||||
*filter_type = info_ptr->filter_type;
|
*filter_type = info_ptr->filter_type;
|
||||||
if (interlace_type != NULL)
|
if (interlace_type != NULL)
|
||||||
*interlace_type = info_ptr->interlace_type;
|
*interlace_type = info_ptr->interlace_type;
|
||||||
|
|
||||||
|
/* check for potential overflow of rowbytes */
|
||||||
|
if (*color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
|
channels = 1;
|
||||||
|
else if (*color_type & PNG_COLOR_MASK_COLOR)
|
||||||
|
channels = 3;
|
||||||
|
else
|
||||||
|
channels = 1;
|
||||||
|
if (*color_type & PNG_COLOR_MASK_ALPHA)
|
||||||
|
channels++;
|
||||||
|
pixel_depth = *bit_depth * channels;
|
||||||
|
rowbytes_per_pixel = (pixel_depth + 7) >> 3;
|
||||||
|
if ((*width > (png_uint_32)2147483647L/rowbytes_per_pixel))
|
||||||
|
{
|
||||||
|
png_warning(png_ptr,
|
||||||
|
"Width too large for libpng to process image data.");
|
||||||
|
}
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
@@ -154,8 +469,8 @@ png_uint_32
|
|||||||
png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
|
png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
|
||||||
png_uint_32 *offset_x, png_uint_32 *offset_y, int *unit_type)
|
png_uint_32 *offset_x, png_uint_32 *offset_y, int *unit_type)
|
||||||
{
|
{
|
||||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_oFFs &&
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
|
||||||
offset_x != NULL && offset_y != NULL && unit_type != NULL)
|
&& offset_x != NULL && offset_y != NULL && unit_type != NULL)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function\n", "oFFs");
|
png_debug1(1, "in %s retrieval function\n", "oFFs");
|
||||||
*offset_x = info_ptr->x_offset;
|
*offset_x = info_ptr->x_offset;
|
||||||
@@ -173,7 +488,7 @@ png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
|
|||||||
png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
|
png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
|
||||||
png_charp *units, png_charpp *params)
|
png_charp *units, png_charpp *params)
|
||||||
{
|
{
|
||||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_pCAL &&
|
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_pCAL &&
|
||||||
purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
|
purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
|
||||||
nparams != NULL && units != NULL && params != NULL)
|
nparams != NULL && units != NULL && params != NULL)
|
||||||
{
|
{
|
||||||
@@ -196,16 +511,28 @@ png_uint_32
|
|||||||
png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
|
png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
|
||||||
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
|
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
|
||||||
{
|
{
|
||||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_pHYs &&
|
png_uint_32 retval = 0;
|
||||||
res_x != NULL && res_y != NULL && unit_type != NULL)
|
|
||||||
|
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_pHYs)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function\n", "pHYs");
|
png_debug1(1, "in %s retrieval function\n", "pHYs");
|
||||||
*res_x = info_ptr->x_pixels_per_unit;
|
if (res_x != NULL)
|
||||||
*res_y = info_ptr->y_pixels_per_unit;
|
{
|
||||||
*unit_type = (int)info_ptr->phys_unit_type;
|
*res_x = info_ptr->x_pixels_per_unit;
|
||||||
return (PNG_INFO_pHYs);
|
retval |= PNG_INFO_pHYs;
|
||||||
|
}
|
||||||
|
if (res_y != NULL)
|
||||||
|
{
|
||||||
|
*res_y = info_ptr->y_pixels_per_unit;
|
||||||
|
retval |= PNG_INFO_pHYs;
|
||||||
|
}
|
||||||
|
if (unit_type != NULL)
|
||||||
|
{
|
||||||
|
*unit_type = (int)info_ptr->phys_unit_type;
|
||||||
|
retval |= PNG_INFO_pHYs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return (0);
|
return (retval);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -213,7 +540,8 @@ png_uint_32
|
|||||||
png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
|
png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
|
||||||
int *num_palette)
|
int *num_palette)
|
||||||
{
|
{
|
||||||
if (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");
|
png_debug1(1, "in %s retrieval function\n", "PLTE");
|
||||||
*palette = info_ptr->palette;
|
*palette = info_ptr->palette;
|
||||||
@@ -228,7 +556,8 @@ png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
|
|||||||
png_uint_32
|
png_uint_32
|
||||||
png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
|
png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
|
||||||
{
|
{
|
||||||
if (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");
|
png_debug1(1, "in %s retrieval function\n", "sBIT");
|
||||||
*sig_bit = &(info_ptr->sig_bit);
|
*sig_bit = &(info_ptr->sig_bit);
|
||||||
@@ -243,15 +572,16 @@ png_uint_32
|
|||||||
png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
|
png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
|
||||||
int *num_text)
|
int *num_text)
|
||||||
{
|
{
|
||||||
if ((info_ptr != NULL) || (info_ptr->num_text > 0))
|
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function\n",
|
png_debug1(1, "in %s retrieval function\n",
|
||||||
(png_ptr->chunk_name[0] == '\0' ? "text" : png_ptr->chunk_name));
|
(png_ptr->chunk_name[0] == '\0' ? "text"
|
||||||
|
: (png_const_charp)png_ptr->chunk_name));
|
||||||
if (text_ptr != NULL)
|
if (text_ptr != NULL)
|
||||||
*text_ptr = info_ptr->text;
|
*text_ptr = info_ptr->text;
|
||||||
if (num_text != NULL)
|
if (num_text != NULL)
|
||||||
*num_text = info_ptr->num_text;
|
*num_text = info_ptr->num_text;
|
||||||
return (info_ptr->num_text);
|
return ((png_uint_32)info_ptr->num_text);
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
@@ -261,7 +591,8 @@ png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
|
|||||||
png_uint_32
|
png_uint_32
|
||||||
png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
|
png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
|
||||||
{
|
{
|
||||||
if (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");
|
png_debug1(1, "in %s retrieval function\n", "tIME");
|
||||||
*mod_time = &(info_ptr->mod_time);
|
*mod_time = &(info_ptr->mod_time);
|
||||||
@@ -276,25 +607,44 @@ png_uint_32
|
|||||||
png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
|
png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||||
png_bytep *trans, int *num_trans, png_color_16p *trans_values)
|
png_bytep *trans, int *num_trans, png_color_16p *trans_values)
|
||||||
{
|
{
|
||||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_tRNS)
|
png_uint_32 retval = 0;
|
||||||
|
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_tRNS)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function\n", "tRNS");
|
png_debug1(1, "in %s retrieval function\n", "tRNS");
|
||||||
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE && trans != NULL)
|
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
{
|
{
|
||||||
*trans = info_ptr->trans;
|
if (trans != NULL)
|
||||||
|
{
|
||||||
|
*trans = info_ptr->trans;
|
||||||
|
retval |= PNG_INFO_tRNS;
|
||||||
|
}
|
||||||
|
if (trans_values != NULL)
|
||||||
|
*trans_values = &(info_ptr->trans_values);
|
||||||
}
|
}
|
||||||
else if (trans_values != NULL)
|
else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
|
||||||
{
|
{
|
||||||
*trans_values = &(info_ptr->trans_values);
|
if (trans_values != NULL)
|
||||||
|
{
|
||||||
|
*trans_values = &(info_ptr->trans_values);
|
||||||
|
retval |= PNG_INFO_tRNS;
|
||||||
|
}
|
||||||
|
if(trans != NULL)
|
||||||
|
*trans = NULL;
|
||||||
}
|
}
|
||||||
else
|
if(num_trans != NULL)
|
||||||
{
|
{
|
||||||
return (0);
|
*num_trans = info_ptr->num_trans;
|
||||||
|
retval |= PNG_INFO_tRNS;
|
||||||
}
|
}
|
||||||
*num_trans = info_ptr->num_trans;
|
|
||||||
return (PNG_INFO_tRNS);
|
|
||||||
}
|
}
|
||||||
return (0);
|
return (retval);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||||
|
png_byte
|
||||||
|
png_get_rgb_to_gray_status (png_structp png_ptr)
|
||||||
|
{
|
||||||
|
return png_ptr->rgb_to_gray_status;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
260
pngmem.c
260
pngmem.c
@@ -1,15 +1,18 @@
|
|||||||
|
|
||||||
/* pngmem.c - stub functions for memory allocation
|
/* pngmem.c - stub functions for memory allocation
|
||||||
|
*
|
||||||
libpng 1.0 beta 6 - version 0.96
|
* libpng 1.0.2b - January 6, 1999
|
||||||
For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
May 12, 1997
|
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||||
|
*
|
||||||
This file provides a location for all memory allocation. Users which
|
* This file provides a location for all memory allocation. Users who
|
||||||
need special memory handling are expected to modify the code in this file
|
* need special memory handling are expected to supply replacement
|
||||||
to meet their needs. See the instructions at each function. */
|
* functions for png_malloc() and png_free(), and to use
|
||||||
|
* png_create_read_struct_2() and png_create_write_struct_2() to
|
||||||
|
* identify the replacement functions.
|
||||||
|
*/
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
@@ -23,6 +26,15 @@
|
|||||||
png_voidp
|
png_voidp
|
||||||
png_create_struct(int type)
|
png_create_struct(int type)
|
||||||
{
|
{
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
return (png_create_struct_2(type, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Alternate version of png_create_struct, for use with user-defined malloc. */
|
||||||
|
png_voidp
|
||||||
|
png_create_struct_2(int type, png_malloc_ptr malloc_fn)
|
||||||
|
{
|
||||||
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
png_size_t size;
|
png_size_t size;
|
||||||
png_voidp struct_ptr;
|
png_voidp struct_ptr;
|
||||||
|
|
||||||
@@ -31,13 +43,20 @@ png_create_struct(int type)
|
|||||||
else if (type == PNG_STRUCT_PNG)
|
else if (type == PNG_STRUCT_PNG)
|
||||||
size = sizeof(png_struct);
|
size = sizeof(png_struct);
|
||||||
else
|
else
|
||||||
return (png_voidp)NULL;
|
return ((png_voidp)NULL);
|
||||||
|
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
if(malloc_fn != NULL)
|
||||||
|
{
|
||||||
|
if ((struct_ptr = (*(malloc_fn))(NULL, size)) != NULL)
|
||||||
|
png_memset(struct_ptr, 0, size);
|
||||||
|
return (struct_ptr);
|
||||||
|
}
|
||||||
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL)
|
if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL)
|
||||||
{
|
{
|
||||||
png_memset(struct_ptr, 0, size);
|
png_memset(struct_ptr, 0, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (struct_ptr);
|
return (struct_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,8 +65,30 @@ png_create_struct(int type)
|
|||||||
void
|
void
|
||||||
png_destroy_struct(png_voidp struct_ptr)
|
png_destroy_struct(png_voidp struct_ptr)
|
||||||
{
|
{
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free memory allocated by a png_create_struct() call */
|
||||||
|
void
|
||||||
|
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
|
||||||
|
{
|
||||||
|
#endif
|
||||||
if (struct_ptr != NULL)
|
if (struct_ptr != NULL)
|
||||||
|
{
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
if(free_fn != NULL)
|
||||||
|
{
|
||||||
|
png_struct dummy_struct;
|
||||||
|
png_structp png_ptr = &dummy_struct;
|
||||||
|
(*(free_fn))(png_ptr, struct_ptr);
|
||||||
|
struct_ptr = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
farfree (struct_ptr);
|
farfree (struct_ptr);
|
||||||
|
struct_ptr = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate memory. For reasonable files, size should never exceed
|
/* Allocate memory. For reasonable files, size should never exceed
|
||||||
@@ -57,7 +98,7 @@ png_destroy_struct(png_voidp struct_ptr)
|
|||||||
* have the ability to do that.
|
* have the ability to do that.
|
||||||
*
|
*
|
||||||
* Borland seems to have a problem in DOS mode for exactly 64K.
|
* Borland seems to have a problem in DOS mode for exactly 64K.
|
||||||
* It gives you a segment with an offset of 8 (perhaps to store it's
|
* It gives you a segment with an offset of 8 (perhaps to store its
|
||||||
* memory stuff). zlib doesn't like this at all, so we have to
|
* memory stuff). zlib doesn't like this at all, so we have to
|
||||||
* detect and deal with it. This code should not be needed in
|
* detect and deal with it. This code should not be needed in
|
||||||
* Windows or OS/2 modes, and only in 16 bit mode. This code has
|
* Windows or OS/2 modes, and only in 16 bit mode. This code has
|
||||||
@@ -72,16 +113,31 @@ png_destroy_struct(png_voidp struct_ptr)
|
|||||||
png_voidp
|
png_voidp
|
||||||
png_malloc(png_structp png_ptr, png_uint_32 size)
|
png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||||
{
|
{
|
||||||
|
#ifndef PNG_USER_MEM_SUPPORTED
|
||||||
png_voidp ret;
|
png_voidp ret;
|
||||||
|
#endif
|
||||||
if (png_ptr == NULL || size == 0)
|
if (png_ptr == NULL || size == 0)
|
||||||
return ((voidp)NULL);
|
return ((png_voidp)NULL);
|
||||||
|
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
if(png_ptr->malloc_fn != NULL)
|
||||||
|
return ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
|
||||||
|
else
|
||||||
|
return png_malloc_default(png_ptr, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
png_voidp
|
||||||
|
png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
||||||
|
{
|
||||||
|
png_voidp ret;
|
||||||
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
|
|
||||||
#ifdef PNG_MAX_MALLOC_64K
|
#ifdef PNG_MAX_MALLOC_64K
|
||||||
if (size > (png_uint_32)65536L)
|
if (size > (png_uint_32)65536L)
|
||||||
png_error(png_ptr, "Cannot Allocate > 64K");
|
png_error(png_ptr, "Cannot Allocate > 64K");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (size == (png_uint_32)(65536L))
|
if (size == (png_uint_32)65536L)
|
||||||
{
|
{
|
||||||
if (png_ptr->offset_table == NULL)
|
if (png_ptr->offset_table == NULL)
|
||||||
{
|
{
|
||||||
@@ -96,8 +152,10 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
|||||||
png_byte huge * hptr;
|
png_byte huge * hptr;
|
||||||
|
|
||||||
if (ret != NULL)
|
if (ret != NULL)
|
||||||
|
{
|
||||||
farfree(ret);
|
farfree(ret);
|
||||||
ret = NULL;
|
ret = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14));
|
num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14));
|
||||||
if (num_blocks < 1)
|
if (num_blocks < 1)
|
||||||
@@ -113,7 +171,7 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
|||||||
|
|
||||||
if (table == NULL)
|
if (table == NULL)
|
||||||
{
|
{
|
||||||
png_error(png_ptr, "Out of Memory");
|
png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((png_size_t)table & 0xfff0)
|
if ((png_size_t)table & 0xfff0)
|
||||||
@@ -127,7 +185,7 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
|||||||
|
|
||||||
if (png_ptr->offset_table_ptr == NULL)
|
if (png_ptr->offset_table_ptr == NULL)
|
||||||
{
|
{
|
||||||
png_error(png_ptr, "Out of memory");
|
png_error(png_ptr, "Out Of memory.");
|
||||||
}
|
}
|
||||||
|
|
||||||
hptr = (png_byte huge *)table;
|
hptr = (png_byte huge *)table;
|
||||||
@@ -139,7 +197,7 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
|||||||
for (i = 0; i < num_blocks; i++)
|
for (i = 0; i < num_blocks; i++)
|
||||||
{
|
{
|
||||||
png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
|
png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
|
||||||
hptr += 65536L;
|
hptr += (png_uint_32)65536L;
|
||||||
}
|
}
|
||||||
|
|
||||||
png_ptr->offset_table_number = num_blocks;
|
png_ptr->offset_table_number = num_blocks;
|
||||||
@@ -149,7 +207,7 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (png_ptr->offset_table_count >= png_ptr->offset_table_number)
|
if (png_ptr->offset_table_count >= png_ptr->offset_table_number)
|
||||||
png_error(png_ptr, "Out of Memory");
|
png_error(png_ptr, "Out of Memory.");
|
||||||
|
|
||||||
ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++];
|
ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++];
|
||||||
}
|
}
|
||||||
@@ -158,10 +216,10 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
|||||||
|
|
||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
{
|
{
|
||||||
png_error(png_ptr, "Out of Memory");
|
png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free a pointer allocated by png_malloc(). In the default
|
/* free a pointer allocated by png_malloc(). In the default
|
||||||
@@ -173,6 +231,21 @@ png_free(png_structp png_ptr, png_voidp ptr)
|
|||||||
if (png_ptr == NULL || ptr == NULL)
|
if (png_ptr == NULL || ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
if (png_ptr->free_fn != NULL)
|
||||||
|
{
|
||||||
|
(*(png_ptr->free_fn))(png_ptr, ptr);
|
||||||
|
ptr = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else png_free_default(png_ptr, ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||||
|
{
|
||||||
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
|
|
||||||
if (png_ptr->offset_table != NULL)
|
if (png_ptr->offset_table != NULL)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -196,7 +269,10 @@ png_free(png_structp png_ptr, png_voidp ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ptr != NULL)
|
if (ptr != NULL)
|
||||||
|
{
|
||||||
farfree(ptr);
|
farfree(ptr);
|
||||||
|
ptr = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* Not the Borland DOS special memory handler */
|
#else /* Not the Borland DOS special memory handler */
|
||||||
@@ -207,6 +283,17 @@ png_free(png_structp png_ptr, png_voidp ptr)
|
|||||||
png_voidp
|
png_voidp
|
||||||
png_create_struct(int type)
|
png_create_struct(int type)
|
||||||
{
|
{
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
return (png_create_struct_2(type, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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_create_struct_2(int type, png_malloc_ptr malloc_fn)
|
||||||
|
{
|
||||||
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
png_size_t size;
|
png_size_t size;
|
||||||
png_voidp struct_ptr;
|
png_voidp struct_ptr;
|
||||||
|
|
||||||
@@ -215,7 +302,16 @@ png_create_struct(int type)
|
|||||||
else if (type == PNG_STRUCT_PNG)
|
else if (type == PNG_STRUCT_PNG)
|
||||||
size = sizeof(png_struct);
|
size = sizeof(png_struct);
|
||||||
else
|
else
|
||||||
return (png_voidp)NULL;
|
return ((png_voidp)NULL);
|
||||||
|
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
if(malloc_fn != NULL)
|
||||||
|
{
|
||||||
|
if ((struct_ptr = (*(malloc_fn))(NULL, size)) != NULL)
|
||||||
|
png_memset(struct_ptr, 0, size);
|
||||||
|
return (struct_ptr);
|
||||||
|
}
|
||||||
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
|
|
||||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||||
if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL)
|
if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL)
|
||||||
@@ -238,16 +334,40 @@ png_create_struct(int type)
|
|||||||
void
|
void
|
||||||
png_destroy_struct(png_voidp struct_ptr)
|
png_destroy_struct(png_voidp struct_ptr)
|
||||||
{
|
{
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free memory allocated by a png_create_struct() call */
|
||||||
|
void
|
||||||
|
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
|
||||||
|
{
|
||||||
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
if (struct_ptr != NULL)
|
if (struct_ptr != NULL)
|
||||||
|
{
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
if(free_fn != NULL)
|
||||||
|
{
|
||||||
|
png_struct dummy_struct;
|
||||||
|
png_structp png_ptr = &dummy_struct;
|
||||||
|
(*(free_fn))(png_ptr, struct_ptr);
|
||||||
|
struct_ptr = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||||
farfree(struct_ptr);
|
farfree(struct_ptr);
|
||||||
|
struct_ptr = NULL;
|
||||||
#else
|
#else
|
||||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||||
hfree(struct_ptr);
|
hfree(struct_ptr);
|
||||||
|
struct_ptr = NULL;
|
||||||
# else
|
# else
|
||||||
free(struct_ptr);
|
free(struct_ptr);
|
||||||
|
struct_ptr = NULL;
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -260,9 +380,23 @@ png_destroy_struct(png_voidp struct_ptr)
|
|||||||
png_voidp
|
png_voidp
|
||||||
png_malloc(png_structp png_ptr, png_uint_32 size)
|
png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||||
{
|
{
|
||||||
|
#ifndef PNG_USER_MEM_SUPPORTED
|
||||||
png_voidp ret;
|
png_voidp ret;
|
||||||
|
#endif
|
||||||
if (png_ptr == NULL || size == 0)
|
if (png_ptr == NULL || size == 0)
|
||||||
return (NULL);
|
return ((png_voidp)NULL);
|
||||||
|
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
if(png_ptr->malloc_fn != NULL)
|
||||||
|
return ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
|
||||||
|
else
|
||||||
|
return (png_malloc_default(png_ptr, size));
|
||||||
|
}
|
||||||
|
png_voidp
|
||||||
|
png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
||||||
|
{
|
||||||
|
png_voidp ret;
|
||||||
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
|
|
||||||
#ifdef PNG_MAX_MALLOC_64K
|
#ifdef PNG_MAX_MALLOC_64K
|
||||||
if (size > (png_uint_32)65536L)
|
if (size > (png_uint_32)65536L)
|
||||||
@@ -270,12 +404,12 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||||
ret = farmalloc((png_size_t)size);
|
ret = farmalloc(size);
|
||||||
#else
|
#else
|
||||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||||
ret = halloc(size, 1);
|
ret = halloc(size, 1);
|
||||||
# else
|
# else
|
||||||
ret = malloc(size);
|
ret = malloc((size_t)size);
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -284,28 +418,94 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
|||||||
png_error(png_ptr, "Out of Memory");
|
png_error(png_ptr, "Out of Memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free a pointer allocated by png_malloc(). In the default
|
/* Free a pointer allocated by png_malloc(). If ptr is NULL, return
|
||||||
configuration, png_ptr is not used, but is passed in case it
|
without taking any action. */
|
||||||
is needed. If ptr is NULL, return without taking any action. */
|
|
||||||
void
|
void
|
||||||
png_free(png_structp png_ptr, png_voidp ptr)
|
png_free(png_structp png_ptr, png_voidp ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL || ptr == NULL)
|
if (png_ptr == NULL || ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
if (png_ptr->free_fn != NULL)
|
||||||
|
{
|
||||||
|
(*(png_ptr->free_fn))(png_ptr, ptr);
|
||||||
|
ptr = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else png_free_default(png_ptr, ptr);
|
||||||
|
}
|
||||||
|
void
|
||||||
|
png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||||
|
{
|
||||||
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
|
|
||||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||||
farfree(ptr);
|
farfree(ptr);
|
||||||
|
ptr = NULL;
|
||||||
#else
|
#else
|
||||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||||
hfree(ptr);
|
hfree(ptr);
|
||||||
|
ptr = NULL;
|
||||||
# else
|
# else
|
||||||
free(ptr);
|
free(ptr);
|
||||||
|
ptr = NULL;
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Not Borland DOS special memory handler */
|
#endif /* Not Borland DOS special memory handler */
|
||||||
|
|
||||||
|
png_voidp
|
||||||
|
png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2,
|
||||||
|
png_uint_32 length)
|
||||||
|
{
|
||||||
|
png_size_t size;
|
||||||
|
|
||||||
|
size = (png_size_t)length;
|
||||||
|
if ((png_uint_32)size != length)
|
||||||
|
png_error(png_ptr,"Overflow in png_memcpy_check.");
|
||||||
|
|
||||||
|
return(png_memcpy (s1, s2, size));
|
||||||
|
}
|
||||||
|
|
||||||
|
png_voidp
|
||||||
|
png_memset_check (png_structp png_ptr, png_voidp s1, int value,
|
||||||
|
png_uint_32 length)
|
||||||
|
{
|
||||||
|
png_size_t size;
|
||||||
|
|
||||||
|
size = (png_size_t)length;
|
||||||
|
if ((png_uint_32)size != length)
|
||||||
|
png_error(png_ptr,"Overflow in png_memset_check.");
|
||||||
|
|
||||||
|
return (png_memset (s1, value, size));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
/* This function is called when the application wants to use another method
|
||||||
|
* of allocating and freeing memory.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||||
|
malloc_fn, png_free_ptr free_fn)
|
||||||
|
{
|
||||||
|
png_ptr->mem_ptr = mem_ptr;
|
||||||
|
png_ptr->malloc_fn = malloc_fn;
|
||||||
|
png_ptr->free_fn = free_fn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This function returns a pointer to the mem_ptr associated with the user
|
||||||
|
* functions. The application should free any memory associated with this
|
||||||
|
* pointer before png_write_destroy and png_read_destroy are called.
|
||||||
|
*/
|
||||||
|
png_voidp
|
||||||
|
png_get_mem_ptr(png_structp png_ptr)
|
||||||
|
{
|
||||||
|
return ((png_voidp)png_ptr->mem_ptr);
|
||||||
|
}
|
||||||
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
|
|||||||
169
pngpread.c
169
pngpread.c
@@ -1,12 +1,12 @@
|
|||||||
|
|
||||||
/* pngpread.c - read a png file in push mode
|
/* pngpread.c - read a png file in push mode
|
||||||
|
*
|
||||||
libpng 1.0 beta 6 - version 0.96
|
* libpng 1.0.2b - January 6, 1999
|
||||||
For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
May 12, 1997
|
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
@@ -77,8 +77,9 @@ png_process_some_data(png_structp png_ptr, png_infop info_ptr)
|
|||||||
|
|
||||||
/* Read any remaining signature bytes from the stream and compare them with
|
/* Read any remaining signature bytes from the stream and compare them with
|
||||||
* the correct PNG signature. It is possible that this routine is called
|
* the correct PNG signature. It is possible that this routine is called
|
||||||
* with bytes already read from the signature, whether because they have been
|
* with bytes already read from the signature, either because they have been
|
||||||
* checked by the calling application, or from multiple calls to this routine.
|
* checked by the calling application, or because of multiple calls to this
|
||||||
|
* routine.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
|
png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
|
||||||
@@ -91,7 +92,7 @@ png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
|
|||||||
num_to_check = png_ptr->buffer_size;
|
num_to_check = png_ptr->buffer_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]),
|
png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]),
|
||||||
num_to_check);
|
num_to_check);
|
||||||
png_ptr->sig_bytes += num_to_check;
|
png_ptr->sig_bytes += num_to_check;
|
||||||
|
|
||||||
@@ -116,10 +117,11 @@ void
|
|||||||
png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
/* First we make sure we have enough data for the 4 byte chunk name
|
/* First we make sure we have enough data for the 4 byte chunk name
|
||||||
and the 4 byte chunk length before proceeding with decoding the
|
* and the 4 byte chunk length before proceeding with decoding the
|
||||||
chunk data. To fully decode each of these chunks, we also make
|
* chunk data. To fully decode each of these chunks, we also make
|
||||||
sure we have enough data in the buffer for the 4 byte CRC at the
|
* sure we have enough data in the buffer for the 4 byte CRC at the
|
||||||
end of every chunk (except IDAT, which is handled separately). */
|
* end of every chunk (except IDAT, which is handled separately).
|
||||||
|
*/
|
||||||
if (!(png_ptr->flags & PNG_FLAG_HAVE_CHUNK_HEADER))
|
if (!(png_ptr->flags & PNG_FLAG_HAVE_CHUNK_HEADER))
|
||||||
{
|
{
|
||||||
png_byte chunk_length[4];
|
png_byte chunk_length[4];
|
||||||
@@ -160,8 +162,9 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
|||||||
else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||||
{
|
{
|
||||||
/* If we reach an IDAT chunk, this means we have read all of the
|
/* If we reach an IDAT chunk, this means we have read all of the
|
||||||
header chunks, and we can start reading the image (or if this
|
* header chunks, and we can start reading the image (or if this
|
||||||
is called after the image has been read - we have an error). */
|
* is called after the image has been read - we have an error).
|
||||||
|
*/
|
||||||
if (png_ptr->mode & PNG_HAVE_IDAT)
|
if (png_ptr->mode & PNG_HAVE_IDAT)
|
||||||
{
|
{
|
||||||
if (png_ptr->push_length == 0)
|
if (png_ptr->push_length == 0)
|
||||||
@@ -227,6 +230,18 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
|||||||
png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length);
|
png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||||
|
else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4))
|
||||||
|
{
|
||||||
|
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||||
|
{
|
||||||
|
png_push_save_buffer(png_ptr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#if defined(PNG_READ_tRNS_SUPPORTED)
|
#if defined(PNG_READ_tRNS_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4))
|
else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4))
|
||||||
{
|
{
|
||||||
@@ -431,13 +446,13 @@ png_push_save_buffer(png_structp png_ptr)
|
|||||||
{
|
{
|
||||||
if (png_ptr->save_buffer_ptr != png_ptr->save_buffer)
|
if (png_ptr->save_buffer_ptr != png_ptr->save_buffer)
|
||||||
{
|
{
|
||||||
png_size_t i;
|
png_size_t i,istop;
|
||||||
png_bytep sp;
|
png_bytep sp;
|
||||||
png_bytep dp;
|
png_bytep dp;
|
||||||
|
|
||||||
|
istop = png_ptr->save_buffer_size;
|
||||||
for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer;
|
for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer;
|
||||||
i < png_ptr->save_buffer_size;
|
i < istop; i++, sp++, dp++)
|
||||||
i++, sp++, dp++)
|
|
||||||
{
|
{
|
||||||
*dp = *sp;
|
*dp = *sp;
|
||||||
}
|
}
|
||||||
@@ -451,7 +466,8 @@ png_push_save_buffer(png_structp png_ptr)
|
|||||||
|
|
||||||
new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256;
|
new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256;
|
||||||
old_buffer = png_ptr->save_buffer;
|
old_buffer = png_ptr->save_buffer;
|
||||||
png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr, new_max);
|
png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr,
|
||||||
|
(png_uint_32)new_max);
|
||||||
png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
|
png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
|
||||||
png_free(png_ptr, old_buffer);
|
png_free(png_ptr, old_buffer);
|
||||||
png_ptr->save_buffer_max = new_max;
|
png_ptr->save_buffer_max = new_max;
|
||||||
@@ -512,7 +528,12 @@ png_push_read_IDAT(png_structp png_ptr)
|
|||||||
png_size_t save_size;
|
png_size_t save_size;
|
||||||
|
|
||||||
if (png_ptr->idat_size < (png_uint_32)png_ptr->save_buffer_size)
|
if (png_ptr->idat_size < (png_uint_32)png_ptr->save_buffer_size)
|
||||||
save_size = png_ptr->idat_size;
|
{
|
||||||
|
save_size = (png_size_t)png_ptr->idat_size;
|
||||||
|
/* check for overflow */
|
||||||
|
if((png_uint_32)save_size != png_ptr->idat_size)
|
||||||
|
png_error(png_ptr, "save_size overflowed in pngpread");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
save_size = png_ptr->save_buffer_size;
|
save_size = png_ptr->save_buffer_size;
|
||||||
|
|
||||||
@@ -529,7 +550,12 @@ png_push_read_IDAT(png_structp png_ptr)
|
|||||||
png_size_t save_size;
|
png_size_t save_size;
|
||||||
|
|
||||||
if (png_ptr->idat_size < (png_uint_32)png_ptr->current_buffer_size)
|
if (png_ptr->idat_size < (png_uint_32)png_ptr->current_buffer_size)
|
||||||
save_size = png_ptr->idat_size;
|
{
|
||||||
|
save_size = (png_size_t)png_ptr->idat_size;
|
||||||
|
/* check for overflow */
|
||||||
|
if((png_uint_32)save_size != png_ptr->idat_size)
|
||||||
|
png_error(png_ptr, "save_size overflowed in pngpread");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
save_size = png_ptr->current_buffer_size;
|
save_size = png_ptr->current_buffer_size;
|
||||||
|
|
||||||
@@ -565,7 +591,7 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
|
|||||||
|
|
||||||
png_ptr->zstream.next_in = buffer;
|
png_ptr->zstream.next_in = buffer;
|
||||||
png_ptr->zstream.avail_in = (uInt)buffer_length;
|
png_ptr->zstream.avail_in = (uInt)buffer_length;
|
||||||
while(1)
|
for(;;)
|
||||||
{
|
{
|
||||||
ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
|
ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
|
||||||
if (ret == Z_STREAM_END)
|
if (ret == Z_STREAM_END)
|
||||||
@@ -604,6 +630,7 @@ png_push_process_row(png_structp png_ptr)
|
|||||||
png_ptr->row_info.channels = png_ptr->channels;
|
png_ptr->row_info.channels = png_ptr->channels;
|
||||||
png_ptr->row_info.bit_depth = png_ptr->bit_depth;
|
png_ptr->row_info.bit_depth = png_ptr->bit_depth;
|
||||||
png_ptr->row_info.pixel_depth = png_ptr->pixel_depth;
|
png_ptr->row_info.pixel_depth = png_ptr->pixel_depth;
|
||||||
|
|
||||||
png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
|
png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
|
||||||
(png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
|
(png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
|
||||||
|
|
||||||
@@ -611,7 +638,8 @@ png_push_process_row(png_structp png_ptr)
|
|||||||
png_ptr->row_buf + 1, png_ptr->prev_row + 1,
|
png_ptr->row_buf + 1, png_ptr->prev_row + 1,
|
||||||
(int)(png_ptr->row_buf[0]));
|
(int)(png_ptr->row_buf[0]));
|
||||||
|
|
||||||
png_memcpy(png_ptr->prev_row, png_ptr->row_buf, png_ptr->rowbytes + 1);
|
png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf,
|
||||||
|
png_ptr->rowbytes + 1);
|
||||||
|
|
||||||
if (png_ptr->transformations)
|
if (png_ptr->transformations)
|
||||||
png_do_read_transformations(png_ptr);
|
png_do_read_transformations(png_ptr);
|
||||||
@@ -746,30 +774,31 @@ png_read_push_finish_row(png_structp png_ptr)
|
|||||||
if (png_ptr->interlaced)
|
if (png_ptr->interlaced)
|
||||||
{
|
{
|
||||||
png_ptr->row_number = 0;
|
png_ptr->row_number = 0;
|
||||||
png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
png_memset_check(png_ptr, png_ptr->prev_row, 0,
|
||||||
|
png_ptr->rowbytes + 1);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
png_ptr->pass++;
|
png_ptr->pass++;
|
||||||
if (png_ptr->pass >= 7)
|
if (png_ptr->pass >= 7)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
png_ptr->iwidth = (png_ptr->width +
|
png_ptr->iwidth = (png_ptr->width +
|
||||||
png_pass_inc[png_ptr->pass] - 1 -
|
png_pass_inc[png_ptr->pass] - 1 -
|
||||||
png_pass_start[png_ptr->pass]) /
|
png_pass_start[png_ptr->pass]) /
|
||||||
png_pass_inc[png_ptr->pass];
|
png_pass_inc[png_ptr->pass];
|
||||||
|
|
||||||
png_ptr->irowbytes = ((png_ptr->iwidth *
|
png_ptr->irowbytes = ((png_ptr->iwidth *
|
||||||
png_ptr->pixel_depth + 7) >> 3) + 1;
|
png_ptr->pixel_depth + 7) >> 3) + 1;
|
||||||
if (!(png_ptr->transformations & PNG_INTERLACE))
|
|
||||||
{
|
|
||||||
png_ptr->num_rows = (png_ptr->height +
|
|
||||||
png_pass_yinc[png_ptr->pass] - 1 -
|
|
||||||
png_pass_ystart[png_ptr->pass]) /
|
|
||||||
png_pass_yinc[png_ptr->pass];
|
|
||||||
if (!(png_ptr->num_rows))
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (png_ptr->transformations & PNG_INTERLACE)
|
if (png_ptr->transformations & PNG_INTERLACE)
|
||||||
break;
|
break;
|
||||||
} while (png_ptr->iwidth == 0);
|
|
||||||
|
png_ptr->num_rows = (png_ptr->height +
|
||||||
|
png_pass_yinc[png_ptr->pass] - 1 -
|
||||||
|
png_pass_ystart[png_ptr->pass]) /
|
||||||
|
png_pass_yinc[png_ptr->pass];
|
||||||
|
|
||||||
|
} while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -778,24 +807,29 @@ void
|
|||||||
png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||||
{
|
{
|
||||||
if (png_ptr->mode == PNG_BEFORE_IHDR || png_ptr->mode & PNG_HAVE_IEND)
|
if (png_ptr->mode == PNG_BEFORE_IHDR || png_ptr->mode & PNG_HAVE_IEND)
|
||||||
png_error(png_ptr, "Out of place tEXt");
|
{
|
||||||
|
png_error(png_ptr, "Out of place tEXt");
|
||||||
|
/* to quiet some compiler warnings */
|
||||||
|
if(info_ptr == NULL) return;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef PNG_MAX_MALLOC_64K
|
#ifdef PNG_MAX_MALLOC_64K
|
||||||
png_ptr->skip_length = 0; /* This may not be necessary */
|
png_ptr->skip_length = 0; /* This may not be necessary */
|
||||||
|
|
||||||
if (length > 65535L) /* We can't hold the entire string in memory */
|
if (length > (png_uint_32)65535L) /* Can't hold the entire string in memory */
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "tEXt chunk too large to fit in memory");
|
png_warning(png_ptr, "tEXt chunk too large to fit in memory");
|
||||||
png_ptr->skip_length = length - 65535L;
|
png_ptr->skip_length = length - (png_uint_32)65535L;
|
||||||
length = 65535L;
|
length = (png_uint_32)65535L;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_ptr->current_text = (png_charp)png_malloc(png_ptr, length+1);
|
png_ptr->current_text = (png_charp)png_malloc(png_ptr,
|
||||||
|
(png_uint_32)(length+1));
|
||||||
png_ptr->current_text[length] = '\0';
|
png_ptr->current_text[length] = '\0';
|
||||||
png_ptr->current_text_ptr = png_ptr->current_text;
|
png_ptr->current_text_ptr = png_ptr->current_text;
|
||||||
png_ptr->current_text_size = length;
|
png_ptr->current_text_size = (png_size_t)length;
|
||||||
png_ptr->current_text_left = length;
|
png_ptr->current_text_left = (png_size_t)length;
|
||||||
png_ptr->process_mode = PNG_READ_tEXt_MODE;
|
png_ptr->process_mode = PNG_READ_tEXt_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -842,7 +876,7 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
|
|||||||
if (text != key + png_ptr->current_text_size)
|
if (text != key + png_ptr->current_text_size)
|
||||||
text++;
|
text++;
|
||||||
|
|
||||||
text_ptr = (png_textp)png_malloc(png_ptr, sizeof(png_text));
|
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
|
||||||
text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
|
text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
|
||||||
text_ptr->key = key;
|
text_ptr->key = key;
|
||||||
text_ptr->text = text;
|
text_ptr->text = text;
|
||||||
@@ -859,14 +893,18 @@ void
|
|||||||
png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||||
{
|
{
|
||||||
if (png_ptr->mode == PNG_BEFORE_IHDR || png_ptr->mode & PNG_HAVE_IEND)
|
if (png_ptr->mode == PNG_BEFORE_IHDR || png_ptr->mode & PNG_HAVE_IEND)
|
||||||
png_error(png_ptr, "Out of place zTXt");
|
{
|
||||||
|
png_error(png_ptr, "Out of place zTXt");
|
||||||
|
/* to quiet some compiler warnings */
|
||||||
|
if(info_ptr == NULL) return;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef PNG_MAX_MALLOC_64K
|
#ifdef PNG_MAX_MALLOC_64K
|
||||||
/* We can't handle zTXt chunks > 64K, since we don't have enough space
|
/* We can't handle zTXt chunks > 64K, since we don't have enough space
|
||||||
* to be able to store the uncompressed data. Actually, the threshold
|
* to be able to store the uncompressed data. Actually, the threshold
|
||||||
* is probably around 32K, but it isn't as definite as 64K is.
|
* is probably around 32K, but it isn't as definite as 64K is.
|
||||||
*/
|
*/
|
||||||
if (length > 65535L)
|
if (length > (png_uint_32)65535L)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "zTXt chunk too large to fit in memory");
|
png_warning(png_ptr, "zTXt chunk too large to fit in memory");
|
||||||
png_push_crc_skip(png_ptr, length);
|
png_push_crc_skip(png_ptr, length);
|
||||||
@@ -874,11 +912,12 @@ png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_ptr->current_text = (png_charp)png_malloc(png_ptr, length+1);
|
png_ptr->current_text = (png_charp)png_malloc(png_ptr,
|
||||||
|
(png_uint_32)(length+1));
|
||||||
png_ptr->current_text[length] = '\0';
|
png_ptr->current_text[length] = '\0';
|
||||||
png_ptr->current_text_ptr = png_ptr->current_text;
|
png_ptr->current_text_ptr = png_ptr->current_text;
|
||||||
png_ptr->current_text_size = length;
|
png_ptr->current_text_size = (png_size_t)length;
|
||||||
png_ptr->current_text_left = length;
|
png_ptr->current_text_left = (png_size_t)length;
|
||||||
png_ptr->process_mode = PNG_READ_zTXt_MODE;
|
png_ptr->process_mode = PNG_READ_zTXt_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -940,7 +979,7 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
|||||||
png_ptr->zstream.avail_in = (uInt)(png_ptr->current_text_size -
|
png_ptr->zstream.avail_in = (uInt)(png_ptr->current_text_size -
|
||||||
(text - key));
|
(text - key));
|
||||||
png_ptr->zstream.next_out = png_ptr->zbuf;
|
png_ptr->zstream.next_out = png_ptr->zbuf;
|
||||||
png_ptr->zstream.avail_out = png_ptr->zbuf_size;
|
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
|
||||||
|
|
||||||
key_size = text - key;
|
key_size = text - key;
|
||||||
text_size = 0;
|
text_size = 0;
|
||||||
@@ -963,8 +1002,8 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
|||||||
if (text == NULL)
|
if (text == NULL)
|
||||||
{
|
{
|
||||||
text = (png_charp)png_malloc(png_ptr,
|
text = (png_charp)png_malloc(png_ptr,
|
||||||
png_ptr->zbuf_size - png_ptr->zstream.avail_out +
|
(png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out +
|
||||||
key_size + 1);
|
key_size + 1));
|
||||||
png_memcpy(text + key_size, png_ptr->zbuf,
|
png_memcpy(text + key_size, png_ptr->zbuf,
|
||||||
png_ptr->zbuf_size - png_ptr->zstream.avail_out);
|
png_ptr->zbuf_size - png_ptr->zstream.avail_out);
|
||||||
png_memcpy(text, key, key_size);
|
png_memcpy(text, key, key_size);
|
||||||
@@ -977,8 +1016,9 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
|||||||
png_charp tmp;
|
png_charp tmp;
|
||||||
|
|
||||||
tmp = text;
|
tmp = text;
|
||||||
text = png_malloc(png_ptr, text_size +
|
text = (png_charp)png_malloc(png_ptr, text_size +
|
||||||
png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1);
|
(png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out
|
||||||
|
+ 1));
|
||||||
png_memcpy(text, tmp, text_size);
|
png_memcpy(text, tmp, text_size);
|
||||||
png_free(png_ptr, tmp);
|
png_free(png_ptr, tmp);
|
||||||
png_memcpy(text + text_size, png_ptr->zbuf,
|
png_memcpy(text + text_size, png_ptr->zbuf,
|
||||||
@@ -1014,9 +1054,8 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
|||||||
png_free(png_ptr, key);
|
png_free(png_ptr, key);
|
||||||
key = text;
|
key = text;
|
||||||
text += key_size;
|
text += key_size;
|
||||||
text_size -= key_size;
|
|
||||||
|
|
||||||
text_ptr = (png_textp)png_malloc(png_ptr, sizeof(png_text));
|
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
|
||||||
text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt;
|
text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||||
text_ptr->key = key;
|
text_ptr->key = key;
|
||||||
text_ptr->text = text;
|
text_ptr->text = text;
|
||||||
@@ -1029,11 +1068,12 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This function is called when we haven't found a handler for this
|
/* This function is called when we haven't found a handler for this
|
||||||
chunk. In the future we will have code here which can handle
|
* chunk. In the future we will have code here that can handle
|
||||||
user-defined callback functions for unknown chunks before they are
|
* user-defined callback functions for unknown chunks before they are
|
||||||
ignored or cause an error. If there isn't a problem with the
|
* 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
|
* chunk itself (ie a bad chunk name or a critical chunk), the chunk
|
||||||
is (currently) silently ignored. */
|
* is (currently) silently ignored.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||||
{
|
{
|
||||||
@@ -1041,10 +1081,9 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 len
|
|||||||
|
|
||||||
if (!(png_ptr->chunk_name[0] & 0x20))
|
if (!(png_ptr->chunk_name[0] & 0x20))
|
||||||
{
|
{
|
||||||
char msg[40];
|
png_chunk_error(png_ptr, "unknown critical chunk");
|
||||||
|
/* to quiet some compiler warnings */
|
||||||
sprintf(msg, "Unknown critical chunk %s", png_ptr->chunk_name);
|
if(info_ptr == NULL) return;
|
||||||
png_error(png_ptr, msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
png_push_crc_skip(png_ptr, length);
|
png_push_crc_skip(png_ptr, length);
|
||||||
@@ -1076,7 +1115,7 @@ void
|
|||||||
png_progressive_combine_row (png_structp png_ptr,
|
png_progressive_combine_row (png_structp png_ptr,
|
||||||
png_bytep old_row, png_bytep new_row)
|
png_bytep old_row, png_bytep new_row)
|
||||||
{
|
{
|
||||||
if (new_row != NULL)
|
if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */
|
||||||
png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]);
|
png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
295
pngread.c
295
pngread.c
@@ -1,27 +1,49 @@
|
|||||||
|
|
||||||
/* pngread.c - read a PNG file
|
/* pngread.c - read a PNG file
|
||||||
|
*
|
||||||
libpng 1.0 beta 6 - version 0.96
|
* libpng 1.0.2b - January 6, 1999
|
||||||
For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
May 12, 1997
|
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||||
*/
|
*
|
||||||
|
* This file contains routines that an application calls directly to
|
||||||
|
* read a PNG file or stream.
|
||||||
|
*/
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
|
||||||
/* Create a PNG structure for reading, and allocate any memory needed. */
|
/* Create a PNG structure for reading, and allocate any memory needed. */
|
||||||
png_structp
|
png_structp
|
||||||
png_create_read_struct(png_charp user_png_ver, png_voidp error_ptr,
|
png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||||
png_error_ptr error_fn, png_error_ptr warn_fn)
|
png_error_ptr error_fn, png_error_ptr warn_fn)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
return (png_create_read_struct_2(user_png_ver, error_ptr, error_fn,
|
||||||
|
warn_fn, NULL, NULL, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Alternate create PNG structure for reading, and allocate any memory needed. */
|
||||||
|
png_structp
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
|
|
||||||
png_structp png_ptr;
|
png_structp png_ptr;
|
||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
jmp_buf jmpbuf;
|
jmp_buf jmpbuf;
|
||||||
#endif
|
#endif
|
||||||
png_debug(1, "in png_create_read_struct\n");
|
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,
|
||||||
|
(png_malloc_ptr)malloc_fn)) == NULL)
|
||||||
|
#else
|
||||||
if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL)
|
if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
return (png_structp)NULL;
|
return (png_structp)NULL;
|
||||||
}
|
}
|
||||||
@@ -38,6 +60,11 @@ png_create_read_struct(png_charp user_png_ver, png_voidp error_ptr,
|
|||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
|
png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
|
||||||
#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);
|
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
|
/* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
|
||||||
@@ -54,7 +81,8 @@ png_create_read_struct(png_charp user_png_ver, png_voidp error_ptr,
|
|||||||
|
|
||||||
/* initialize zbuf - compression buffer */
|
/* initialize zbuf - compression buffer */
|
||||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||||
png_ptr->zbuf = png_malloc(png_ptr, png_ptr->zbuf_size);
|
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
|
||||||
|
(png_uint_32)png_ptr->zbuf_size);
|
||||||
png_ptr->zstream.zalloc = png_zalloc;
|
png_ptr->zstream.zalloc = png_zalloc;
|
||||||
png_ptr->zstream.zfree = png_zfree;
|
png_ptr->zstream.zfree = png_zfree;
|
||||||
png_ptr->zstream.opaque = (voidpf)png_ptr;
|
png_ptr->zstream.opaque = (voidpf)png_ptr;
|
||||||
@@ -76,9 +104,8 @@ png_create_read_struct(png_charp user_png_ver, png_voidp error_ptr,
|
|||||||
return (png_ptr);
|
return (png_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Initialize PNG structure for reading, and allocate any memory needed.
|
/* Initialize PNG structure for reading, and allocate any memory needed.
|
||||||
This interface is depreciated in favour of the png_create_read_struct(),
|
This interface is deprecated in favour of the png_create_read_struct(),
|
||||||
and it will eventually disappear. */
|
and it will eventually disappear. */
|
||||||
void
|
void
|
||||||
png_read_init(png_structp png_ptr)
|
png_read_init(png_structp png_ptr)
|
||||||
@@ -97,7 +124,8 @@ png_read_init(png_structp png_ptr)
|
|||||||
|
|
||||||
/* initialize zbuf - compression buffer */
|
/* initialize zbuf - compression buffer */
|
||||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||||
png_ptr->zbuf = png_malloc(png_ptr, png_ptr->zbuf_size);
|
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
|
||||||
|
(png_uint_32)png_ptr->zbuf_size);
|
||||||
png_ptr->zstream.zalloc = png_zalloc;
|
png_ptr->zstream.zalloc = png_zalloc;
|
||||||
png_ptr->zstream.zfree = png_zfree;
|
png_ptr->zstream.zfree = png_zfree;
|
||||||
png_ptr->zstream.opaque = (voidpf)png_ptr;
|
png_ptr->zstream.opaque = (voidpf)png_ptr;
|
||||||
@@ -118,9 +146,9 @@ png_read_init(png_structp png_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Read the information before the actual image data. This has been
|
/* Read the information before the actual image data. This has been
|
||||||
* changed in v0.90 to allow reading a file which already has the magic
|
* changed in v0.90 to allow reading a file that already has the magic
|
||||||
* bytes read from the stream. You can tell libpng how many bytes have
|
* bytes read from the stream. You can tell libpng how many bytes have
|
||||||
* been read from the beginning of the stream (up to the maxumum of 8)
|
* been read from the beginning of the stream (up to the maximum of 8)
|
||||||
* via png_set_sig_bytes(), and we will only check the remaining bytes
|
* via png_set_sig_bytes(), and we will only check the remaining bytes
|
||||||
* here. The application can then have access to the signature bytes we
|
* here. The application can then have access to the signature bytes we
|
||||||
* read if it is determined that this isn't a valid PNG file.
|
* read if it is determined that this isn't a valid PNG file.
|
||||||
@@ -149,7 +177,7 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1)
|
for(;;)
|
||||||
{
|
{
|
||||||
png_byte chunk_length[4];
|
png_byte chunk_length[4];
|
||||||
png_uint_32 length;
|
png_uint_32 length;
|
||||||
@@ -215,6 +243,10 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
|||||||
else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4))
|
else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4))
|
||||||
png_handle_sBIT(png_ptr, info_ptr, length);
|
png_handle_sBIT(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||||
|
else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4))
|
||||||
|
png_handle_sRGB(png_ptr, info_ptr, length);
|
||||||
|
#endif
|
||||||
#if defined(PNG_READ_tEXt_SUPPORTED)
|
#if defined(PNG_READ_tEXt_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
|
else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
|
||||||
png_handle_tEXt(png_ptr, info_ptr, length);
|
png_handle_tEXt(png_ptr, info_ptr, length);
|
||||||
@@ -247,10 +279,11 @@ png_read_update_info(png_structp png_ptr, png_infop info_ptr)
|
|||||||
png_read_transform_info(png_ptr, info_ptr);
|
png_read_transform_info(png_ptr, info_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize palette, background, etc, after transformations
|
/* Initialize palette, background, etc, after transformations
|
||||||
are set, but before any reading takes place. This allows
|
* are set, but before any reading takes place. This allows
|
||||||
the user to obtail a gamma corrected palette, for example.
|
* the user to obtain a gamma-corrected palette, for example.
|
||||||
If the user doesn't call this, we will do it ourselves. */
|
* If the user doesn't call this, we will do it ourselves.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
png_start_read_image(png_structp png_ptr)
|
png_start_read_image(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
@@ -269,6 +302,38 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||||||
/* save jump buffer and error functions */
|
/* save jump buffer and error functions */
|
||||||
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||||
png_read_start_row(png_ptr);
|
png_read_start_row(png_ptr);
|
||||||
|
if (png_ptr->row_number == 0 && png_ptr->pass == 0)
|
||||||
|
{
|
||||||
|
/* check for transforms that have been set but were defined out */
|
||||||
|
#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED)
|
||||||
|
if (png_ptr->transformations & PNG_INVERT_MONO)
|
||||||
|
png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined.");
|
||||||
|
#endif
|
||||||
|
#if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED)
|
||||||
|
if (png_ptr->transformations & PNG_FILLER)
|
||||||
|
png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined.");
|
||||||
|
#endif
|
||||||
|
#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && !defined(PNG_READ_PACKSWAP_SUPPORTED)
|
||||||
|
if (png_ptr->transformations & PNG_PACKSWAP)
|
||||||
|
png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined.");
|
||||||
|
#endif
|
||||||
|
#if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED)
|
||||||
|
if (png_ptr->transformations & PNG_PACK)
|
||||||
|
png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined.");
|
||||||
|
#endif
|
||||||
|
#if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED)
|
||||||
|
if (png_ptr->transformations & PNG_SHIFT)
|
||||||
|
png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined.");
|
||||||
|
#endif
|
||||||
|
#if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED)
|
||||||
|
if (png_ptr->transformations & PNG_BGR)
|
||||||
|
png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined.");
|
||||||
|
#endif
|
||||||
|
#if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED)
|
||||||
|
if (png_ptr->transformations & PNG_SWAP_BYTES)
|
||||||
|
png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined.");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(PNG_READ_INTERLACING_SUPPORTED)
|
#if defined(PNG_READ_INTERLACING_SUPPORTED)
|
||||||
/* if interlaced and we do not need a new row, combine row and return */
|
/* if interlaced and we do not need a new row, combine row and return */
|
||||||
@@ -399,14 +464,17 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||||||
png_ptr->row_info.channels = png_ptr->channels;
|
png_ptr->row_info.channels = png_ptr->channels;
|
||||||
png_ptr->row_info.bit_depth = png_ptr->bit_depth;
|
png_ptr->row_info.bit_depth = png_ptr->bit_depth;
|
||||||
png_ptr->row_info.pixel_depth = png_ptr->pixel_depth;
|
png_ptr->row_info.pixel_depth = png_ptr->pixel_depth;
|
||||||
png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
|
{
|
||||||
(png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
|
png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
|
||||||
|
(png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
|
||||||
|
}
|
||||||
|
|
||||||
png_read_filter_row(png_ptr, &(png_ptr->row_info),
|
png_read_filter_row(png_ptr, &(png_ptr->row_info),
|
||||||
png_ptr->row_buf + 1, png_ptr->prev_row + 1,
|
png_ptr->row_buf + 1, png_ptr->prev_row + 1,
|
||||||
(int)(png_ptr->row_buf[0]));
|
(int)(png_ptr->row_buf[0]));
|
||||||
|
|
||||||
png_memcpy(png_ptr->prev_row, png_ptr->row_buf, png_ptr->rowbytes + 1);
|
png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf,
|
||||||
|
png_ptr->rowbytes + 1);
|
||||||
|
|
||||||
if (png_ptr->transformations)
|
if (png_ptr->transformations)
|
||||||
png_do_read_transformations(png_ptr);
|
png_do_read_transformations(png_ptr);
|
||||||
@@ -436,26 +504,34 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||||||
png_combine_row(png_ptr, dsp_row, 0xff);
|
png_combine_row(png_ptr, dsp_row, 0xff);
|
||||||
}
|
}
|
||||||
png_read_finish_row(png_ptr);
|
png_read_finish_row(png_ptr);
|
||||||
|
|
||||||
|
if (png_ptr->read_row_fn != NULL)
|
||||||
|
(*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read one or more rows of image data. If the image is interlaced,
|
/* Read one or more rows of image data. If the image is interlaced,
|
||||||
and png_set_interlace_handling() has been called, the rows need to
|
* and png_set_interlace_handling() has been called, the rows need to
|
||||||
to contain the contents of the rows from the previous pass. If
|
* contain the contents of the rows from the previous pass. If the
|
||||||
the image has alpha or transparency, and png_handle_alpha() has been
|
* image has alpha or transparency, and png_handle_alpha()[*] has been
|
||||||
called, the rows contents must be initialized to the contents of the
|
* called, the rows contents must be initialized to the contents of the
|
||||||
screen. "row" holds the actual image, and pixels are placed in it
|
* screen.
|
||||||
as they arrive. If the image is displayed after each pass, it will
|
*
|
||||||
appear to "sparkle" in. "display_row" can be used to display a
|
* "row" holds the actual image, and pixels are placed in it
|
||||||
"chunky" progressive image, with finer detail added as it becomes
|
* as they arrive. If the image is displayed after each pass, it will
|
||||||
available. If you do not want this "chunky" display, you may pass
|
* appear to "sparkle" in. "display_row" can be used to display a
|
||||||
NULL for display_row. If you do not want the sparkle display, and
|
* "chunky" progressive image, with finer detail added as it becomes
|
||||||
you have not called png_handle_alpha(), you may pass NULL for rows.
|
* available. If you do not want this "chunky" display, you may pass
|
||||||
If you have called png_handle_alpha(), and the image has either an
|
* NULL for display_row. If you do not want the sparkle display, and
|
||||||
alpha channel or a transparency chunk, you must provide a buffer for
|
* you have not called png_handle_alpha(), you may pass NULL for rows.
|
||||||
rows. In this case, you do not have to provide a display_row buffer
|
* If you have called png_handle_alpha(), and the image has either an
|
||||||
also, but you may. If the image is not interlaced, or if you have
|
* alpha channel or a transparency chunk, you must provide a buffer for
|
||||||
not called png_set_interlace_handling(), the display_row buffer will
|
* rows. In this case, you do not have to provide a display_row buffer
|
||||||
be ignored, so pass NULL to it. */
|
* also, but you may. If the image is not interlaced, or if you have
|
||||||
|
* 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.2b.
|
||||||
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
png_read_rows(png_structp png_ptr, png_bytepp row,
|
png_read_rows(png_structp png_ptr, png_bytepp row,
|
||||||
@@ -469,40 +545,46 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
|
|||||||
/* save jump buffer and error functions */
|
/* save jump buffer and error functions */
|
||||||
rp = row;
|
rp = row;
|
||||||
dp = display_row;
|
dp = display_row;
|
||||||
for (i = 0; i < num_rows; i++)
|
if (rp != NULL && dp != NULL)
|
||||||
{
|
for (i = 0; i < num_rows; i++)
|
||||||
png_bytep rptr;
|
{
|
||||||
png_bytep dptr;
|
png_bytep rptr = *rp++;
|
||||||
|
png_bytep dptr = *dp++;
|
||||||
|
|
||||||
if (rp != NULL)
|
png_read_row(png_ptr, rptr, dptr);
|
||||||
rptr = *rp;
|
}
|
||||||
else
|
else if(rp != NULL)
|
||||||
rptr = NULL;
|
for (i = 0; i < num_rows; i++)
|
||||||
if (dp != NULL)
|
{
|
||||||
dptr = *dp;
|
png_bytep rptr = *rp;
|
||||||
else
|
png_read_row(png_ptr, rptr, NULL);
|
||||||
dptr = NULL;
|
|
||||||
png_read_row(png_ptr, rptr, dptr);
|
|
||||||
if (row != NULL)
|
|
||||||
rp++;
|
rp++;
|
||||||
if (display_row != NULL)
|
}
|
||||||
|
else if(dp != NULL)
|
||||||
|
for (i = 0; i < num_rows; i++)
|
||||||
|
{
|
||||||
|
png_bytep dptr = *dp;
|
||||||
|
png_read_row(png_ptr, NULL, dptr);
|
||||||
dp++;
|
dp++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the entire image. If the image has an alpha channel or a tRNS
|
/* Read the entire image. If the image has an alpha channel or a tRNS
|
||||||
chunk, and you have called png_handle_alpha(), you will need to
|
* chunk, and you have called png_handle_alpha()[*], you will need to
|
||||||
initialize the image to the current image that PNG will be overlaying.
|
* initialize the image to the current image that PNG will be overlaying.
|
||||||
We set the num_rows again here, in case it was incorrectly set in
|
* We set the num_rows again here, in case it was incorrectly set in
|
||||||
png_read_start_row() by a call to png_read_update_info() or
|
* png_read_start_row() by a call to png_read_update_info() or
|
||||||
png_start_read_image() if png_set_interlace_handling() wasn't called
|
* png_start_read_image() if png_set_interlace_handling() wasn't called
|
||||||
prior to either of these functions like it should have been. You can
|
* prior to either of these functions like it should have been. You can
|
||||||
only call this function once. If you desire to have an image for
|
* only call this function once. If you desire to have an image for
|
||||||
each pass of a interlaced image, use png_read_rows() instead */
|
* each pass of a interlaced image, use png_read_rows() instead.
|
||||||
|
*
|
||||||
|
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.2b.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
png_read_image(png_structp png_ptr, png_bytepp image)
|
png_read_image(png_structp png_ptr, png_bytepp image)
|
||||||
{
|
{
|
||||||
png_uint_32 i;
|
png_uint_32 i,image_height;
|
||||||
int pass, j;
|
int pass, j;
|
||||||
png_bytepp rp;
|
png_bytepp rp;
|
||||||
|
|
||||||
@@ -510,12 +592,13 @@ png_read_image(png_structp png_ptr, png_bytepp image)
|
|||||||
/* save jump buffer and error functions */
|
/* save jump buffer and error functions */
|
||||||
pass = png_set_interlace_handling(png_ptr);
|
pass = png_set_interlace_handling(png_ptr);
|
||||||
|
|
||||||
png_ptr->num_rows = png_ptr->height; /* Make sure this is set correctly */
|
image_height=png_ptr->height;
|
||||||
|
png_ptr->num_rows = image_height; /* Make sure this is set correctly */
|
||||||
|
|
||||||
for (j = 0; j < pass; j++)
|
for (j = 0; j < pass; j++)
|
||||||
{
|
{
|
||||||
rp = image;
|
rp = image;
|
||||||
for (i = 0; i < png_ptr->height; i++)
|
for (i = 0; i < image_height; i++)
|
||||||
{
|
{
|
||||||
png_read_row(png_ptr, *rp, NULL);
|
png_read_row(png_ptr, *rp, NULL);
|
||||||
rp++;
|
rp++;
|
||||||
@@ -524,8 +607,9 @@ png_read_image(png_structp png_ptr, png_bytepp image)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Read the end of the PNG file. Will not read past the end of the
|
/* Read the end of the PNG file. Will not read past the end of the
|
||||||
file, will verify the end is accurate, and will read any comments
|
* file, will verify the end is accurate, and will read any comments
|
||||||
or time information at the end of the file, if info is not NULL. */
|
* or time information at the end of the file, if info is not NULL.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
png_read_end(png_structp png_ptr, png_infop info_ptr)
|
png_read_end(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
@@ -594,6 +678,10 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
|
|||||||
else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4))
|
else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4))
|
||||||
png_handle_sBIT(png_ptr, info_ptr, length);
|
png_handle_sBIT(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||||
|
else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4))
|
||||||
|
png_handle_sRGB(png_ptr, info_ptr, length);
|
||||||
|
#endif
|
||||||
#if defined(PNG_READ_tEXt_SUPPORTED)
|
#if defined(PNG_READ_tEXt_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
|
else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
|
||||||
png_handle_tEXt(png_ptr, info_ptr, length);
|
png_handle_tEXt(png_ptr, info_ptr, length);
|
||||||
@@ -622,6 +710,9 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
|||||||
{
|
{
|
||||||
png_structp png_ptr = NULL;
|
png_structp png_ptr = NULL;
|
||||||
png_infop info_ptr = NULL, end_info_ptr = NULL;
|
png_infop info_ptr = NULL, end_info_ptr = NULL;
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
png_free_ptr free_fn = NULL;
|
||||||
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
|
|
||||||
png_debug(1, "in png_destroy_read_struct\n");
|
png_debug(1, "in png_destroy_read_struct\n");
|
||||||
/* save jump buffer and error functions */
|
/* save jump buffer and error functions */
|
||||||
@@ -634,23 +725,46 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
|||||||
if (end_info_ptr_ptr != NULL)
|
if (end_info_ptr_ptr != NULL)
|
||||||
end_info_ptr = *end_info_ptr_ptr;
|
end_info_ptr = *end_info_ptr_ptr;
|
||||||
|
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
free_fn = png_ptr->free_fn;
|
||||||
|
#endif
|
||||||
|
|
||||||
png_read_destroy(png_ptr, info_ptr, end_info_ptr);
|
png_read_destroy(png_ptr, info_ptr, end_info_ptr);
|
||||||
|
|
||||||
if (info_ptr != NULL)
|
if (info_ptr != NULL)
|
||||||
{
|
{
|
||||||
|
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
|
||||||
|
png_free(png_ptr, info_ptr->text);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
png_destroy_struct_2((png_voidp)info_ptr, free_fn);
|
||||||
|
#else
|
||||||
png_destroy_struct((png_voidp)info_ptr);
|
png_destroy_struct((png_voidp)info_ptr);
|
||||||
|
#endif
|
||||||
*info_ptr_ptr = (png_infop)NULL;
|
*info_ptr_ptr = (png_infop)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end_info_ptr != NULL)
|
if (end_info_ptr != NULL)
|
||||||
{
|
{
|
||||||
|
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
|
||||||
|
png_free(png_ptr, end_info_ptr->text);
|
||||||
|
#endif
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
png_destroy_struct_2((png_voidp)end_info_ptr, free_fn);
|
||||||
|
#else
|
||||||
png_destroy_struct((png_voidp)end_info_ptr);
|
png_destroy_struct((png_voidp)end_info_ptr);
|
||||||
|
#endif
|
||||||
*end_info_ptr_ptr = (png_infop)NULL;
|
*end_info_ptr_ptr = (png_infop)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (png_ptr != NULL)
|
if (png_ptr != NULL)
|
||||||
{
|
{
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
png_destroy_struct_2((png_voidp)png_ptr, free_fn);
|
||||||
|
#else
|
||||||
png_destroy_struct((png_voidp)png_ptr);
|
png_destroy_struct((png_voidp)png_ptr);
|
||||||
|
#endif
|
||||||
*png_ptr_ptr = (png_structp)NULL;
|
*png_ptr_ptr = (png_structp)NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -659,11 +773,13 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
|||||||
void
|
void
|
||||||
png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr)
|
png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
jmp_buf tmp_jmp;
|
jmp_buf tmp_jmp;
|
||||||
png_error_ptr error_fn;
|
png_error_ptr error_fn;
|
||||||
png_error_ptr warning_fn;
|
png_error_ptr warning_fn;
|
||||||
png_voidp error_ptr;
|
png_voidp error_ptr;
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
png_free_ptr free_fn;
|
||||||
|
#endif
|
||||||
|
|
||||||
png_debug(1, "in png_read_destroy\n");
|
png_debug(1, "in png_read_destroy\n");
|
||||||
/* save jump buffer and error functions */
|
/* save jump buffer and error functions */
|
||||||
@@ -688,11 +804,9 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
|||||||
png_free(png_ptr, png_ptr->gamma_to_1);
|
png_free(png_ptr, png_ptr->gamma_to_1);
|
||||||
#endif
|
#endif
|
||||||
if (png_ptr->flags & PNG_FLAG_FREE_PALETTE)
|
if (png_ptr->flags & PNG_FLAG_FREE_PALETTE)
|
||||||
png_free(png_ptr, png_ptr->palette);
|
png_zfree(png_ptr, png_ptr->palette);
|
||||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_bKGD_SUPPORTED)
|
|
||||||
if (png_ptr->flags & PNG_FLAG_FREE_TRANS)
|
if (png_ptr->flags & PNG_FLAG_FREE_TRANS)
|
||||||
png_free(png_ptr, png_ptr->trans);
|
png_free(png_ptr, png_ptr->trans);
|
||||||
#endif
|
|
||||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||||
if (png_ptr->flags & PNG_FLAG_FREE_HIST)
|
if (png_ptr->flags & PNG_FLAG_FREE_HIST)
|
||||||
png_free(png_ptr, png_ptr->hist);
|
png_free(png_ptr, png_ptr->hist);
|
||||||
@@ -700,31 +814,40 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
|||||||
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
||||||
if (png_ptr->gamma_16_table != NULL)
|
if (png_ptr->gamma_16_table != NULL)
|
||||||
{
|
{
|
||||||
for (i = 0; i < (1 << (8 - png_ptr->gamma_shift)); i++)
|
int i;
|
||||||
|
int istop = (1 << (8 - png_ptr->gamma_shift));
|
||||||
|
for (i = 0; i < istop; i++)
|
||||||
{
|
{
|
||||||
png_free(png_ptr, png_ptr->gamma_16_table[i]);
|
png_free(png_ptr, png_ptr->gamma_16_table[i]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
|
|
||||||
png_free(png_ptr, png_ptr->gamma_16_table);
|
png_free(png_ptr, png_ptr->gamma_16_table);
|
||||||
|
}
|
||||||
|
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||||
if (png_ptr->gamma_16_from_1 != NULL)
|
if (png_ptr->gamma_16_from_1 != NULL)
|
||||||
{
|
{
|
||||||
for (i = 0; i < (1 << (8 - png_ptr->gamma_shift)); i++)
|
int i;
|
||||||
|
int istop = (1 << (8 - png_ptr->gamma_shift));
|
||||||
|
for (i = 0; i < istop; i++)
|
||||||
{
|
{
|
||||||
png_free(png_ptr, png_ptr->gamma_16_from_1[i]);
|
png_free(png_ptr, png_ptr->gamma_16_from_1[i]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
png_free(png_ptr, png_ptr->gamma_16_from_1);
|
png_free(png_ptr, png_ptr->gamma_16_from_1);
|
||||||
|
}
|
||||||
if (png_ptr->gamma_16_to_1 != NULL)
|
if (png_ptr->gamma_16_to_1 != NULL)
|
||||||
{
|
{
|
||||||
for (i = 0; i < (1 << (8 - png_ptr->gamma_shift)); i++)
|
int i;
|
||||||
|
int istop = (1 << (8 - png_ptr->gamma_shift));
|
||||||
|
for (i = 0; i < istop; i++)
|
||||||
{
|
{
|
||||||
png_free(png_ptr, png_ptr->gamma_16_to_1[i]);
|
png_free(png_ptr, png_ptr->gamma_16_to_1[i]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
png_free(png_ptr, png_ptr->gamma_16_to_1);
|
png_free(png_ptr, png_ptr->gamma_16_to_1);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||||
|
png_free(png_ptr, png_ptr->time_buffer);
|
||||||
|
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||||
|
|
||||||
inflateEnd(&png_ptr->zstream);
|
inflateEnd(&png_ptr->zstream);
|
||||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||||
@@ -739,12 +862,24 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
|||||||
error_fn = png_ptr->error_fn;
|
error_fn = png_ptr->error_fn;
|
||||||
warning_fn = png_ptr->warning_fn;
|
warning_fn = png_ptr->warning_fn;
|
||||||
error_ptr = png_ptr->error_ptr;
|
error_ptr = png_ptr->error_ptr;
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
free_fn = png_ptr->free_fn;
|
||||||
|
#endif
|
||||||
|
|
||||||
png_memset(png_ptr, 0, sizeof (png_struct));
|
png_memset(png_ptr, 0, sizeof (png_struct));
|
||||||
|
|
||||||
png_ptr->error_fn = error_fn;
|
png_ptr->error_fn = error_fn;
|
||||||
png_ptr->warning_fn = warning_fn;
|
png_ptr->warning_fn = warning_fn;
|
||||||
png_ptr->error_ptr = error_ptr;
|
png_ptr->error_ptr = error_ptr;
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
png_ptr->free_fn = free_fn;
|
||||||
|
#endif
|
||||||
|
|
||||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
|
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn)
|
||||||
|
{
|
||||||
|
png_ptr->read_row_fn = read_row_fn;
|
||||||
|
}
|
||||||
|
|||||||
54
pngrio.c
54
pngrio.c
@@ -1,18 +1,19 @@
|
|||||||
|
|
||||||
/* pngrio.c - functions for data input
|
/* pngrio.c - functions for data input
|
||||||
|
*
|
||||||
libpng 1.0 beta 6 - version 0.96
|
* libpng 1.0.2b - January 6, 1999
|
||||||
For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
May 12, 1997
|
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||||
|
*
|
||||||
This file provides a location for all input. Users which need
|
* This file provides a location for all input. Users who need
|
||||||
special handling are expected to write a function which has the same
|
* special handling are expected to write a function that has the same
|
||||||
arguments as this, and perform a similar function, but possibly has
|
* arguments as this and performs a similar function, but that possibly
|
||||||
a different input method. Note that you shouldn't change this
|
* has a different input method. Note that you shouldn't change this
|
||||||
function, but rather write a replacement function and then make
|
* function, but rather write a replacement function and then make
|
||||||
libpng use it at run time with png_set_read_fn(...) */
|
* libpng use it at run time with png_set_read_fn(...).
|
||||||
|
*/
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
@@ -32,7 +33,8 @@ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||||||
png_error(png_ptr, "Call to NULL read function");
|
png_error(png_ptr, "Call to NULL read function");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is the function which does the actual reading of data. If you are
|
#if !defined(PNG_NO_STDIO)
|
||||||
|
/* This is the function that does the actual reading of data. If you are
|
||||||
not reading from a standard C stream, you should create a replacement
|
not reading from a standard C stream, you should create a replacement
|
||||||
read_data function and use it at run time with png_set_read_fn(), rather
|
read_data function and use it at run time with png_set_read_fn(), rather
|
||||||
than changing the library. */
|
than changing the library. */
|
||||||
@@ -58,10 +60,10 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||||||
can't handle far buffers in the medium and small models, we have to copy
|
can't handle far buffers in the medium and small models, we have to copy
|
||||||
the data.
|
the data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define NEAR_BUF_SIZE 1024
|
#define NEAR_BUF_SIZE 1024
|
||||||
#define MIN(a,b) (a <= b ? a : b)
|
#define MIN(a,b) (a <= b ? a : b)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
{
|
{
|
||||||
@@ -96,12 +98,13 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||||||
}
|
}
|
||||||
while (remaining != 0);
|
while (remaining != 0);
|
||||||
}
|
}
|
||||||
if (check != length)
|
if ((png_uint_32)check != (png_uint_32)length)
|
||||||
{
|
{
|
||||||
png_error(png_ptr, "read Error");
|
png_error(png_ptr, "read Error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This function allows the application to supply a new input function
|
/* This function allows the application to supply a new input function
|
||||||
for libpng if standard C streams aren't being used.
|
for libpng if standard C streams aren't being used.
|
||||||
@@ -110,10 +113,10 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||||||
png_ptr - pointer to a png input data structure
|
png_ptr - pointer to a png input data structure
|
||||||
io_ptr - pointer to user supplied structure containing info about
|
io_ptr - pointer to user supplied structure containing info about
|
||||||
the input functions. May be NULL.
|
the input functions. May be NULL.
|
||||||
read_data_fn - pointer to a new input function which takes as it's
|
read_data_fn - pointer to a new input function that takes as its
|
||||||
arguments a pointer to a png_struct, a pointer to
|
arguments a pointer to a png_struct, a pointer to
|
||||||
a location where input data can be stored, and a 32-bit
|
a location where input data can be stored, and a 32-bit
|
||||||
unsigned int which is the number of bytes to be read.
|
unsigned int that is the number of bytes to be read.
|
||||||
To exit and output any fatal error messages the new write
|
To exit and output any fatal error messages the new write
|
||||||
function should call png_error(png_ptr, "Error msg"). */
|
function should call png_error(png_ptr, "Error msg"). */
|
||||||
void
|
void
|
||||||
@@ -122,13 +125,24 @@ png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
|||||||
{
|
{
|
||||||
png_ptr->io_ptr = io_ptr;
|
png_ptr->io_ptr = io_ptr;
|
||||||
|
|
||||||
|
#if !defined(PNG_NO_STDIO)
|
||||||
if (read_data_fn != NULL)
|
if (read_data_fn != NULL)
|
||||||
png_ptr->read_data_fn = read_data_fn;
|
png_ptr->read_data_fn = read_data_fn;
|
||||||
else
|
else
|
||||||
png_ptr->read_data_fn = png_default_read_data;
|
png_ptr->read_data_fn = png_default_read_data;
|
||||||
|
#else
|
||||||
|
png_ptr->read_data_fn = read_data_fn;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* It is an error to write to a read device */
|
/* It is an error to write to a read device */
|
||||||
png_ptr->write_data_fn = NULL;
|
if (png_ptr->write_data_fn != NULL)
|
||||||
|
{
|
||||||
|
png_ptr->write_data_fn = NULL;
|
||||||
|
png_warning(png_ptr,
|
||||||
|
"It's an error to set both read_data_fn and write_data_fn in the ");
|
||||||
|
png_warning(png_ptr,
|
||||||
|
"same structure. Resetting write_data_fn to NULL.");
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||||
png_ptr->output_flush_fn = NULL;
|
png_ptr->output_flush_fn = NULL;
|
||||||
|
|||||||
1874
pngrtran.c
1874
pngrtran.c
File diff suppressed because it is too large
Load Diff
729
pngrutil.c
729
pngrutil.c
File diff suppressed because it is too large
Load Diff
134
pngset.c
134
pngset.c
@@ -1,12 +1,17 @@
|
|||||||
|
|
||||||
/* pngset.c - storage of image information into info struct
|
/* pngset.c - storage of image information into info struct
|
||||||
|
*
|
||||||
libpng 1.0 beta 6 - version 0.96
|
* libpng 1.0.2b - January 6, 1999
|
||||||
For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
May 12, 1997
|
* Copyright (c) 1998, 1999 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
|
||||||
|
* into the info struct for writing into the file. This abstracts the
|
||||||
|
* info struct and allows us to change the structure in the future.
|
||||||
|
*/
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
@@ -16,7 +21,7 @@ void
|
|||||||
png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
|
png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s storage function\n", "bKGD");
|
png_debug1(1, "in %s storage function\n", "bKGD");
|
||||||
if (info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
png_memcpy(&(info_ptr->background), background, sizeof(png_color_16));
|
png_memcpy(&(info_ptr->background), background, sizeof(png_color_16));
|
||||||
@@ -31,7 +36,7 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
|
|||||||
double green_x, double green_y, double blue_x, double blue_y)
|
double green_x, double green_y, double blue_x, double blue_y)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s storage function\n", "cHRM");
|
png_debug1(1, "in %s storage function\n", "cHRM");
|
||||||
if (info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
info_ptr->x_white = (float)white_x;
|
info_ptr->x_white = (float)white_x;
|
||||||
@@ -51,7 +56,7 @@ void
|
|||||||
png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
|
png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s storage function\n", "gAMA");
|
png_debug1(1, "in %s storage function\n", "gAMA");
|
||||||
if (info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
info_ptr->gamma = (float)file_gamma;
|
info_ptr->gamma = (float)file_gamma;
|
||||||
@@ -64,7 +69,7 @@ void
|
|||||||
png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
|
png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s storage function\n", "hIST");
|
png_debug1(1, "in %s storage function\n", "hIST");
|
||||||
if (info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
info_ptr->hist = hist;
|
info_ptr->hist = hist;
|
||||||
@@ -78,8 +83,9 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
|
|||||||
int color_type, int interlace_type, int compression_type,
|
int color_type, int interlace_type, int compression_type,
|
||||||
int filter_type)
|
int filter_type)
|
||||||
{
|
{
|
||||||
|
int rowbytes_per_pixel;
|
||||||
png_debug1(1, "in %s storage function\n", "IHDR");
|
png_debug1(1, "in %s storage function\n", "IHDR");
|
||||||
if (info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
info_ptr->width = width;
|
info_ptr->width = width;
|
||||||
@@ -98,7 +104,17 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
|
|||||||
if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
|
if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
|
||||||
info_ptr->channels++;
|
info_ptr->channels++;
|
||||||
info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
|
info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
|
||||||
info_ptr->rowbytes = ((info_ptr->width * info_ptr->pixel_depth + 7) >> 3);
|
|
||||||
|
/* check for overflow */
|
||||||
|
rowbytes_per_pixel = (info_ptr->pixel_depth + 7) >> 3;
|
||||||
|
if (( width > (png_uint_32)2147483647L/rowbytes_per_pixel))
|
||||||
|
{
|
||||||
|
png_warning(png_ptr,
|
||||||
|
"Width too large to process image data; rowbytes will overflow.");
|
||||||
|
info_ptr->rowbytes = (png_size_t)0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
info_ptr->rowbytes = (info_ptr->width * info_ptr->pixel_depth + 7) >> 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||||
@@ -107,7 +123,7 @@ png_set_oFFs(png_structp png_ptr, png_infop info_ptr,
|
|||||||
png_uint_32 offset_x, png_uint_32 offset_y, int unit_type)
|
png_uint_32 offset_x, png_uint_32 offset_y, int unit_type)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s storage function\n", "oFFs");
|
png_debug1(1, "in %s storage function\n", "oFFs");
|
||||||
if (info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
info_ptr->x_offset = offset_x;
|
info_ptr->x_offset = offset_x;
|
||||||
@@ -123,17 +139,17 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
|||||||
png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams,
|
png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams,
|
||||||
png_charp units, png_charpp params)
|
png_charp units, png_charpp params)
|
||||||
{
|
{
|
||||||
png_size_t length;
|
png_uint_32 length;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
png_debug1(1, "in %s storage function\n", "pCAL");
|
png_debug1(1, "in %s storage function\n", "pCAL");
|
||||||
if (info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
length = png_strlen(purpose) + 1;
|
length = png_strlen(purpose) + 1;
|
||||||
png_debug1(3, "allocating purpose for info (%d bytes)\n", length);
|
png_debug1(3, "allocating purpose for info (%d bytes)\n", length);
|
||||||
info_ptr->pcal_purpose = (png_charp)png_malloc(png_ptr, length);
|
info_ptr->pcal_purpose = (png_charp)png_malloc(png_ptr, length);
|
||||||
png_memcpy(info_ptr->pcal_purpose, purpose, length);
|
png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length);
|
||||||
|
|
||||||
png_debug(3, "storing X0, X1, type, and nparams in info\n");
|
png_debug(3, "storing X0, X1, type, and nparams in info\n");
|
||||||
info_ptr->pcal_X0 = X0;
|
info_ptr->pcal_X0 = X0;
|
||||||
@@ -144,10 +160,10 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
|||||||
length = png_strlen(units) + 1;
|
length = png_strlen(units) + 1;
|
||||||
png_debug1(3, "allocating units for info (%d bytes)\n", length);
|
png_debug1(3, "allocating units for info (%d bytes)\n", length);
|
||||||
info_ptr->pcal_units = (png_charp)png_malloc(png_ptr, length);
|
info_ptr->pcal_units = (png_charp)png_malloc(png_ptr, length);
|
||||||
png_memcpy(info_ptr->pcal_units, units, length);
|
png_memcpy(info_ptr->pcal_units, units, (png_size_t)length);
|
||||||
|
|
||||||
info_ptr->pcal_params = (png_charpp)png_malloc(png_ptr,
|
info_ptr->pcal_params = (png_charpp)png_malloc(png_ptr,
|
||||||
(nparams + 1) * sizeof(png_charp));
|
(png_uint_32)((nparams + 1) * sizeof(png_charp)));
|
||||||
info_ptr->pcal_params[nparams] = NULL;
|
info_ptr->pcal_params[nparams] = NULL;
|
||||||
|
|
||||||
for (i = 0; i < nparams; i++)
|
for (i = 0; i < nparams; i++)
|
||||||
@@ -155,7 +171,7 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
|||||||
length = png_strlen(params[i]) + 1;
|
length = png_strlen(params[i]) + 1;
|
||||||
png_debug2(3, "allocating parameter %d for info (%d bytes)\n", i, length);
|
png_debug2(3, "allocating parameter %d for info (%d bytes)\n", i, length);
|
||||||
info_ptr->pcal_params[i] = (png_charp)png_malloc(png_ptr, length);
|
info_ptr->pcal_params[i] = (png_charp)png_malloc(png_ptr, length);
|
||||||
png_memcpy(info_ptr->pcal_params[i], params[i], length);
|
png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length);
|
||||||
}
|
}
|
||||||
|
|
||||||
info_ptr->valid |= PNG_INFO_pCAL;
|
info_ptr->valid |= PNG_INFO_pCAL;
|
||||||
@@ -168,7 +184,7 @@ png_set_pHYs(png_structp png_ptr, png_infop info_ptr,
|
|||||||
png_uint_32 res_x, png_uint_32 res_y, int unit_type)
|
png_uint_32 res_x, png_uint_32 res_y, int unit_type)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s storage function\n", "pHYs");
|
png_debug1(1, "in %s storage function\n", "pHYs");
|
||||||
if (info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
info_ptr->x_pixels_per_unit = res_x;
|
info_ptr->x_pixels_per_unit = res_x;
|
||||||
@@ -183,7 +199,7 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
|
|||||||
png_colorp palette, int num_palette)
|
png_colorp palette, int num_palette)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s storage function\n", "PLTE");
|
png_debug1(1, "in %s storage function\n", "PLTE");
|
||||||
if (info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
info_ptr->palette = palette;
|
info_ptr->palette = palette;
|
||||||
@@ -197,7 +213,7 @@ png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
|
|||||||
png_color_8p sig_bit)
|
png_color_8p sig_bit)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s storage function\n", "sBIT");
|
png_debug1(1, "in %s storage function\n", "sBIT");
|
||||||
if (info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
png_memcpy(&(info_ptr->sig_bit), sig_bit, sizeof (png_color_8));
|
png_memcpy(&(info_ptr->sig_bit), sig_bit, sizeof (png_color_8));
|
||||||
@@ -205,8 +221,57 @@ png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED) || \
|
#if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
|
||||||
defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
|
void
|
||||||
|
png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent)
|
||||||
|
{
|
||||||
|
png_debug1(1, "in %s storage function\n", "sRGB");
|
||||||
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
info_ptr->srgb_intent = (png_byte)intent;
|
||||||
|
info_ptr->valid |= PNG_INFO_sRGB;
|
||||||
|
}
|
||||||
|
void
|
||||||
|
png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||||
|
int intent)
|
||||||
|
{
|
||||||
|
#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
|
||||||
|
float file_gamma;
|
||||||
|
#endif
|
||||||
|
#if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
|
||||||
|
float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
|
||||||
|
#endif
|
||||||
|
png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM");
|
||||||
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
png_set_sRGB(png_ptr, info_ptr, intent);
|
||||||
|
|
||||||
|
#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
|
||||||
|
file_gamma = (float).45;
|
||||||
|
png_set_gAMA(png_ptr, info_ptr, file_gamma);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
|
||||||
|
white_x = (float).3127;
|
||||||
|
white_y = (float).3290;
|
||||||
|
red_x = (float).64;
|
||||||
|
red_y = (float).33;
|
||||||
|
green_x = (float).30;
|
||||||
|
green_y = (float).60;
|
||||||
|
blue_x = (float).15;
|
||||||
|
blue_y = (float).06;
|
||||||
|
|
||||||
|
png_set_cHRM(png_ptr, info_ptr,
|
||||||
|
white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
|
||||||
|
defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
|
||||||
void
|
void
|
||||||
png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||||
int num_text)
|
int num_text)
|
||||||
@@ -214,9 +279,9 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ?
|
png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ?
|
||||||
"text" : png_ptr->chunk_name));
|
"text" : (png_const_charp)png_ptr->chunk_name));
|
||||||
|
|
||||||
if (info_ptr == NULL || num_text == 0)
|
if (png_ptr == NULL || info_ptr == NULL || num_text == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Make sure we have enough space in the "text" array in info_struct
|
/* Make sure we have enough space in the "text" array in info_struct
|
||||||
@@ -233,8 +298,9 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
|||||||
info_ptr->max_text = info_ptr->num_text + num_text + 8;
|
info_ptr->max_text = info_ptr->num_text + num_text + 8;
|
||||||
old_text = info_ptr->text;
|
old_text = info_ptr->text;
|
||||||
info_ptr->text = (png_textp)png_malloc(png_ptr,
|
info_ptr->text = (png_textp)png_malloc(png_ptr,
|
||||||
info_ptr->max_text * sizeof (png_text));
|
(png_uint_32)(info_ptr->max_text * sizeof (png_text)));
|
||||||
png_memcpy(info_ptr->text, old_text, old_max * sizeof(png_text));
|
png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max *
|
||||||
|
sizeof(png_text)));
|
||||||
png_free(png_ptr, old_text);
|
png_free(png_ptr, old_text);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -242,7 +308,7 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
|||||||
info_ptr->max_text = num_text + 8;
|
info_ptr->max_text = num_text + 8;
|
||||||
info_ptr->num_text = 0;
|
info_ptr->num_text = 0;
|
||||||
info_ptr->text = (png_textp)png_malloc(png_ptr,
|
info_ptr->text = (png_textp)png_malloc(png_ptr,
|
||||||
info_ptr->max_text * sizeof (png_text));
|
(png_uint_32)(info_ptr->max_text * sizeof (png_text)));
|
||||||
}
|
}
|
||||||
png_debug1(3, "allocated %d entries for info_ptr->text\n",
|
png_debug1(3, "allocated %d entries for info_ptr->text\n",
|
||||||
info_ptr->max_text);
|
info_ptr->max_text);
|
||||||
@@ -253,7 +319,7 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
|||||||
png_textp textp = &(info_ptr->text[info_ptr->num_text]);
|
png_textp textp = &(info_ptr->text[info_ptr->num_text]);
|
||||||
|
|
||||||
if (text_ptr[i].text == NULL)
|
if (text_ptr[i].text == NULL)
|
||||||
text_ptr[i].text = "";
|
text_ptr[i].text = (png_charp)"";
|
||||||
|
|
||||||
if (text_ptr[i].text[0] == '\0')
|
if (text_ptr[i].text[0] == '\0')
|
||||||
{
|
{
|
||||||
@@ -278,7 +344,7 @@ void
|
|||||||
png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
|
png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s storage function\n", "tIME");
|
png_debug1(1, "in %s storage function\n", "tIME");
|
||||||
if (info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
png_memcpy(&(info_ptr->mod_time), mod_time, sizeof (png_time));
|
png_memcpy(&(info_ptr->mod_time), mod_time, sizeof (png_time));
|
||||||
@@ -292,7 +358,7 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
|||||||
png_bytep trans, int num_trans, png_color_16p trans_values)
|
png_bytep trans, int num_trans, png_color_16p trans_values)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s storage function\n", "tRNS");
|
png_debug1(1, "in %s storage function\n", "tRNS");
|
||||||
if (info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (trans != NULL)
|
if (trans != NULL)
|
||||||
@@ -304,6 +370,8 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
|||||||
{
|
{
|
||||||
png_memcpy(&(info_ptr->trans_values), trans_values,
|
png_memcpy(&(info_ptr->trans_values), trans_values,
|
||||||
sizeof(png_color_16));
|
sizeof(png_color_16));
|
||||||
|
if (num_trans == 0)
|
||||||
|
num_trans = 1;
|
||||||
}
|
}
|
||||||
info_ptr->num_trans = (png_uint_16)num_trans;
|
info_ptr->num_trans = (png_uint_16)num_trans;
|
||||||
info_ptr->valid |= PNG_INFO_tRNS;
|
info_ptr->valid |= PNG_INFO_tRNS;
|
||||||
|
|||||||
824
pngtest.c
824
pngtest.c
@@ -1,12 +1,31 @@
|
|||||||
|
|
||||||
/* pngtest.c - a simple test program to test libpng
|
/* pngtest.c - a simple test program to test libpng
|
||||||
|
*
|
||||||
libpng 1.0 beta 6 - version 0.96
|
* libpng 1.0.2b -January 6, 1999
|
||||||
For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
May 12, 1997
|
* Copyright (c) 1998, 1999 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
|
||||||
|
* the basic chunk handling, filtering, and (de)compression code is working
|
||||||
|
* properly. It does not currently test all of the transforms, although
|
||||||
|
* it probably should.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* testing a wide variety of files easily. You can also test a number
|
||||||
|
* of files at once by typing "pngtest -m file1.png file2.png ..."
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -18,6 +37,13 @@
|
|||||||
|
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
|
||||||
|
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||||
|
static int tIME_chunk_present=0;
|
||||||
|
static char tIME_string[30] = "no tIME chunk present in file";
|
||||||
|
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||||
|
|
||||||
|
int test_one_file PNGARG((PNG_CONST char *inname, PNG_CONST char *outname));
|
||||||
|
|
||||||
#ifdef __TURBOC__
|
#ifdef __TURBOC__
|
||||||
#include <mem.h>
|
#include <mem.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -26,21 +52,418 @@
|
|||||||
/* #define STDERR stderr */
|
/* #define STDERR stderr */
|
||||||
#define STDERR stdout /* for DOS */
|
#define STDERR stdout /* for DOS */
|
||||||
|
|
||||||
/* input and output filenames */
|
/* example of using row callbacks to make a simple progress meter */
|
||||||
#ifdef RISCOS
|
static int status_pass=1;
|
||||||
char *inname = "pngtest_png";
|
static int status_dots_requested=0;
|
||||||
char *outname = "pngout_png";
|
static int status_dots=1;
|
||||||
|
|
||||||
|
void
|
||||||
|
read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
|
||||||
|
{
|
||||||
|
if(png_ptr == NULL || row_number > 0x3fffffffL) return;
|
||||||
|
if(status_pass != pass)
|
||||||
|
{
|
||||||
|
fprintf(stdout,"\n Pass %d: ",pass);
|
||||||
|
status_pass = pass;
|
||||||
|
status_dots = 30;
|
||||||
|
}
|
||||||
|
status_dots--;
|
||||||
|
if(status_dots == 0)
|
||||||
|
{
|
||||||
|
fprintf(stdout, "\n ");
|
||||||
|
status_dots=30;
|
||||||
|
}
|
||||||
|
fprintf(stdout, "r");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
|
||||||
|
{
|
||||||
|
if(png_ptr == NULL || row_number > 0x3fffffffL || pass > 7) return;
|
||||||
|
fprintf(stdout, "w");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||||
|
/* example of using user transform callback (we don't transform anything,
|
||||||
|
but merely count the zero samples) */
|
||||||
|
|
||||||
|
static png_uint_32 zero_samples;
|
||||||
|
|
||||||
|
void
|
||||||
|
count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||||
|
{
|
||||||
|
png_bytep dp = data;
|
||||||
|
if(png_ptr == NULL)return;
|
||||||
|
|
||||||
|
/* contents of row_info:
|
||||||
|
* png_uint_32 width width of row
|
||||||
|
* png_uint_32 rowbytes number of bytes in row
|
||||||
|
* png_byte color_type color type of pixels
|
||||||
|
* png_byte bit_depth bit depth of samples
|
||||||
|
* png_byte channels number of channels (1-4)
|
||||||
|
* png_byte pixel_depth bits per pixel (depth*channels)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* counts the number of zero samples (or zero pixels if color_type is 3 */
|
||||||
|
|
||||||
|
if(row_info->color_type == 0 || row_info->color_type == 3)
|
||||||
|
{
|
||||||
|
int pos=0;
|
||||||
|
png_uint_32 n, nstop;
|
||||||
|
for (n=0, nstop=row_info->width; n<nstop; n++)
|
||||||
|
{
|
||||||
|
if(row_info->bit_depth == 1)
|
||||||
|
{
|
||||||
|
if(((*dp << pos++ )& 0x80) == 0) zero_samples++;
|
||||||
|
if(pos == 8)
|
||||||
|
{
|
||||||
|
pos = 0;
|
||||||
|
dp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(row_info->bit_depth == 2)
|
||||||
|
{
|
||||||
|
if(((*dp << (pos+=2))& 0xc0) == 0) zero_samples++;
|
||||||
|
if(pos == 8)
|
||||||
|
{
|
||||||
|
pos = 0;
|
||||||
|
dp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(row_info->bit_depth == 4)
|
||||||
|
{
|
||||||
|
if(((*dp << (pos+=4))& 0xf0) == 0) zero_samples++;
|
||||||
|
if(pos == 8)
|
||||||
|
{
|
||||||
|
pos = 0;
|
||||||
|
dp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(row_info->bit_depth == 8)
|
||||||
|
if(*dp++ == 0) zero_samples++;
|
||||||
|
if(row_info->bit_depth == 16)
|
||||||
|
{
|
||||||
|
if((*dp | *(dp+1)) == 0) zero_samples++;
|
||||||
|
dp+=2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else /* other color types */
|
||||||
|
{
|
||||||
|
png_uint_32 n, nstop;
|
||||||
|
int channel;
|
||||||
|
int color_channels = row_info->channels;
|
||||||
|
if(row_info->color_type > 3)color_channels--;
|
||||||
|
|
||||||
|
for (n=0, nstop=row_info->width; n<nstop; n++)
|
||||||
|
{
|
||||||
|
for (channel = 0; channel < color_channels; channel++)
|
||||||
|
{
|
||||||
|
if(row_info->bit_depth == 8)
|
||||||
|
if(*dp++ == 0) zero_samples++;
|
||||||
|
if(row_info->bit_depth == 16)
|
||||||
|
{
|
||||||
|
if((*dp | *(dp+1)) == 0) zero_samples++;
|
||||||
|
dp+=2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(row_info->color_type > 3)
|
||||||
|
{
|
||||||
|
dp++;
|
||||||
|
if(row_info->bit_depth == 16)dp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* PNG_WRITE_USER_TRANSFORM_SUPPORTED */
|
||||||
|
|
||||||
|
static int verbose = 0;
|
||||||
|
static int wrote_question = 0;
|
||||||
|
|
||||||
|
#if defined(PNG_NO_STDIO)
|
||||||
|
/* START of code to validate stdio-free compilation */
|
||||||
|
/* These copies of the default read/write functions come from pngrio.c and */
|
||||||
|
/* pngwio.c. They allow "don't include stdio" testing of the library. */
|
||||||
|
/* This is the function that does the actual reading of data. If you are
|
||||||
|
not reading from a standard C stream, you should create a replacement
|
||||||
|
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
|
||||||
|
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
|
{
|
||||||
|
png_size_t check;
|
||||||
|
|
||||||
|
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
|
||||||
|
* instead of an int, which is what fread() actually returns.
|
||||||
|
*/
|
||||||
|
check = (png_size_t)fread(data, (png_size_t)1, length,
|
||||||
|
(FILE *)png_ptr->io_ptr);
|
||||||
|
|
||||||
|
if (check != length)
|
||||||
|
{
|
||||||
|
png_error(png_ptr, "Read Error");
|
||||||
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
char *inname = "pngtest.png";
|
/* this is the model-independent version. Since the standard I/O library
|
||||||
char *outname = "pngout.png";
|
can't handle far buffers in the medium and small models, we have to copy
|
||||||
|
the data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define NEAR_BUF_SIZE 1024
|
||||||
|
#define MIN(a,b) (a <= b ? a : b)
|
||||||
|
|
||||||
|
static void
|
||||||
|
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
|
{
|
||||||
|
int check;
|
||||||
|
png_byte *n_data;
|
||||||
|
FILE *io_ptr;
|
||||||
|
|
||||||
|
/* Check if data really is near. If so, use usual code. */
|
||||||
|
n_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||||
|
io_ptr = (FILE *)CVT_PTR(png_ptr->io_ptr);
|
||||||
|
if ((png_bytep)n_data == data)
|
||||||
|
{
|
||||||
|
check = fread(n_data, 1, length, io_ptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
png_byte buf[NEAR_BUF_SIZE];
|
||||||
|
png_size_t read, remaining, err;
|
||||||
|
check = 0;
|
||||||
|
remaining = length;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
read = MIN(NEAR_BUF_SIZE, remaining);
|
||||||
|
err = fread(buf, (png_size_t)1, read, io_ptr);
|
||||||
|
png_memcpy(data, buf, read); /* copy far buffer to near buffer */
|
||||||
|
if(err != read)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
check += err;
|
||||||
|
data += read;
|
||||||
|
remaining -= read;
|
||||||
|
}
|
||||||
|
while (remaining != 0);
|
||||||
|
}
|
||||||
|
if (check != length)
|
||||||
|
{
|
||||||
|
png_error(png_ptr, "read Error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* USE_FAR_KEYWORD */
|
||||||
|
|
||||||
|
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||||
|
static void
|
||||||
|
png_default_flush(png_structp png_ptr)
|
||||||
|
{
|
||||||
|
FILE *io_ptr;
|
||||||
|
io_ptr = (FILE *)CVT_PTR((png_ptr->io_ptr));
|
||||||
|
if (io_ptr != NULL)
|
||||||
|
fflush(io_ptr);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char inbuf[256], outbuf[256];
|
/* This is the function that does the actual writing of data. If you are
|
||||||
|
not writing to a standard C stream, you should create a replacement
|
||||||
int
|
write_data function and use it at run time with png_set_write_fn(), rather
|
||||||
main(int argc, char *argv[])
|
than changing the library. */
|
||||||
|
#ifndef USE_FAR_KEYWORD
|
||||||
|
static void
|
||||||
|
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
{
|
{
|
||||||
FILE *fpin, *fpout;
|
png_uint_32 check;
|
||||||
|
|
||||||
|
check = fwrite(data, 1, length, (FILE *)(png_ptr->io_ptr));
|
||||||
|
if (check != length)
|
||||||
|
{
|
||||||
|
png_error(png_ptr, "Write Error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/* this is the model-independent version. Since the standard I/O library
|
||||||
|
can't handle far buffers in the medium and small models, we have to copy
|
||||||
|
the data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define NEAR_BUF_SIZE 1024
|
||||||
|
#define MIN(a,b) (a <= b ? a : b)
|
||||||
|
|
||||||
|
static void
|
||||||
|
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
|
{
|
||||||
|
png_uint_32 check;
|
||||||
|
png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */
|
||||||
|
FILE *io_ptr;
|
||||||
|
|
||||||
|
/* Check if data really is near. If so, use usual code. */
|
||||||
|
near_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||||
|
io_ptr = (FILE *)CVT_PTR(png_ptr->io_ptr);
|
||||||
|
if ((png_bytep)near_data == data)
|
||||||
|
{
|
||||||
|
check = fwrite(near_data, 1, length, io_ptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
png_byte buf[NEAR_BUF_SIZE];
|
||||||
|
png_size_t written, remaining, err;
|
||||||
|
check = 0;
|
||||||
|
remaining = length;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
written = MIN(NEAR_BUF_SIZE, remaining);
|
||||||
|
png_memcpy(buf, data, written); /* copy far buffer to near buffer */
|
||||||
|
err = fwrite(buf, 1, written, io_ptr);
|
||||||
|
if (err != written)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
check += err;
|
||||||
|
data += written;
|
||||||
|
remaining -= written;
|
||||||
|
}
|
||||||
|
while (remaining != 0);
|
||||||
|
}
|
||||||
|
if (check != length)
|
||||||
|
{
|
||||||
|
png_error(png_ptr, "Write Error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* USE_FAR_KEYWORD */
|
||||||
|
|
||||||
|
/* This function is called when there is a warning, but the library thinks
|
||||||
|
* it can continue anyway. Replacement functions don't have to do anything
|
||||||
|
* here if you don't want to. In the default configuration, png_ptr is
|
||||||
|
* not used, but it is passed in case it may be useful.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
png_default_warning(png_structp png_ptr, png_const_charp message)
|
||||||
|
{
|
||||||
|
PNG_CONST char *name = "UNKNOWN (ERROR!)";
|
||||||
|
if (png_ptr != NULL && png_ptr->error_ptr != NULL)
|
||||||
|
name = png_ptr->error_ptr;
|
||||||
|
fprintf(STDERR, "%s: libpng warning: %s\n", name, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This is the default error handling function. Note that replacements for
|
||||||
|
* this function MUST NOT RETURN, or the program will likely crash. This
|
||||||
|
* function is used by default, or if the program supplies NULL for the
|
||||||
|
* error function pointer in png_set_error_fn().
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
png_default_error(png_structp png_ptr, png_const_charp message)
|
||||||
|
{
|
||||||
|
png_default_warning(png_ptr, message);
|
||||||
|
/* We can return because png_error calls the default handler, which is
|
||||||
|
* actually OK in this case. */
|
||||||
|
}
|
||||||
|
#endif /* PNG_NO_STDIO */
|
||||||
|
/* END of code to validate stdio-free compilation */
|
||||||
|
|
||||||
|
/* START of code to validate memory allocation and deallocation */
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
|
||||||
|
/* Allocate memory. For reasonable files, size should never exceed
|
||||||
|
64K. However, zlib may allocate more then 64K if you don't tell
|
||||||
|
it not to. See zconf.h and png.h for more information. zlib does
|
||||||
|
need to allocate exactly 64K, so whatever you call here must
|
||||||
|
have the ability to do that.
|
||||||
|
|
||||||
|
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 {
|
||||||
|
png_uint_32 size;
|
||||||
|
png_voidp pointer;
|
||||||
|
struct memory_information FAR *next;
|
||||||
|
} memory_information;
|
||||||
|
typedef memory_information FAR *memory_infop;
|
||||||
|
|
||||||
|
static memory_infop pinformation = NULL;
|
||||||
|
static int current_allocation = 0;
|
||||||
|
static int maximum_allocation = 0;
|
||||||
|
|
||||||
|
extern PNG_EXPORT(png_voidp,png_debug_malloc) PNGARG((png_structp png_ptr,
|
||||||
|
png_uint_32 size));
|
||||||
|
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_malloc has already tested for NULL; png_create_struct calls
|
||||||
|
png_debug_malloc directly, with png_ptr == NULL which is OK */
|
||||||
|
|
||||||
|
if (size == 0)
|
||||||
|
return (png_voidp)(NULL);
|
||||||
|
|
||||||
|
/* This calls the library allocator twice, once to get the requested
|
||||||
|
buffer and once to get a new free list entry. */
|
||||||
|
{
|
||||||
|
memory_infop pinfo = png_malloc_default(png_ptr, sizeof *pinfo);
|
||||||
|
pinfo->size = size;
|
||||||
|
current_allocation += size;
|
||||||
|
if (current_allocation > maximum_allocation)
|
||||||
|
maximum_allocation = current_allocation;
|
||||||
|
pinfo->pointer = png_malloc_default(png_ptr, size);
|
||||||
|
pinfo->next = pinformation;
|
||||||
|
pinformation = pinfo;
|
||||||
|
/* Make sure the caller isn't assuming zeroed memory. */
|
||||||
|
png_memset(pinfo->pointer, 0xdd, pinfo->size);
|
||||||
|
return (png_voidp)(pinfo->pointer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free a pointer. It is removed from the list at the same time. */
|
||||||
|
void
|
||||||
|
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 0 /* This happens all the time. */
|
||||||
|
fprintf(STDERR, "WARNING: freeing NULL pointer\n");
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unlink the element from the list. */
|
||||||
|
{
|
||||||
|
memory_infop FAR *ppinfo = &pinformation;
|
||||||
|
for (;;) {
|
||||||
|
memory_infop pinfo = *ppinfo;
|
||||||
|
if (pinfo->pointer == ptr) {
|
||||||
|
*ppinfo = pinfo->next;
|
||||||
|
current_allocation -= pinfo->size;
|
||||||
|
if (current_allocation < 0)
|
||||||
|
fprintf(STDERR, "Duplicate free of memory\n");
|
||||||
|
/* We must free the list element too, but first kill
|
||||||
|
the memory that is to be freed. */
|
||||||
|
memset(ptr, 0x55, pinfo->size);
|
||||||
|
png_free_default(png_ptr, pinfo);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (pinfo->next == NULL) {
|
||||||
|
fprintf(STDERR, "Pointer %x not found\n", ptr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ppinfo = &pinfo->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Finally free the data. */
|
||||||
|
png_free_default(png_ptr, ptr);
|
||||||
|
}
|
||||||
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
|
/* END of code to test memory allocation/deallocation */
|
||||||
|
|
||||||
|
/* Test one file */
|
||||||
|
int
|
||||||
|
test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
|
{
|
||||||
|
static FILE *fpin, *fpout; /* "static" prevents setjmp corruption */
|
||||||
png_structp read_ptr, write_ptr;
|
png_structp read_ptr, write_ptr;
|
||||||
png_infop read_info_ptr, write_info_ptr, end_info_ptr;
|
png_infop read_info_ptr, write_info_ptr, end_info_ptr;
|
||||||
png_bytep row_buf;
|
png_bytep row_buf;
|
||||||
@@ -51,52 +474,55 @@ main(int argc, char *argv[])
|
|||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
jmp_buf jmpbuf;
|
jmp_buf jmpbuf;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
char inbuf[256], outbuf[256];
|
||||||
|
|
||||||
row_buf = (png_bytep)NULL;
|
row_buf = (png_bytep)NULL;
|
||||||
|
|
||||||
fprintf(STDERR, "Testing libpng version %s\n", PNG_LIBPNG_VER_STRING);
|
|
||||||
|
|
||||||
if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING))
|
|
||||||
{
|
|
||||||
fprintf(STDERR,
|
|
||||||
"Warning: versions are different between png.h and png.c\n");
|
|
||||||
fprintf(STDERR, " png.h version: %s\n", PNG_LIBPNG_VER_STRING);
|
|
||||||
fprintf(STDERR, " png.c version: %s\n\n", png_libpng_ver);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc > 1)
|
|
||||||
inname = argv[1];
|
|
||||||
|
|
||||||
if (argc > 2)
|
|
||||||
outname = argv[2];
|
|
||||||
|
|
||||||
if (argc > 3)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "usage: %s [infile.png] [outfile.png]\n", argv[0]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((fpin = fopen(inname, "rb")) == NULL)
|
if ((fpin = fopen(inname, "rb")) == NULL)
|
||||||
{
|
{
|
||||||
fprintf(STDERR, "Could not find input file %s\n", inname);
|
fprintf(STDERR, "Could not find input file %s\n", inname);
|
||||||
return 1;
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((fpout = fopen(outname, "wb")) == NULL)
|
if ((fpout = fopen(outname, "wb")) == NULL)
|
||||||
{
|
{
|
||||||
fprintf(STDERR, "Could not open output file %s\n", outname);
|
fprintf(STDERR, "Could not open output file %s\n", outname);
|
||||||
fclose(fpin);
|
fclose(fpin);
|
||||||
return 1;
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
png_debug(0, "Allocating read and write structures\n");
|
png_debug(0, "Allocating read and write structures\n");
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
read_ptr = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
|
||||||
|
(png_error_ptr)NULL, (png_error_ptr)NULL, (png_voidp)NULL,
|
||||||
|
(png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free);
|
||||||
|
#else
|
||||||
read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
|
read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
|
||||||
(png_error_ptr)NULL, (png_error_ptr)NULL);
|
(png_error_ptr)NULL, (png_error_ptr)NULL);
|
||||||
|
#endif
|
||||||
|
#if defined(PNG_NO_STDIO)
|
||||||
|
png_set_error_fn(read_ptr, (png_voidp)inname, png_default_error,
|
||||||
|
png_default_warning);
|
||||||
|
#endif
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
|
||||||
|
(png_error_ptr)NULL, (png_error_ptr)NULL, (png_voidp)NULL,
|
||||||
|
(png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free);
|
||||||
|
#else
|
||||||
write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
|
write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
|
||||||
(png_error_ptr)NULL, (png_error_ptr)NULL);
|
(png_error_ptr)NULL, (png_error_ptr)NULL);
|
||||||
|
#endif
|
||||||
|
#if defined(PNG_NO_STDIO)
|
||||||
|
png_set_error_fn(write_ptr, (png_voidp)inname, png_default_error,
|
||||||
|
png_default_warning);
|
||||||
|
#endif
|
||||||
png_debug(0, "Allocating read_info, write_info and end_info structures\n");
|
png_debug(0, "Allocating read_info, write_info and end_info structures\n");
|
||||||
read_info_ptr = png_create_info_struct(read_ptr);
|
read_info_ptr = png_create_info_struct(read_ptr);
|
||||||
write_info_ptr = png_create_info_struct(read_ptr);
|
write_info_ptr = png_create_info_struct(write_ptr);
|
||||||
end_info_ptr = png_create_info_struct(read_ptr);
|
end_info_ptr = png_create_info_struct(read_ptr);
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
#endif
|
||||||
|
|
||||||
png_debug(0, "Setting jmpbuf for read struct\n");
|
png_debug(0, "Setting jmpbuf for read struct\n");
|
||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
@@ -105,36 +531,63 @@ main(int argc, char *argv[])
|
|||||||
if (setjmp(read_ptr->jmpbuf))
|
if (setjmp(read_ptr->jmpbuf))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
fprintf(STDERR, "libpng read error\n");
|
fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname);
|
||||||
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
||||||
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
||||||
fclose(fpin);
|
fclose(fpin);
|
||||||
fclose(fpout);
|
fclose(fpout);
|
||||||
return 1;
|
return (1);
|
||||||
}
|
}
|
||||||
|
#ifdef USE_FAR_KEYWORD
|
||||||
|
png_memcpy(read_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
|
||||||
|
#endif
|
||||||
|
|
||||||
png_debug(0, "Setting jmpbuf for write struct\n");
|
png_debug(0, "Setting jmpbuf for write struct\n");
|
||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
png_memcpy(read_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
|
|
||||||
if (setjmp(jmpbuf))
|
if (setjmp(jmpbuf))
|
||||||
#else
|
#else
|
||||||
if (setjmp(write_ptr->jmpbuf))
|
if (setjmp(write_ptr->jmpbuf))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
fprintf(STDERR, "libpng write error\n");
|
fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname);
|
||||||
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
||||||
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
||||||
fclose(fpin);
|
fclose(fpin);
|
||||||
fclose(fpout);
|
fclose(fpout);
|
||||||
return 1;
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
png_memcpy(write_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
|
png_memcpy(write_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_debug(0, "Initializing input and output streams\n");
|
png_debug(0, "Initializing input and output streams\n");
|
||||||
|
#if !defined(PNG_NO_STDIO)
|
||||||
png_init_io(read_ptr, fpin);
|
png_init_io(read_ptr, fpin);
|
||||||
png_init_io(write_ptr, fpout);
|
png_init_io(write_ptr, fpout);
|
||||||
|
#else
|
||||||
|
png_set_read_fn(read_ptr, (png_voidp)fpin, png_default_read_data);
|
||||||
|
png_set_write_fn(write_ptr, (png_voidp)fpout, png_default_write_data,
|
||||||
|
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||||
|
png_default_flush);
|
||||||
|
#else
|
||||||
|
NULL);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
if(status_dots_requested == 1)
|
||||||
|
{
|
||||||
|
png_set_write_status_fn(write_ptr, write_row_callback);
|
||||||
|
png_set_read_status_fn(read_ptr, read_row_callback);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
png_set_write_status_fn(write_ptr, NULL);
|
||||||
|
png_set_read_status_fn(read_ptr, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
# if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||||
|
zero_samples=0;
|
||||||
|
png_set_write_user_transform_fn(write_ptr, count_zero_samples);
|
||||||
|
# endif
|
||||||
|
|
||||||
png_debug(0, "Reading info struct\n");
|
png_debug(0, "Reading info struct\n");
|
||||||
png_read_info(read_ptr, read_info_ptr);
|
png_read_info(read_ptr, read_info_ptr);
|
||||||
@@ -147,7 +600,11 @@ main(int argc, char *argv[])
|
|||||||
&color_type, &interlace_type, &compression_type, &filter_type))
|
&color_type, &interlace_type, &compression_type, &filter_type))
|
||||||
{
|
{
|
||||||
png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth,
|
png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth,
|
||||||
|
#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||||
color_type, interlace_type, compression_type, filter_type);
|
color_type, interlace_type, compression_type, filter_type);
|
||||||
|
#else
|
||||||
|
color_type, PNG_INTERLACE_NONE, compression_type, filter_type);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if defined(PNG_READ_bKGD_SUPPORTED) && defined(PNG_WRITE_bKGD_SUPPORTED)
|
#if defined(PNG_READ_bKGD_SUPPORTED) && defined(PNG_WRITE_bKGD_SUPPORTED)
|
||||||
@@ -182,6 +639,16 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(PNG_READ_sRGB_SUPPORTED) && defined(PNG_WRITE_sRGB_SUPPORTED)
|
||||||
|
{
|
||||||
|
int intent;
|
||||||
|
|
||||||
|
if (png_get_sRGB(read_ptr, read_info_ptr, &intent))
|
||||||
|
{
|
||||||
|
png_set_sRGB(write_ptr, write_info_ptr, intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#if defined(PNG_READ_hIST_SUPPORTED) && defined(PNG_WRITE_hIST_SUPPORTED)
|
#if defined(PNG_READ_hIST_SUPPORTED) && defined(PNG_WRITE_hIST_SUPPORTED)
|
||||||
{
|
{
|
||||||
png_uint_16p hist;
|
png_uint_16p hist;
|
||||||
@@ -268,6 +735,13 @@ main(int argc, char *argv[])
|
|||||||
if (png_get_tIME(read_ptr, read_info_ptr, &mod_time))
|
if (png_get_tIME(read_ptr, read_info_ptr, &mod_time))
|
||||||
{
|
{
|
||||||
png_set_tIME(write_ptr, write_info_ptr, mod_time);
|
png_set_tIME(write_ptr, write_info_ptr, mod_time);
|
||||||
|
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||||
|
/* we have to use png_strcpy instead of "=" because the string
|
||||||
|
pointed to by png_convert_to_rfc1123() gets free'ed before
|
||||||
|
we use it */
|
||||||
|
png_strcpy(tIME_string,png_convert_to_rfc1123(read_ptr, mod_time));
|
||||||
|
tIME_chunk_present++;
|
||||||
|
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -289,7 +763,8 @@ main(int argc, char *argv[])
|
|||||||
png_debug(0, "\nWriting info struct\n");
|
png_debug(0, "\nWriting info struct\n");
|
||||||
png_write_info(write_ptr, write_info_ptr);
|
png_write_info(write_ptr, write_info_ptr);
|
||||||
|
|
||||||
row_buf = (png_bytep)png_malloc(read_ptr,
|
png_debug(0, "\nAllocating row buffer \n");
|
||||||
|
row_buf = (png_bytep)png_malloc(read_ptr,
|
||||||
png_get_rowbytes(read_ptr, read_info_ptr));
|
png_get_rowbytes(read_ptr, read_info_ptr));
|
||||||
if (row_buf == NULL)
|
if (row_buf == NULL)
|
||||||
{
|
{
|
||||||
@@ -298,14 +773,16 @@ main(int argc, char *argv[])
|
|||||||
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
||||||
fclose(fpin);
|
fclose(fpin);
|
||||||
fclose(fpout);
|
fclose(fpout);
|
||||||
return 1;
|
return (1);
|
||||||
}
|
}
|
||||||
|
png_debug(0, "Writing row data\n");
|
||||||
|
|
||||||
num_pass = png_set_interlace_handling(read_ptr);
|
num_pass = png_set_interlace_handling(read_ptr);
|
||||||
png_set_interlace_handling(write_ptr);
|
png_set_interlace_handling(write_ptr);
|
||||||
|
|
||||||
for (pass = 0; pass < num_pass; pass++)
|
for (pass = 0; pass < num_pass; pass++)
|
||||||
{
|
{
|
||||||
|
png_debug1(0, "Writing row data for pass %d\n",pass);
|
||||||
for (y = 0; y < height; y++)
|
for (y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
png_read_rows(read_ptr, (png_bytepp)&row_buf, (png_bytepp)NULL, 1);
|
png_read_rows(read_ptr, (png_bytepp)&row_buf, (png_bytepp)NULL, 1);
|
||||||
@@ -317,30 +794,40 @@ main(int argc, char *argv[])
|
|||||||
png_read_end(read_ptr, end_info_ptr);
|
png_read_end(read_ptr, end_info_ptr);
|
||||||
png_write_end(write_ptr, end_info_ptr);
|
png_write_end(write_ptr, end_info_ptr);
|
||||||
|
|
||||||
|
#ifdef PNG_EASY_ACCESS_SUPPORTED
|
||||||
|
if(verbose)
|
||||||
|
{
|
||||||
|
png_uint_32 iwidth, iheight;
|
||||||
|
iwidth = png_get_image_width(write_ptr, write_info_ptr);
|
||||||
|
iheight = png_get_image_height(write_ptr, write_info_ptr);
|
||||||
|
fprintf(STDERR, "Image width = %lu, height = %lu\n",
|
||||||
|
iwidth, iheight);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
png_debug(0, "Destroying data structs\n");
|
png_debug(0, "Destroying data structs\n");
|
||||||
|
png_free(read_ptr, row_buf);
|
||||||
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
||||||
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
||||||
|
|
||||||
fclose(fpin);
|
fclose(fpin);
|
||||||
fclose(fpout);
|
fclose(fpout);
|
||||||
|
|
||||||
png_free(read_ptr, row_buf);
|
|
||||||
|
|
||||||
png_debug(0, "Opening files for comparison\n");
|
png_debug(0, "Opening files for comparison\n");
|
||||||
if ((fpin = fopen(inname, "rb")) == NULL)
|
if ((fpin = fopen(inname, "rb")) == NULL)
|
||||||
{
|
{
|
||||||
fprintf(STDERR, "Could not find file %s\n", inname);
|
fprintf(STDERR, "Could not find file %s\n", inname);
|
||||||
return 1;
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((fpout = fopen(outname, "rb")) == NULL)
|
if ((fpout = fopen(outname, "rb")) == NULL)
|
||||||
{
|
{
|
||||||
fprintf(STDERR, "Could not find file %s\n", outname);
|
fprintf(STDERR, "Could not find file %s\n", outname);
|
||||||
fclose(fpin);
|
fclose(fpin);
|
||||||
return 1;
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1)
|
for(;;)
|
||||||
{
|
{
|
||||||
png_size_t num_in, num_out;
|
png_size_t num_in, num_out;
|
||||||
|
|
||||||
@@ -351,9 +838,20 @@ main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
fprintf(STDERR, "Files %s and %s are of a different size\n",
|
fprintf(STDERR, "Files %s and %s are of a different size\n",
|
||||||
inname, outname);
|
inname, outname);
|
||||||
|
if(wrote_question == 0)
|
||||||
|
{
|
||||||
|
fprintf(STDERR,
|
||||||
|
" Was %s written with the same chunk size (8k),",inname);
|
||||||
|
fprintf(STDERR,
|
||||||
|
" filtering\n heuristic (libpng default), compression");
|
||||||
|
fprintf(STDERR,
|
||||||
|
" level (zlib default)\n and zlib version (%s)?\n\n",
|
||||||
|
ZLIB_VERSION);
|
||||||
|
wrote_question=1;
|
||||||
|
}
|
||||||
fclose(fpin);
|
fclose(fpin);
|
||||||
fclose(fpout);
|
fclose(fpout);
|
||||||
return 1;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!num_in)
|
if (!num_in)
|
||||||
@@ -362,16 +860,222 @@ main(int argc, char *argv[])
|
|||||||
if (png_memcmp(inbuf, outbuf, num_in))
|
if (png_memcmp(inbuf, outbuf, num_in))
|
||||||
{
|
{
|
||||||
fprintf(STDERR, "Files %s and %s are different\n", inname, outname);
|
fprintf(STDERR, "Files %s and %s are different\n", inname, outname);
|
||||||
|
if(wrote_question == 0)
|
||||||
|
{
|
||||||
|
fprintf(STDERR,
|
||||||
|
" Was %s written with the same chunk size (8k),",inname);
|
||||||
|
fprintf(STDERR,
|
||||||
|
" filtering\n heuristic (libpng default), compression");
|
||||||
|
fprintf(STDERR,
|
||||||
|
" level (zlib default)\n and zlib version (%s)?\n\n",
|
||||||
|
ZLIB_VERSION);
|
||||||
|
wrote_question=1;
|
||||||
|
}
|
||||||
fclose(fpin);
|
fclose(fpin);
|
||||||
fclose(fpout);
|
fclose(fpout);
|
||||||
return 1;
|
return (0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fpin);
|
fclose(fpin);
|
||||||
fclose(fpout);
|
fclose(fpout);
|
||||||
fprintf(STDERR, "libpng passes test\n");
|
|
||||||
|
|
||||||
return 0;
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* input and output filenames */
|
||||||
|
#ifdef RISCOS
|
||||||
|
PNG_CONST char *inname = "pngtest/png";
|
||||||
|
PNG_CONST char *outname = "pngout/png";
|
||||||
|
#else
|
||||||
|
static PNG_CONST char *inname = "pngtest.png";
|
||||||
|
static PNG_CONST char *outname = "pngout.png";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int multiple = 0;
|
||||||
|
int ierror = 0;
|
||||||
|
|
||||||
|
fprintf(STDERR, "Testing libpng version %s\n", PNG_LIBPNG_VER_STRING);
|
||||||
|
fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION);
|
||||||
|
fprintf(STDERR,"%s",png_get_copyright(NULL));
|
||||||
|
|
||||||
|
/* 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
|
||||||
|
tests should be impossible because of the way the macros are set
|
||||||
|
in pngconf.h */
|
||||||
|
#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
|
||||||
|
fprintf(STDERR, " NOTE: Zlib compiled for max 64k, libpng not\n");
|
||||||
|
#endif
|
||||||
|
/* I think the following can happen. */
|
||||||
|
#if !defined(MAXSEG_64K) && defined(PNG_MAX_MALLOC_64K)
|
||||||
|
fprintf(STDERR, " NOTE: libpng compiled for max 64k, zlib not\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING))
|
||||||
|
{
|
||||||
|
fprintf(STDERR,
|
||||||
|
"Warning: versions are different between png.h and png.c\n");
|
||||||
|
fprintf(STDERR, " png.h version: %s\n", PNG_LIBPNG_VER_STRING);
|
||||||
|
fprintf(STDERR, " png.c version: %s\n\n", png_libpng_ver);
|
||||||
|
++ierror;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc > 1)
|
||||||
|
{
|
||||||
|
if (strcmp(argv[1], "-m") == 0)
|
||||||
|
{
|
||||||
|
multiple = 1;
|
||||||
|
status_dots_requested = 0;
|
||||||
|
}
|
||||||
|
else if (strcmp(argv[1], "-mv") == 0 ||
|
||||||
|
strcmp(argv[1], "-vm") == 0 )
|
||||||
|
{
|
||||||
|
multiple = 1;
|
||||||
|
verbose = 1;
|
||||||
|
status_dots_requested = 1;
|
||||||
|
}
|
||||||
|
else if (strcmp(argv[1], "-v") == 0)
|
||||||
|
{
|
||||||
|
verbose = 1;
|
||||||
|
status_dots_requested = 1;
|
||||||
|
inname = argv[2];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inname = argv[1];
|
||||||
|
status_dots_requested = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!multiple && argc == 3+verbose)
|
||||||
|
outname = argv[2+verbose];
|
||||||
|
|
||||||
|
if ((!multiple && argc > 3+verbose) || (multiple && argc < 2))
|
||||||
|
{
|
||||||
|
fprintf(STDERR,
|
||||||
|
"usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n",
|
||||||
|
argv[0], argv[0]);
|
||||||
|
fprintf(STDERR,
|
||||||
|
" reads/writes one PNG file (without -m) or multiple files (-m)\n");
|
||||||
|
fprintf(STDERR,
|
||||||
|
" with -m %s is used as a temporary file\n", outname);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (multiple)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
int allocation_now = current_allocation;
|
||||||
|
#endif
|
||||||
|
for (i=2; i<argc; ++i)
|
||||||
|
{
|
||||||
|
int kerror;
|
||||||
|
fprintf(STDERR, "Testing %s:",argv[i]);
|
||||||
|
kerror = test_one_file(argv[i], outname);
|
||||||
|
if (kerror == 0)
|
||||||
|
{
|
||||||
|
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||||
|
fprintf(STDERR, " PASS (%lu zero samples)\n",zero_samples);
|
||||||
|
#else
|
||||||
|
fprintf(STDERR, " PASS\n");
|
||||||
|
#endif
|
||||||
|
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||||
|
if(tIME_chunk_present != 0)
|
||||||
|
fprintf(STDERR, " tIME = %s\n",tIME_string);
|
||||||
|
tIME_chunk_present = 0;
|
||||||
|
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(STDERR, " FAIL\n");
|
||||||
|
ierror += kerror;
|
||||||
|
}
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
if (allocation_now != current_allocation)
|
||||||
|
fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
|
||||||
|
current_allocation-allocation_now);
|
||||||
|
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);
|
||||||
|
pinfo = pinfo->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
fprintf(STDERR, "Maximum memory allocation: %d bytes\n",
|
||||||
|
maximum_allocation);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i=0; i<3; ++i) {
|
||||||
|
int kerror;
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
int allocation_now = current_allocation;
|
||||||
|
#endif
|
||||||
|
if (i == 1) status_dots_requested = 1;
|
||||||
|
else if(verbose == 0)status_dots_requested = 0;
|
||||||
|
if (i == 0 || verbose == 1 || ierror != 0)
|
||||||
|
fprintf(STDERR, "Testing %s:",inname);
|
||||||
|
kerror = test_one_file(inname, outname);
|
||||||
|
if(kerror == 0)
|
||||||
|
{
|
||||||
|
if(verbose == 1 || i == 2)
|
||||||
|
{
|
||||||
|
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||||
|
fprintf(STDERR, " PASS (%lu zero samples)\n",zero_samples);
|
||||||
|
#else
|
||||||
|
fprintf(STDERR, " PASS\n");
|
||||||
|
#endif
|
||||||
|
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||||
|
if(tIME_chunk_present != 0)
|
||||||
|
fprintf(STDERR, " tIME = %s\n",tIME_string);
|
||||||
|
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(verbose == 0 && i != 2)
|
||||||
|
fprintf(STDERR, "Testing %s:",inname);
|
||||||
|
fprintf(STDERR, " FAIL\n");
|
||||||
|
ierror += kerror;
|
||||||
|
}
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
if (allocation_now != current_allocation)
|
||||||
|
fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
|
||||||
|
current_allocation-allocation_now);
|
||||||
|
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);
|
||||||
|
pinfo = pinfo->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
fprintf(STDERR, "Maximum memory allocation: %d bytes\n",
|
||||||
|
maximum_allocation);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ierror == 0)
|
||||||
|
fprintf(STDERR, "libpng passes test\n");
|
||||||
|
else
|
||||||
|
fprintf(STDERR, "libpng FAILS test\n");
|
||||||
|
return (int)(ierror != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
pngtest.png
BIN
pngtest.png
Binary file not shown.
|
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 8.4 KiB |
163
pngtrans.c
163
pngtrans.c
@@ -1,12 +1,12 @@
|
|||||||
|
|
||||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||||
|
*
|
||||||
libpng 1.0 beta 6 - version 0.96
|
* libpng 1.0.2b - January 6, 1999
|
||||||
For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
May 12, 1997
|
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
@@ -67,7 +67,8 @@ png_set_shift(png_structp png_ptr, png_color_8p true_bits)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_INTERLACING_SUPPORTED) || defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
|
||||||
|
defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||||
int
|
int
|
||||||
png_set_interlace_handling(png_structp png_ptr)
|
png_set_interlace_handling(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
@@ -75,18 +76,18 @@ png_set_interlace_handling(png_structp png_ptr)
|
|||||||
if (png_ptr->interlaced)
|
if (png_ptr->interlaced)
|
||||||
{
|
{
|
||||||
png_ptr->transformations |= PNG_INTERLACE;
|
png_ptr->transformations |= PNG_INTERLACE;
|
||||||
return 7;
|
return (7);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return (1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||||
/* Add a filler byte on read, or remove a filler or alpha byte on write.
|
/* Add a filler byte on read, or remove a filler or alpha byte on write.
|
||||||
* The filler type has changed in v0.95 to allow future 2-byte fillers
|
* The filler type has changed in v0.95 to allow future 2-byte fillers
|
||||||
* for 48-bit input data, as well as avoiding problems with some compilers
|
* for 48-bit input data, as well as to avoid problems with some compilers
|
||||||
* which don't like bytes as parameters.
|
* that don't like bytes as parameters.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||||
@@ -99,11 +100,23 @@ png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
|||||||
else
|
else
|
||||||
png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER;
|
png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER;
|
||||||
|
|
||||||
/* This should probably go in the "do_filler" routine */
|
/* This should probably go in the "do_filler" routine.
|
||||||
if (png_ptr->color_type == PNG_COLOR_TYPE_RGB && png_ptr->bit_depth == 8)
|
* I attempted to do that in libpng-1.0.1a but that caused problems
|
||||||
|
* so I restored it in libpng-1.0.2a
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
|
||||||
{
|
{
|
||||||
png_ptr->usr_channels = 4;
|
png_ptr->usr_channels = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Also I added this in libpng-1.0.2a (what happens when we expand
|
||||||
|
* a less-than-8-bit grayscale to GA? */
|
||||||
|
|
||||||
|
if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8)
|
||||||
|
{
|
||||||
|
png_ptr->usr_channels = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -117,6 +130,16 @@ png_set_swap_alpha(png_structp png_ptr)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
|
||||||
|
defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||||
|
void
|
||||||
|
png_set_invert_alpha(png_structp png_ptr)
|
||||||
|
{
|
||||||
|
png_debug(1, "in png_set_invert_alpha\n");
|
||||||
|
png_ptr->transformations |= PNG_INVERT_ALPHA;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
|
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
|
||||||
void
|
void
|
||||||
png_set_invert_mono(png_structp png_ptr)
|
png_set_invert_mono(png_structp png_ptr)
|
||||||
@@ -125,7 +148,7 @@ png_set_invert_mono(png_structp png_ptr)
|
|||||||
png_ptr->transformations |= PNG_INVERT_MONO;
|
png_ptr->transformations |= PNG_INVERT_MONO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* invert monocrome grayscale data */
|
/* invert monochrome grayscale data */
|
||||||
void
|
void
|
||||||
png_do_invert(png_row_infop row_info, png_bytep row)
|
png_do_invert(png_row_infop row_info, png_bytep row)
|
||||||
{
|
{
|
||||||
@@ -136,12 +159,14 @@ png_do_invert(png_row_infop row_info, png_bytep row)
|
|||||||
#endif
|
#endif
|
||||||
row_info->color_type == PNG_COLOR_TYPE_GRAY)
|
row_info->color_type == PNG_COLOR_TYPE_GRAY)
|
||||||
{
|
{
|
||||||
png_bytep rp;
|
png_bytep rp = row;
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
|
png_uint_32 istop = row_info->rowbytes;
|
||||||
|
|
||||||
for (i = 0, rp = row; i < row_info->rowbytes; i++, rp++)
|
for (i = 0; i < istop; i++)
|
||||||
{
|
{
|
||||||
*rp = (png_byte)(~(*rp));
|
*rp = (png_byte)(~(*rp));
|
||||||
|
rp++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,15 +184,13 @@ png_do_swap(png_row_infop row_info, png_bytep row)
|
|||||||
#endif
|
#endif
|
||||||
row_info->bit_depth == 16)
|
row_info->bit_depth == 16)
|
||||||
{
|
{
|
||||||
png_bytep rp;
|
png_bytep rp = row;
|
||||||
png_byte t;
|
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
|
png_uint_32 istop= row_info->width * row_info->channels;
|
||||||
|
|
||||||
for (i = 0, rp = row;
|
for (i = 0; i < istop; i++, rp += 2)
|
||||||
i < row_info->width * row_info->channels;
|
|
||||||
i++, rp += 2)
|
|
||||||
{
|
{
|
||||||
t = *rp;
|
png_byte t = *rp;
|
||||||
*rp = *(rp + 1);
|
*rp = *(rp + 1);
|
||||||
*(rp + 1) = t;
|
*(rp + 1) = t;
|
||||||
}
|
}
|
||||||
@@ -288,7 +311,7 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
|
|||||||
png_debug(1, "in png_do_packswap\n");
|
png_debug(1, "in png_do_packswap\n");
|
||||||
if (
|
if (
|
||||||
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
||||||
row != NULL && row_info != NULL
|
row != NULL && row_info != NULL &&
|
||||||
#endif
|
#endif
|
||||||
row_info->bit_depth < 8)
|
row_info->bit_depth < 8)
|
||||||
{
|
{
|
||||||
@@ -326,6 +349,11 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
|||||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB ||
|
if (row_info->color_type == PNG_COLOR_TYPE_RGB ||
|
||||||
row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||||
*/
|
*/
|
||||||
|
png_bytep sp=row;
|
||||||
|
png_bytep dp=row;
|
||||||
|
png_uint_32 row_width=row_info->width;
|
||||||
|
png_uint_32 i;
|
||||||
|
|
||||||
if (row_info->channels == 4)
|
if (row_info->channels == 4)
|
||||||
{
|
{
|
||||||
if (row_info->bit_depth == 8)
|
if (row_info->bit_depth == 8)
|
||||||
@@ -333,10 +361,8 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
|||||||
/* This converts from RGBX or RGBA to RGB */
|
/* This converts from RGBX or RGBA to RGB */
|
||||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||||
{
|
{
|
||||||
png_bytep sp, dp;
|
dp+=3; sp+=4;
|
||||||
png_uint_32 i;
|
for (i = 1; i < row_width; i++)
|
||||||
|
|
||||||
for (i = 1, sp = row + 4, dp = row + 3; i < row_info->width; i++)
|
|
||||||
{
|
{
|
||||||
*dp++ = *sp++;
|
*dp++ = *sp++;
|
||||||
*dp++ = *sp++;
|
*dp++ = *sp++;
|
||||||
@@ -347,10 +373,7 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
|||||||
/* This converts from XRGB or ARGB to RGB */
|
/* This converts from XRGB or ARGB to RGB */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
png_bytep sp, dp;
|
for (i = 0; i < row_width; i++)
|
||||||
png_uint_32 i;
|
|
||||||
|
|
||||||
for (i = 0, sp = row, dp = row; i < row_info->width; i++)
|
|
||||||
{
|
{
|
||||||
sp++;
|
sp++;
|
||||||
*dp++ = *sp++;
|
*dp++ = *sp++;
|
||||||
@@ -359,17 +382,15 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
row_info->pixel_depth = 24;
|
row_info->pixel_depth = 24;
|
||||||
row_info->rowbytes = row_info->width * 3;
|
row_info->rowbytes = row_width * 3;
|
||||||
}
|
}
|
||||||
else /* if (row_info->bit_depth == 16) */
|
else /* if (row_info->bit_depth == 16) */
|
||||||
{
|
{
|
||||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||||
{
|
{
|
||||||
png_bytep sp, dp;
|
|
||||||
png_uint_32 i;
|
|
||||||
|
|
||||||
/* This converts from RRGGBBXX or RRGGBBAA to RRGGBB */
|
/* This converts from RRGGBBXX or RRGGBBAA to RRGGBB */
|
||||||
for (i = 1, sp = row + 8, dp = row + 6; i < row_info->width; i++)
|
sp += 8; dp += 6;
|
||||||
|
for (i = 1; i < row_width; i++)
|
||||||
{
|
{
|
||||||
/* This could be (although memcpy is probably slower):
|
/* This could be (although memcpy is probably slower):
|
||||||
png_memcpy(dp, sp, 6);
|
png_memcpy(dp, sp, 6);
|
||||||
@@ -387,17 +408,15 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
png_bytep sp, dp;
|
|
||||||
png_uint_32 i;
|
|
||||||
|
|
||||||
/* This converts from XXRRGGBB or AARRGGBB to RRGGBB */
|
/* This converts from XXRRGGBB or AARRGGBB to RRGGBB */
|
||||||
for (i = 0, sp = row + 2, dp = row; i < row_info->width; i++)
|
for (i = 0; i < row_width; i++)
|
||||||
{
|
{
|
||||||
/* This could be (although memcpy is probably slower):
|
/* This could be (although memcpy is probably slower):
|
||||||
png_memcpy(dp, sp, 6);
|
png_memcpy(dp, sp, 6);
|
||||||
sp += 8;
|
sp += 8;
|
||||||
dp += 6;
|
dp += 6;
|
||||||
*/
|
*/
|
||||||
|
sp+=2;
|
||||||
*dp++ = *sp++;
|
*dp++ = *sp++;
|
||||||
*dp++ = *sp++;
|
*dp++ = *sp++;
|
||||||
*dp++ = *sp++;
|
*dp++ = *sp++;
|
||||||
@@ -407,9 +426,10 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
row_info->pixel_depth = 48;
|
row_info->pixel_depth = 48;
|
||||||
row_info->rowbytes = row_info->width * 6;
|
row_info->rowbytes = row_width * 6;
|
||||||
}
|
}
|
||||||
row_info->channels = 3;
|
row_info->channels = 3;
|
||||||
|
row_info->color_type &= ~PNG_COLOR_MASK_ALPHA;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY ||
|
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY ||
|
||||||
@@ -422,10 +442,7 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
|||||||
/* This converts from GX or GA to G */
|
/* This converts from GX or GA to G */
|
||||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||||
{
|
{
|
||||||
png_bytep sp, dp;
|
for (i = 0; i < row_width; i++)
|
||||||
png_uint_32 i;
|
|
||||||
|
|
||||||
for (i = 1, sp = row + 2, dp = row + 1; i < row_info->width; i++)
|
|
||||||
{
|
{
|
||||||
*dp++ = *sp++;
|
*dp++ = *sp++;
|
||||||
sp++;
|
sp++;
|
||||||
@@ -434,27 +451,22 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
|||||||
/* This converts from XG or AG to G */
|
/* This converts from XG or AG to G */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
png_bytep sp, dp;
|
for (i = 0; i < row_width; i++)
|
||||||
png_uint_32 i;
|
|
||||||
|
|
||||||
for (i = 0, sp = row, dp = row; i < row_info->width; i++)
|
|
||||||
{
|
{
|
||||||
sp++;
|
sp++;
|
||||||
*dp++ = *sp++;
|
*dp++ = *sp++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
row_info->pixel_depth = 8;
|
row_info->pixel_depth = 8;
|
||||||
row_info->rowbytes = row_info->width;
|
row_info->rowbytes = row_width;
|
||||||
}
|
}
|
||||||
else /* if (row_info->bit_depth == 16) */
|
else /* if (row_info->bit_depth == 16) */
|
||||||
{
|
{
|
||||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||||
{
|
{
|
||||||
png_bytep sp, dp;
|
|
||||||
png_uint_32 i;
|
|
||||||
|
|
||||||
/* This converts from GGXX or GGAA to GG */
|
/* This converts from GGXX or GGAA to GG */
|
||||||
for (i = 1, sp = row + 4, dp = row + 2; i < row_info->width; i++)
|
sp += 4; dp += 2;
|
||||||
|
for (i = 1; i < row_width; i++)
|
||||||
{
|
{
|
||||||
*dp++ = *sp++;
|
*dp++ = *sp++;
|
||||||
*dp++ = *sp++;
|
*dp++ = *sp++;
|
||||||
@@ -463,11 +475,8 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
png_bytep sp, dp;
|
|
||||||
png_uint_32 i;
|
|
||||||
|
|
||||||
/* This converts from XXGG or AAGG to GG */
|
/* This converts from XXGG or AAGG to GG */
|
||||||
for (i = 0, sp = row, dp = row; i < row_info->width; i++)
|
for (i = 0; i < row_width; i++)
|
||||||
{
|
{
|
||||||
sp += 2;
|
sp += 2;
|
||||||
*dp++ = *sp++;
|
*dp++ = *sp++;
|
||||||
@@ -475,9 +484,10 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
row_info->pixel_depth = 16;
|
row_info->pixel_depth = 16;
|
||||||
row_info->rowbytes = row_info->width * 2;
|
row_info->rowbytes = row_width * 2;
|
||||||
}
|
}
|
||||||
row_info->channels = 1;
|
row_info->channels = 1;
|
||||||
|
row_info->color_type &= ~PNG_COLOR_MASK_ALPHA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -495,17 +505,17 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
|||||||
#endif
|
#endif
|
||||||
(row_info->color_type & PNG_COLOR_MASK_COLOR))
|
(row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||||
{
|
{
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
if (row_info->bit_depth == 8)
|
if (row_info->bit_depth == 8)
|
||||||
{
|
{
|
||||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||||
{
|
{
|
||||||
png_bytep rp;
|
png_bytep rp;
|
||||||
png_byte save;
|
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
|
|
||||||
for (i = 0, rp = row; i < row_info->width; i++, rp += 3)
|
for (i = 0, rp = row; i < row_width; i++, rp += 3)
|
||||||
{
|
{
|
||||||
save = *rp;
|
png_byte save = *rp;
|
||||||
*rp = *(rp + 2);
|
*rp = *(rp + 2);
|
||||||
*(rp + 2) = save;
|
*(rp + 2) = save;
|
||||||
}
|
}
|
||||||
@@ -513,12 +523,11 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
|||||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||||
{
|
{
|
||||||
png_bytep rp;
|
png_bytep rp;
|
||||||
png_byte save;
|
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
|
|
||||||
for (i = 0, rp = row; i < row_info->width; i++, rp += 4)
|
for (i = 0, rp = row; i < row_width; i++, rp += 4)
|
||||||
{
|
{
|
||||||
save = *rp;
|
png_byte save = *rp;
|
||||||
*rp = *(rp + 2);
|
*rp = *(rp + 2);
|
||||||
*(rp + 2) = save;
|
*(rp + 2) = save;
|
||||||
}
|
}
|
||||||
@@ -529,33 +538,31 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
|||||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||||
{
|
{
|
||||||
png_bytep rp;
|
png_bytep rp;
|
||||||
png_byte save[2];
|
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
|
|
||||||
for (i = 0, rp = row; i < row_info->width; i++, rp += 6)
|
for (i = 0, rp = row; i < row_width; i++, rp += 6)
|
||||||
{
|
{
|
||||||
save[0] = *rp;
|
png_byte save = *rp;
|
||||||
save[1] = *(rp + 1);
|
|
||||||
*rp = *(rp + 4);
|
*rp = *(rp + 4);
|
||||||
|
*(rp + 4) = save;
|
||||||
|
save = *(rp + 1);
|
||||||
*(rp + 1) = *(rp + 5);
|
*(rp + 1) = *(rp + 5);
|
||||||
*(rp + 4) = save[0];
|
*(rp + 5) = save;
|
||||||
*(rp + 5) = save[1];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||||
{
|
{
|
||||||
png_bytep rp;
|
png_bytep rp;
|
||||||
png_byte save[2];
|
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
|
|
||||||
for (i = 0, rp = row; i < row_info->width; i++, rp += 8)
|
for (i = 0, rp = row; i < row_width; i++, rp += 8)
|
||||||
{
|
{
|
||||||
save[0] = *rp;
|
png_byte save = *rp;
|
||||||
save[1] = *(rp + 1);
|
|
||||||
*rp = *(rp + 4);
|
*rp = *(rp + 4);
|
||||||
|
*(rp + 4) = save;
|
||||||
|
save = *(rp + 1);
|
||||||
*(rp + 1) = *(rp + 5);
|
*(rp + 1) = *(rp + 5);
|
||||||
*(rp + 4) = save[0];
|
*(rp + 5) = save;
|
||||||
*(rp + 5) = save[1];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
70
pngwio.c
70
pngwio.c
@@ -1,18 +1,19 @@
|
|||||||
|
|
||||||
/* pngwio.c - functions for data output
|
/* pngwio.c - functions for data output
|
||||||
|
*
|
||||||
libpng 1.0 beta 6 - version 0.96
|
* libpng 1.0.2b - January 6, 1999
|
||||||
For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
May 12, 1997
|
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||||
|
*
|
||||||
This file provides a location for all output. Users which need
|
* This file provides a location for all output. Users who need
|
||||||
special handling are expected to write functions which have the same
|
* special handling are expected to write functions that have the same
|
||||||
arguments as these, and perform similar functions, but possibly use
|
* arguments as these and perform similar functions, but that possibly
|
||||||
different output methods. Note that you shouldn't change these
|
* use different output methods. Note that you shouldn't change these
|
||||||
functions, but rather write replacement functions and then change
|
* functions, but rather write replacement functions and then change
|
||||||
them at run time with png_set_write_fn(...) */
|
* them at run time with png_set_write_fn(...).
|
||||||
|
*/
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
@@ -21,7 +22,7 @@
|
|||||||
writes to a file pointer. Note that this routine sometimes gets called
|
writes to a file pointer. Note that this routine sometimes gets called
|
||||||
with very small lengths, so you should implement some kind of simple
|
with very small lengths, so you should implement some kind of simple
|
||||||
buffering if you are using unbuffered writes. This should never be asked
|
buffering if you are using unbuffered writes. This should never be asked
|
||||||
to write more then 64K on a 16 bit machine. */
|
to write more than 64K on a 16 bit machine. */
|
||||||
|
|
||||||
void
|
void
|
||||||
png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
@@ -32,7 +33,8 @@ png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||||||
png_error(png_ptr, "Call to NULL write function");
|
png_error(png_ptr, "Call to NULL write function");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is the function which does the actual writing of data. If you are
|
#if !defined(PNG_NO_STDIO)
|
||||||
|
/* This is the function that does the actual writing of data. If you are
|
||||||
not writing to a standard C stream, you should create a replacement
|
not writing to a standard C stream, you should create a replacement
|
||||||
write_data function and use it at run time with png_set_write_fn(), rather
|
write_data function and use it at run time with png_set_write_fn(), rather
|
||||||
than changing the library. */
|
than changing the library. */
|
||||||
@@ -97,6 +99,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This function is called to output any data pending writing (normally
|
/* This function is called to output any data pending writing (normally
|
||||||
@@ -110,6 +113,7 @@ png_flush(png_structp png_ptr)
|
|||||||
(*(png_ptr->output_flush_fn))(png_ptr);
|
(*(png_ptr->output_flush_fn))(png_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(PNG_NO_STDIO)
|
||||||
static void
|
static void
|
||||||
png_default_flush(png_structp png_ptr)
|
png_default_flush(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
@@ -119,6 +123,7 @@ png_default_flush(png_structp png_ptr)
|
|||||||
fflush(io_ptr);
|
fflush(io_ptr);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This function allows the application to supply new output functions for
|
/* This function allows the application to supply new output functions for
|
||||||
libpng if standard C streams aren't being used.
|
libpng if standard C streams aren't being used.
|
||||||
@@ -127,13 +132,13 @@ png_default_flush(png_structp png_ptr)
|
|||||||
png_ptr - pointer to a png output data structure
|
png_ptr - pointer to a png output data structure
|
||||||
io_ptr - pointer to user supplied structure containing info about
|
io_ptr - pointer to user supplied structure containing info about
|
||||||
the output functions. May be NULL.
|
the output functions. May be NULL.
|
||||||
write_data_fn - pointer to a new output function which takes as its
|
write_data_fn - pointer to a new output function that takes as its
|
||||||
arguments a pointer to a png_struct, a pointer to
|
arguments a pointer to a png_struct, a pointer to
|
||||||
data to be written, and a 32-bit unsigned int which is
|
data to be written, and a 32-bit unsigned int that is
|
||||||
the number of bytes to be written. The new write
|
the number of bytes to be written. The new write
|
||||||
function should call png_error(png_ptr, "Error msg")
|
function should call png_error(png_ptr, "Error msg")
|
||||||
to exit and output any fatal error messages.
|
to exit and output any fatal error messages.
|
||||||
flush_data_fn - pointer to a new flush function which takes as its
|
flush_data_fn - pointer to a new flush function that takes as its
|
||||||
arguments a pointer to a png_struct. After a call to
|
arguments a pointer to a png_struct. After a call to
|
||||||
the flush function, there should be no data in any buffers
|
the flush function, there should be no data in any buffers
|
||||||
or pending transmission. If the output method doesn't do
|
or pending transmission. If the output method doesn't do
|
||||||
@@ -148,27 +153,42 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
|||||||
{
|
{
|
||||||
png_ptr->io_ptr = io_ptr;
|
png_ptr->io_ptr = io_ptr;
|
||||||
|
|
||||||
|
#if !defined(PNG_NO_STDIO)
|
||||||
if (write_data_fn != NULL)
|
if (write_data_fn != NULL)
|
||||||
png_ptr->write_data_fn = write_data_fn;
|
png_ptr->write_data_fn = write_data_fn;
|
||||||
else
|
else
|
||||||
png_ptr->write_data_fn = png_default_write_data;
|
png_ptr->write_data_fn = png_default_write_data;
|
||||||
|
#else
|
||||||
|
png_ptr->write_data_fn = write_data_fn;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||||
|
#if !defined(PNG_NO_STDIO)
|
||||||
if (output_flush_fn != NULL)
|
if (output_flush_fn != NULL)
|
||||||
png_ptr->output_flush_fn = output_flush_fn;
|
png_ptr->output_flush_fn = output_flush_fn;
|
||||||
else
|
else
|
||||||
png_ptr->output_flush_fn = png_default_flush;
|
png_ptr->output_flush_fn = png_default_flush;
|
||||||
|
#else
|
||||||
|
png_ptr->output_flush_fn = output_flush_fn;
|
||||||
|
#endif
|
||||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||||
|
|
||||||
/* It is an error to read while writing a png file */
|
/* It is an error to read while writing a png file */
|
||||||
png_ptr->read_data_fn = NULL;
|
if (png_ptr->read_data_fn != NULL)
|
||||||
|
{
|
||||||
|
png_ptr->read_data_fn = NULL;
|
||||||
|
png_warning(png_ptr,
|
||||||
|
"Attempted to set both read_data_fn and write_data_fn in");
|
||||||
|
png_warning(png_ptr,
|
||||||
|
"the same structure. Resetting read_data_fn to NULL.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(USE_FAR_KEYWORD)
|
#if defined(USE_FAR_KEYWORD)
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
void *far_to_near(png_structp png_ptr,png_voidp ptr, int check)
|
void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check)
|
||||||
{
|
{
|
||||||
void *near_ptr;
|
void *near_ptr;
|
||||||
void FAR *far_ptr;
|
void FAR *far_ptr;
|
||||||
FP_OFF(near_ptr) = FP_OFF(ptr);
|
FP_OFF(near_ptr) = FP_OFF(ptr);
|
||||||
far_ptr = (void FAR *)near_ptr;
|
far_ptr = (void FAR *)near_ptr;
|
||||||
@@ -178,9 +198,9 @@ void *far_to_near(png_structp png_ptr,png_voidp ptr, int check)
|
|||||||
return(near_ptr);
|
return(near_ptr);
|
||||||
}
|
}
|
||||||
# else
|
# else
|
||||||
void *far_to_near(png_structp png_ptr,png_voidp ptr, int check)
|
void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check)
|
||||||
{
|
{
|
||||||
void *near_ptr;
|
void *near_ptr;
|
||||||
void FAR *far_ptr;
|
void FAR *far_ptr;
|
||||||
near_ptr = (void FAR *)ptr;
|
near_ptr = (void FAR *)ptr;
|
||||||
far_ptr = (void FAR *)near_ptr;
|
far_ptr = (void FAR *)near_ptr;
|
||||||
|
|||||||
255
pngwrite.c
255
pngwrite.c
@@ -1,12 +1,12 @@
|
|||||||
|
|
||||||
/* pngwrite.c - general routines to write a PNG file
|
|
||||||
|
|
||||||
libpng 1.0 beta 6 - version 0.96
|
/* pngwrite.c - general routines to write a PNG file
|
||||||
For conditions of distribution and use, see copyright notice in png.h
|
*
|
||||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* libpng 1.0.2b - January 6, 1999
|
||||||
Copyright (c) 1996, 1997 Andreas Dilger
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
May 12, 1997
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
*/
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
|
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||||
|
*/
|
||||||
|
|
||||||
/* get internal access to png.h */
|
/* get internal access to png.h */
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
/* Writes all the PNG information. This is the suggested way to use the
|
/* Writes all the PNG information. This is the suggested way to use the
|
||||||
* library. If you have a new chunk to add, make a function to write it,
|
* library. If you have a new chunk to add, make a function to write it,
|
||||||
* and put it in the correct location here. If you want the chunk written
|
* and put it in the correct location here. If you want the chunk written
|
||||||
* after the image data, put it in png_write_end(). I strongly encurage
|
* after the image data, put it in png_write_end(). I strongly encourage
|
||||||
* you to supply a PNG_INFO_ flag, and check info_ptr->valid before writing
|
* you to supply a PNG_INFO_ flag, and check info_ptr->valid before writing
|
||||||
* the chunk, as that will keep the code from breaking if you want to just
|
* the chunk, as that will keep the code from breaking if you want to just
|
||||||
* write a plain PNG file. If you have long comments, I suggest writing
|
* write a plain PNG file. If you have long comments, I suggest writing
|
||||||
@@ -24,20 +24,31 @@
|
|||||||
void
|
void
|
||||||
png_write_info(png_structp png_ptr, png_infop info_ptr)
|
png_write_info(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
|
#if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
|
||||||
int i;
|
int i;
|
||||||
|
#endif
|
||||||
|
|
||||||
png_debug(1, "in png_write_info\n");
|
png_debug(1, "in png_write_info\n");
|
||||||
png_write_sig(png_ptr); /* write PNG signature */
|
png_write_sig(png_ptr); /* write PNG signature */
|
||||||
/* write IHDR information. */
|
/* write IHDR information. */
|
||||||
png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height,
|
png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height,
|
||||||
info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type,
|
info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type,
|
||||||
info_ptr->filter_type, info_ptr->interlace_type);
|
info_ptr->filter_type,
|
||||||
|
#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||||
|
info_ptr->interlace_type);
|
||||||
|
#else
|
||||||
|
0);
|
||||||
|
#endif
|
||||||
/* the rest of these check to see if the valid field has the appropriate
|
/* the rest of these check to see if the valid field has the appropriate
|
||||||
flag set, and if it does, writes the chunk. */
|
flag set, and if it does, writes the chunk. */
|
||||||
#if defined(PNG_WRITE_gAMA_SUPPORTED)
|
#if defined(PNG_WRITE_gAMA_SUPPORTED)
|
||||||
if (info_ptr->valid & PNG_INFO_gAMA)
|
if (info_ptr->valid & PNG_INFO_gAMA)
|
||||||
png_write_gAMA(png_ptr, info_ptr->gamma);
|
png_write_gAMA(png_ptr, info_ptr->gamma);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(PNG_WRITE_sRGB_SUPPORTED)
|
||||||
|
if (info_ptr->valid & PNG_INFO_sRGB)
|
||||||
|
png_write_sRGB(png_ptr, (int)info_ptr->srgb_intent);
|
||||||
|
#endif
|
||||||
#if defined(PNG_WRITE_sBIT_SUPPORTED)
|
#if defined(PNG_WRITE_sBIT_SUPPORTED)
|
||||||
if (info_ptr->valid & PNG_INFO_sBIT)
|
if (info_ptr->valid & PNG_INFO_sBIT)
|
||||||
png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type);
|
png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type);
|
||||||
@@ -55,10 +66,23 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
|
|||||||
(png_uint_32)info_ptr->num_palette);
|
(png_uint_32)info_ptr->num_palette);
|
||||||
else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
png_error(png_ptr, "Valid palette required for paletted images\n");
|
png_error(png_ptr, "Valid palette required for paletted images\n");
|
||||||
|
|
||||||
#if defined(PNG_WRITE_tRNS_SUPPORTED)
|
#if defined(PNG_WRITE_tRNS_SUPPORTED)
|
||||||
if (info_ptr->valid & PNG_INFO_tRNS)
|
if (info_ptr->valid & PNG_INFO_tRNS)
|
||||||
|
{
|
||||||
|
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||||
|
/* invert the alpha channel (in tRNS) */
|
||||||
|
if (png_ptr->transformations & PNG_INVERT_ALPHA &&
|
||||||
|
info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
for (j=0; j<(int)info_ptr->num_trans; j++)
|
||||||
|
info_ptr->trans[j] = 255 - info_ptr->trans[j];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
png_write_tRNS(png_ptr, info_ptr->trans, &(info_ptr->trans_values),
|
png_write_tRNS(png_ptr, info_ptr->trans, &(info_ptr->trans_values),
|
||||||
info_ptr->num_trans, info_ptr->color_type);
|
info_ptr->num_trans, info_ptr->color_type);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_WRITE_bKGD_SUPPORTED)
|
#if defined(PNG_WRITE_bKGD_SUPPORTED)
|
||||||
if (info_ptr->valid & PNG_INFO_bKGD)
|
if (info_ptr->valid & PNG_INFO_bKGD)
|
||||||
@@ -128,9 +152,10 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Writes the end of the PNG file. If you don't want to write comments or
|
/* Writes the end of the PNG file. If you don't want to write comments or
|
||||||
time information, you can pass NULL for info. If you already wrote these
|
* time information, you can pass NULL for info. If you already wrote these
|
||||||
in png_write_info(), do not write them again here. If you have long
|
* in png_write_info(), do not write them again here. If you have long
|
||||||
comments, I suggest writing them here, and compressing them. */
|
* comments, I suggest writing them here, and compressing them.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
png_write_end(png_structp png_ptr, png_infop info_ptr)
|
png_write_end(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
@@ -141,7 +166,9 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
|
|||||||
/* see if user wants us to write information chunks */
|
/* see if user wants us to write information chunks */
|
||||||
if (info_ptr != NULL)
|
if (info_ptr != NULL)
|
||||||
{
|
{
|
||||||
|
#if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
|
||||||
int i; /* local index variable */
|
int i; /* local index variable */
|
||||||
|
#endif
|
||||||
#if defined(PNG_WRITE_tIME_SUPPORTED)
|
#if defined(PNG_WRITE_tIME_SUPPORTED)
|
||||||
/* check to see if user has supplied a time chunk */
|
/* check to see if user has supplied a time chunk */
|
||||||
if (info_ptr->valid & PNG_INFO_tIME &&
|
if (info_ptr->valid & PNG_INFO_tIME &&
|
||||||
@@ -216,17 +243,34 @@ png_convert_from_time_t(png_timep ptime, time_t ttime)
|
|||||||
|
|
||||||
/* Initialize png_ptr structure, and allocate any memory needed */
|
/* Initialize png_ptr structure, and allocate any memory needed */
|
||||||
png_structp
|
png_structp
|
||||||
png_create_write_struct(png_const_charp user_png_ver, voidp error_ptr,
|
png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||||
png_error_ptr error_fn, png_error_ptr warn_fn)
|
png_error_ptr error_fn, png_error_ptr warn_fn)
|
||||||
{
|
{
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
return (png_create_write_struct_2(user_png_ver, error_ptr, error_fn,
|
||||||
|
warn_fn, NULL, NULL, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Alternate initialize png_ptr structure, and allocate any memory needed */
|
||||||
|
png_structp
|
||||||
|
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;
|
png_structp png_ptr;
|
||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
jmp_buf jmpbuf;
|
jmp_buf jmpbuf;
|
||||||
#endif
|
#endif
|
||||||
png_debug(1, "in png_create_write_struct\n");
|
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,
|
||||||
|
(png_malloc_ptr)malloc_fn)) == NULL)
|
||||||
|
#else
|
||||||
if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL)
|
if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL)
|
||||||
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
{
|
{
|
||||||
return (png_structp)NULL;
|
return ((png_structp)NULL);
|
||||||
}
|
}
|
||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
if (setjmp(jmpbuf))
|
if (setjmp(jmpbuf))
|
||||||
@@ -236,11 +280,14 @@ png_create_write_struct(png_const_charp user_png_ver, voidp error_ptr,
|
|||||||
{
|
{
|
||||||
png_free(png_ptr, png_ptr->zbuf);
|
png_free(png_ptr, png_ptr->zbuf);
|
||||||
png_destroy_struct(png_ptr);
|
png_destroy_struct(png_ptr);
|
||||||
return (png_structp)NULL;
|
return ((png_structp)NULL);
|
||||||
}
|
}
|
||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
|
png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
|
||||||
#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);
|
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
|
/* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
|
||||||
@@ -257,13 +304,18 @@ png_create_write_struct(png_const_charp user_png_ver, voidp error_ptr,
|
|||||||
|
|
||||||
/* initialize zbuf - compression buffer */
|
/* initialize zbuf - compression buffer */
|
||||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||||
png_ptr->zbuf = png_malloc(png_ptr, png_ptr->zbuf_size);
|
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
|
||||||
|
(png_uint_32)png_ptr->zbuf_size);
|
||||||
|
|
||||||
png_set_write_fn(png_ptr, NULL, NULL, NULL);
|
png_set_write_fn(png_ptr, NULL, NULL, NULL);
|
||||||
|
|
||||||
return (png_ptr);
|
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||||
}
|
png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT,
|
||||||
|
1, NULL, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ((png_structp)png_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
/* Initialize png_ptr structure, and allocate any memory needed */
|
/* Initialize png_ptr structure, and allocate any memory needed */
|
||||||
void
|
void
|
||||||
@@ -283,7 +335,8 @@ png_write_init(png_structp png_ptr)
|
|||||||
|
|
||||||
/* initialize zbuf - compression buffer */
|
/* initialize zbuf - compression buffer */
|
||||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||||
png_ptr->zbuf = png_malloc(png_ptr, png_ptr->zbuf_size);
|
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
|
||||||
|
(png_uint_32)png_ptr->zbuf_size);
|
||||||
png_set_write_fn(png_ptr, NULL, NULL, NULL);
|
png_set_write_fn(png_ptr, NULL, NULL, NULL);
|
||||||
|
|
||||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||||
@@ -292,10 +345,11 @@ png_write_init(png_structp png_ptr)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write a few rows of image data. If the image is interlaced,
|
/* Write a few rows of image data. If the image is interlaced,
|
||||||
either you will have to write the 7 sub images, or, if you
|
* either you will have to write the 7 sub images, or, if you
|
||||||
have called png_set_interlace_handling(), you will have to
|
* have called png_set_interlace_handling(), you will have to
|
||||||
"write" the image seven times */
|
* "write" the image seven times.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
png_write_rows(png_structp png_ptr, png_bytepp row,
|
png_write_rows(png_structp png_ptr, png_bytepp row,
|
||||||
png_uint_32 num_rows)
|
png_uint_32 num_rows)
|
||||||
@@ -311,8 +365,9 @@ png_write_rows(png_structp png_ptr, png_bytepp row,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write the image. You only need to call this function once, even
|
/* Write the image. You only need to call this function once, even
|
||||||
if you are writing an interlaced image. */
|
* if you are writing an interlaced image.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
png_write_image(png_structp png_ptr, png_bytepp image)
|
png_write_image(png_structp png_ptr, png_bytepp image)
|
||||||
{
|
{
|
||||||
@@ -321,9 +376,13 @@ png_write_image(png_structp png_ptr, png_bytepp image)
|
|||||||
png_bytepp rp; /* points to current row */
|
png_bytepp rp; /* points to current row */
|
||||||
|
|
||||||
png_debug(1, "in png_write_image\n");
|
png_debug(1, "in png_write_image\n");
|
||||||
|
#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||||
/* intialize interlace handling. If image is not interlaced,
|
/* intialize interlace handling. If image is not interlaced,
|
||||||
this will set pass to 1 */
|
this will set pass to 1 */
|
||||||
num_pass = png_set_interlace_handling(png_ptr);
|
num_pass = png_set_interlace_handling(png_ptr);
|
||||||
|
#else
|
||||||
|
num_pass = 1;
|
||||||
|
#endif
|
||||||
/* loop through passes */
|
/* loop through passes */
|
||||||
for (pass = 0; pass < num_pass; pass++)
|
for (pass = 0; pass < num_pass; pass++)
|
||||||
{
|
{
|
||||||
@@ -339,10 +398,41 @@ png_write_image(png_structp png_ptr, png_bytepp image)
|
|||||||
void
|
void
|
||||||
png_write_row(png_structp png_ptr, png_bytep row)
|
png_write_row(png_structp png_ptr, png_bytep row)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_write_row\n");
|
png_debug2(1, "in png_write_row (row %ld, pass %d)\n",
|
||||||
|
png_ptr->row_number, png_ptr->pass);
|
||||||
/* initialize transformations and other stuff if first time */
|
/* initialize transformations and other stuff if first time */
|
||||||
if (png_ptr->row_number == 0 && png_ptr->pass == 0)
|
if (png_ptr->row_number == 0 && png_ptr->pass == 0)
|
||||||
{
|
{
|
||||||
|
/* check for transforms that have been set but were defined out */
|
||||||
|
#if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED)
|
||||||
|
if (png_ptr->transformations & PNG_INVERT_MONO)
|
||||||
|
png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined.");
|
||||||
|
#endif
|
||||||
|
#if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED)
|
||||||
|
if (png_ptr->transformations & PNG_FILLER)
|
||||||
|
png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined.");
|
||||||
|
#endif
|
||||||
|
#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && defined(PNG_READ_PACKSWAP_SUPPORTED)
|
||||||
|
if (png_ptr->transformations & PNG_PACKSWAP)
|
||||||
|
png_warning(png_ptr, "PNG_WRITE_PACKSWAP_SUPPORTED is not defined.");
|
||||||
|
#endif
|
||||||
|
#if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED)
|
||||||
|
if (png_ptr->transformations & PNG_PACK)
|
||||||
|
png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined.");
|
||||||
|
#endif
|
||||||
|
#if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED)
|
||||||
|
if (png_ptr->transformations & PNG_SHIFT)
|
||||||
|
png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined.");
|
||||||
|
#endif
|
||||||
|
#if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED)
|
||||||
|
if (png_ptr->transformations & PNG_BGR)
|
||||||
|
png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined.");
|
||||||
|
#endif
|
||||||
|
#if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED)
|
||||||
|
if (png_ptr->transformations & PNG_SWAP_BYTES)
|
||||||
|
png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined.");
|
||||||
|
#endif
|
||||||
|
|
||||||
png_write_start_row(png_ptr);
|
png_write_start_row(png_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,18 +502,20 @@ png_write_row(png_structp png_ptr, png_bytep row)
|
|||||||
png_ptr->row_info.bit_depth = png_ptr->usr_bit_depth;
|
png_ptr->row_info.bit_depth = png_ptr->usr_bit_depth;
|
||||||
png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth *
|
png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth *
|
||||||
png_ptr->row_info.channels);
|
png_ptr->row_info.channels);
|
||||||
|
|
||||||
png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
|
png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
|
||||||
(png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
|
(png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
|
||||||
|
|
||||||
png_debug1(4, "row_info->color_type = %d\n", png_ptr->row_info.color_type);
|
png_debug1(3, "row_info->color_type = %d\n", png_ptr->row_info.color_type);
|
||||||
png_debug1(4, "row_info->width = %d\n", png_ptr->row_info.width);
|
png_debug1(3, "row_info->width = %d\n", png_ptr->row_info.width);
|
||||||
png_debug1(4, "row_info->channels = %d\n", png_ptr->row_info.channels);
|
png_debug1(3, "row_info->channels = %d\n", png_ptr->row_info.channels);
|
||||||
png_debug1(4, "row_info->bit_depth = %d\n", png_ptr->row_info.bit_depth);
|
png_debug1(3, "row_info->bit_depth = %d\n", png_ptr->row_info.bit_depth);
|
||||||
png_debug1(4, "row_info->pixel_depth = %d\n", png_ptr->row_info.pixel_depth);
|
png_debug1(3, "row_info->pixel_depth = %d\n", png_ptr->row_info.pixel_depth);
|
||||||
png_debug1(4, "row_info->rowbytes = %d\n", png_ptr->row_info.rowbytes);
|
png_debug1(3, "row_info->rowbytes = %d\n", png_ptr->row_info.rowbytes);
|
||||||
|
|
||||||
/* Copy user's row into buffer, leaving room for filter byte. */
|
/* Copy user's row into buffer, leaving room for filter byte. */
|
||||||
png_memcpy(png_ptr->row_buf + 1, row, png_ptr->row_info.rowbytes);
|
png_memcpy_check(png_ptr, png_ptr->row_buf + 1, row,
|
||||||
|
png_ptr->row_info.rowbytes);
|
||||||
|
|
||||||
#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||||
/* handle interlacing */
|
/* handle interlacing */
|
||||||
@@ -447,6 +539,9 @@ png_write_row(png_structp png_ptr, png_bytep row)
|
|||||||
|
|
||||||
/* Find a filter if necessary, filter the row and write it out. */
|
/* Find a filter if necessary, filter the row and write it out. */
|
||||||
png_write_find_filter(png_ptr, &(png_ptr->row_info));
|
png_write_find_filter(png_ptr, &(png_ptr->row_info));
|
||||||
|
|
||||||
|
if (png_ptr->write_row_fn != NULL)
|
||||||
|
(*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||||
@@ -517,24 +612,56 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
|
|||||||
{
|
{
|
||||||
png_structp png_ptr = NULL;
|
png_structp png_ptr = NULL;
|
||||||
png_infop info_ptr = NULL;
|
png_infop info_ptr = NULL;
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
png_free_ptr free_fn = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
png_debug(1, "in png_destroy_write_struct\n");
|
png_debug(1, "in png_destroy_write_struct\n");
|
||||||
if (png_ptr_ptr != NULL)
|
if (png_ptr_ptr != NULL)
|
||||||
|
{
|
||||||
png_ptr = *png_ptr_ptr;
|
png_ptr = *png_ptr_ptr;
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
free_fn = png_ptr->free_fn;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (info_ptr_ptr != NULL)
|
if (info_ptr_ptr != NULL)
|
||||||
info_ptr = *info_ptr_ptr;
|
info_ptr = *info_ptr_ptr;
|
||||||
|
|
||||||
if (info_ptr != NULL)
|
if (info_ptr != NULL)
|
||||||
{
|
{
|
||||||
|
#ifdef PNG_WRITE_tEXt_SUPPORTED
|
||||||
|
png_free(png_ptr, info_ptr->text);
|
||||||
|
#endif
|
||||||
|
#if defined(PNG_READ_pCAL_SUPPORTED)
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
png_destroy_struct_2((png_voidp)info_ptr, free_fn);
|
||||||
|
#else
|
||||||
png_destroy_struct((png_voidp)info_ptr);
|
png_destroy_struct((png_voidp)info_ptr);
|
||||||
|
#endif
|
||||||
*info_ptr_ptr = (png_infop)NULL;
|
*info_ptr_ptr = (png_infop)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (png_ptr != NULL)
|
if (png_ptr != NULL)
|
||||||
{
|
{
|
||||||
png_write_destroy(png_ptr);
|
png_write_destroy(png_ptr);
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
png_destroy_struct_2((png_voidp)png_ptr, free_fn);
|
||||||
|
#else
|
||||||
png_destroy_struct((png_voidp)png_ptr);
|
png_destroy_struct((png_voidp)png_ptr);
|
||||||
|
#endif
|
||||||
*png_ptr_ptr = (png_structp)NULL;
|
*png_ptr_ptr = (png_structp)NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -548,6 +675,9 @@ png_write_destroy(png_structp png_ptr)
|
|||||||
png_error_ptr error_fn;
|
png_error_ptr error_fn;
|
||||||
png_error_ptr warning_fn;
|
png_error_ptr warning_fn;
|
||||||
png_voidp error_ptr;
|
png_voidp error_ptr;
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
png_free_ptr free_fn;
|
||||||
|
#endif
|
||||||
|
|
||||||
png_debug(1, "in png_write_destroy\n");
|
png_debug(1, "in png_write_destroy\n");
|
||||||
/* free any memory zlib uses */
|
/* free any memory zlib uses */
|
||||||
@@ -561,6 +691,9 @@ png_write_destroy(png_structp png_ptr)
|
|||||||
png_free(png_ptr, png_ptr->up_row);
|
png_free(png_ptr, png_ptr->up_row);
|
||||||
png_free(png_ptr, png_ptr->avg_row);
|
png_free(png_ptr, png_ptr->avg_row);
|
||||||
png_free(png_ptr, png_ptr->paeth_row);
|
png_free(png_ptr, png_ptr->paeth_row);
|
||||||
|
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||||
|
png_free(png_ptr, png_ptr->time_buffer);
|
||||||
|
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||||
png_free(png_ptr, png_ptr->prev_filters);
|
png_free(png_ptr, png_ptr->prev_filters);
|
||||||
png_free(png_ptr, png_ptr->filter_weights);
|
png_free(png_ptr, png_ptr->filter_weights);
|
||||||
@@ -575,12 +708,18 @@ png_write_destroy(png_structp png_ptr)
|
|||||||
error_fn = png_ptr->error_fn;
|
error_fn = png_ptr->error_fn;
|
||||||
warning_fn = png_ptr->warning_fn;
|
warning_fn = png_ptr->warning_fn;
|
||||||
error_ptr = png_ptr->error_ptr;
|
error_ptr = png_ptr->error_ptr;
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
free_fn = png_ptr->free_fn;
|
||||||
|
#endif
|
||||||
|
|
||||||
png_memset(png_ptr, 0, sizeof (png_struct));
|
png_memset(png_ptr, 0, sizeof (png_struct));
|
||||||
|
|
||||||
png_ptr->error_fn = error_fn;
|
png_ptr->error_fn = error_fn;
|
||||||
png_ptr->warning_fn = warning_fn;
|
png_ptr->warning_fn = warning_fn;
|
||||||
png_ptr->error_ptr = error_ptr;
|
png_ptr->error_ptr = error_ptr;
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
png_ptr->free_fn = free_fn;
|
||||||
|
#endif
|
||||||
|
|
||||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
|
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
|
||||||
}
|
}
|
||||||
@@ -620,7 +759,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
|
|||||||
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->sub_row = (png_bytep)png_malloc(png_ptr,
|
||||||
png_ptr->rowbytes + 1);
|
(png_ptr->rowbytes + 1));
|
||||||
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
|
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -634,7 +773,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
|
png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
|
||||||
png_ptr->rowbytes + 1);
|
(png_ptr->rowbytes + 1));
|
||||||
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
|
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -649,7 +788,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
|
png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
|
||||||
png_ptr->rowbytes + 1);
|
(png_ptr->rowbytes + 1));
|
||||||
png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
|
png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -664,8 +803,8 @@ png_set_filter(png_structp png_ptr, int method, int filters)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
png_ptr->paeth_row = (png_bytep )png_malloc(png_ptr,
|
png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
|
||||||
png_ptr->rowbytes + 1);
|
(png_ptr->rowbytes + 1));
|
||||||
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
|
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -683,7 +822,8 @@ png_set_filter(png_structp png_ptr, int method, int filters)
|
|||||||
* differences metric is relatively fast and effective, there is some
|
* differences metric is relatively fast and effective, there is some
|
||||||
* question as to whether it can be improved upon by trying to keep the
|
* question as to whether it can be improved upon by trying to keep the
|
||||||
* filtered data going to zlib more consistent, hopefully resulting in
|
* filtered data going to zlib more consistent, hopefully resulting in
|
||||||
* better compression. */
|
* better compression.
|
||||||
|
*/
|
||||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* GRR 970116 */
|
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* GRR 970116 */
|
||||||
void
|
void
|
||||||
png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
|
png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
|
||||||
@@ -718,7 +858,7 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
|
|||||||
if (png_ptr->prev_filters == NULL)
|
if (png_ptr->prev_filters == NULL)
|
||||||
{
|
{
|
||||||
png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr,
|
png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr,
|
||||||
sizeof(png_byte) * num_weights);
|
(png_uint_32)(sizeof(png_byte) * num_weights));
|
||||||
|
|
||||||
/* To make sure that the weighting starts out fairly */
|
/* To make sure that the weighting starts out fairly */
|
||||||
for (i = 0; i < num_weights; i++)
|
for (i = 0; i < num_weights; i++)
|
||||||
@@ -729,11 +869,11 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
|
|||||||
|
|
||||||
if (png_ptr->filter_weights == NULL)
|
if (png_ptr->filter_weights == NULL)
|
||||||
{
|
{
|
||||||
png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr,
|
png_ptr->filter_weights = (png_uint_16p) png_malloc(png_ptr,
|
||||||
sizeof(png_uint_16) * num_weights);
|
(png_uint_32)(sizeof(png_uint_16) * num_weights));
|
||||||
|
|
||||||
png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr,
|
png_ptr->inv_filter_weights = (png_uint_16p) png_malloc(png_ptr,
|
||||||
sizeof(png_uint_16) * num_weights);
|
(png_uint_32)(sizeof(png_uint_16) * num_weights));
|
||||||
|
|
||||||
for (i = 0; i < num_weights; i++)
|
for (i = 0; i < num_weights; i++)
|
||||||
{
|
{
|
||||||
@@ -764,11 +904,11 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
|
|||||||
*/
|
*/
|
||||||
if (png_ptr->filter_costs == NULL)
|
if (png_ptr->filter_costs == NULL)
|
||||||
{
|
{
|
||||||
png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr,
|
png_ptr->filter_costs = (png_uint_16p) png_malloc(png_ptr,
|
||||||
sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST);
|
(png_uint_32)(sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
|
||||||
|
|
||||||
png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr,
|
png_ptr->inv_filter_costs = (png_uint_16p) png_malloc(png_ptr,
|
||||||
sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST);
|
(png_uint_32)(sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
|
||||||
|
|
||||||
for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)
|
for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)
|
||||||
{
|
{
|
||||||
@@ -845,3 +985,20 @@ png_set_compression_method(png_structp png_ptr, int method)
|
|||||||
png_ptr->zlib_method = method;
|
png_ptr->zlib_method = method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
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
|
||||||
|
png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
|
||||||
|
write_user_transform_fn)
|
||||||
|
{
|
||||||
|
png_debug(1, "in png_set_write_user_transform_fn\n");
|
||||||
|
png_ptr->transformations |= PNG_USER_TRANSFORM;
|
||||||
|
png_ptr->write_user_transform_fn = write_user_transform_fn;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
251
pngwtran.c
251
pngwtran.c
@@ -1,40 +1,64 @@
|
|||||||
|
|
||||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||||
|
*
|
||||||
libpng 1.0 beta 6 - version 0.96
|
* libpng 1.0.2b - January 6, 1999
|
||||||
For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
May 12, 1997
|
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
|
||||||
/* transform the data according to the users wishes. The order of
|
/* Transform the data according to the user's wishes. The order of
|
||||||
transformations is significant. */
|
* transformations is significant.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
png_do_write_transformations(png_structp png_ptr)
|
png_do_write_transformations(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_do_write_transformations\n");
|
png_debug(1, "in png_do_write_transformations\n");
|
||||||
|
|
||||||
|
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||||
|
if (png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||||
|
if(png_ptr->write_user_transform_fn != NULL)
|
||||||
|
(*(png_ptr->write_user_transform_fn)) /* user write transform function */
|
||||||
|
(png_ptr, /* png_ptr */
|
||||||
|
&(png_ptr->row_info), /* row_info: */
|
||||||
|
/* png_uint_32 width; width of row */
|
||||||
|
/* png_uint_32 rowbytes; number of bytes in row */
|
||||||
|
/* png_byte color_type; color type of pixels */
|
||||||
|
/* png_byte bit_depth; bit depth of samples */
|
||||||
|
/* 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 */
|
||||||
|
#endif
|
||||||
#if defined(PNG_WRITE_FILLER_SUPPORTED)
|
#if defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||||
if (png_ptr->transformations & PNG_FILLER)
|
if (png_ptr->transformations & PNG_FILLER)
|
||||||
png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||||
png_ptr->flags);
|
png_ptr->flags);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
||||||
|
if (png_ptr->transformations & PNG_PACKSWAP)
|
||||||
|
png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||||
|
#endif
|
||||||
#if defined(PNG_WRITE_PACK_SUPPORTED)
|
#if defined(PNG_WRITE_PACK_SUPPORTED)
|
||||||
if (png_ptr->transformations & PNG_PACK)
|
if (png_ptr->transformations & PNG_PACK)
|
||||||
png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||||
(png_uint_32)png_ptr->bit_depth);
|
(png_uint_32)png_ptr->bit_depth);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||||
|
if (png_ptr->transformations & PNG_SWAP_BYTES)
|
||||||
|
png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||||
|
#endif
|
||||||
#if defined(PNG_WRITE_SHIFT_SUPPORTED)
|
#if defined(PNG_WRITE_SHIFT_SUPPORTED)
|
||||||
if (png_ptr->transformations & PNG_SHIFT)
|
if (png_ptr->transformations & PNG_SHIFT)
|
||||||
png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||||
&(png_ptr->shift));
|
&(png_ptr->shift));
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_WRITE_SWAP_SUPPORTED)
|
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||||
if (png_ptr->transformations & PNG_SWAP_BYTES)
|
if (png_ptr->transformations & PNG_INVERT_ALPHA)
|
||||||
png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
|
#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
|
||||||
if (png_ptr->transformations & PNG_SWAP_ALPHA)
|
if (png_ptr->transformations & PNG_SWAP_ALPHA)
|
||||||
@@ -51,9 +75,10 @@ png_do_write_transformations(png_structp png_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PNG_WRITE_PACK_SUPPORTED)
|
#if defined(PNG_WRITE_PACK_SUPPORTED)
|
||||||
/* pack pixels into bytes. Pass the true bit depth in bit_depth. The
|
/* Pack pixels into bytes. Pass the true bit depth in bit_depth. The
|
||||||
row_info bit depth should be 8 (one pixel per byte). The channels
|
* row_info bit depth should be 8 (one pixel per byte). The channels
|
||||||
should be 1 (this only happens on grayscale and paletted images) */
|
* should be 1 (this only happens on grayscale and paletted images).
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||||
{
|
{
|
||||||
@@ -71,12 +96,14 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
|||||||
png_bytep sp, dp;
|
png_bytep sp, dp;
|
||||||
int mask, v;
|
int mask, v;
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
sp = row;
|
sp = row;
|
||||||
dp = row;
|
dp = row;
|
||||||
mask = 0x80;
|
mask = 0x80;
|
||||||
v = 0;
|
v = 0;
|
||||||
for (i = 0; i < row_info->width; i++)
|
|
||||||
|
for (i = 0; i < row_width; i++)
|
||||||
{
|
{
|
||||||
if (*sp != 0)
|
if (*sp != 0)
|
||||||
v |= mask;
|
v |= mask;
|
||||||
@@ -100,12 +127,13 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
|||||||
png_bytep sp, dp;
|
png_bytep sp, dp;
|
||||||
int shift, v;
|
int shift, v;
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
sp = row;
|
sp = row;
|
||||||
dp = row;
|
dp = row;
|
||||||
shift = 6;
|
shift = 6;
|
||||||
v = 0;
|
v = 0;
|
||||||
for (i = 0; i < row_info->width; i++)
|
for (i = 0; i < row_width; i++)
|
||||||
{
|
{
|
||||||
png_byte value;
|
png_byte value;
|
||||||
|
|
||||||
@@ -131,12 +159,13 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
|||||||
png_bytep sp, dp;
|
png_bytep sp, dp;
|
||||||
int shift, v;
|
int shift, v;
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
sp = row;
|
sp = row;
|
||||||
dp = row;
|
dp = row;
|
||||||
shift = 4;
|
shift = 4;
|
||||||
v = 0;
|
v = 0;
|
||||||
for (i = 0; i < row_info->width; i++)
|
for (i = 0; i < row_width; i++)
|
||||||
{
|
{
|
||||||
png_byte value;
|
png_byte value;
|
||||||
|
|
||||||
@@ -169,12 +198,13 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_WRITE_SHIFT_SUPPORTED)
|
#if defined(PNG_WRITE_SHIFT_SUPPORTED)
|
||||||
/* shift pixel values to take advantage of whole range. Pass the
|
/* Shift pixel values to take advantage of whole range. Pass the
|
||||||
true number of bits in bit_depth. The row should be packed
|
* true number of bits in bit_depth. The row should be packed
|
||||||
according to row_info->bit_depth. Thus, if you had a row of
|
* according to row_info->bit_depth. Thus, if you had a row of
|
||||||
bit depth 4, but the pixels only had values from 0 to 7, you
|
* bit depth 4, but the pixels only had values from 0 to 7, you
|
||||||
would pass 3 as bit_depth, and this routine would translate the
|
* would pass 3 as bit_depth, and this routine would translate the
|
||||||
data to 0 to 15. */
|
* data to 0 to 15.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
||||||
{
|
{
|
||||||
@@ -187,9 +217,8 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
|||||||
row_info->color_type != PNG_COLOR_TYPE_PALETTE)
|
row_info->color_type != PNG_COLOR_TYPE_PALETTE)
|
||||||
{
|
{
|
||||||
int shift_start[4], shift_dec[4];
|
int shift_start[4], shift_dec[4];
|
||||||
png_uint_32 channels;
|
int channels = 0;
|
||||||
|
|
||||||
channels = 0;
|
|
||||||
if (row_info->color_type & PNG_COLOR_MASK_COLOR)
|
if (row_info->color_type & PNG_COLOR_MASK_COLOR)
|
||||||
{
|
{
|
||||||
shift_start[channels] = row_info->bit_depth - bit_depth->red;
|
shift_start[channels] = row_info->bit_depth - bit_depth->red;
|
||||||
@@ -215,12 +244,13 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
|||||||
channels++;
|
channels++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* with low row dephts, could only be grayscale, so one channel */
|
/* with low row depths, could only be grayscale, so one channel */
|
||||||
if (row_info->bit_depth < 8)
|
if (row_info->bit_depth < 8)
|
||||||
{
|
{
|
||||||
png_bytep bp;
|
png_bytep bp = row;
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
png_byte mask;
|
png_byte mask;
|
||||||
|
png_uint_32 row_bytes = row_info->rowbytes;
|
||||||
|
|
||||||
if (bit_depth->gray == 1 && row_info->bit_depth == 2)
|
if (bit_depth->gray == 1 && row_info->bit_depth == 2)
|
||||||
mask = 0x55;
|
mask = 0x55;
|
||||||
@@ -229,7 +259,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
|||||||
else
|
else
|
||||||
mask = 0xff;
|
mask = 0xff;
|
||||||
|
|
||||||
for (bp = row, i = 0; i < row_info->rowbytes; i++, bp++)
|
for (i = 0; i < row_bytes; i++, bp++)
|
||||||
{
|
{
|
||||||
png_uint_16 v;
|
png_uint_16 v;
|
||||||
int j;
|
int j;
|
||||||
@@ -247,27 +277,25 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
|||||||
}
|
}
|
||||||
else if (row_info->bit_depth == 8)
|
else if (row_info->bit_depth == 8)
|
||||||
{
|
{
|
||||||
png_bytep bp;
|
png_bytep bp = row;
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
|
png_uint_32 istop = channels * row_info->width;
|
||||||
|
|
||||||
for (bp = row, i = 0; i < row_info->width; i++)
|
for (i = 0; i < istop; i++, bp++)
|
||||||
{
|
{
|
||||||
int c;
|
|
||||||
|
|
||||||
for (c = 0; c < channels; c++, bp++)
|
png_uint_16 v;
|
||||||
|
int j;
|
||||||
|
int c = (int)(i%channels);
|
||||||
|
|
||||||
|
v = *bp;
|
||||||
|
*bp = 0;
|
||||||
|
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
||||||
{
|
{
|
||||||
png_uint_16 v;
|
if (j > 0)
|
||||||
int j;
|
*bp |= (png_byte)((v << j) & 0xff);
|
||||||
|
else
|
||||||
v = *bp;
|
*bp |= (png_byte)((v >> (-j)) & 0xff);
|
||||||
*bp = 0;
|
|
||||||
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
|
||||||
{
|
|
||||||
if (j > 0)
|
|
||||||
*bp |= (png_byte)((v << j) & 0xff);
|
|
||||||
else
|
|
||||||
*bp |= (png_byte)((v >> (-j)) & 0xff);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -275,28 +303,25 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
|||||||
{
|
{
|
||||||
png_bytep bp;
|
png_bytep bp;
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
|
png_uint_32 istop = channels * row_info->width;
|
||||||
|
|
||||||
for (bp = row, i = 0; i < row_info->width * row_info->channels; i++)
|
for (bp = row, i = 0; i < istop; i++)
|
||||||
{
|
{
|
||||||
int c;
|
int c = (int)(i%channels);
|
||||||
|
png_uint_16 value, v;
|
||||||
|
int j;
|
||||||
|
|
||||||
for (c = 0; c < channels; c++, bp += 2)
|
v = ((png_uint_16)(*bp) << 8) + *(bp + 1);
|
||||||
|
value = 0;
|
||||||
|
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
||||||
{
|
{
|
||||||
png_uint_16 value, v;
|
if (j > 0)
|
||||||
int j;
|
value |= (png_uint_16)((v << j) & (png_uint_16)0xffff);
|
||||||
|
else
|
||||||
v = ((png_uint_16)(*bp) << 8) + *(bp + 1);
|
value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff);
|
||||||
value = 0;
|
|
||||||
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
|
||||||
{
|
|
||||||
if (j > 0)
|
|
||||||
value |= (png_uint_16)((v << j) & (png_uint_16)0xffff);
|
|
||||||
else
|
|
||||||
value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff);
|
|
||||||
}
|
|
||||||
*bp = (png_byte)(value >> 8);
|
|
||||||
*(bp + 1) = (png_byte)(value & 0xff);
|
|
||||||
}
|
}
|
||||||
|
*bp++ = (png_byte)(value >> 8);
|
||||||
|
*bp++ = (png_byte)(value & 0xff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -318,12 +343,11 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
|||||||
if (row_info->bit_depth == 8)
|
if (row_info->bit_depth == 8)
|
||||||
{
|
{
|
||||||
png_bytep sp, dp;
|
png_bytep sp, dp;
|
||||||
png_byte save;
|
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
for (i = 0, sp = dp = row; i < row_info->width; i++)
|
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||||
{
|
{
|
||||||
save = *(sp++);
|
png_byte save = *(sp++);
|
||||||
*(dp++) = *(sp++);
|
*(dp++) = *(sp++);
|
||||||
*(dp++) = *(sp++);
|
*(dp++) = *(sp++);
|
||||||
*(dp++) = *(sp++);
|
*(dp++) = *(sp++);
|
||||||
@@ -334,11 +358,12 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
png_bytep sp, dp;
|
png_bytep sp, dp;
|
||||||
png_byte save[2];
|
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
for (i = 0, sp = dp = row; i < row_info->width; i++)
|
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||||
{
|
{
|
||||||
|
png_byte save[2];
|
||||||
save[0] = *(sp++);
|
save[0] = *(sp++);
|
||||||
save[1] = *(sp++);
|
save[1] = *(sp++);
|
||||||
*(dp++) = *(sp++);
|
*(dp++) = *(sp++);
|
||||||
@@ -358,12 +383,12 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
|||||||
if (row_info->bit_depth == 8)
|
if (row_info->bit_depth == 8)
|
||||||
{
|
{
|
||||||
png_bytep sp, dp;
|
png_bytep sp, dp;
|
||||||
png_byte save;
|
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
for (i = 0, sp = dp = row; i < row_info->width; i++)
|
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||||
{
|
{
|
||||||
save = *(sp++);
|
png_byte save = *(sp++);
|
||||||
*(dp++) = *(sp++);
|
*(dp++) = *(sp++);
|
||||||
*(dp++) = save;
|
*(dp++) = save;
|
||||||
}
|
}
|
||||||
@@ -372,11 +397,12 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
png_bytep sp, dp;
|
png_bytep sp, dp;
|
||||||
png_byte save[2];
|
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
for (i = 0, sp = dp = row; i < row_info->width; i++)
|
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||||
{
|
{
|
||||||
|
png_byte save[2];
|
||||||
save[0] = *(sp++);
|
save[0] = *(sp++);
|
||||||
save[1] = *(sp++);
|
save[1] = *(sp++);
|
||||||
*(dp++) = *(sp++);
|
*(dp++) = *(sp++);
|
||||||
@@ -390,3 +416,82 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||||
|
void
|
||||||
|
png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||||
|
{
|
||||||
|
png_debug(1, "in png_do_write_invert_alpha\n");
|
||||||
|
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
||||||
|
if (row != NULL && row_info != NULL)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||||
|
{
|
||||||
|
/* This inverts the alpha channel in RGBA */
|
||||||
|
if (row_info->bit_depth == 8)
|
||||||
|
{
|
||||||
|
png_bytep sp, dp;
|
||||||
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||||
|
{
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = 255 - *(sp++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* This inverts the alpha channel in RRGGBBAA */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
png_bytep sp, dp;
|
||||||
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
|
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||||
|
{
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = 255 - *(sp++);
|
||||||
|
*(dp++) = 255 - *(sp++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||||
|
{
|
||||||
|
/* This inverts the alpha channel in GA */
|
||||||
|
if (row_info->bit_depth == 8)
|
||||||
|
{
|
||||||
|
png_bytep sp, dp;
|
||||||
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
|
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||||
|
{
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = 255 - *(sp++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* This inverts the alpha channel in GGAA */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
png_bytep sp, dp;
|
||||||
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
|
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||||
|
{
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = 255 - *(sp++);
|
||||||
|
*(dp++) = 255 - *(sp++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
568
pngwutil.c
568
pngwutil.c
File diff suppressed because it is too large
Load Diff
7
scripts/SCOPTIONS.ppc
Normal file
7
scripts/SCOPTIONS.ppc
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
OPTIMIZE
|
||||||
|
OPTPEEP
|
||||||
|
OPTTIME
|
||||||
|
OPTSCHED
|
||||||
|
AUTOREGISTER
|
||||||
|
PARMS=REGISTERS
|
||||||
|
INCLUDEDIR=hlp:ppc/include
|
||||||
51
scripts/makefile.aco
Normal file
51
scripts/makefile.aco
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
# Project: libpng
|
||||||
|
|
||||||
|
|
||||||
|
# Toolflags:
|
||||||
|
CCflags = -c -depend !Depend -IC:,Zlib: -g -throwback -DRISCOS -fnah
|
||||||
|
C++flags = -c -depend !Depend -IC: -throwback
|
||||||
|
Linkflags = -aif -c++ -o $@
|
||||||
|
ObjAsmflags = -throwback -NoCache -depend !Depend
|
||||||
|
CMHGflags =
|
||||||
|
LibFileflags = -c -l -o $@
|
||||||
|
Squeezeflags = -o $@
|
||||||
|
|
||||||
|
|
||||||
|
# Final targets:
|
||||||
|
@.libpng-lib: @.o.png @.o.pngerror @.o.pngrio @.o.pngwio @.o.pngmem \
|
||||||
|
@.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngrtran \
|
||||||
|
@.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil
|
||||||
|
LibFile $(LibFileflags) @.o.png @.o.pngerror @.o.pngrio @.o.pngrtran \
|
||||||
|
@.o.pngmem @.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngwio \
|
||||||
|
@.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil
|
||||||
|
@.mm-libpng-lib: @.mm.png @.mm.pngerror @.mm.pngrio @.mm.pngwio @.mm.pngmem \
|
||||||
|
@.mm.pngpread @.mm.pngset @.mm.pngget @.mm.pngread @.mm.pngrtran \
|
||||||
|
@.mm.pngrutil @.mm.pngtrans @.mm.pngwrite @.mm.pngwtran @.mm.pngwutil
|
||||||
|
LibFile $(LibFileflags) @.mm.png @.mm.pngerror @.mm.pngrio \
|
||||||
|
@.mm.pngwio @.mm.pngmem @.mm.pngpread @.mm.pngset @.mm.pngget \
|
||||||
|
@.mm.pngread @.mm.pngrtran @.mm.pngrutil @.mm.pngtrans @.mm.pngwrite \
|
||||||
|
@.mm.pngwtran @.mm.pngwutil
|
||||||
|
|
||||||
|
|
||||||
|
# User-editable dependencies:
|
||||||
|
# (C) Copyright 1997 Tom Tanner
|
||||||
|
Test: @.pngtest
|
||||||
|
<Prefix$Dir>.pngtest
|
||||||
|
@remove <Prefix$Dir>.pngtest
|
||||||
|
|
||||||
|
#It would be nice if you could stop "make" listing from here on!
|
||||||
|
@.pngtest: @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib
|
||||||
|
Link $(Linkflags) @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib
|
||||||
|
|
||||||
|
.SUFFIXES: .o .mm .c
|
||||||
|
|
||||||
|
.c.mm:
|
||||||
|
MemCheck.CC cc $(ccflags) -o $@ LibPng:$<
|
||||||
|
.c.o:
|
||||||
|
cc $(ccflags) -o $@ $<
|
||||||
|
|
||||||
|
|
||||||
|
# Static dependencies:
|
||||||
|
|
||||||
|
|
||||||
|
# Dynamic dependencies:
|
||||||
@@ -9,6 +9,7 @@ LBR = png.lib
|
|||||||
LDFLAGS=-lpng -lz -lm
|
LDFLAGS=-lpng -lz -lm
|
||||||
|
|
||||||
# where make install puts libpng.a and png.h
|
# where make install puts libpng.a and png.h
|
||||||
|
prefix=/usr/local
|
||||||
|
|
||||||
OBJS = $(LBR)(png.o) $(LBR)(pngset.o) $(LBR)(pngget.o) $(LBR)(pngrutil.o)\
|
OBJS = $(LBR)(png.o) $(LBR)(pngset.o) $(LBR)(pngget.o) $(LBR)(pngrutil.o)\
|
||||||
$(LBR)(pngtrans.o) $(LBR)(pngwutil.o)\
|
$(LBR)(pngtrans.o) $(LBR)(pngwutil.o)\
|
||||||
@@ -28,4 +29,5 @@ install: libpng.a
|
|||||||
-@mkdir $(prefix)/lib
|
-@mkdir $(prefix)/lib
|
||||||
cp png.h $(prefix)/include
|
cp png.h $(prefix)/include
|
||||||
cp pngconf.h $(prefix)/include
|
cp pngconf.h $(prefix)/include
|
||||||
chmod 644 $(prefix)/include/p
|
chmod 644 $(prefix)/include/png.h
|
||||||
|
chmod 644 $(prefix)/include/pngconf.h
|
||||||
@@ -100,7 +100,7 @@ LIBOBJS = \
|
|||||||
+pngtrans.$(O) \
|
+pngtrans.$(O) \
|
||||||
+pngwrite.$(O) \
|
+pngwrite.$(O) \
|
||||||
+pngwtran.$(O) \
|
+pngwtran.$(O) \
|
||||||
+pngwio.$(O)
|
+pngwio.$(O) \
|
||||||
+pngwutil.$(O)
|
+pngwutil.$(O)
|
||||||
|
|
||||||
LIBNAME=libpng$(MODEL).lib
|
LIBNAME=libpng$(MODEL).lib
|
||||||
@@ -121,7 +121,7 @@ libpng: $(LIBNAME)
|
|||||||
|
|
||||||
pngtest: pngtest$(MODEL).exe
|
pngtest: pngtest$(MODEL).exe
|
||||||
|
|
||||||
test:
|
test: pngtest$(MODEL).exe
|
||||||
pngtest$(MODEL)
|
pngtest$(MODEL)
|
||||||
|
|
||||||
|
|
||||||
89
scripts/makefile.dec
Normal file
89
scripts/makefile.dec
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
# makefile for libpng on DEC Alpha Unix
|
||||||
|
# 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/lib
|
||||||
|
#ZLIBINC=/usr/local/include
|
||||||
|
ZLIBLIB=../zlib
|
||||||
|
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.2b
|
||||||
|
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||||
|
|
||||||
|
CC=cc
|
||||||
|
CFLAGS=-std -w1 -I$(ZLIBINC) -O # -g -DPNG_DEBUG=1
|
||||||
|
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
|
||||||
|
|
||||||
|
#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.so libpng.a pngtest
|
||||||
|
|
||||||
|
libpng.a: $(OBJS)
|
||||||
|
ar rc $@ $(OBJS)
|
||||||
|
$(RANLIB) $@
|
||||||
|
|
||||||
|
libpng.so: libpng.so.$(PNGMAJ)
|
||||||
|
ln -s -f libpng.so.$(PNGMAJ) libpng.so
|
||||||
|
|
||||||
|
libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
|
||||||
|
ln -s -f libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
|
||||||
|
|
||||||
|
libpng.so.$(PNGVER): $(OBJS)
|
||||||
|
$(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB) -lz -lm
|
||||||
|
|
||||||
|
pngtest: pngtest.o libpng.a
|
||||||
|
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
|
||||||
|
|
||||||
|
test: pngtest
|
||||||
|
./pngtest
|
||||||
|
|
||||||
|
install: libpng.a libpng.so.$(PNGVER)
|
||||||
|
-@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
|
||||||
|
cp libpng.so.$(PNGVER) $(prefix)/lib
|
||||||
|
chmod 644 $(prefix)/lib/libpng.a
|
||||||
|
chmod 644 $(prefix)/lib/libpng.so.$(PNGVER)
|
||||||
|
-@/bin/rm -f $(LIBPATH)/libpng.so.$(PNGMAJ) $(LIBPATH)/libpng.so
|
||||||
|
(cd $(LIBPATH); ln -s -f libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
|
||||||
|
ln -s -f libpng.so.$(PNGMAJ) libpng.so)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o libpng.a pngtest pngout.png libpng.so*
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
@@ -2,16 +2,16 @@
|
|||||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||||
# For conditions of distribution and use, see copyright notice in png.h
|
# For conditions of distribution and use, see copyright notice in png.h
|
||||||
|
|
||||||
|
# where make install puts libpng.a and png.h
|
||||||
|
#prefix=/usr/local
|
||||||
|
prefix=.
|
||||||
|
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-I../zlib -O
|
CFLAGS=-I../zlib -O
|
||||||
LDFLAGS=-L. -L../zlib/ -lpng -lz -lm
|
LDFLAGS=-L. -L../zlib/ -lpng -lz -lm
|
||||||
|
|
||||||
RANLIB=ranlib
|
RANLIB=ranlib
|
||||||
|
|
||||||
# where make install puts libpng.a and png.h
|
|
||||||
#prefix=/usr/local
|
|
||||||
prefix=.
|
|
||||||
|
|
||||||
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
|
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
|
||||||
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o pngwtran.o \
|
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o pngwtran.o \
|
||||||
pngmem.o pngerror.o pngpread.o
|
pngmem.o pngerror.o pngpread.o
|
||||||
@@ -23,7 +23,7 @@ libpng.a: $(OBJS)
|
|||||||
$(RANLIB) $@
|
$(RANLIB) $@
|
||||||
|
|
||||||
pngtest: pngtest.o libpng.a
|
pngtest: pngtest.o libpng.a
|
||||||
$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
|
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
|
||||||
coff2exe pngtest
|
coff2exe pngtest
|
||||||
|
|
||||||
test: pngtest
|
test: pngtest
|
||||||
@@ -2,6 +2,9 @@
|
|||||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||||
# For conditions of distribution and use, see copyright notice in png.h
|
# For conditions of distribution and use, see copyright notice in png.h
|
||||||
|
|
||||||
|
# where make install puts libpng.a and png.h
|
||||||
|
prefix=/usr/local
|
||||||
|
|
||||||
CC=cc
|
CC=cc
|
||||||
CFLAGS=-I../zlib -O
|
CFLAGS=-I../zlib -O
|
||||||
LDFLAGS=-L. -L../zlib/ -lpng -lz -lm
|
LDFLAGS=-L. -L../zlib/ -lpng -lz -lm
|
||||||
@@ -11,9 +14,6 @@ ANSI2KNRFLAGS=
|
|||||||
RANLIB=ranlib
|
RANLIB=ranlib
|
||||||
#RANLIB=echo
|
#RANLIB=echo
|
||||||
|
|
||||||
# where make install puts libpng.a and png.h
|
|
||||||
prefix=/usr/local
|
|
||||||
|
|
||||||
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
|
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
|
||||||
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
|
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
|
||||||
pngwtran.o pngmem.o pngerror.o pngpread.o
|
pngwtran.o pngmem.o pngerror.o pngpread.o
|
||||||
@@ -34,8 +34,8 @@ libpng.a: ansi2knr $(OBJS)
|
|||||||
ar rc $@ $(OBJS)
|
ar rc $@ $(OBJS)
|
||||||
$(RANLIB) $@
|
$(RANLIB) $@
|
||||||
|
|
||||||
pngtest: pngtest.o libpng.a ansi2knr
|
pngtest: pngtest.o libpng.a
|
||||||
cc -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
|
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
|
||||||
|
|
||||||
test: pngtest
|
test: pngtest
|
||||||
./pngtest
|
./pngtest
|
||||||
105
scripts/makefile.lnx
Normal file
105
scripts/makefile.lnx
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
# makefile for libpng on Linux ELF with gcc
|
||||||
|
# Copyright (C) 1996, 1997 Andreas Dilger
|
||||||
|
# Copyright (C) 1998 Greg Roelofs
|
||||||
|
# For conditions of distribution and use, see copyright notice in png.h
|
||||||
|
|
||||||
|
CC=gcc
|
||||||
|
|
||||||
|
# where make install puts libpng.a, libpng.so*, and png.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 I-386:
|
||||||
|
#ALIGN=-malign-loops=2 -malign-functions=2
|
||||||
|
|
||||||
|
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
|
||||||
|
-Wmissing-declarations -Wtraditional -Wcast-align \
|
||||||
|
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
|
||||||
|
|
||||||
|
CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \
|
||||||
|
$(ALIGN) # $(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.2b
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
libpng.a: $(OBJS)
|
||||||
|
ar rc $@ $(OBJS)
|
||||||
|
$(RANLIB) $@
|
||||||
|
|
||||||
|
libpng.so: libpng.so.$(PNGMAJ)
|
||||||
|
ln -s -f libpng.so.$(PNGMAJ) libpng.so
|
||||||
|
|
||||||
|
libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
|
||||||
|
ln -s -f 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)
|
||||||
|
-@mkdir $(INCPATH) $(LIBPATH)
|
||||||
|
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 -s -f libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
|
||||||
|
ln -s -f libpng.so.$(PNGMAJ) libpng.so)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
/bin/rm -f *.o libpng.a libpng.so* pngtest pngout.png
|
||||||
|
|
||||||
|
# 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
|
||||||
@@ -2,6 +2,9 @@
|
|||||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||||
# For conditions of distribution and use, see copyright notice in png.h
|
# For conditions of distribution and use, see copyright notice in png.h
|
||||||
|
|
||||||
|
# where make install puts libpng.a and png.h
|
||||||
|
prefix=/usr/local
|
||||||
|
|
||||||
CC=cc
|
CC=cc
|
||||||
CFLAGS=-I../zlib -O -systype sysv -DSYSV -w -Dmips
|
CFLAGS=-I../zlib -O -systype sysv -DSYSV -w -Dmips
|
||||||
#CFLAGS=-O
|
#CFLAGS=-O
|
||||||
@@ -10,9 +13,6 @@ LDFLAGS=-L. -L../zlib/ -lpng -lz -lm
|
|||||||
#RANLIB=ranlib
|
#RANLIB=ranlib
|
||||||
RANLIB=echo
|
RANLIB=echo
|
||||||
|
|
||||||
# where make install puts libpng.a and png.h
|
|
||||||
prefix=/usr/local
|
|
||||||
|
|
||||||
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
|
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
|
||||||
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
|
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
|
||||||
pngwtran.o pngmem.o pngerror.o pngpread.o
|
pngwtran.o pngmem.o pngerror.o pngpread.o
|
||||||
@@ -24,7 +24,7 @@ libpng.a: $(OBJS)
|
|||||||
$(RANLIB) $@
|
$(RANLIB) $@
|
||||||
|
|
||||||
pngtest: pngtest.o libpng.a
|
pngtest: pngtest.o libpng.a
|
||||||
cc -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
|
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
|
||||||
|
|
||||||
test: pngtest
|
test: pngtest
|
||||||
./pngtest
|
./pngtest
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
# ------------- Microsoft C 5.1 and later -------------
|
# ------------- Microsoft C 5.1 and later -------------
|
||||||
MODEL=-AL
|
MODEL=-AL
|
||||||
CFLAGS=-Oait -Gs -nologo -W2 $(MODEL) -I..\zlib
|
CFLAGS=-Oait -Gs -nologo -W3 $(MODEL) -I..\zlib
|
||||||
#-Ox generates bad code with MSC 5.1
|
#-Ox generates bad code with MSC 5.1
|
||||||
CC=cl
|
CC=cl
|
||||||
LD=link
|
LD=link
|
||||||
69
scripts/makefile.os2
Normal file
69
scripts/makefile.os2
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
# makefile for libpng on OS/2 with gcc
|
||||||
|
# For conditions of distribution and use, see copyright notice in png.h
|
||||||
|
|
||||||
|
# Related files: pngos2.def
|
||||||
|
|
||||||
|
CC=gcc -Zomf -s
|
||||||
|
|
||||||
|
# Where the zlib library and include files are located
|
||||||
|
ZLIBLIB=../zlib
|
||||||
|
ZLIBINC=../zlib
|
||||||
|
|
||||||
|
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
|
||||||
|
-Wmissing-declarations -Wtraditional -Wcast-align \
|
||||||
|
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
|
||||||
|
CFLAGS=-I$(ZLIBINC) -Wall -O6 -funroll-loops -malign-loops=2 \
|
||||||
|
-malign-functions=2 #$(WARNMORE) -g -DPNG_DEBUG=5
|
||||||
|
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lzdll -Zcrtdll
|
||||||
|
AR=emxomfar
|
||||||
|
|
||||||
|
PNGLIB=png.lib
|
||||||
|
IMPLIB=emximp
|
||||||
|
SHAREDLIB=png.dll
|
||||||
|
SHAREDLIBIMP=pngdll.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
|
||||||
|
|
||||||
|
.SUFFIXES: .c .o
|
||||||
|
|
||||||
|
all: $(PNGLIB) $(SHAREDLIB) $(SHAREDLIBIMP)
|
||||||
|
|
||||||
|
$(PNGLIB): $(OBJS)
|
||||||
|
$(AR) rc $@ $(OBJS)
|
||||||
|
|
||||||
|
$(SHAREDLIB): $(OBJS) pngos2.def
|
||||||
|
$(CC) $(LDFLAGS) -Zdll -o $@ $^
|
||||||
|
|
||||||
|
$(SHAREDLIBIMP): pngos2.def
|
||||||
|
$(IMPLIB) -o $@ $^
|
||||||
|
|
||||||
|
pngtest.exe: pngtest.o png.dll pngdll.lib
|
||||||
|
$(CC) -o $@ $(CFLAGS) $< $(LDFLAGS)
|
||||||
|
|
||||||
|
test: pngtest.exe
|
||||||
|
./pngtest.exe
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o $(PNGLIB) png.dll pngdll.lib pngtest.exe pngout.png
|
||||||
|
|
||||||
|
# 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
|
||||||
104
scripts/makefile.s2x
Normal file
104
scripts/makefile.s2x
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
# makefile for libpng on Solaris 2.x with gcc
|
||||||
|
# Contributed by William L. Sebok, based on makefile.lnx
|
||||||
|
# Copyright (C) 1996, 1997 Andreas Dilger
|
||||||
|
# Copyright (C) 1998 Greg Roelofs
|
||||||
|
# For conditions of distribution and use, see copyright notice in png.h
|
||||||
|
|
||||||
|
CC=gcc
|
||||||
|
|
||||||
|
# where make install puts libpng.a, libpng.so*, and png.h
|
||||||
|
prefix=/usr/local
|
||||||
|
|
||||||
|
# Where the zlib library and include files are located
|
||||||
|
# Changing these to ../zlib poses a security risk. If you want
|
||||||
|
# to have zlib in an adjacent directory, specify the full path instead of "..".
|
||||||
|
#ZLIBLIB=../zlib
|
||||||
|
#ZLIBINC=../zlib
|
||||||
|
|
||||||
|
ZLIBLIB=/usr/local/lib
|
||||||
|
ZLIBINC=/usr/local/include
|
||||||
|
|
||||||
|
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
|
||||||
|
-Wmissing-declarations -Wtraditional -Wcast-align \
|
||||||
|
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
|
||||||
|
CFLAGS=-I$(ZLIBINC) -Wall -O3 \
|
||||||
|
# $(WARNMORE) -g -DPNG_DEBUG=5
|
||||||
|
LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(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.2b
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
libpng.a: $(OBJS)
|
||||||
|
ar rc $@ $(OBJS)
|
||||||
|
$(RANLIB) $@
|
||||||
|
|
||||||
|
libpng.so: libpng.so.$(PNGMAJ)
|
||||||
|
ln -s -f libpng.so.$(PNGMAJ) libpng.so
|
||||||
|
|
||||||
|
libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
|
||||||
|
ln -s -f libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
|
||||||
|
|
||||||
|
libpng.so.$(PNGVER): $(OBJSDLL)
|
||||||
|
$(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h libpng.so.$(PNGMAJ) \
|
||||||
|
-o libpng.so.$(PNGVER) $(OBJSDLL) -lz
|
||||||
|
|
||||||
|
pngtest: pngtest.o libpng.so
|
||||||
|
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
|
||||||
|
|
||||||
|
test: pngtest
|
||||||
|
./pngtest
|
||||||
|
|
||||||
|
install: libpng.a libpng.so.$(PNGVER)
|
||||||
|
-@mkdir $(INCPATH) $(LIBPATH)
|
||||||
|
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 -s -f libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
|
||||||
|
ln -s -f libpng.so.$(PNGMAJ) libpng.so)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
/bin/rm -f *.o libpng.a libpng.so* pngtest pngout.png
|
||||||
|
|
||||||
|
# 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
|
||||||
98
scripts/makefile.sco
Normal file
98
scripts/makefile.sco
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
# makefile for SCO OSr5 ELF and Unixware 7 with Native cc
|
||||||
|
# Contributed by Mike Hopkirk (hops@sco.com) modified from Makefile.lnx
|
||||||
|
# force ELF build dynamic linking, SONAME setting in lib and RPATH in app
|
||||||
|
# Copyright (C) 1996, 1997 Andreas Dilger
|
||||||
|
# Copyright (C) 1998 Greg Roelofs
|
||||||
|
# For conditions of distribution and use, see copyright notice in png.h
|
||||||
|
|
||||||
|
CC=cc
|
||||||
|
|
||||||
|
# where make install puts libpng.a, libpng.so*, and png.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
|
||||||
|
|
||||||
|
CFLAGS= -dy -belf -I$(ZLIBINC) -O3
|
||||||
|
LDFLAGS=-L. -L$(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.2b
|
||||||
|
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
|
||||||
|
|
||||||
|
OBJSDLL = $(OBJS:.o=.pic.o)
|
||||||
|
|
||||||
|
.SUFFIXES: .c .o .pic.o
|
||||||
|
|
||||||
|
.c.pic.o:
|
||||||
|
$(CC) -c $(CFLAGS) -KPIC -o $@ $*.c
|
||||||
|
|
||||||
|
all: libpng.a libpng.so pngtest
|
||||||
|
|
||||||
|
libpng.a: $(OBJS)
|
||||||
|
ar rc $@ $(OBJS)
|
||||||
|
$(RANLIB) $@
|
||||||
|
|
||||||
|
libpng.so: libpng.so.$(PNGMAJ)
|
||||||
|
ln -s -f libpng.so.$(PNGMAJ) libpng.so
|
||||||
|
|
||||||
|
libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
|
||||||
|
ln -s -f libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
|
||||||
|
|
||||||
|
libpng.so.$(PNGVER): $(OBJSDLL)
|
||||||
|
$(CC) -G -Wl,-h,libpng.so.$(PNGMAJ) -o libpng.so.$(PNGVER) \
|
||||||
|
$(OBJSDLL)
|
||||||
|
|
||||||
|
pngtest: pngtest.o libpng.so
|
||||||
|
LD_RUN_PATH=.:$(ZLIBLIB) $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
|
||||||
|
|
||||||
|
test: pngtest
|
||||||
|
./pngtest
|
||||||
|
|
||||||
|
install: libpng.a libpng.so.$(PNGVER)
|
||||||
|
-@mkdir $(INCPATH) $(LIBPATH)
|
||||||
|
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 -s -f libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
|
||||||
|
ln -s -f libpng.so.$(PNGMAJ) libpng.so)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
/bin/rm -f *.o libpng.a libpng.so* pngtest pngout.png
|
||||||
|
|
||||||
|
# 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
|
||||||
@@ -2,6 +2,9 @@
|
|||||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||||
# For conditions of distribution and use, see copyright notice in png.h
|
# For conditions of distribution and use, see copyright notice in png.h
|
||||||
|
|
||||||
|
# where make install puts libpng.a and png.h
|
||||||
|
prefix=/usr/local
|
||||||
|
|
||||||
# Where the zlib library and include files are located
|
# Where the zlib library and include files are located
|
||||||
#ZLIBLIB=/usr/local/lib
|
#ZLIBLIB=/usr/local/lib
|
||||||
#ZLIBINC=/usr/local/include
|
#ZLIBINC=/usr/local/include
|
||||||
@@ -9,14 +12,13 @@ ZLIBLIB=../zlib
|
|||||||
ZLIBINC=../zlib
|
ZLIBINC=../zlib
|
||||||
|
|
||||||
CC=cc
|
CC=cc
|
||||||
CFLAGS=-I$(ZLIBINC) -O # -g -DPNG_DEBUG=1
|
|
||||||
|
WARNMORE=-fullwarn
|
||||||
|
CFLAGS=-I$(ZLIBINC) -O $(WARNMORE) # -g -DPNG_DEBUG=5
|
||||||
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
|
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
|
||||||
|
|
||||||
#RANLIB=echo
|
RANLIB=echo
|
||||||
RANLIB=ranlib
|
#RANLIB=ranlib
|
||||||
|
|
||||||
# where make install puts libpng.a and png.h
|
|
||||||
prefix=/usr/local
|
|
||||||
|
|
||||||
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
|
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
|
||||||
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
|
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
|
||||||
@@ -29,7 +31,7 @@ libpng.a: $(OBJS)
|
|||||||
$(RANLIB) $@
|
$(RANLIB) $@
|
||||||
|
|
||||||
pngtest: pngtest.o libpng.a
|
pngtest: pngtest.o libpng.a
|
||||||
$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
|
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
|
||||||
|
|
||||||
test: pngtest
|
test: pngtest
|
||||||
./pngtest
|
./pngtest
|
||||||
@@ -2,6 +2,9 @@
|
|||||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||||
# For conditions of distribution and use, see copyright notice in png.h
|
# For conditions of distribution and use, see copyright notice in png.h
|
||||||
|
|
||||||
|
# where make install puts libpng.a and png.h
|
||||||
|
prefix=/usr/local
|
||||||
|
|
||||||
# Where the zlib library and include files are located
|
# Where the zlib library and include files are located
|
||||||
#ZLIBLIB=/usr/local/lib
|
#ZLIBLIB=/usr/local/lib
|
||||||
#ZLIBINC=/usr/local/include
|
#ZLIBINC=/usr/local/include
|
||||||
@@ -9,15 +12,12 @@ ZLIBLIB=../zlib
|
|||||||
ZLIBINC=../zlib
|
ZLIBINC=../zlib
|
||||||
|
|
||||||
CC=cc
|
CC=cc
|
||||||
CFLAGS=-I$(ZLIBINC) -O # -g -DPNG_DEBUG=1
|
CFLAGS=-I$(ZLIBINC) -O # -g -DPNG_DEBUG=5
|
||||||
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
|
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
|
||||||
|
|
||||||
#RANLIB=echo
|
#RANLIB=echo
|
||||||
RANLIB=ranlib
|
RANLIB=ranlib
|
||||||
|
|
||||||
# where make install puts libpng.a and png.h
|
|
||||||
prefix=/usr/local
|
|
||||||
|
|
||||||
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
|
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
|
||||||
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
|
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
|
||||||
pngwtran.o pngmem.o pngerror.o pngpread.o
|
pngwtran.o pngmem.o pngerror.o pngpread.o
|
||||||
@@ -29,7 +29,7 @@ libpng.a: $(OBJS)
|
|||||||
$(RANLIB) $@
|
$(RANLIB) $@
|
||||||
|
|
||||||
pngtest: pngtest.o libpng.a
|
pngtest: pngtest.o libpng.a
|
||||||
$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
|
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
|
||||||
|
|
||||||
test: pngtest
|
test: pngtest
|
||||||
./pngtest
|
./pngtest
|
||||||
@@ -2,6 +2,9 @@
|
|||||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||||
# For conditions of distribution and use, see copyright notice in png.h
|
# For conditions of distribution and use, see copyright notice in png.h
|
||||||
|
|
||||||
|
# where make install puts libpng.a and png.h
|
||||||
|
prefix=/usr/local
|
||||||
|
|
||||||
# Where the zlib library and include files are located
|
# Where the zlib library and include files are located
|
||||||
#ZLIBLIB=/usr/local/lib
|
#ZLIBLIB=/usr/local/lib
|
||||||
#ZLIBINC=/usr/local/include
|
#ZLIBINC=/usr/local/include
|
||||||
@@ -13,15 +16,12 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow -Wconversion \
|
|||||||
-Wmissing-declarations -Wtraditional -Wcast-align \
|
-Wmissing-declarations -Wtraditional -Wcast-align \
|
||||||
-Wstrict-prototypes -Wmissing-prototypes
|
-Wstrict-prototypes -Wmissing-prototypes
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-I$(ZLIBINC) -O $(WARNMORE) -DPNG_DEBUG=4
|
CFLAGS=-I$(ZLIBINC) -O # $(WARNMORE) -DPNG_DEBUG=5
|
||||||
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
|
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
|
||||||
|
|
||||||
RANLIB=ranlib
|
RANLIB=ranlib
|
||||||
#RANLIB=echo
|
#RANLIB=echo
|
||||||
|
|
||||||
# where make install puts libpng.a and png.h
|
|
||||||
prefix=/usr/local
|
|
||||||
|
|
||||||
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
|
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
|
||||||
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
|
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
|
||||||
pngwtran.o pngmem.o pngerror.o pngpread.o
|
pngwtran.o pngmem.o pngerror.o pngpread.o
|
||||||
@@ -33,7 +33,7 @@ libpng.a: $(OBJS)
|
|||||||
$(RANLIB) $@
|
$(RANLIB) $@
|
||||||
|
|
||||||
pngtest: pngtest.o libpng.a
|
pngtest: pngtest.o libpng.a
|
||||||
$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
|
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
|
||||||
|
|
||||||
test: pngtest
|
test: pngtest
|
||||||
./pngtest
|
./pngtest
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
# Makefile for libpng
|
# Makefile for libpng
|
||||||
# TurboC++ 3.0 (Note: All modules are compiled in C mode)
|
# TurboC++ 3.0 (Note: All modules are compiled in C mode)
|
||||||
|
|
||||||
# To use, do "make -fmakefile.tc"
|
# To use, do "make -fmakefile.tc3"
|
||||||
|
|
||||||
# ------------- Turbo C++ 3.0 -------------
|
# ------------- Turbo C++ 3.0 -------------
|
||||||
MODEL=-ml
|
MODEL=-ml
|
||||||
@@ -9,8 +9,9 @@ CFLAGS=-O2 -Z $(MODEL) -I..\zlib
|
|||||||
CC=tcc
|
CC=tcc
|
||||||
LD=tcc
|
LD=tcc
|
||||||
LIB=tlib
|
LIB=tlib
|
||||||
LDFLAGS=$(MODEL)
|
LDFLAGS=$(MODEL) -L..\zlib
|
||||||
O=.obj
|
O=.obj
|
||||||
|
E=.exe
|
||||||
|
|
||||||
# variables
|
# variables
|
||||||
OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O)
|
OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O)
|
||||||
@@ -20,7 +21,7 @@ OBJSL1 = +png$(O) +pngset$(O) +pngget$(O) +pngrutil$(O) +pngtrans$(O)
|
|||||||
OBJSL2 = +pngwutil$(O) +pngmem$(O) +pngpread$(O) +pngread$(O) +pngerror$(O)
|
OBJSL2 = +pngwutil$(O) +pngmem$(O) +pngpread$(O) +pngread$(O) +pngerror$(O)
|
||||||
OBJSL3 = +pngwrite$(O) +pngrtran$(O) +pngwtran$(O) +pngrio$(O) +pngwio$(O)
|
OBJSL3 = +pngwrite$(O) +pngrtran$(O) +pngwtran$(O) +pngrio$(O) +pngwio$(O)
|
||||||
|
|
||||||
all: libpng.lib
|
all: libpng.lib pngtest.exe
|
||||||
|
|
||||||
png$(O): png.h pngconf.h
|
png$(O): png.h pngconf.h
|
||||||
$(CC) -c $(CFLAGS) $*.c
|
$(CC) -c $(CFLAGS) $*.c
|
||||||
@@ -75,4 +76,7 @@ libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3)
|
|||||||
$(LIB) libpng +$(OBJSL2)
|
$(LIB) libpng +$(OBJSL2)
|
||||||
$(LIB) libpng +$(OBJSL3)
|
$(LIB) libpng +$(OBJSL3)
|
||||||
|
|
||||||
|
pngtest$(E): pngtest$(O) libpng.lib
|
||||||
|
$(CC) $(LDFLAGS) pngtest.obj libpng.lib zlib.lib
|
||||||
|
|
||||||
# End of makefile for libpng
|
# End of makefile for libpng
|
||||||
85
scripts/makefile.w32
Normal file
85
scripts/makefile.w32
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
# makefile for libpng
|
||||||
|
# Copyright (C) 1998 Tim Wegner
|
||||||
|
# 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 "nmake /f scripts\makefile.w32"
|
||||||
|
|
||||||
|
# ------------- Microsoft Visual C++ 4.0 and later -------------
|
||||||
|
MODEL=-
|
||||||
|
CFLAGS=-Ox -GA3s -nologo -W3 -I..\zlib
|
||||||
|
|
||||||
|
CC=cl
|
||||||
|
LD=link
|
||||||
|
LDFLAGS=
|
||||||
|
O=.obj
|
||||||
|
|
||||||
|
#uncomment next to put error messages in a file
|
||||||
|
#ERRFILE= >> pngerrs
|
||||||
|
|
||||||
|
# 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: libpng.lib
|
||||||
|
|
||||||
|
png$(O): png.h pngconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
|
||||||
|
|
||||||
|
pngset$(O): png.h pngconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
|
||||||
|
|
||||||
|
pngget$(O): png.h pngconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
|
||||||
|
|
||||||
|
pngread$(O): png.h pngconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
|
||||||
|
|
||||||
|
pngpread$(O): png.h pngconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
|
||||||
|
|
||||||
|
pngrtran$(O): png.h pngconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
|
||||||
|
|
||||||
|
pngrutil$(O): png.h pngconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
|
||||||
|
|
||||||
|
pngerror$(O): png.h pngconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
|
||||||
|
|
||||||
|
pngmem$(O): png.h pngconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
|
||||||
|
|
||||||
|
pngrio$(O): png.h pngconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
|
||||||
|
|
||||||
|
pngwio$(O): png.h pngconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
|
||||||
|
|
||||||
|
pngtest$(O): png.h pngconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
|
||||||
|
|
||||||
|
pngtrans$(O): png.h pngconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
|
||||||
|
|
||||||
|
pngwrite$(O): png.h pngconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
|
||||||
|
|
||||||
|
pngwtran$(O): png.h pngconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
|
||||||
|
|
||||||
|
pngwutil$(O): png.h pngconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
|
||||||
|
|
||||||
|
libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3)
|
||||||
|
del libpng.lib
|
||||||
|
lib /OUT:libpng.lib $(OBJS1) $(OBJS2) $(OBJS3)
|
||||||
|
|
||||||
|
pngtest.exe: pngtest.obj libpng.lib
|
||||||
|
$(LD) $(LDFLAGS) pngtest.obj libpng.lib ..\zlib\zlib.lib /OUT:pngtest.exe /SUBSYSTEM:CONSOLE
|
||||||
|
|
||||||
|
test: pngtest.exe
|
||||||
|
pngtest
|
||||||
|
|
||||||
|
# End of makefile for libpng
|
||||||
|
|
||||||
88
scripts/makefile.wat
Normal file
88
scripts/makefile.wat
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
# Makefile for libpng
|
||||||
|
# Watcom 10.0a and later 32-bit protected mode flat memory model
|
||||||
|
|
||||||
|
# Adapted by Pawel Mrochen, based on makefile.msc
|
||||||
|
# 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 makefile.wat"
|
||||||
|
|
||||||
|
# ------------- Watcom 10.0a and later -------------
|
||||||
|
MODEL=-mf
|
||||||
|
CFLAGS= $(MODEL) -5r -fp5 -fpi87 -oneatx -zp8 -i=..\zlib
|
||||||
|
CC=wcc386
|
||||||
|
LD=wcl386
|
||||||
|
LIB=wlib -b -c
|
||||||
|
LDFLAGS=
|
||||||
|
O=.obj
|
||||||
|
|
||||||
|
#uncomment next to put error messages in a file
|
||||||
|
#ERRFILE= >> pngerrs
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
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: $(OBJS1) $(OBJS2) $(OBJS3)
|
||||||
|
$(LIB) -n libpng.lib $(OBJS1)
|
||||||
|
$(LIB) libpng.lib $(OBJS2)
|
||||||
|
$(LIB) libpng.lib $(OBJS3)
|
||||||
|
|
||||||
|
pngtest.exe: pngtest.obj libpng.lib
|
||||||
|
$(LD) $(LDFLAGS) pngtest.obj libpng.lib ..\zlib\zlib.lib
|
||||||
|
|
||||||
|
test: pngtest.exe
|
||||||
|
pngtest
|
||||||
|
|
||||||
|
# End of makefile for libpng
|
||||||
716
scripts/pngdef.pas
Normal file
716
scripts/pngdef.pas
Normal file
@@ -0,0 +1,716 @@
|
|||||||
|
unit pngdef;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
const
|
||||||
|
PNG_LIBPNG_VER_STRING = '1.0.2b';
|
||||||
|
PNG_LIBPNG_VER = 10001;
|
||||||
|
|
||||||
|
type
|
||||||
|
png_uint_32 = Cardinal;
|
||||||
|
png_int_32 = Longint;
|
||||||
|
png_uint_16 = Word;
|
||||||
|
png_int_16 = Smallint;
|
||||||
|
png_byte = Byte;
|
||||||
|
png_size_t = png_uint_32;
|
||||||
|
png_charpp = ^png_charp;
|
||||||
|
png_charp = PChar;
|
||||||
|
float = single;
|
||||||
|
int = Integer;
|
||||||
|
png_bytepp = ^png_bytep;
|
||||||
|
png_bytep = ^png_byte;
|
||||||
|
png_uint_16p = ^png_uint_16;
|
||||||
|
png_uint_16pp = ^png_uint_16p;
|
||||||
|
png_voidp = pointer;
|
||||||
|
time_t = Longint;
|
||||||
|
png_doublep = ^png_double;
|
||||||
|
png_double = double;
|
||||||
|
|
||||||
|
user_error_ptr = Pointer;
|
||||||
|
png_error_ptrp = ^png_error_ptr;
|
||||||
|
png_error_ptr = procedure(png_ptr: Pointer; msg: Pointer);
|
||||||
|
stdcall;
|
||||||
|
png_rw_ptrp = ^png_rw_ptr;
|
||||||
|
png_rw_ptr = procedure(png_ptr: Pointer; data: Pointer;
|
||||||
|
length: png_size_t);
|
||||||
|
stdcall;
|
||||||
|
png_flush_ptrp = ^png_flush_ptr;
|
||||||
|
png_flush_ptr = procedure(png_ptr: Pointer);
|
||||||
|
stdcall;
|
||||||
|
png_progressive_info_ptrp = ^png_progressive_info_ptr;
|
||||||
|
png_progressive_info_ptr = procedure(png_ptr: Pointer;
|
||||||
|
info_ptr: Pointer);
|
||||||
|
stdcall;
|
||||||
|
png_progressive_end_ptrp = ^png_progressive_end_ptr;
|
||||||
|
png_progressive_end_ptr = procedure(png_ptr: Pointer;
|
||||||
|
info_ptr: Pointer);
|
||||||
|
stdcall;
|
||||||
|
png_progressive_row_ptrp = ^png_progressive_row_ptr;
|
||||||
|
png_progressive_row_ptr = procedure(png_ptr: Pointer;
|
||||||
|
data: Pointer; length: png_uint_32;
|
||||||
|
count: int);
|
||||||
|
stdcall;
|
||||||
|
png_read_status_ptr = procedure(png_ptr: Pointer;
|
||||||
|
row_number: png_uint_32; pass: int);
|
||||||
|
stdcall;
|
||||||
|
png_write_status_ptr = procedure(png_ptr: Pointer;
|
||||||
|
row_number: png_uint_32; pass: int);
|
||||||
|
stdcall;
|
||||||
|
png_user_transform_ptr = procedure(png_ptr: Pointer;
|
||||||
|
row_info: Pointer; data: png_bytep);
|
||||||
|
stdcall;
|
||||||
|
|
||||||
|
png_colorpp = ^png_colorp;
|
||||||
|
png_colorp = ^png_color;
|
||||||
|
png_color = packed record
|
||||||
|
red, green, blue: png_byte;
|
||||||
|
end;
|
||||||
|
|
||||||
|
png_color_16pp = ^png_color_16p;
|
||||||
|
png_color_16p = ^png_color_16;
|
||||||
|
png_color_16 = packed record
|
||||||
|
index: png_byte; //used for palette files
|
||||||
|
red, green, blue: png_uint_16; //for use in red green blue files
|
||||||
|
gray: png_uint_16; //for use in grayscale files
|
||||||
|
end;
|
||||||
|
|
||||||
|
png_color_8pp = ^png_color_8p;
|
||||||
|
png_color_8p = ^png_color_8;
|
||||||
|
png_color_8 = packed record
|
||||||
|
red, green, blue: png_byte; //for use in red green blue files
|
||||||
|
gray: png_byte; //for use in grayscale files
|
||||||
|
alpha: png_byte; //for alpha channel files
|
||||||
|
end;
|
||||||
|
|
||||||
|
png_textpp = ^png_textp;
|
||||||
|
png_textp = ^png_text;
|
||||||
|
png_text = packed record
|
||||||
|
compression: int; //compression value
|
||||||
|
key: png_charp; //keyword, 1-79 character description of "text"
|
||||||
|
text: png_charp; //comment, may be empty ("")
|
||||||
|
text_length: png_size_t; //length of text field
|
||||||
|
end;
|
||||||
|
|
||||||
|
png_timepp = ^png_timep;
|
||||||
|
png_timep = ^png_time;
|
||||||
|
png_time = packed record
|
||||||
|
year: png_uint_16; //yyyy
|
||||||
|
month: png_byte; //1..12
|
||||||
|
day: png_byte; //1..31
|
||||||
|
hour: png_byte; //0..23
|
||||||
|
minute: png_byte; //0..59
|
||||||
|
second: png_byte; //0..60 (leap seconds)
|
||||||
|
end;
|
||||||
|
|
||||||
|
png_infopp = ^png_infop;
|
||||||
|
png_infop = Pointer;
|
||||||
|
|
||||||
|
png_row_infopp = ^png_row_infop;
|
||||||
|
png_row_infop = ^png_row_info;
|
||||||
|
png_row_info = packed record
|
||||||
|
width: png_uint_32; //width of row
|
||||||
|
rowbytes: png_size_t; //number of bytes in row
|
||||||
|
color_type: png_byte; //color type of row
|
||||||
|
bit_depth: png_byte; //bit depth of row
|
||||||
|
channels: png_byte; //number of channels (1, 2, 3, or 4)
|
||||||
|
pixel_depth: png_byte; //bits per pixel (depth * channels)
|
||||||
|
end;
|
||||||
|
|
||||||
|
png_structpp = ^png_structp;
|
||||||
|
png_structp = Pointer;
|
||||||
|
|
||||||
|
const
|
||||||
|
|
||||||
|
// Supported compression types for text in PNG files (tEXt, and zTXt).
|
||||||
|
// The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed.
|
||||||
|
|
||||||
|
PNG_TEXT_COMPRESSION_NONE_WR = -3;
|
||||||
|
PNG_TEXT_COMPRESSION_zTXt_WR = -2;
|
||||||
|
PNG_TEXT_COMPRESSION_NONE = -1;
|
||||||
|
PNG_TEXT_COMPRESSION_zTXt = 0;
|
||||||
|
|
||||||
|
// These describe the color_type field in png_info.
|
||||||
|
// color type masks
|
||||||
|
|
||||||
|
PNG_COLOR_MASK_PALETTE = 1;
|
||||||
|
PNG_COLOR_MASK_COLOR = 2;
|
||||||
|
PNG_COLOR_MASK_ALPHA = 4;
|
||||||
|
|
||||||
|
// color types. Note that not all combinations are legal
|
||||||
|
|
||||||
|
PNG_COLOR_TYPE_GRAY = 0;
|
||||||
|
PNG_COLOR_TYPE_PALETTE = PNG_COLOR_MASK_COLOR or
|
||||||
|
PNG_COLOR_MASK_PALETTE;
|
||||||
|
PNG_COLOR_TYPE_RGB = PNG_COLOR_MASK_COLOR;
|
||||||
|
PNG_COLOR_TYPE_RGB_ALPHA = PNG_COLOR_MASK_COLOR or
|
||||||
|
PNG_COLOR_MASK_ALPHA;
|
||||||
|
PNG_COLOR_TYPE_GRAY_ALPHA = PNG_COLOR_MASK_ALPHA;
|
||||||
|
|
||||||
|
// This is for compression type. PNG 1.0 only defines the single type.
|
||||||
|
|
||||||
|
PNG_COMPRESSION_TYPE_BASE = 0; // Deflate method 8, 32K window
|
||||||
|
PNG_COMPRESSION_TYPE_DEFAULT = PNG_COMPRESSION_TYPE_BASE;
|
||||||
|
|
||||||
|
// This is for filter type. PNG 1.0 only defines the single type.
|
||||||
|
|
||||||
|
PNG_FILTER_TYPE_BASE = 0; // Single row per-byte filtering
|
||||||
|
PNG_FILTER_TYPE_DEFAULT = PNG_FILTER_TYPE_BASE;
|
||||||
|
|
||||||
|
// These are for the interlacing type. These values should NOT be changed.
|
||||||
|
|
||||||
|
PNG_INTERLACE_NONE = 0; // Non-interlaced image
|
||||||
|
PNG_INTERLACE_ADAM7 = 1; // Adam7 interlacing
|
||||||
|
|
||||||
|
// These are for the oFFs chunk. These values should NOT be changed.
|
||||||
|
|
||||||
|
PNG_OFFSET_PIXEL = 0; // Offset in pixels
|
||||||
|
PNG_OFFSET_MICROMETER = 1; // Offset in micrometers (1/10^6 meter)
|
||||||
|
|
||||||
|
// These are for the pCAL chunk. These values should NOT be changed.
|
||||||
|
|
||||||
|
PNG_EQUATION_LINEAR = 0; // Linear transformation
|
||||||
|
PNG_EQUATION_BASE_E = 1; // Exponential base e transform
|
||||||
|
PNG_EQUATION_ARBITRARY = 2; // Arbitrary base exponential transform
|
||||||
|
PNG_EQUATION_HYPERBOLIC = 3; // Hyperbolic sine transformation
|
||||||
|
|
||||||
|
// These are for the pHYs chunk. These values should NOT be changed.
|
||||||
|
|
||||||
|
PNG_RESOLUTION_UNKNOWN = 0; // pixels/unknown unit (aspect ratio)
|
||||||
|
PNG_RESOLUTION_METER = 1; // pixels/meter
|
||||||
|
|
||||||
|
// These are for the sRGB chunk. These values should NOT be changed.
|
||||||
|
PNG_sRGB_INTENT_SATURATION = 0;
|
||||||
|
PNG_sRGB_INTENT_PERCEPTUAL = 1;
|
||||||
|
PNG_sRGB_INTENT_ABSOLUTE = 2;
|
||||||
|
PNG_sRGB_INTENT_RELATIVE = 3;
|
||||||
|
|
||||||
|
// Handle alpha and tRNS by replacing with a background color.
|
||||||
|
PNG_BACKGROUND_GAMMA_UNKNOWN = 0;
|
||||||
|
PNG_BACKGROUND_GAMMA_SCREEN = 1;
|
||||||
|
PNG_BACKGROUND_GAMMA_FILE = 2;
|
||||||
|
PNG_BACKGROUND_GAMMA_UNIQUE = 3;
|
||||||
|
|
||||||
|
// Values for png_set_crc_action() to say how to handle CRC errors in
|
||||||
|
// ancillary and critical chunks, and whether to use the data contained
|
||||||
|
// therein. Note that it is impossible to "discard" data in a critical
|
||||||
|
// chunk. For versions prior to 0.90, the action was always error/quit,
|
||||||
|
// whereas in version 0.90 and later, the action for CRC errors in ancillary
|
||||||
|
// chunks is warn/discard. These values should NOT be changed.
|
||||||
|
|
||||||
|
// value action:critical action:ancillary
|
||||||
|
|
||||||
|
PNG_CRC_DEFAULT = 0; // error/quit warn/discard data
|
||||||
|
PNG_CRC_ERROR_QUIT = 1; // error/quit error/quit
|
||||||
|
PNG_CRC_WARN_DISCARD = 2; // (INVALID) warn/discard data
|
||||||
|
PNG_CRC_WARN_USE = 3; // warn/use data warn/use data
|
||||||
|
PNG_CRC_QUIET_USE = 4; // quiet/use data quiet/use data
|
||||||
|
PNG_CRC_NO_CHANGE = 5; // use current value use current value
|
||||||
|
|
||||||
|
// Flags for png_set_filter() to say which filters to use. The flags
|
||||||
|
// are chosen so that they don't conflict with real filter types
|
||||||
|
// below, in case they are supplied instead of the #defined constants.
|
||||||
|
// These values should NOT be changed.
|
||||||
|
|
||||||
|
PNG_NO_FILTERS = $00;
|
||||||
|
PNG_FILTER_NONE = $08;
|
||||||
|
PNG_FILTER_SUB = $10;
|
||||||
|
PNG_FILTER_UP = $20;
|
||||||
|
PNG_FILTER_AVG = $40;
|
||||||
|
PNG_FILTER_PAETH = $80;
|
||||||
|
PNG_ALL_FILTERS = PNG_FILTER_NONE or PNG_FILTER_SUB or
|
||||||
|
PNG_FILTER_UP or PNG_FILTER_AVG or
|
||||||
|
PNG_FILTER_PAETH;
|
||||||
|
|
||||||
|
// Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
|
||||||
|
// These defines should NOT be changed.
|
||||||
|
|
||||||
|
PNG_FILTER_VALUE_NONE = 0;
|
||||||
|
PNG_FILTER_VALUE_SUB = 1;
|
||||||
|
PNG_FILTER_VALUE_UP = 2;
|
||||||
|
PNG_FILTER_VALUE_AVG = 3;
|
||||||
|
PNG_FILTER_VALUE_PAETH = 4;
|
||||||
|
|
||||||
|
// Heuristic used for row filter selection. These defines should NOT be
|
||||||
|
// changed.
|
||||||
|
|
||||||
|
PNG_FILTER_HEURISTIC_DEFAULT = 0; // Currently "UNWEIGHTED"
|
||||||
|
PNG_FILTER_HEURISTIC_UNWEIGHTED = 1; // Used by libpng < 0.95
|
||||||
|
PNG_FILTER_HEURISTIC_WEIGHTED = 2; // Experimental feature
|
||||||
|
PNG_FILTER_HEURISTIC_LAST = 3; // Not a valid value
|
||||||
|
|
||||||
|
procedure png_build_grayscale_palette(bit_depth: int; palette: png_colorp);
|
||||||
|
stdcall;
|
||||||
|
function png_check_sig(sig: png_bytep; num: int): int;
|
||||||
|
stdcall;
|
||||||
|
procedure png_chunk_error(png_ptr: png_structp;
|
||||||
|
const mess: png_charp);
|
||||||
|
stdcall;
|
||||||
|
procedure png_chunk_warning(png_ptr: png_structp;
|
||||||
|
const mess: png_charp);
|
||||||
|
stdcall;
|
||||||
|
procedure png_convert_from_time_t(ptime: png_timep; ttime: time_t);
|
||||||
|
stdcall;
|
||||||
|
function png_convert_to_rfc1123(png_ptr: png_structp; ptime: png_timep):
|
||||||
|
png_charp;
|
||||||
|
stdcall;
|
||||||
|
function png_create_info_struct(png_ptr: png_structp): png_infop;
|
||||||
|
stdcall;
|
||||||
|
function png_create_read_struct(user_png_ver: png_charp;
|
||||||
|
error_ptr: user_error_ptr; error_fn: png_error_ptr;
|
||||||
|
warn_fn: png_error_ptr): png_structp;
|
||||||
|
stdcall;
|
||||||
|
function png_get_copyright(png_ptr: png_structp): png_charp;
|
||||||
|
stdcall;
|
||||||
|
function png_get_header_version(png_ptr: png_structp): png_charp;
|
||||||
|
stdcall;
|
||||||
|
function png_create_write_struct(user_png_ver: png_charp;
|
||||||
|
error_ptr: user_error_ptr; error_fn: png_error_ptr;
|
||||||
|
warn_fn: png_error_ptr): png_structp;
|
||||||
|
stdcall;
|
||||||
|
procedure png_destroy_info_struct(png_ptr: png_structp;
|
||||||
|
info_ptr_ptr: png_infopp);
|
||||||
|
stdcall;
|
||||||
|
procedure png_destroy_read_struct(png_ptr_ptr: png_structpp;
|
||||||
|
info_ptr_ptr, end_info_ptr_ptr: png_infopp);
|
||||||
|
stdcall;
|
||||||
|
procedure png_destroy_write_struct(png_ptr_ptr: png_structpp;
|
||||||
|
info_ptr_ptr: png_infopp);
|
||||||
|
stdcall;
|
||||||
|
function png_get_IHDR(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
var width, height: png_uint_32; var bit_depth,
|
||||||
|
color_type, interlace_type, compression_type,
|
||||||
|
filter_type: int): png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_PLTE(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
var palette: png_colorp; var num_palette: int):
|
||||||
|
png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_bKGD(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
var background: png_color_16p): png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_bit_depth(png_ptr: png_structp; info_ptr: png_infop):
|
||||||
|
png_byte;
|
||||||
|
stdcall;
|
||||||
|
function png_get_cHRM(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
var white_x, white_y, red_x, red_y, green_x, green_y,
|
||||||
|
blue_x, blue_y: double): png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_channels(png_ptr: png_structp; info_ptr: png_infop):
|
||||||
|
png_byte;
|
||||||
|
stdcall;
|
||||||
|
function png_get_color_type(png_ptr: png_structp; info_ptr: png_infop):
|
||||||
|
png_byte;
|
||||||
|
stdcall;
|
||||||
|
function png_get_compression_type(png_ptr: png_structp;
|
||||||
|
info_ptr: png_infop): png_byte;
|
||||||
|
stdcall;
|
||||||
|
function png_get_error_ptr(png_ptr: png_structp): png_voidp;
|
||||||
|
stdcall;
|
||||||
|
function png_get_filter_type(png_ptr: png_structp; info_ptr: png_infop):
|
||||||
|
png_byte;
|
||||||
|
stdcall;
|
||||||
|
function png_get_gAMA(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
var file_gamma: double): png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_hIST(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
var hist: png_uint_16p): png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_image_height(png_ptr: png_structp; info_ptr: png_infop):
|
||||||
|
png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_image_width(png_ptr: png_structp; info_ptr: png_infop):
|
||||||
|
png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_interlace_type(png_ptr: png_structp;
|
||||||
|
info_ptr: png_infop): png_byte;
|
||||||
|
stdcall;
|
||||||
|
function png_get_io_ptr(png_ptr: png_structp): png_voidp;
|
||||||
|
stdcall;
|
||||||
|
function png_get_oFFs(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
var offset_x, offset_y: png_uint_32;
|
||||||
|
var unit_type: int): png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_pCAL(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
var purpose: png_charp; var X0, X1: png_int_32;
|
||||||
|
var typ, nparams: int; var units: png_charp;
|
||||||
|
var params: png_charpp): png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_pHYs(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
var res_x, res_y: png_uint_32; var unit_type: int):
|
||||||
|
png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_pixel_aspect_ratio(png_ptr: png_structp;
|
||||||
|
info_ptr: png_infop): float;
|
||||||
|
stdcall;
|
||||||
|
function png_get_pixels_per_meter(png_ptr: png_structp;
|
||||||
|
info_ptr: png_infop): png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_progressive_ptr(png_ptr: png_structp): png_voidp;
|
||||||
|
stdcall;
|
||||||
|
function png_get_rgb_to_gray_status(png_ptr: png_structp);
|
||||||
|
stdcall;
|
||||||
|
function png_get_rowbytes(png_ptr: png_structp; info_ptr: png_infop):
|
||||||
|
png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_sBIT(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
var sig_bits: png_color_8p): png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_sRGB(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
var file_srgb_intent: int): png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_signature(png_ptr: png_structp; info_ptr: png_infop):
|
||||||
|
png_bytep;
|
||||||
|
stdcall;
|
||||||
|
function png_get_tIME(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
var mod_time: png_timep): png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_tRNS(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
var trans: png_bytep; var num_trans: int;
|
||||||
|
var trans_values: png_color_16p): png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
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_valid(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
flag: png_uint_32): png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_x_offset_microns(png_ptr: png_structp;
|
||||||
|
info_ptr: png_infop): png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_x_offset_pixels(png_ptr: png_structp;
|
||||||
|
info_ptr: png_infop): png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_x_pixels_per_meter(png_ptr: png_structp;
|
||||||
|
info_ptr: png_infop): png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_y_offset_microns(png_ptr: png_structp;
|
||||||
|
info_ptr: png_infop): png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_y_offset_pixels(png_ptr: png_structp;
|
||||||
|
info_ptr: png_infop): png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
function png_get_y_pixels_per_meter(png_ptr: png_structp;
|
||||||
|
info_ptr: png_infop): png_uint_32;
|
||||||
|
stdcall;
|
||||||
|
procedure png_process_data(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
buffer: png_bytep; buffer_size: png_size_t);
|
||||||
|
stdcall;
|
||||||
|
procedure png_progressive_combine_row(png_ptr: png_structp;
|
||||||
|
old_row, new_row: png_bytep);
|
||||||
|
stdcall;
|
||||||
|
procedure png_read_end(png_ptr: png_structp; info_ptr: png_infop);
|
||||||
|
stdcall;
|
||||||
|
procedure png_read_image(png_ptr: png_structp; image: png_bytepp);
|
||||||
|
stdcall;
|
||||||
|
procedure png_read_info(png_ptr: png_structp; info_ptr: png_infop);
|
||||||
|
stdcall;
|
||||||
|
procedure png_read_row(png_ptr: png_structp; row, dsp_row: png_bytep);
|
||||||
|
stdcall;
|
||||||
|
procedure png_read_rows(png_ptr: png_structp; row, display_row:
|
||||||
|
png_bytepp; num_rows: png_uint_32);
|
||||||
|
stdcall;
|
||||||
|
procedure png_read_update_info(png_ptr: png_structp; info_ptr: png_infop);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_IHDR(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
width, height: png_uint_32; bit_depth, color_type,
|
||||||
|
interlace_type, compression_type, filter_type: int);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_PLTE(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
palette: png_colorp; num_palette: int);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_bKGD(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
background: png_color_16p);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_background(png_ptr: png_structp;
|
||||||
|
background_color: png_color_16p;
|
||||||
|
background_gamma_code, need_expand: int;
|
||||||
|
background_gamma: double);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_bgr(png_ptr: png_structp);
|
||||||
|
stdcall;
|
||||||
|
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_compression_level(png_ptr: png_structp; level: int);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_compression_mem_level(png_ptr: png_structp;
|
||||||
|
mem_level: int);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_compression_method(png_ptr: png_structp; method: int);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_compression_strategy(png_ptr: png_structp;
|
||||||
|
strategy: int);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_compression_window_bits(png_ptr: png_structp;
|
||||||
|
window_bits: int);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_crc_action(png_ptr: png_structp;
|
||||||
|
crit_action, ancil_action: int);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_dither(png_ptr: png_structp; plaette: png_colorp;
|
||||||
|
num_palette, maximum_colors: int;
|
||||||
|
histogram: png_uint_16p; full_dither: int);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_error_fn(png_ptr: png_structp; error_ptr: png_voidp;
|
||||||
|
error_fn, warning_fn: png_error_ptr);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_expand(png_ptr: png_structp);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_filler(png_ptr: png_structp; filler: png_uint_32;
|
||||||
|
filler_loc: int);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_filter(png_ptr: png_structp; method, filters: int);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_filter_heuristics(png_ptr: png_structp;
|
||||||
|
heuristic_method, num_weights: int;
|
||||||
|
filter_weights, filter_costs: png_doublep);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_flush(png_ptr: png_structp; nrows: int);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_gAMA(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
file_gamma: double);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_gamma(png_ptr: png_structp; screen_gamma,
|
||||||
|
default_file_gamma: double);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_gray_to_rgb(png_ptr: png_structp);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_hIST(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
hist: png_uint_16p);
|
||||||
|
stdcall;
|
||||||
|
function png_set_interlace_handling(png_ptr: png_structp): int;
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_invert_alpha(png_ptr: png_structp);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_invert_mono(png_ptr: png_structp);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_oFFs(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
offset_x, offset_y: png_uint_32; unit_type: int);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_pCAL(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
purpose: png_charp; X0, X1: png_int_32;
|
||||||
|
typ, nparams: int; units: png_charp;
|
||||||
|
params: png_charpp);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_pHYs(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
res_x, res_y: png_uint_32; unit_type: int);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_packing(png_ptr: png_structp);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_packswap(png_ptr: png_structp);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_progressive_read_fn(png_ptr: png_structp;
|
||||||
|
progressive_ptr: png_voidp;
|
||||||
|
info_fn: png_progressive_info_ptr;
|
||||||
|
row_fn: png_progressive_row_ptr;
|
||||||
|
end_fn: png_progressive_end_ptr);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_read_fn(png_ptr: png_structp;
|
||||||
|
io_ptr: png_voidp; read_data_fn: png_rw_ptr);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_read_status_fn(png_ptr: png_structp;
|
||||||
|
read_row_fn: png_read_status_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);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_sBIT(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
sig_bits: png_color_8p);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_sRGB(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
intent: int);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_sRGB_gAMA_and_cHRM(png_ptr: png_structp;
|
||||||
|
info_ptr: png_infop; intent: int);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_shift(png_ptr: png_structp; true_bits: png_color_8p);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_sig_bytes(png_ptr: png_structp; num_bytes: int);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_strip_16(png_ptr: png_structp);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_strip_alpha(png_ptr: png_structp);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_swap(png_ptr: png_structp);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_swap_alpha(png_ptr: png_structp);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_tIME(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
mod_time: png_timep);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_tRNS(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
trans: png_bytep; num_trans: int;
|
||||||
|
trans_values: png_color_16p);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_text(png_ptr: png_structp; info_ptr: png_infop;
|
||||||
|
text_ptr: png_textp; num_text: int);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_write_fn(png_ptr: png_structp;
|
||||||
|
io_ptr: png_voidp; write_data_fn: png_rw_ptr;
|
||||||
|
output_flush_fn: png_flush_ptr);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_write_status_fn(png_ptr: png_structp;
|
||||||
|
write_row_fn: png_write_status_ptr);
|
||||||
|
stdcall;
|
||||||
|
procedure png_set_write_user_transform_fn(png_ptr: png_structp;
|
||||||
|
write_user_transform_fn: png_user_transform_ptr);
|
||||||
|
stdcall;
|
||||||
|
function png_sig_cmp(sig: png_bytep; start, num_to_check: png_size_t):
|
||||||
|
int;
|
||||||
|
stdcall;
|
||||||
|
procedure png_start_read_image(png_ptr: png_structp);
|
||||||
|
stdcall;
|
||||||
|
procedure png_write_chunk(png_ptr: png_structp;
|
||||||
|
chunk_name, data: png_bytep; length: png_size_t);
|
||||||
|
stdcall;
|
||||||
|
procedure png_write_chunk_data(png_ptr: png_structp;
|
||||||
|
data: png_bytep; length: png_size_t);
|
||||||
|
stdcall;
|
||||||
|
procedure png_write_chunk_end(png_ptr: png_structp);
|
||||||
|
stdcall;
|
||||||
|
procedure png_write_chunk_start(png_ptr: png_structp;
|
||||||
|
chunk_name: png_bytep; length: png_uint_32);
|
||||||
|
stdcall;
|
||||||
|
procedure png_write_end(png_ptr: png_structp; info_ptr: png_infop);
|
||||||
|
stdcall;
|
||||||
|
procedure png_write_flush(png_ptr: png_structp);
|
||||||
|
stdcall;
|
||||||
|
procedure png_write_image(png_ptr: png_structp; image: png_bytepp);
|
||||||
|
stdcall;
|
||||||
|
procedure png_write_info(png_ptr: png_structp; info_ptr: png_infop);
|
||||||
|
stdcall;
|
||||||
|
procedure png_write_row(png_ptr: png_structp; row: png_bytep);
|
||||||
|
stdcall;
|
||||||
|
procedure png_write_rows(png_ptr: png_structp; row: png_bytepp;
|
||||||
|
num_rows: png_uint_32);
|
||||||
|
stdcall;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
const
|
||||||
|
pngDLL = 'png32bd.dll';
|
||||||
|
|
||||||
|
procedure png_build_grayscale_palette; external pngDLL;
|
||||||
|
function png_check_sig; external pngDLL;
|
||||||
|
procedure png_chunk_error; external pngDLL;
|
||||||
|
procedure png_chunk_warning; external pngDLL;
|
||||||
|
procedure png_convert_from_time_t; external pngDLL;
|
||||||
|
function png_convert_to_rfc1123; external pngDLL;
|
||||||
|
function png_create_info_struct; external pngDLL;
|
||||||
|
function png_create_read_struct; external pngDLL;
|
||||||
|
function png_create_write_struct; external pngDLL;
|
||||||
|
procedure png_destroy_info_struct; external pngDLL;
|
||||||
|
procedure png_destroy_read_struct; external pngDLL;
|
||||||
|
procedure png_destroy_write_struct; external pngDLL;
|
||||||
|
function png_get_IHDR; external pngDLL;
|
||||||
|
function png_get_PLTE; external pngDLL;
|
||||||
|
function png_get_bKGD; external pngDLL;
|
||||||
|
function png_get_bit_depth; external pngDLL;
|
||||||
|
function png_get_cHRM; external pngDLL;
|
||||||
|
function png_get_channels; external pngDLL;
|
||||||
|
function png_get_color_type; external pngDLL;
|
||||||
|
function png_get_compression_type; external pngDLL;
|
||||||
|
function png_get_error_ptr; external pngDLL;
|
||||||
|
function png_get_filter_type; external pngDLL;
|
||||||
|
function png_get_gAMA; external pngDLL;
|
||||||
|
function png_get_hIST; external pngDLL;
|
||||||
|
function png_get_image_height; external pngDLL;
|
||||||
|
function png_get_image_width; external pngDLL;
|
||||||
|
function png_get_interlace_type; external pngDLL;
|
||||||
|
function png_get_io_ptr; external pngDLL;
|
||||||
|
function png_get_oFFs; external pngDLL;
|
||||||
|
function png_get_pCAL; external pngDLL;
|
||||||
|
function png_get_pHYs; external pngDLL;
|
||||||
|
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_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_valid; external pngDLL;
|
||||||
|
function png_get_x_offset_microns; external pngDLL;
|
||||||
|
function png_get_x_offset_pixels; external pngDLL;
|
||||||
|
function png_get_x_pixels_per_meter; external pngDLL;
|
||||||
|
function png_get_y_offset_microns; external pngDLL;
|
||||||
|
function png_get_y_offset_pixels; external pngDLL;
|
||||||
|
function png_get_y_pixels_per_meter; external pngDLL;
|
||||||
|
procedure png_process_data; external pngDLL;
|
||||||
|
procedure png_progressive_combine_row; external pngDLL;
|
||||||
|
procedure png_read_end; external pngDLL;
|
||||||
|
procedure png_read_image; external pngDLL;
|
||||||
|
procedure png_read_info; external pngDLL;
|
||||||
|
procedure png_read_row; external pngDLL;
|
||||||
|
procedure png_read_rows; external pngDLL;
|
||||||
|
procedure png_read_update_info; external pngDLL;
|
||||||
|
procedure png_set_IHDR; external pngDLL;
|
||||||
|
procedure png_set_PLTE; external pngDLL;
|
||||||
|
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_compression_level; external pngDLL;
|
||||||
|
procedure png_set_compression_mem_level; external pngDLL;
|
||||||
|
procedure png_set_compression_method; external pngDLL;
|
||||||
|
procedure png_set_compression_strategy; external pngDLL;
|
||||||
|
procedure png_set_compression_window_bits; external pngDLL;
|
||||||
|
procedure png_set_crc_action; external pngDLL;
|
||||||
|
procedure png_set_dither; external pngDLL;
|
||||||
|
procedure png_set_error_fn; external pngDLL;
|
||||||
|
procedure png_set_expand; external pngDLL;
|
||||||
|
procedure png_set_filler; external pngDLL;
|
||||||
|
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_gamma; external pngDLL;
|
||||||
|
procedure png_set_gray_to_rgb; external pngDLL;
|
||||||
|
procedure png_set_hIST; external pngDLL;
|
||||||
|
function png_set_interlace_handling; external pngDLL;
|
||||||
|
procedure png_set_invert_alpha; external pngDLL;
|
||||||
|
procedure png_set_invert_mono; external pngDLL;
|
||||||
|
procedure png_set_oFFs; external pngDLL;
|
||||||
|
procedure png_set_pCAL; external pngDLL;
|
||||||
|
procedure png_set_pHYs; external pngDLL;
|
||||||
|
procedure png_set_packing; external pngDLL;
|
||||||
|
procedure png_set_packswap; external pngDLL;
|
||||||
|
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_sBIT; external pngDLL;
|
||||||
|
procedure png_set_sRGB; external pngDLL;
|
||||||
|
procedure png_set_sRGB_gAMA_and_cHRM; external pngDLL;
|
||||||
|
procedure png_set_shift; external pngDLL;
|
||||||
|
procedure png_set_sig_bytes; external pngDLL;
|
||||||
|
procedure png_set_strip_16; external pngDLL;
|
||||||
|
procedure png_set_strip_alpha; external pngDLL;
|
||||||
|
procedure png_set_swap; external pngDLL;
|
||||||
|
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_write_fn; external pngDLL;
|
||||||
|
procedure png_set_write_status_fn; external pngDLL;
|
||||||
|
procedure png_set_write_user_transform_fn; external pngDLL;
|
||||||
|
function png_sig_cmp; external pngDLL;
|
||||||
|
procedure png_start_read_image; external pngDLL;
|
||||||
|
procedure png_write_chunk; external pngDLL;
|
||||||
|
procedure png_write_chunk_data; external pngDLL;
|
||||||
|
procedure png_write_chunk_end; external pngDLL;
|
||||||
|
procedure png_write_chunk_start; external pngDLL;
|
||||||
|
procedure png_write_end; external pngDLL;
|
||||||
|
procedure png_write_flush; external pngDLL;
|
||||||
|
procedure png_write_image; external pngDLL;
|
||||||
|
procedure png_write_info; external pngDLL;
|
||||||
|
procedure png_write_row; external pngDLL;
|
||||||
|
procedure png_write_rows; external pngDLL;
|
||||||
|
|
||||||
|
end.
|
||||||
53
scripts/pngdll.mak
Normal file
53
scripts/pngdll.mak
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# Makefile for png32bd.dll
|
||||||
|
# ------------- Borland C++ 4.5 -------------
|
||||||
|
|
||||||
|
# This makefile expects to find zlib.h and zlib32bd.lib in the
|
||||||
|
# $(ZLIBDIR) directory.
|
||||||
|
|
||||||
|
# The object files here are compiled with the "stdcall" calling convention.
|
||||||
|
# This DLL requires zlib32bd.lib to be compiled in the same way.
|
||||||
|
|
||||||
|
# Note that png32bd.dll exports the zlib functions adler32, crc32 and
|
||||||
|
# the deflate... and inflate... functions. It does not export the
|
||||||
|
# compress and uncompress functions, nor any of the gz... functions,
|
||||||
|
# since libpng does not call them.
|
||||||
|
|
||||||
|
ZLIBDIR=..\zlib112
|
||||||
|
ZLIB=zlib32bd.lib
|
||||||
|
PNGDLL=png32bd.dll
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
.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
|
||||||
|
OBJ3=pngtrans.obj pngwio.obj pngwrite.obj pngwtran.obj pngwutil.obj
|
||||||
|
|
||||||
|
all: $(PNGDLL)
|
||||||
|
|
||||||
|
$(PNGDLL): $(OBJ1) $(OBJ2) $(OBJ3) $(ZLIBDIR)\$(ZLIB)
|
||||||
|
$(LINK) @&&|
|
||||||
|
$(LINKFLAGS) $(LIBDIR)\c0d32 +
|
||||||
|
$(OBJ1) +
|
||||||
|
$(OBJ2) +
|
||||||
|
$(OBJ3)
|
||||||
|
$@
|
||||||
|
-x
|
||||||
|
$(ZLIBDIR)\$(ZLIB) $(LIBDIR)\import32 $(LIBDIR)\cw32
|
||||||
|
|,&&|
|
||||||
|
LIBRARY $(@B)
|
||||||
|
EXETYPE WINDOWS
|
||||||
|
CODE PRELOAD MOVEABLE DISCARDABLE
|
||||||
|
DATA PRELOAD MOVEABLE MULTIPLE
|
||||||
|
|
|
||||||
|
$(IMPLIB) -c $(@R).lib $@
|
||||||
|
|
||||||
|
# End of makefile for png32bd.dll
|
||||||
293
scripts/pngos2.def
Normal file
293
scripts/pngos2.def
Normal file
@@ -0,0 +1,293 @@
|
|||||||
|
;----------------------------------------
|
||||||
|
; PNGLIB module definition file for OS/2
|
||||||
|
;----------------------------------------
|
||||||
|
|
||||||
|
LIBRARY PNG
|
||||||
|
DESCRIPTION "PNG image compression library for OS/2"
|
||||||
|
CODE PRELOAD MOVEABLE DISCARDABLE
|
||||||
|
DATA PRELOAD MOVEABLE MULTIPLE
|
||||||
|
|
||||||
|
EXPORTS
|
||||||
|
png_set_sig_bytes
|
||||||
|
png_sig_cmp
|
||||||
|
png_check_sig
|
||||||
|
png_create_read_struct
|
||||||
|
; png_create_read_struct_2
|
||||||
|
png_create_write_struct
|
||||||
|
; png_create_write_struct_2
|
||||||
|
png_write_chunk
|
||||||
|
png_write_chunk_start
|
||||||
|
png_write_chunk_data
|
||||||
|
png_write_chunk_end
|
||||||
|
png_create_info_struct
|
||||||
|
png_info_init
|
||||||
|
png_write_info
|
||||||
|
png_read_info
|
||||||
|
png_convert_to_rfc1123
|
||||||
|
png_convert_from_struct_tm
|
||||||
|
png_convert_from_time_t
|
||||||
|
png_set_expand
|
||||||
|
png_set_bgr
|
||||||
|
png_set_gray_to_rgb
|
||||||
|
png_set_rgb_to_gray
|
||||||
|
png_build_grayscale_palette
|
||||||
|
png_set_strip_alpha
|
||||||
|
png_set_swap_alpha
|
||||||
|
png_set_invert_alpha
|
||||||
|
png_set_filler
|
||||||
|
png_set_swap
|
||||||
|
png_set_packing
|
||||||
|
png_set_packswap
|
||||||
|
png_set_shift
|
||||||
|
png_set_interlace_handling
|
||||||
|
png_set_invert_mono
|
||||||
|
png_set_background
|
||||||
|
png_set_strip_16
|
||||||
|
png_set_dither
|
||||||
|
png_set_gamma
|
||||||
|
png_set_flush
|
||||||
|
png_write_flush
|
||||||
|
png_start_read_image
|
||||||
|
png_read_update_info
|
||||||
|
png_read_rows
|
||||||
|
png_read_row
|
||||||
|
png_read_image
|
||||||
|
png_write_row
|
||||||
|
png_write_rows
|
||||||
|
png_write_image
|
||||||
|
png_write_end
|
||||||
|
png_read_end
|
||||||
|
png_destroy_info_struct
|
||||||
|
png_destroy_read_struct
|
||||||
|
png_read_destroy
|
||||||
|
png_destroy_write_struct
|
||||||
|
; png_write_destroy_info
|
||||||
|
png_write_destroy
|
||||||
|
png_set_crc_action
|
||||||
|
png_set_filter
|
||||||
|
png_set_filter_heuristics
|
||||||
|
png_set_compression_level
|
||||||
|
png_set_compression_mem_level
|
||||||
|
png_set_compression_strategy
|
||||||
|
png_set_compression_window_bits
|
||||||
|
png_set_compression_method
|
||||||
|
png_init_io
|
||||||
|
png_get_copyright
|
||||||
|
png_set_error_fn
|
||||||
|
png_get_error_ptr
|
||||||
|
png_get_header_version
|
||||||
|
; png_get_mem_fn
|
||||||
|
; png_set_mem_fn
|
||||||
|
png_set_write_fn
|
||||||
|
png_set_read_fn
|
||||||
|
png_set_write_status_fn
|
||||||
|
png_set_read_status_fn
|
||||||
|
png_get_io_ptr
|
||||||
|
png_set_progressive_read_fn
|
||||||
|
png_set_read_status_fn
|
||||||
|
png_set_read_user_transform_fn
|
||||||
|
png_set_write_status_fn
|
||||||
|
png_set_write_user_transform_fn
|
||||||
|
png_get_progressive_ptr
|
||||||
|
png_process_data
|
||||||
|
png_progressive_combine_row
|
||||||
|
png_malloc
|
||||||
|
png_free
|
||||||
|
png_memcpy_check
|
||||||
|
png_memset_check
|
||||||
|
; png_malloc_default
|
||||||
|
; png_free_default
|
||||||
|
; png_far_to_near
|
||||||
|
png_error
|
||||||
|
png_chunk_error
|
||||||
|
png_warning
|
||||||
|
png_chunk_warning
|
||||||
|
png_get_valid
|
||||||
|
png_get_rowbytes
|
||||||
|
png_get_channels
|
||||||
|
png_get_image_width
|
||||||
|
png_get_image_height
|
||||||
|
png_get_bit_depth
|
||||||
|
png_get_color_type
|
||||||
|
png_get_filter_type
|
||||||
|
png_get_interlace_type
|
||||||
|
png_get_compression_type
|
||||||
|
png_get_pixels_per_meter
|
||||||
|
png_get_pixel_aspect_ratio
|
||||||
|
png_get_rgb_to_gray_status
|
||||||
|
png_get_x_offset_pixels
|
||||||
|
png_get_y_offset_pixels
|
||||||
|
png_get_x_offset_microns
|
||||||
|
png_get_y_offset_microns
|
||||||
|
png_get_signature
|
||||||
|
png_get_bKGD
|
||||||
|
png_set_bKGD
|
||||||
|
png_get_cHRM
|
||||||
|
png_set_cHRM
|
||||||
|
png_get_gAMA
|
||||||
|
png_set_gAMA
|
||||||
|
png_get_hIST
|
||||||
|
png_set_hIST
|
||||||
|
png_get_IHDR
|
||||||
|
png_set_IHDR
|
||||||
|
png_get_oFFs
|
||||||
|
png_set_oFFs
|
||||||
|
png_get_pCAL
|
||||||
|
png_set_pCAL
|
||||||
|
png_get_pHYs
|
||||||
|
png_set_pHYs
|
||||||
|
png_get_PLTE
|
||||||
|
png_set_PLTE
|
||||||
|
png_get_sBIT
|
||||||
|
png_set_sBIT
|
||||||
|
png_get_sRGB
|
||||||
|
png_set_sRGB
|
||||||
|
png_set_sRGB_gAMA_and_cHRM
|
||||||
|
png_get_text
|
||||||
|
png_set_text
|
||||||
|
png_get_tIME
|
||||||
|
png_set_tIME
|
||||||
|
png_get_tRNS
|
||||||
|
png_set_tRNS
|
||||||
|
|
||||||
|
png_create_struct
|
||||||
|
png_destroy_struct
|
||||||
|
png_info_destroy
|
||||||
|
png_zalloc
|
||||||
|
png_zfree
|
||||||
|
png_reset_crc
|
||||||
|
png_write_data
|
||||||
|
png_read_data
|
||||||
|
png_crc_read
|
||||||
|
png_crc_finish
|
||||||
|
png_crc_error
|
||||||
|
png_calculate_crc
|
||||||
|
png_flush
|
||||||
|
png_save_uint_32
|
||||||
|
png_save_int_32
|
||||||
|
png_save_uint_16
|
||||||
|
png_write_sig
|
||||||
|
png_write_IHDR
|
||||||
|
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_hIST
|
||||||
|
png_check_keyword
|
||||||
|
png_write_tEXt
|
||||||
|
png_write_zTXt
|
||||||
|
png_write_oFFs
|
||||||
|
png_write_pCAL
|
||||||
|
png_write_pHYs
|
||||||
|
png_write_tIME
|
||||||
|
png_write_finish_row
|
||||||
|
png_write_start_row
|
||||||
|
png_build_gamma_table
|
||||||
|
png_combine_row
|
||||||
|
png_do_read_interlace
|
||||||
|
png_do_write_interlace
|
||||||
|
png_read_filter_row
|
||||||
|
png_write_find_filter
|
||||||
|
png_write_filtered_row
|
||||||
|
png_read_finish_row
|
||||||
|
png_read_start_row
|
||||||
|
png_read_transform_info
|
||||||
|
png_do_read_filler
|
||||||
|
png_do_read_swap_alpha
|
||||||
|
png_do_write_swap_alpha
|
||||||
|
png_do_read_invert_alpha
|
||||||
|
png_do_write_invert_alpha
|
||||||
|
png_do_strip_filler
|
||||||
|
png_do_swap
|
||||||
|
png_do_packswap
|
||||||
|
png_do_rgb_to_gray
|
||||||
|
png_do_gray_to_rgb
|
||||||
|
png_do_unpack
|
||||||
|
png_do_unshift
|
||||||
|
png_do_invert
|
||||||
|
png_do_chop
|
||||||
|
png_do_dither
|
||||||
|
; png_correct_palette
|
||||||
|
png_do_bgr
|
||||||
|
png_do_pack
|
||||||
|
png_do_shift
|
||||||
|
png_do_background
|
||||||
|
png_do_gamma
|
||||||
|
png_do_expand_palette
|
||||||
|
png_do_expand
|
||||||
|
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_hIST
|
||||||
|
png_handle_oFFs
|
||||||
|
png_handle_pCAL
|
||||||
|
png_handle_pHYs
|
||||||
|
png_handle_tIME
|
||||||
|
png_handle_tEXt
|
||||||
|
png_handle_zTXt
|
||||||
|
png_handle_unknown
|
||||||
|
png_check_chunk_name
|
||||||
|
png_do_read_transformations
|
||||||
|
png_do_write_transformations
|
||||||
|
png_init_read_transformations
|
||||||
|
png_push_read_chunk
|
||||||
|
png_push_read_sig
|
||||||
|
; png_push_check_crc
|
||||||
|
png_push_crc_skip
|
||||||
|
png_push_crc_finish
|
||||||
|
png_push_fill_buffer
|
||||||
|
png_push_save_buffer
|
||||||
|
png_push_restore_buffer
|
||||||
|
png_push_read_IDAT
|
||||||
|
png_process_IDAT_data
|
||||||
|
png_push_process_row
|
||||||
|
png_push_handle_unknown
|
||||||
|
png_push_have_info
|
||||||
|
png_push_have_end
|
||||||
|
png_push_have_row
|
||||||
|
; png_push_read_end
|
||||||
|
png_process_some_data
|
||||||
|
png_read_push_finish_row
|
||||||
|
png_push_handle_tEXt
|
||||||
|
png_push_read_tEXt
|
||||||
|
png_push_handle_zTXt
|
||||||
|
png_push_read_zTXt
|
||||||
|
|
||||||
|
png_libpng_ver
|
||||||
|
png_pass_start
|
||||||
|
png_pass_inc
|
||||||
|
png_pass_ystart
|
||||||
|
png_pass_yinc
|
||||||
|
png_pass_mask
|
||||||
|
png_pass_dsp_mask
|
||||||
|
; png_pass_width
|
||||||
|
; png_pass_height
|
||||||
|
|
||||||
|
png_IHDR
|
||||||
|
png_IDAT
|
||||||
|
png_IEND
|
||||||
|
png_PLTE
|
||||||
|
png_bKGD
|
||||||
|
png_cHRM
|
||||||
|
png_gAMA
|
||||||
|
png_hIST
|
||||||
|
png_oFFs
|
||||||
|
png_pCAL
|
||||||
|
png_pHYs
|
||||||
|
png_sBIT
|
||||||
|
png_sRGB
|
||||||
|
png_tEXt
|
||||||
|
png_tIME
|
||||||
|
png_tRNS
|
||||||
|
png_zTXt
|
||||||
29
scripts/smakefile.ppc
Normal file
29
scripts/smakefile.ppc
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# Amiga powerUP (TM) Makefile
|
||||||
|
# makefile for libpng and SAS C V6.58/7.00 PPC compiler
|
||||||
|
# Copyright (C) 1998 by Andreas R. Kleinert
|
||||||
|
|
||||||
|
CC = scppc
|
||||||
|
CFLAGS = NOSTKCHK NOSINT OPTIMIZE OPTGO OPTPEEP OPTINLOCAL OPTINL IDIR /zlib \
|
||||||
|
OPTLOOP OPTRDEP=8 OPTDEP=8 OPTCOMP=8
|
||||||
|
LIBNAME = libpng.a
|
||||||
|
AR = ppc-amigaos-ar
|
||||||
|
AR_FLAGS = cr
|
||||||
|
RANLIB = ppc-amigaos-ranlib
|
||||||
|
LDFLAGS = -r -o
|
||||||
|
LDLIBS = ../zlib/libzip.a LIB:scppc.a
|
||||||
|
LN = ppc-amigaos-ld
|
||||||
|
RM = delete quiet
|
||||||
|
MKDIR = makedir
|
||||||
|
|
||||||
|
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o pngread.o \
|
||||||
|
pngerror.o pngpread.o pngwrite.o pngrtran.o pngwtran.o pngrio.o pngwio.o pngmem.o
|
||||||
|
|
||||||
|
all: $(LIBNAME) pngtest
|
||||||
|
|
||||||
|
$(LIBNAME): $(OBJS)
|
||||||
|
$(AR) $(AR_FLAGS) $@ $(OBJS)
|
||||||
|
$(RANLIB) $@
|
||||||
|
|
||||||
|
pngtest: pngtest.o $(LIBNAME)
|
||||||
|
$(LN) $(LDFLAGS) pngtest LIB:c_ppc.o pngtest.o $(LIBNAME) $(LDLIBS) \
|
||||||
|
LIB:end.o
|
||||||
169
scripts/zlibdef.pas
Normal file
169
scripts/zlibdef.pas
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
unit zlibdef;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Windows;
|
||||||
|
|
||||||
|
const
|
||||||
|
ZLIB_VERSION = '1.1.2';
|
||||||
|
|
||||||
|
type
|
||||||
|
voidpf = Pointer;
|
||||||
|
int = Integer;
|
||||||
|
uInt = Cardinal;
|
||||||
|
pBytef = PChar;
|
||||||
|
uLong = Cardinal;
|
||||||
|
|
||||||
|
alloc_func = function(opaque: voidpf; items, size: uInt): voidpf;
|
||||||
|
stdcall;
|
||||||
|
free_func = procedure(opaque, address: voidpf);
|
||||||
|
stdcall;
|
||||||
|
|
||||||
|
internal_state = Pointer;
|
||||||
|
|
||||||
|
z_streamp = ^z_stream;
|
||||||
|
z_stream = packed record
|
||||||
|
next_in: pBytef; // next input byte
|
||||||
|
avail_in: uInt; // number of bytes available at next_in
|
||||||
|
total_in: uLong; // total nb of input bytes read so far
|
||||||
|
|
||||||
|
next_out: pBytef; // next output byte should be put there
|
||||||
|
avail_out: uInt; // remaining free space at next_out
|
||||||
|
total_out: uLong; // total nb of bytes output so far
|
||||||
|
|
||||||
|
msg: PChar; // last error message, NULL if no error
|
||||||
|
state: internal_state; // not visible by applications
|
||||||
|
|
||||||
|
zalloc: alloc_func; // used to allocate the internal state
|
||||||
|
zfree: free_func; // used to free the internal state
|
||||||
|
opaque: voidpf; // private data object passed to zalloc and zfree
|
||||||
|
|
||||||
|
data_type: int; // best guess about the data type: ascii or binary
|
||||||
|
adler: uLong; // adler32 value of the uncompressed data
|
||||||
|
reserved: uLong; // reserved for future use
|
||||||
|
end;
|
||||||
|
|
||||||
|
const
|
||||||
|
Z_NO_FLUSH = 0;
|
||||||
|
Z_SYNC_FLUSH = 2;
|
||||||
|
Z_FULL_FLUSH = 3;
|
||||||
|
Z_FINISH = 4;
|
||||||
|
|
||||||
|
Z_OK = 0;
|
||||||
|
Z_STREAM_END = 1;
|
||||||
|
|
||||||
|
Z_NO_COMPRESSION = 0;
|
||||||
|
Z_BEST_SPEED = 1;
|
||||||
|
Z_BEST_COMPRESSION = 9;
|
||||||
|
Z_DEFAULT_COMPRESSION = -1;
|
||||||
|
|
||||||
|
Z_FILTERED = 1;
|
||||||
|
Z_HUFFMAN_ONLY = 2;
|
||||||
|
Z_DEFAULT_STRATEGY = 0;
|
||||||
|
|
||||||
|
Z_BINARY = 0;
|
||||||
|
Z_ASCII = 1;
|
||||||
|
Z_UNKNOWN = 2;
|
||||||
|
|
||||||
|
Z_DEFLATED = 8;
|
||||||
|
|
||||||
|
MAX_MEM_LEVEL = 9;
|
||||||
|
|
||||||
|
function adler32(adler: uLong; const buf: pBytef; len: uInt): uLong;
|
||||||
|
stdcall;
|
||||||
|
function crc32(crc: uLong; const buf: pBytef; len: uInt): uLong;
|
||||||
|
stdcall;
|
||||||
|
function deflate(strm: z_streamp; flush: int): int;
|
||||||
|
stdcall;
|
||||||
|
function deflateCopy(dest, source: z_streamp): int;
|
||||||
|
stdcall;
|
||||||
|
function deflateEnd(strm: z_streamp): int;
|
||||||
|
stdcall;
|
||||||
|
function deflateInit2_(strm: z_streamp; level, method,
|
||||||
|
windowBits, memLevel, strategy: int;
|
||||||
|
const version: PChar; stream_size: int): int;
|
||||||
|
stdcall;
|
||||||
|
function deflateInit_(strm: z_streamp; level: int;
|
||||||
|
const version: PChar; stream_size: int): int;
|
||||||
|
stdcall;
|
||||||
|
function deflateParams(strm: z_streamp; level, strategy: int): int;
|
||||||
|
stdcall;
|
||||||
|
function deflateReset(strm: z_streamp): int;
|
||||||
|
stdcall;
|
||||||
|
function deflateSetDictionary(strm: z_streamp;
|
||||||
|
const dictionary: pBytef;
|
||||||
|
dictLength: uInt): int;
|
||||||
|
stdcall;
|
||||||
|
function inflate(strm: z_streamp; flush: int): int;
|
||||||
|
stdcall;
|
||||||
|
function inflateEnd(strm: z_streamp): int;
|
||||||
|
stdcall;
|
||||||
|
function inflateInit2_(strm: z_streamp; windowBits: int;
|
||||||
|
const version: PChar; stream_size: int): int;
|
||||||
|
stdcall;
|
||||||
|
function inflateInit_(strm: z_streamp; const version: PChar;
|
||||||
|
stream_size: int): int;
|
||||||
|
stdcall;
|
||||||
|
function inflateReset(strm: z_streamp): int;
|
||||||
|
stdcall;
|
||||||
|
function inflateSetDictionary(strm: z_streamp;
|
||||||
|
const dictionary: pBytef;
|
||||||
|
dictLength: uInt): int;
|
||||||
|
stdcall;
|
||||||
|
function inflateSync(strm: z_streamp): int;
|
||||||
|
stdcall;
|
||||||
|
|
||||||
|
function deflateInit(strm: z_streamp; level: int): int;
|
||||||
|
function deflateInit2(strm: z_streamp; level, method, windowBits,
|
||||||
|
memLevel, strategy: int): int;
|
||||||
|
function inflateInit(strm: z_streamp): int;
|
||||||
|
function inflateInit2(strm: z_streamp; windowBits: int): int;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
function deflateInit(strm: z_streamp; level: int): int;
|
||||||
|
begin
|
||||||
|
Result := deflateInit_(strm, level, ZLIB_VERSION, sizeof(z_stream));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function deflateInit2(strm: z_streamp; level, method, windowBits,
|
||||||
|
memLevel, strategy: int): int;
|
||||||
|
begin
|
||||||
|
Result := deflateInit2_(strm, level, method, windowBits, memLevel,
|
||||||
|
strategy, ZLIB_VERSION, sizeof(z_stream));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function inflateInit(strm: z_streamp): int;
|
||||||
|
begin
|
||||||
|
Result := inflateInit_(strm, ZLIB_VERSION, sizeof(z_stream));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function inflateInit2(strm: z_streamp; windowBits: int): int;
|
||||||
|
begin
|
||||||
|
Result := inflateInit2_(strm, windowBits, ZLIB_VERSION,
|
||||||
|
sizeof(z_stream));
|
||||||
|
end;
|
||||||
|
|
||||||
|
const
|
||||||
|
zlibDLL = 'png32bd.dll';
|
||||||
|
|
||||||
|
function adler32; external zlibDLL;
|
||||||
|
function crc32; external zlibDLL;
|
||||||
|
function deflate; external zlibDLL;
|
||||||
|
function deflateCopy; external zlibDLL;
|
||||||
|
function deflateEnd; external zlibDLL;
|
||||||
|
function deflateInit2_; external zlibDLL;
|
||||||
|
function deflateInit_; external zlibDLL;
|
||||||
|
function deflateParams; external zlibDLL;
|
||||||
|
function deflateReset; external zlibDLL;
|
||||||
|
function deflateSetDictionary; external zlibDLL;
|
||||||
|
function inflate; external zlibDLL;
|
||||||
|
function inflateEnd; external zlibDLL;
|
||||||
|
function inflateInit2_; external zlibDLL;
|
||||||
|
function inflateInit_; external zlibDLL;
|
||||||
|
function inflateReset; external zlibDLL;
|
||||||
|
function inflateSetDictionary; external zlibDLL;
|
||||||
|
function inflateSync; external zlibDLL;
|
||||||
|
|
||||||
|
end.
|
||||||
36
scripts/zlibdll.mak
Normal file
36
scripts/zlibdll.mak
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# Makefile for zlib32bd.lib
|
||||||
|
# ------------- Borland C++ 4.5 -------------
|
||||||
|
|
||||||
|
# The (32-bit) zlib32bd.lib made with this makefile is intended for use
|
||||||
|
# in making the (32-bit) DLL, png32bd.dll. It uses the "stdcall" calling
|
||||||
|
# convention.
|
||||||
|
|
||||||
|
CFLAGS= -ps -O2 -C -K -N- -k- -d -3 -r- -w-par -w-aus -WDE
|
||||||
|
CC=f:\bc45\bin\bcc32
|
||||||
|
LIBFLAGS= /C
|
||||||
|
LIB=f:\bc45\bin\tlib
|
||||||
|
ZLIB=zlib32bd.lib
|
||||||
|
|
||||||
|
.autodepend
|
||||||
|
.c.obj:
|
||||||
|
$(CC) -c $(CFLAGS) $<
|
||||||
|
|
||||||
|
OBJ1=adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infblock.obj
|
||||||
|
OBJ2=infcodes.obj inflate.obj inftrees.obj infutil.obj inffast.obj
|
||||||
|
OBJ3=trees.obj uncompr.obj zutil.obj
|
||||||
|
pOBJ1=+adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infblock.obj
|
||||||
|
pOBJ2=+infcodes.obj+inflate.obj+inftrees.obj+infutil.obj+inffast.obj
|
||||||
|
pOBJ3=+trees.obj+uncompr.obj+zutil.obj
|
||||||
|
|
||||||
|
all: $(ZLIB)
|
||||||
|
|
||||||
|
$(ZLIB): $(OBJ1) $(OBJ2) $(OBJ3)
|
||||||
|
@if exist $@ del $@
|
||||||
|
$(LIB) @&&|
|
||||||
|
$@ $(LIBFLAGS) &
|
||||||
|
$(pOBJ1) &
|
||||||
|
$(pOBJ2) &
|
||||||
|
$(pOBJ3)
|
||||||
|
|
|
||||||
|
|
||||||
|
# End of makefile for zlib32bd.lib
|
||||||
Reference in New Issue
Block a user