mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0dce40075 | ||
|
|
1d96361273 | ||
|
|
896239be20 | ||
|
|
f9f2fe0ce7 | ||
|
|
d12aa50322 | ||
|
|
8f8fb6ae7a | ||
|
|
0f7202f074 | ||
|
|
397100eb8a | ||
|
|
4922b1b6e9 |
49
ANNOUNCE
Normal file
49
ANNOUNCE
Normal file
@@ -0,0 +1,49 @@
|
||||
|
||||
Libpng 1.0.1c May 9, 1998
|
||||
|
||||
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.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 9, 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_WRIGHT_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" for the capabilities in pngconf.h
|
||||
to make it easier to remove unwanted capabilities via the compile line
|
||||
|
||||
Send comments/corrections/commendations to
|
||||
png-implement@dworkin.wustl.edu or to randeg@alumni.rpi.edu
|
||||
|
||||
Glenn R-P
|
||||
530
CHANGES
530
CHANGES
@@ -1,270 +1,324 @@
|
||||
CHANGES - changes for libpng
|
||||
|
||||
version 0.2
|
||||
added reader into png.h
|
||||
fixed small problems in stub file
|
||||
added reader into png.h
|
||||
fixed small problems in stub file
|
||||
version 0.3
|
||||
added pull reader
|
||||
split up pngwrite.c to several files
|
||||
added pnglib.txt
|
||||
added example.c
|
||||
cleaned up writer, adding a few new tranformations
|
||||
fixed some bugs in writer
|
||||
interfaced with zlib 0.5
|
||||
added K&R support
|
||||
added check for 64 KB blocks for 16 bit machines
|
||||
added pull reader
|
||||
split up pngwrite.c to several files
|
||||
added pnglib.txt
|
||||
added example.c
|
||||
cleaned up writer, adding a few new tranformations
|
||||
fixed some bugs in writer
|
||||
interfaced with zlib 0.5
|
||||
added K&R support
|
||||
added check for 64 KB blocks for 16 bit machines
|
||||
version 0.4
|
||||
cleaned up code and commented code
|
||||
simplified time handling into png_time
|
||||
created png_color_16 and png_color_8 to handle color needs
|
||||
cleaned up color type defines
|
||||
fixed various bugs
|
||||
made various names more consistant
|
||||
interfaced with zlib 0.71
|
||||
cleaned up zTXt reader and writer (using zlib's Reset functions)
|
||||
split transformations into pngrtran.c and pngwtran.c
|
||||
cleaned up code and commented code
|
||||
simplified time handling into png_time
|
||||
created png_color_16 and png_color_8 to handle color needs
|
||||
cleaned up color type defines
|
||||
fixed various bugs
|
||||
made various names more consistant
|
||||
interfaced with zlib 0.71
|
||||
cleaned up zTXt reader and writer (using zlib's Reset functions)
|
||||
split transformations into pngrtran.c and pngwtran.c
|
||||
version 0.5
|
||||
interfaced with zlib 0.8
|
||||
fixed many reading and writing bugs
|
||||
saved using 3 spaces instead of tabs
|
||||
interfaced with zlib 0.8
|
||||
fixed many reading and writing bugs
|
||||
saved using 3 spaces instead of tabs
|
||||
version 0.6
|
||||
added png_large_malloc() and png_large_free()
|
||||
added png_size_t
|
||||
cleaned up some compiler warnings
|
||||
added png_start_read_image()
|
||||
added png_large_malloc() and png_large_free()
|
||||
added png_size_t
|
||||
cleaned up some compiler warnings
|
||||
added png_start_read_image()
|
||||
version 0.7
|
||||
cleaned up lots of bugs
|
||||
finished dithering and other stuff
|
||||
added test program
|
||||
changed name from pnglib to libpng
|
||||
cleaned up lots of bugs
|
||||
finished dithering and other stuff
|
||||
added test program
|
||||
changed name from pnglib to libpng
|
||||
version 0.71 [June, 1995]
|
||||
changed pngtest.png for zlib 0.93
|
||||
fixed error in libpng.txt and example.c
|
||||
changed pngtest.png for zlib 0.93
|
||||
fixed error in libpng.txt and example.c
|
||||
version 0.8
|
||||
cleaned up some bugs
|
||||
added png_set_filler()
|
||||
split up pngstub.c into pngmem.c, pngio.c, and pngerror.c
|
||||
added #define's to remove unwanted code
|
||||
moved png_info_init() to png.c
|
||||
added old_size into png_realloc()
|
||||
added functions to manually set filtering and compression info
|
||||
changed compression parameters based on image type
|
||||
optimized filter selection code
|
||||
added version info
|
||||
changed external functions passing floats to doubles (k&r problems?)
|
||||
put all the configurable stuff in pngconf.h
|
||||
enabled png_set_shift to work with paletted images on read
|
||||
added png_read_update_info() - updates info structure with
|
||||
transformations
|
||||
cleaned up some bugs
|
||||
added png_set_filler()
|
||||
split up pngstub.c into pngmem.c, pngio.c, and pngerror.c
|
||||
added #define's to remove unwanted code
|
||||
moved png_info_init() to png.c
|
||||
added old_size into png_realloc()
|
||||
added functions to manually set filtering and compression info
|
||||
changed compression parameters based on image type
|
||||
optimized filter selection code
|
||||
added version info
|
||||
changed external functions passing floats to doubles (k&r problems?)
|
||||
put all the configurable stuff in pngconf.h
|
||||
enabled png_set_shift to work with paletted images on read
|
||||
added png_read_update_info() - updates info structure with
|
||||
transformations
|
||||
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]
|
||||
[unspecified changes]
|
||||
[unspecified changes]
|
||||
version 0.85 [December, 1995]
|
||||
added more medium model code (almost everything's a far)
|
||||
added i/o, error, and memory callback functions
|
||||
fixed some bugs (16 bit, 4 bit interlaced, etc.)
|
||||
added first run progressive reader (barely tested)
|
||||
added more medium model code (almost everything's a far)
|
||||
added i/o, error, and memory callback functions
|
||||
fixed some bugs (16 bit, 4 bit interlaced, etc.)
|
||||
added first run progressive reader (barely tested)
|
||||
version 0.86 [January, 1996]
|
||||
fixed bugs
|
||||
improved documentation
|
||||
fixed bugs
|
||||
improved documentation
|
||||
version 0.87 [January, 1996]
|
||||
fixed medium model bugs
|
||||
fixed other bugs introduced in 0.85 and 0.86
|
||||
added some minor documentation
|
||||
fixed medium model bugs
|
||||
fixed other bugs introduced in 0.85 and 0.86
|
||||
added some minor documentation
|
||||
version 0.88 [January, 1996]
|
||||
fixed progressive bugs
|
||||
replaced tabs with spaces
|
||||
cleaned up documentation
|
||||
added callbacks for read/write and warning/error functions
|
||||
fixed progressive bugs
|
||||
replaced tabs with spaces
|
||||
cleaned up documentation
|
||||
added callbacks for read/write and warning/error functions
|
||||
version 0.89 [July, 1996]
|
||||
added new initialization API to make libpng work better with shared libs
|
||||
we now have png_create_read_struct(), png_create_write_struct(),
|
||||
png_create_info_struct(), png_destroy_read_struct(), and
|
||||
png_destroy_write_struct() instead of the separate calls to
|
||||
malloc and png_read_init(), png_info_init(), and png_write_init()
|
||||
changed warning/error callback functions to fix bug - this means you
|
||||
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
|
||||
so that people are aware that they need to change their code
|
||||
changed filter selection API to allow selection of multiple filters
|
||||
since it didn't work in previous versions of libpng anyways
|
||||
optimized filter selection code
|
||||
fixed png_set_background() to allow using an arbitrary RGB color for
|
||||
paletted images
|
||||
fixed gamma and background correction for paletted images, so
|
||||
png_correct_palette is not needed unless you are correcting an
|
||||
external palette (you will need to #define PNG_CORRECT_PALETTE_SUPPORTED
|
||||
in pngconf.h) - if nobody uses this, it may disappear in the future.
|
||||
fixed bug with Borland 64K memory allocation (Alexander Lehmann)
|
||||
fixed bug in interlace handling (Smarasderagd, I think)
|
||||
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
|
||||
into a binary when only reading or writing functionality is used
|
||||
new pngtest image also has interlacing and zTXt
|
||||
updated documentation to reflect new API
|
||||
added new initialization API to make libpng work better with shared libs
|
||||
we now have png_create_read_struct(), png_create_write_struct(),
|
||||
png_create_info_struct(), png_destroy_read_struct(), and
|
||||
png_destroy_write_struct() instead of the separate calls to
|
||||
malloc and png_read_init(), png_info_init(), and png_write_init()
|
||||
changed warning/error callback functions to fix bug - this means you
|
||||
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
|
||||
so that people are aware that they need to change their code
|
||||
changed filter selection API to allow selection of multiple filters
|
||||
since it didn't work in previous versions of libpng anyways
|
||||
optimized filter selection code
|
||||
fixed png_set_background() to allow using an arbitrary RGB color for
|
||||
paletted images
|
||||
fixed gamma and background correction for paletted images, so
|
||||
png_correct_palette is not needed unless you are correcting an
|
||||
external palette (you will need to #define PNG_CORRECT_PALETTE_SUPPORTED
|
||||
in pngconf.h) - if nobody uses this, it may disappear in the future.
|
||||
fixed bug with Borland 64K memory allocation (Alexander Lehmann)
|
||||
fixed bug in interlace handling (Smarasderagd, I think)
|
||||
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
|
||||
into a binary when only reading or writing functionality is used
|
||||
new pngtest image also has interlacing and zTXt
|
||||
updated documentation to reflect new API
|
||||
version 0.90 [January, 1997]
|
||||
made CRC errors/warnings on critical and ancillary chunks configurable
|
||||
libpng will use the zlib CRC routines by (compile-time) default
|
||||
changed DOS small/medium model memory support - needs zlib 1.04 (Tim Wegner)
|
||||
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
|
||||
been read from the beginning of the stream. ****This affects the size
|
||||
of info_struct and invalidates all programs that use a shared libpng****
|
||||
fixed png_filler() declarations
|
||||
fixed? background color conversions
|
||||
fixed order of error function pointers to match documentation
|
||||
current chunk name is now available in png_struct to reduce the number
|
||||
of nearly identical error messages (will simplify multi-lingual
|
||||
support when available)
|
||||
try to get ready for unknown-chunk callback functions:
|
||||
- previously read critical chunks are flagged, so the chunk handling
|
||||
routines can determine if the chunk is in the right place
|
||||
- all chunk handling routines have the same prototypes, so we will
|
||||
be able to handle all chunks via a callback mechanism
|
||||
try to fix Linux "setjmp" buffer size problems
|
||||
made CRC errors/warnings on critical and ancillary chunks configurable
|
||||
libpng will use the zlib CRC routines by (compile-time) default
|
||||
changed DOS small/medium model memory support - needs zlib 1.04 (Tim Wegner)
|
||||
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
|
||||
been read from the beginning of the stream. ****This affects the size
|
||||
of info_struct and invalidates all programs that use a shared libpng****
|
||||
fixed png_filler() declarations
|
||||
fixed? background color conversions
|
||||
fixed order of error function pointers to match documentation
|
||||
current chunk name is now available in png_struct to reduce the number
|
||||
of nearly identical error messages (will simplify multi-lingual
|
||||
support when available)
|
||||
try to get ready for unknown-chunk callback functions:
|
||||
- previously read critical chunks are flagged, so the chunk handling
|
||||
routines can determine if the chunk is in the right place
|
||||
- all chunk handling routines have the same prototypes, so we will
|
||||
be able to handle all chunks via a callback mechanism
|
||||
try to fix Linux "setjmp" buffer size problems
|
||||
version 0.95 [March, 1997]
|
||||
fixed bug in pngwutil.c allocating "up_row" twice and "avg_row" never
|
||||
fixed bug in PNG file signature compares when start != 0
|
||||
changed parameter type of png_set_filler(...filler...) from png_byte
|
||||
to png_uint_32
|
||||
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 "packswap" transformation, which changes the endianness of
|
||||
packed-pixel bytes (Kevin Bracey)
|
||||
added "strip_alpha" transformation, which removes the alpha channel of
|
||||
input images without using it (not neccesarily a good idea)
|
||||
added "swap_alpha" transformation, which puts the alpha channel in front
|
||||
of the color bytes instead of after
|
||||
removed all implicit variable tests which assume NULL == 0 (I think)
|
||||
changed several variables to "png_size_t" to show 16/32-bit limitations
|
||||
added new pCAL chunk read/write support
|
||||
added experimental filter selection weighting (Greg Roelofs)
|
||||
removed old png_set_rgbx() and png_set_xrgb() functions that have been
|
||||
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
|
||||
used only on those systems that support it (namely PowerPC and 680x0)
|
||||
With some testing, this may become the default for MACOS/PPC systems.
|
||||
only calculate CRC on data if we are going to use it
|
||||
added macros for zTXt compression type PNG_zTXt_COMPRESSION_???
|
||||
added macros for simple libpng debugging output selectable at compile time
|
||||
removed PNG_READ_END_MODE in progressive reader (Smarasderagd)
|
||||
more description of info_struct in libpng.txt and png.h
|
||||
more instructions in example.c
|
||||
more chunk types tested in pngtest.c
|
||||
renamed pngrcb.c to pngset.c, and all png_read_<chunk> functions to be
|
||||
png_set_<chunk>. We now have corresponding png_get_<chunk>
|
||||
functions in pngget.c to get infomation in info_ptr. This isolates
|
||||
the application from the internal organization of png_info_struct
|
||||
(good for shared library implementations).
|
||||
fixed bug in pngwutil.c allocating "up_row" twice and "avg_row" never
|
||||
fixed bug in PNG file signature compares when start != 0
|
||||
changed parameter type of png_set_filler(...filler...) from png_byte
|
||||
to png_uint_32
|
||||
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 "packswap" transformation, which changes the endianness of
|
||||
packed-pixel bytes (Kevin Bracey)
|
||||
added "strip_alpha" transformation, which removes the alpha channel of
|
||||
input images without using it (not neccesarily a good idea)
|
||||
added "swap_alpha" transformation, which puts the alpha channel in front
|
||||
of the color bytes instead of after
|
||||
removed all implicit variable tests which assume NULL == 0 (I think)
|
||||
changed several variables to "png_size_t" to show 16/32-bit limitations
|
||||
added new pCAL chunk read/write support
|
||||
added experimental filter selection weighting (Greg Roelofs)
|
||||
removed old png_set_rgbx() and png_set_xrgb() functions that have been
|
||||
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
|
||||
used only on those systems that support it (namely PowerPC and 680x0)
|
||||
With some testing, this may become the default for MACOS/PPC systems.
|
||||
only calculate CRC on data if we are going to use it
|
||||
added macros for zTXt compression type PNG_zTXt_COMPRESSION_???
|
||||
added macros for simple libpng debugging output selectable at compile time
|
||||
removed PNG_READ_END_MODE in progressive reader (Smarasderagd)
|
||||
more description of info_struct in libpng.txt and png.h
|
||||
more instructions in example.c
|
||||
more chunk types tested in pngtest.c
|
||||
renamed pngrcb.c to pngset.c, and all png_read_<chunk> functions to be
|
||||
png_set_<chunk>. We now have corresponding png_get_<chunk>
|
||||
functions in pngget.c to get infomation in info_ptr. This isolates
|
||||
the application from the internal organization of png_info_struct
|
||||
(good for shared library implementations).
|
||||
version 0.96 [May, 1997]
|
||||
fixed serious bug with < 8bpp images introduced in 0.95
|
||||
fixed 256-color transparency bug (Greg Roelofs)
|
||||
fixed up documentation (Greg Roelofs, Laszlo Nyul)
|
||||
fixed "error" in pngconf.h for Linux setjmp() behaviour
|
||||
fixed DOS medium model support (Tim Wegner)
|
||||
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 typecasts to quiet compiler errors
|
||||
added more debugging info
|
||||
fixed serious bug with < 8bpp images introduced in 0.95
|
||||
fixed 256-color transparency bug (Greg Roelofs)
|
||||
fixed up documentation (Greg Roelofs, Laszlo Nyul)
|
||||
fixed "error" in pngconf.h for Linux setjmp() behaviour
|
||||
fixed DOS medium model support (Tim Wegner)
|
||||
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 typecasts to quiet compiler errors
|
||||
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)
|
||||
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
|
||||
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
|
||||
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.)
|
||||
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.
|
||||
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.
|
||||
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
|
||||
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)
|
||||
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
|
||||
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.
|
||||
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
|
||||
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
|
||||
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 9, 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_WRIGHT_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
|
||||
|
||||
10
INSTALL
10
INSTALL
@@ -1,5 +1,5 @@
|
||||
|
||||
Installing libpng version 1.00 March 7, 1998
|
||||
Installing libpng version %VER% %DATE%
|
||||
|
||||
Before installing libpng, you must first install zlib. zlib
|
||||
can usually be found wherever you got libpng. zlib can be
|
||||
@@ -10,7 +10,7 @@ zlib.h and zconf.h include files that correspond to the
|
||||
version of zlib that's installed.
|
||||
|
||||
You can rename the directories that you downloaded (they
|
||||
might be called "libpng-1.00 or "lpng100" and "zlib-1.1.1"
|
||||
might be called "libpng-%VER% or "lpng100" and "zlib-1.1.1"
|
||||
or "zlib111") so that you have directories called "zlib" and "libpng".
|
||||
|
||||
Your directory structure should look like this:
|
||||
@@ -44,11 +44,13 @@ include
|
||||
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.00)
|
||||
makefile.lnx => Linux/ELF makefile (gcc, creates libpng.so.2.1.00)
|
||||
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
|
||||
|
||||
158
KNOWNBUG
Normal file
158
KNOWNBUG
Normal file
@@ -0,0 +1,158 @@
|
||||
|
||||
Known bugs and suggested enhancements in libpng-1.0.1
|
||||
|
||||
1. March 13, 1998 -- BUG -- pngtrans.c:
|
||||
|
||||
row_info->channels should be updated --
|
||||
row_info->color_type should be updated --
|
||||
|
||||
STATUS: I think this is all fixed in libpng-1.0.1a but needs
|
||||
to be tested.
|
||||
|
||||
2. March 14, 1998 -- ENHANCEMENT -- Glenn
|
||||
|
||||
We should add the G>GA, G>GX, G>AG, and G>XG transformations
|
||||
in png_do_read_filler()
|
||||
|
||||
STATUS: Implemented in libpng-1.0.1a
|
||||
|
||||
3. March 14, 1998 -- BUG? -- Greg Roelofs
|
||||
|
||||
pngrtran.c: if-test for channels/FILLER may be incorrect
|
||||
|
||||
STATUS: Under investigation. Appears to be working correctly
|
||||
in libpng-1.0.1c.
|
||||
|
||||
4. March 15, 1998 -- BUG -- Kevin Bracey
|
||||
|
||||
pngwtran.c:
|
||||
line 306: loop should count to row_info->width, not to
|
||||
row_info->width*row_info->channnels
|
||||
|
||||
STATUS: Fixed in libpng-1.0.1a
|
||||
|
||||
5. March 15, 1998 -- OPTIMIZATION -- Kevin Bracey
|
||||
|
||||
Loops need to be optimized everywhere
|
||||
|
||||
a. 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.
|
||||
|
||||
b. Remove products and structure members from loop tests -- Glenn R-P
|
||||
|
||||
Can be accomplished without messing with loop guts. This
|
||||
was shown to be effective on optimized SGI compiler:
|
||||
|
||||
replace
|
||||
png_uint_32 i;
|
||||
for(i=0; i < s->a*s->b; i++)
|
||||
with
|
||||
png_uint_32 i, istop;
|
||||
istop = s->a*s->b;
|
||||
for(i=0; i<istop; i++)
|
||||
|
||||
STATUS: Mostly done in libpng-1.0.1a, done for all important loops.
|
||||
More done in libpng-1.0.1b.
|
||||
|
||||
c. Replace abs() with intrinsic ternary operations in Paeth
|
||||
filtering -- Glenn R-P
|
||||
|
||||
STATUS: Done in libpng-1.0.1a
|
||||
(can be restored to original behavior with #define PNG_USE_ABS)
|
||||
|
||||
d. In pngwutil.c, make separate simple loops to use when filter
|
||||
heuristic sums aren't needed. -- Glenn R-P
|
||||
|
||||
STATUS: Done in libpng-1.0.1a
|
||||
|
||||
6. April 6, 1998 -- BUG -- bug in pngset.c (rowbytes too large) -- Bob Dellaca
|
||||
|
||||
pngset.c has a bug, introduced in version 0.99c, that sets rowbytes
|
||||
too large when writing an image with bit_depth < 8
|
||||
|
||||
STATUS: Fixed in libpng-1.0.1a
|
||||
|
||||
7. April 10, 1998 -- BUG -- pngwutil weighted filtering bugs -- Glenn R-P
|
||||
|
||||
pngwutil.c has some bugs in the experimental weighted filter
|
||||
algorithm (PNG_FILTER_XXX should be PNG_FILTER_VALUE_XXX in
|
||||
several places)
|
||||
|
||||
STATUS: Andreas concurs. Fixed in libpng-1.0.1a
|
||||
|
||||
8. April 10, 1998 -- ENHANCEMENT -- run-time selection of malloc function
|
||||
-- Bob Dellaca
|
||||
|
||||
pngmem.c currently provides a compile-time option to replace
|
||||
png_malloc() and png_free(). It's been requested that these
|
||||
be made possible at run time, via calls to new png_set_malloc_fn()
|
||||
and png_set_free_fn() functions.
|
||||
|
||||
STATUS: Under consideration
|
||||
|
||||
9. April 11, 1998 -- BUG -- incorrect truncation of tRNS data in
|
||||
illegal PNG file where tRNS precedes PLTE -- Larry Reeve
|
||||
|
||||
There is a misplaced pngrutil code block that truncates tRNS if it has
|
||||
more than num_palette entries -- test was done before num_palette was
|
||||
defined. Although the PNG file is illegal, it shouldn't crash apps.
|
||||
There is a simple fix; just moving the test to the point after
|
||||
num_palette has been defined.
|
||||
|
||||
STATUS: Fixed in libpng-1.0.1a
|
||||
|
||||
10. April 16, 1998 -- BUG -- incorrect operation of png_convert_to_rfc1123
|
||||
with 31st day of the month -- Steve Eddins
|
||||
|
||||
The "ptime->date % 31" is wrong, should be "ptime->date % 32".
|
||||
|
||||
STATUS: Fixed in libpng-1.0.1a
|
||||
|
||||
11. April 21, 1998 -- ENHANCEMENT -- relocation of composite macros
|
||||
|
||||
png_composite() and png_composite_16() relocated to png.h
|
||||
|
||||
STATUS: Done in libpng-1.0.1b
|
||||
|
||||
12. April 22, 1998 -- ENHANCEMENT -- makefile.sco
|
||||
|
||||
Mike Hopkirk contributed a makefile for SCO osr5 and sco UW7
|
||||
|
||||
STATUS: Added to libpng-1.0.1b distribution
|
||||
|
||||
13: April 30, 1998 -- ENHANCEMENT -- warnings
|
||||
|
||||
When people define out some of the read transformations and then
|
||||
try to use them, the request is silently ignored. It was suggested
|
||||
that a warning be issued in such cases.
|
||||
|
||||
STATUS: Done in libpng-1.0.1b
|
||||
|
||||
14. May 2, 1998 -- BUG -- incorrect mask for filler bytes
|
||||
|
||||
In pngrtran.c, png_do_filler(), the masks for hi_filler and low_filler
|
||||
should be 0xff instead of 0xf
|
||||
|
||||
STATUS: Fixed in libpng-1.0.1c
|
||||
|
||||
15. May 3, 1998 -- BUG -- buffer overflow in png_do_read_filler()
|
||||
|
||||
In pngrutil.c, max_pixel_depth needs to be set to 32 when using
|
||||
png_do_read_filler with palette images.
|
||||
|
||||
STATUS: Fixed in libpng-1.0.1c (see also items 1 and 3 above).
|
||||
|
||||
16. May 3, 1998 -- BUG -- type definitions wrong on error functions -- Tom Lane
|
||||
|
||||
In png_create_xxx_struct(), the error functions should have typedef
|
||||
png_voidp instead of (void *). Needs to be corrected in the functions,
|
||||
the prototypes in png.h, the example.c file, and libpng.txt and libpng.3
|
||||
|
||||
|
||||
STATUS: Fixed in libpng-1.0.1c
|
||||
8
README
8
README
@@ -1,4 +1,4 @@
|
||||
README for libpng 1.00 (shared library 2.1)
|
||||
README for libpng %VER% (shared library 2.1)
|
||||
See the note about version numbers near the top of png.h
|
||||
|
||||
See INSTALL for instructions on how to install libpng.
|
||||
@@ -161,11 +161,13 @@ Files in this distribution:
|
||||
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.00)
|
||||
makefile.lnx => Linux/ELF makefile (gcc, creates libpng.so.2.1.00)
|
||||
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
|
||||
|
||||
2
TODO
2
TODO
@@ -1,7 +1,9 @@
|
||||
TODO - list of things to do for libpng
|
||||
|
||||
fix problem with C++ and EXTERN "C"
|
||||
add capability to set user malloc/free functions at run time
|
||||
add "grayscale->palette" transformation and "palette->grayscale" detection
|
||||
color to gray transformation
|
||||
improved dithering
|
||||
multi-lingual error and warning message support
|
||||
sPLT chunk handling
|
||||
|
||||
12
ansi2knr.c
12
ansi2knr.c
@@ -1,7 +1,9 @@
|
||||
/* ansi2knr.c */
|
||||
/* Convert ANSI C function definitions to K&R ("traditional C") syntax */
|
||||
|
||||
/*
|
||||
/* Convert ANSI C function definitions to K&R ("traditional C") syntax
|
||||
Copyright (C) 1989 Aladdin Enterprises. All rights reserved.
|
||||
Copyright (C) 1988 Richard M. Stallman
|
||||
|
||||
ansi2knr is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY. No author or distributor accepts responsibility to anyone for the
|
||||
consequences of using it or for whether it serves any particular purpose or
|
||||
@@ -12,12 +14,12 @@ 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 IJG distribution, the GPL appears below, not in a separate file.]
|
||||
[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 set of sources and a
|
||||
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
|
||||
@@ -27,7 +29,7 @@ program under the GPL.
|
||||
|
||||
/*
|
||||
---------- 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
|
||||
(Clarified 11 Feb 1988)
|
||||
|
||||
16
example.c
16
example.c
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "png.h"
|
||||
|
||||
/* Check to see if a file is a PNG file using png_check_sig(). Returns
|
||||
/* Check to see if a file is a PNG file using png_sig_cmp(). Returns
|
||||
* non-zero if the image is a PNG, and 0 if it isn't a PNG.
|
||||
*
|
||||
* If this call is successful, and you are going to keep the file open,
|
||||
@@ -29,7 +29,7 @@
|
||||
*
|
||||
* 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
|
||||
* to pass the bytes to png_check_sig() or even skip that if you know
|
||||
* 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
|
||||
@@ -46,7 +46,7 @@ int check_if_png(char *file_name, FILE **fp)
|
||||
return 0;
|
||||
|
||||
/* Compare the first PNG_BYTES_TO_CHECK bytes of the signature. */
|
||||
return(png_check_sig(buf, PNG_BYTES_TO_CHECK));
|
||||
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
|
||||
@@ -83,7 +83,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
* was compiled with a compatible version of the library. REQUIRED
|
||||
*/
|
||||
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)
|
||||
{
|
||||
@@ -92,7 +92,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
}
|
||||
|
||||
/* 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)
|
||||
{
|
||||
fclose(fp);
|
||||
@@ -127,7 +127,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
#endif no_streams /* Use only one I/O method! */
|
||||
|
||||
/* 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
|
||||
* PNG file before the first IDAT (image data chunk). REQUIRED
|
||||
@@ -362,7 +362,7 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
|
||||
* linked libraries.
|
||||
*/
|
||||
*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)
|
||||
{
|
||||
@@ -498,7 +498,7 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
* in case we are using dynamically linked libraries. REQUIRED.
|
||||
*/
|
||||
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)
|
||||
{
|
||||
|
||||
121
libpng.3
121
libpng.3
@@ -1,4 +1,4 @@
|
||||
.TH LIBPNG 3 "March 7, 1998"
|
||||
.TH LIBPNG 3 "May 9, 1998"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library
|
||||
.SH SYNOPSIS
|
||||
@@ -396,7 +396,7 @@ Following is a copy of the libpng.txt file that accompanies libpng.
|
||||
.SH LIBPNG.TXT
|
||||
libpng.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.00 March 7, 1998
|
||||
libpng version 1.0.1c May 9, 1998
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<randeg@alumni.rpi.edu>
|
||||
Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
@@ -539,7 +539,7 @@ be NULL if the default error handlers are to be used). See the section
|
||||
on Changes to Libpng below regarding the old initialization functions.
|
||||
|
||||
png_structp png_ptr = png_create_read_struct
|
||||
(PNG_LIBPNG_VER_STRING, (void *)user_error_ptr,
|
||||
(PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
|
||||
user_error_fn, user_warning_fn);
|
||||
if (!png_ptr)
|
||||
return;
|
||||
@@ -872,11 +872,14 @@ unless the library has been told to transform it into another format.
|
||||
For example, 4 bit/pixel paletted or grayscale data will be returned
|
||||
2 pixels/byte with the leftmost pixel in the high-order bits of the
|
||||
byte, unless png_set_packing() is called. 8-bit RGB data will be stored
|
||||
in RGBRGBRGB format unless png_set_filler() is called to insert filler
|
||||
in RGB RGB RGB format unless png_set_filler() is called to insert filler
|
||||
bytes, either before or after each RGB triplet. 16-bit RGB data will
|
||||
be returned RRGGBBRRGGBB, with the most significant byte of the color
|
||||
be returned RRGGBB RRGGBB, with the most significant byte of the color
|
||||
value first, unless png_set_strip_16() is called to transform it to
|
||||
regular RGBRGB triplets.
|
||||
regular RGB RGB triplets, or png_set_filler() is called to insert
|
||||
filler bytes, either before or after each RRGGBB triplet. Similarly,
|
||||
8-bit or 16-bit grayscale data can be modified with png_set_filler()
|
||||
or png_set_strip_16().
|
||||
|
||||
The following code transforms grayscale images of less than 8 to 8 bits,
|
||||
changes paletted images to RGB, and adds a full alpha channel if there is
|
||||
@@ -952,7 +955,7 @@ into 4 bytes for windowing systems that need them in this format:
|
||||
PNG_COLOR_TYPE_RGB) png_set_filler(png_ptr,
|
||||
filler, PNG_FILLER_BEFORE);
|
||||
|
||||
where "filler" is the number to fill with, and the location is
|
||||
where "filler" is the 8 or 16-bit number to fill with, and the location is
|
||||
either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether
|
||||
you want the filler before the RGB or after. This transformation
|
||||
does not affect images that already have full alpha channels.
|
||||
@@ -971,21 +974,19 @@ RGB. This code will do that conversion:
|
||||
png_set_gray_to_rgb(png_ptr);
|
||||
|
||||
If you have a grayscale and you are using png_set_expand() to change to
|
||||
a higher bit-depth you must indicate if the supplied background gray
|
||||
is supplied in the original file bit depth (need_expand = 1) or in the
|
||||
expanded bit depth (need_expand = 0). Similarly, if you are reading
|
||||
a paletted image, you must indicate if you have supplied the background
|
||||
as a palette index that needs to be expanded (need_expand = 1). You can
|
||||
also specify an RGB triplet that isn't in the palette when setting your
|
||||
background for a paletted image.
|
||||
a higher bit-depth, you must either supply the background color as a gray
|
||||
value at the original file bit-depth (need_expand = 1) or else supply the
|
||||
background color as an RGB triplet at the final, expanded bit depth
|
||||
(need_expand = 0). Similarly, if you are reading a paletted image, you
|
||||
must either supply the background color as a palette index (need_expand = 1)
|
||||
or as an RGB triplet that may or may not be in the palette (need_expand = 0).
|
||||
|
||||
png_color_16 my_background;
|
||||
png_color_16p image_background;
|
||||
|
||||
if (png_get_bKGD(png_ptr, info_ptr,
|
||||
&image_background))
|
||||
png_set_background(png_ptr, image_background),
|
||||
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
|
||||
if (png_get_bKGD(png_ptr, info_ptr, &image_background))
|
||||
png_set_background(png_ptr, image_background,
|
||||
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
|
||||
else
|
||||
png_set_background(png_ptr, &my_background,
|
||||
PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
|
||||
@@ -1268,7 +1269,7 @@ png_infop info_ptr;
|
||||
initialize_png_reader()
|
||||
{
|
||||
png_ptr = png_create_read_struct
|
||||
(PNG_LIBPNG_VER_STRING, (void *)user_error_ptr,
|
||||
(PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
|
||||
user_error_fn, user_warning_fn);
|
||||
if (!png_ptr)
|
||||
return -1;
|
||||
@@ -1412,6 +1413,8 @@ png_infop info_ptr;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
.SH IV. Writing
|
||||
|
||||
Much of this is very similar to reading. However, everything of
|
||||
@@ -1438,7 +1441,7 @@ both "png_ptr"; you can call them anything you like, such as
|
||||
"read_ptr" and "write_ptr". Look at pngtest.c, for example.
|
||||
|
||||
png_structp png_ptr = png_create_write_struct
|
||||
(PNG_LIBPNG_VER_STRING, (void *)user_error_ptr,
|
||||
(PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
|
||||
user_error_fn, user_warning_fn);
|
||||
if (!png_ptr)
|
||||
return;
|
||||
@@ -1504,9 +1507,9 @@ not calling this function at all, as it has been tuned to deliver a good
|
||||
speed/compression ratio. The second parameter to png_set_filter() is
|
||||
the filter method, for which the only valid value is '0' (as of the
|
||||
October 1996 PNG specification, version 1.0). The third parameter is a
|
||||
flag that indicates
|
||||
which filter type(s) are to be tested for each scanline. See the
|
||||
Compression Library for details on the specific filter types.
|
||||
flag that indicates which filter type(s) are to be tested for each
|
||||
scanline. See the Compression Library for details on the specific filter
|
||||
types.
|
||||
|
||||
|
||||
/* turn on or off filtering, and/or choose
|
||||
@@ -1780,8 +1783,9 @@ checks to see if it has data that it can do something with, you should
|
||||
make sure to only enable a transformation if it will be valid for the
|
||||
data. For example, don't swap red and blue on grayscale data.
|
||||
|
||||
PNG files store RGB pixels packed into 3 bytes. This code tells
|
||||
the library to expect input data with 4 bytes per pixel
|
||||
PNG files store RGB pixels packed into 3 or 6 bytes. This code tells
|
||||
the library to expand the input data to 4 or 8 bytes per pixel
|
||||
(or expand 1 or 2-byte grayscale data to 2 or 4 bytes per pixel).
|
||||
|
||||
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
|
||||
|
||||
@@ -1899,11 +1903,11 @@ times, or any of that other stuff necessary with png_write_rows().
|
||||
|
||||
where row_pointers is:
|
||||
|
||||
png_bytef *row_pointers[height];
|
||||
png_byte *row_pointers[height];
|
||||
|
||||
You can point to void or char or whatever you use for pixels.
|
||||
|
||||
If you can't want to write the whole image at once, you can
|
||||
If you don't want to write the whole image at once, you can
|
||||
use png_write_rows() instead. If the file is not interlaced,
|
||||
this is simple:
|
||||
|
||||
@@ -2217,19 +2221,23 @@ Removing unwanted object code:
|
||||
|
||||
There are a bunch of #define's in pngconf.h that control what parts of
|
||||
libpng are compiled. All the defines end in _SUPPORTED. If you are
|
||||
never going to use an ability, you can change the #define to #undef
|
||||
before recompiling libpng and save yourself code and data space.
|
||||
You can also turn a number of them off en masse with a compiler directive
|
||||
that defines PNG_READ[or WRITE]_TRANSFORMS_NOT_SUPPORTED, or
|
||||
PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED, or all four,
|
||||
never going to use a capability, you can change the #define to #undef
|
||||
before recompiling libpng and save yourself code and data space, or
|
||||
you can turn off individual capabilities with defines that begin with
|
||||
PNG_NO_.
|
||||
|
||||
You can also turn all of the transforms and ancillary chunk capabilities
|
||||
off en masse with compiler directives that define
|
||||
PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
|
||||
or all four,
|
||||
along with directives to turn on any of the capabilities that you do
|
||||
want. The PNG_READ[or WRITE]_TRANSFORMS_NOT_SUPPORTED directives disable
|
||||
want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable
|
||||
the extra transformations but still leave the library fully capable of reading
|
||||
and writing PNG files with all known public chunks [except for sPLT].
|
||||
Use of the PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED directive
|
||||
Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive
|
||||
produces a library that is incapable of reading or writing ancillary chunks.
|
||||
If you are not using the progressive reading capability, you can
|
||||
turn that off with PNG_PROGRESSIVE_READ_NOT_SUPPORTED (don't confuse
|
||||
turn that off with PNG_NO_PROGRESSIVE_READ (don't confuse
|
||||
this with the INTERLACING capability, which you'll still have).
|
||||
|
||||
All the reading and writing specific code are in separate files, so the
|
||||
@@ -2291,28 +2299,29 @@ on the library has not always been consistent and straightforward.
|
||||
The following table summarizes matters since version 0.89c, which was
|
||||
the first widely used release:
|
||||
|
||||
source png.h shared-lib
|
||||
version string version
|
||||
------- ------ ----------
|
||||
0.89c ("1.0 beta 3") 0.89 1.0.89
|
||||
0.90 ("1.0 beta 4") 0.90 0.90
|
||||
[should have been 2.0.90]
|
||||
0.95 ("1.0 beta 5") 0.95 0.95
|
||||
[should have been 2.0.95]
|
||||
0.96 ("1.0 beta 6") 0.96 0.96
|
||||
[should have been 2.0.96]
|
||||
0.97b ("1.00.97 beta 7") 1.00.97 1.0.0
|
||||
[should have been 2.0.97]
|
||||
0.97c 0.97 2.0.97
|
||||
0.98 0.98 2.0.98
|
||||
0.99 0.99 2.0.99
|
||||
0.99a-m 0.99 2.0.99
|
||||
1.0 1.00 2.1.0
|
||||
source png.h png.h shared-lib
|
||||
version string int version
|
||||
------- ------ ------ ----------
|
||||
0.89c 0.89 89 1.0.89
|
||||
0.90 0.90 90 0.90 [should be 2.0.90]
|
||||
0.95 0.95 95 0.95 [should be 2.0.95]
|
||||
0.96 0.96 96 0.96 [should be 2.0.96]
|
||||
0.97b 1.00.97 97 1.0.1 [should be 2.0.97]
|
||||
0.97c 0.97 97 2.0.97
|
||||
0.98 0.98 98 2.0.98
|
||||
0.99 0.99 98 2.0.99
|
||||
0.99a-m 0.99 99 2.0.99
|
||||
1.00 1.00 100 2.1.0 [int should be 10000]
|
||||
1.0.0 1.0.0 100 2.1.0 [int should be 10000]
|
||||
1.0.1 1.0.1 10001 2.1.0
|
||||
|
||||
Henceforth the source version will match the shared-library minor
|
||||
and patch numbers; the shared-library major version number will be
|
||||
Henceforth the source version will match the shared-library
|
||||
minor and patch numbers; the shared-library major version number will be
|
||||
used for changes in backward compatibility, as it is intended.
|
||||
|
||||
The PNG_PNGLIB_VER macro, which is not used within libpng but
|
||||
is available for applications, is an unsigned integer of the form
|
||||
xyyzz corresponding to the source version x.y.z (leading zeros in y and z).
|
||||
|
||||
.SH "SEE ALSO"
|
||||
libpngpf(3), png(5)
|
||||
.LP
|
||||
@@ -2365,7 +2374,7 @@ possible without all of you.
|
||||
|
||||
Thanks to Frank J. T. Wojcik for helping with the documentation.
|
||||
|
||||
Libpng version 1.00 (March 7, 1998):
|
||||
Libpng version 1.0.1c May 9, 1998:
|
||||
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
|
||||
Currently maintained by Glenn Randers-Pehrson (randeg@alumni.rpi.edu).
|
||||
|
||||
|
||||
77
libpng.txt
77
libpng.txt
@@ -1,6 +1,6 @@
|
||||
libpng.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.00 March 7, 1998
|
||||
libpng version 1.0.1c May 9, 1998
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<randeg@alumni.rpi.edu>
|
||||
Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
@@ -22,7 +22,7 @@ libpng.txt - A description on how to use and modify libpng
|
||||
Copyright (c) 1995 Frank J. T. Wojcik
|
||||
December 18, 1995 && January 20, 1996
|
||||
|
||||
Introduction
|
||||
I. Introduction
|
||||
|
||||
This file describes how to use and modify the PNG reference library
|
||||
(known as libpng) for your own use. There are five sections to this
|
||||
@@ -143,7 +143,7 @@ be NULL if the default error handlers are to be used). See the section
|
||||
on Changes to Libpng below regarding the old initialization functions.
|
||||
|
||||
png_structp png_ptr = png_create_read_struct
|
||||
(PNG_LIBPNG_VER_STRING, (void *)user_error_ptr,
|
||||
(PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
|
||||
user_error_fn, user_warning_fn);
|
||||
if (!png_ptr)
|
||||
return;
|
||||
@@ -476,11 +476,14 @@ unless the library has been told to transform it into another format.
|
||||
For example, 4 bit/pixel paletted or grayscale data will be returned
|
||||
2 pixels/byte with the leftmost pixel in the high-order bits of the
|
||||
byte, unless png_set_packing() is called. 8-bit RGB data will be stored
|
||||
in RGBRGBRGB format unless png_set_filler() is called to insert filler
|
||||
in RGB RGB RGB format unless png_set_filler() is called to insert filler
|
||||
bytes, either before or after each RGB triplet. 16-bit RGB data will
|
||||
be returned RRGGBBRRGGBB, with the most significant byte of the color
|
||||
be returned RRGGBB RRGGBB, with the most significant byte of the color
|
||||
value first, unless png_set_strip_16() is called to transform it to
|
||||
regular RGBRGB triplets.
|
||||
regular RGB RGB triplets, or png_set_filler() is called to insert
|
||||
filler bytes, either before or after each RRGGBB triplet. Similarly,
|
||||
8-bit or 16-bit grayscale data can be modified with png_set_filler()
|
||||
or png_set_strip_16().
|
||||
|
||||
The following code transforms grayscale images of less than 8 to 8 bits,
|
||||
changes paletted images to RGB, and adds a full alpha channel if there is
|
||||
@@ -556,7 +559,7 @@ into 4 bytes for windowing systems that need them in this format:
|
||||
PNG_COLOR_TYPE_RGB) png_set_filler(png_ptr,
|
||||
filler, PNG_FILLER_BEFORE);
|
||||
|
||||
where "filler" is the number to fill with, and the location is
|
||||
where "filler" is the 8 or 16-bit number to fill with, and the location is
|
||||
either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether
|
||||
you want the filler before the RGB or after. This transformation
|
||||
does not affect images that already have full alpha channels.
|
||||
@@ -575,21 +578,19 @@ RGB. This code will do that conversion:
|
||||
png_set_gray_to_rgb(png_ptr);
|
||||
|
||||
If you have a grayscale and you are using png_set_expand() to change to
|
||||
a higher bit-depth you must indicate if the supplied background gray
|
||||
is supplied in the original file bit depth (need_expand = 1) or in the
|
||||
expanded bit depth (need_expand = 0). Similarly, if you are reading
|
||||
a paletted image, you must indicate if you have supplied the background
|
||||
as a palette index that needs to be expanded (need_expand = 1). You can
|
||||
also specify an RGB triplet that isn't in the palette when setting your
|
||||
background for a paletted image.
|
||||
a higher bit-depth, you must either supply the background color as a gray
|
||||
value at the original file bit-depth (need_expand = 1) or else supply the
|
||||
background color as an RGB triplet at the final, expanded bit depth
|
||||
(need_expand = 0). Similarly, if you are reading a paletted image, you
|
||||
must either supply the background color as a palette index (need_expand = 1)
|
||||
or as an RGB triplet that may or may not be in the palette (need_expand = 0).
|
||||
|
||||
png_color_16 my_background;
|
||||
png_color_16p image_background;
|
||||
|
||||
if (png_get_bKGD(png_ptr, info_ptr,
|
||||
&image_background))
|
||||
png_set_background(png_ptr, image_background),
|
||||
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
|
||||
if (png_get_bKGD(png_ptr, info_ptr, &image_background))
|
||||
png_set_background(png_ptr, image_background,
|
||||
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
|
||||
else
|
||||
png_set_background(png_ptr, &my_background,
|
||||
PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
|
||||
@@ -872,7 +873,7 @@ png_infop info_ptr;
|
||||
initialize_png_reader()
|
||||
{
|
||||
png_ptr = png_create_read_struct
|
||||
(PNG_LIBPNG_VER_STRING, (void *)user_error_ptr,
|
||||
(PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
|
||||
user_error_fn, user_warning_fn);
|
||||
if (!png_ptr)
|
||||
return -1;
|
||||
@@ -1044,7 +1045,7 @@ both "png_ptr"; you can call them anything you like, such as
|
||||
"read_ptr" and "write_ptr". Look at pngtest.c, for example.
|
||||
|
||||
png_structp png_ptr = png_create_write_struct
|
||||
(PNG_LIBPNG_VER_STRING, (void *)user_error_ptr,
|
||||
(PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
|
||||
user_error_fn, user_warning_fn);
|
||||
if (!png_ptr)
|
||||
return;
|
||||
@@ -1110,9 +1111,9 @@ not calling this function at all, as it has been tuned to deliver a good
|
||||
speed/compression ratio. The second parameter to png_set_filter() is
|
||||
the filter method, for which the only valid value is '0' (as of the
|
||||
October 1996 PNG specification, version 1.0). The third parameter is a
|
||||
flag that indicates
|
||||
which filter type(s) are to be tested for each scanline. See the
|
||||
Compression Library for details on the specific filter types.
|
||||
flag that indicates which filter type(s) are to be tested for each
|
||||
scanline. See the Compression Library for details on the specific filter
|
||||
types.
|
||||
|
||||
|
||||
/* turn on or off filtering, and/or choose
|
||||
@@ -1386,8 +1387,9 @@ checks to see if it has data that it can do something with, you should
|
||||
make sure to only enable a transformation if it will be valid for the
|
||||
data. For example, don't swap red and blue on grayscale data.
|
||||
|
||||
PNG files store RGB pixels packed into 3 bytes. This code tells
|
||||
the library to expect input data with 4 bytes per pixel
|
||||
PNG files store RGB pixels packed into 3 or 6 bytes. This code tells
|
||||
the library to expand the input data to 4 or 8 bytes per pixel
|
||||
(or expand 1 or 2-byte grayscale data to 2 or 4 bytes per pixel).
|
||||
|
||||
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
|
||||
|
||||
@@ -1505,11 +1507,11 @@ times, or any of that other stuff necessary with png_write_rows().
|
||||
|
||||
where row_pointers is:
|
||||
|
||||
png_bytef *row_pointers[height];
|
||||
png_byte *row_pointers[height];
|
||||
|
||||
You can point to void or char or whatever you use for pixels.
|
||||
|
||||
If you can't want to write the whole image at once, you can
|
||||
If you don't want to write the whole image at once, you can
|
||||
use png_write_rows() instead. If the file is not interlaced,
|
||||
this is simple:
|
||||
|
||||
@@ -1823,19 +1825,23 @@ Removing unwanted object code:
|
||||
|
||||
There are a bunch of #define's in pngconf.h that control what parts of
|
||||
libpng are compiled. All the defines end in _SUPPORTED. If you are
|
||||
never going to use an ability, you can change the #define to #undef
|
||||
before recompiling libpng and save yourself code and data space.
|
||||
You can also turn a number of them off en masse with a compiler directive
|
||||
that defines PNG_READ[or WRITE]_TRANSFORMS_NOT_SUPPORTED, or
|
||||
PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED, or all four,
|
||||
never going to use a capability, you can change the #define to #undef
|
||||
before recompiling libpng and save yourself code and data space, or
|
||||
you can turn off individual capabilities with defines that begin with
|
||||
PNG_NO_.
|
||||
|
||||
You can also turn all of the transforms and ancillary chunk capabilities
|
||||
off en masse with compiler directives that define
|
||||
PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
|
||||
or all four,
|
||||
along with directives to turn on any of the capabilities that you do
|
||||
want. The PNG_READ[or WRITE]_TRANSFORMS_NOT_SUPPORTED directives disable
|
||||
want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable
|
||||
the extra transformations but still leave the library fully capable of reading
|
||||
and writing PNG files with all known public chunks [except for sPLT].
|
||||
Use of the PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED directive
|
||||
Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive
|
||||
produces a library that is incapable of reading or writing ancillary chunks.
|
||||
If you are not using the progressive reading capability, you can
|
||||
turn that off with PNG_PROGRESSIVE_READ_NOT_SUPPORTED (don't confuse
|
||||
turn that off with PNG_NO_PROGRESSIVE_READ (don't confuse
|
||||
this with the INTERLACING capability, which you'll still have).
|
||||
|
||||
All the reading and writing specific code are in separate files, so the
|
||||
@@ -1886,4 +1892,3 @@ to set the error callbacks AFTER png_read_init(), or to change them with
|
||||
png_set_error_fn(), which is essentially the same function, but with a
|
||||
new name to force compilation errors with applications that try to use
|
||||
the old method.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.TH LIBPNGPF 3 "March 7, 1998"
|
||||
.TH LIBPNGPF 3 "May 9, 1998"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library
|
||||
(private functions)
|
||||
|
||||
2
png.5
2
png.5
@@ -1,4 +1,4 @@
|
||||
.TH PNG 5 "March 7, 1998"
|
||||
.TH PNG 5 "May 9, 1998"
|
||||
.SH NAME
|
||||
png \- Portable Network Graphics (PNG) format
|
||||
.SH DESCRIPTION
|
||||
|
||||
6
png.c
6
png.c
@@ -1,12 +1,12 @@
|
||||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* libpng 1.00
|
||||
* libpng 1.0.1c
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
* May 9, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@@ -16,7 +16,7 @@
|
||||
/* Version information for C files. This had better match the version
|
||||
* string defined in png.h.
|
||||
*/
|
||||
char png_libpng_ver[5] = "1.00";
|
||||
char png_libpng_ver[12] = "1.0.1c";
|
||||
|
||||
/* Place to hold the signature string for a PNG file. */
|
||||
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
|
||||
108
png.h
108
png.h
@@ -1,12 +1,12 @@
|
||||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng 1.00
|
||||
* libpng 1.0.1c
|
||||
* For conditions of distribution and use, see the COPYRIGHT NOTICE below.
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998 Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
* May 9, 1998
|
||||
*
|
||||
* Note about libpng version numbers:
|
||||
*
|
||||
@@ -16,26 +16,34 @@
|
||||
* The following table summarizes matters since version 0.89c, which was
|
||||
* the first widely used release:
|
||||
*
|
||||
* source png.h shared-lib
|
||||
* version string version
|
||||
* ------- ------ ----------
|
||||
* 0.89c ("1.0 beta 3") 0.89 1.0.89
|
||||
* 0.90 ("1.0 beta 4") 0.90 0.90 [should have been 2.0.90]
|
||||
* 0.95 ("1.0 beta 5") 0.95 0.95 [should have been 2.0.95]
|
||||
* 0.96 ("1.0 beta 6") 0.96 0.96 [should have been 2.0.96]
|
||||
* 0.97b ("1.00.97 beta 7") 1.00.97 1.0.0 [should have been 2.0.97]
|
||||
* 0.97c 0.97 2.0.97
|
||||
* 0.98 0.98 2.0.98
|
||||
* 0.99 0.99 2.0.99
|
||||
* 0.99a-m 0.99 2.0.99
|
||||
* 1.00 1.00 2.1.0
|
||||
* source png.h png.h shared-lib
|
||||
* version string int version
|
||||
* ------- ------ ----- ----------
|
||||
* 0.89c ("1.0 beta 3") 0.89 89 1.0.89
|
||||
* 0.90 ("1.0 beta 4") 0.90 90 0.90 [should have been 2.0.90]
|
||||
* 0.95 ("1.0 beta 5") 0.95 95 0.95 [should have been 2.0.95]
|
||||
* 0.96 ("1.0 beta 6") 0.96 96 0.96 [should have been 2.0.96]
|
||||
* 0.97b ("1.00.97 beta 7") 1.00.97 97 1.0.1 [should have been 2.0.97]
|
||||
* 0.97c 0.97 97 2.0.97
|
||||
* 0.98 0.98 98 2.0.98
|
||||
* 0.99 0.99 98 2.0.99
|
||||
* 0.99a-m 0.99 99 2.0.99
|
||||
* 1.00 1.00 100 2.1.0 [int should be 10000]
|
||||
* 1.0.0 1.0.0 100 2.1.0 [int should be 10000]
|
||||
* 1.0.1 1.0.1 10001 2.1.0
|
||||
* 1.0.1a 1.0.1a 10002 2.1.0.1a
|
||||
* 1.0.1b 1.0.1b 10002 2.1.0.1b
|
||||
* 1.0.1c 1.0.1c 10002 2.1.0.1c
|
||||
*
|
||||
* Henceforth the source version will match the shared-library minor
|
||||
* and patch numbers; the shared-library major version number will be
|
||||
* used for changes in backward compatibility, as it is intended.
|
||||
* used for changes in backward compatibility, as it is intended. The
|
||||
* PNG_PNGLIB_VER macro, which is not used within libpng but is available
|
||||
* for applications, is an unsigned integer of the form xyyzz corresponding
|
||||
* to the source version x.y.z (leading zeros in y and z).
|
||||
*
|
||||
* See libpng.txt for more information. The PNG specification is available
|
||||
* as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/>
|
||||
* See libpng.txt or libpng.3 for more information. The PNG specification
|
||||
* is available as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/>
|
||||
* and as a W3C Recommendation <http://www.w3.org/TR/REC.png.html>
|
||||
*
|
||||
* Contributing Authors:
|
||||
@@ -112,19 +120,21 @@ extern "C" {
|
||||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.00"
|
||||
#define PNG_LIBPNG_VER_STRING "1.0.1c"
|
||||
|
||||
/* careful here. At one time, I wanted to use 082, but that would be octal.
|
||||
* Version 1.0 will be 100 here, etc.
|
||||
*/
|
||||
#define PNG_LIBPNG_VER 100
|
||||
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
|
||||
* We must not include leading zeros.
|
||||
* Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
|
||||
* version 1.0.0 was mis-numbered 100 instead of 10000). From
|
||||
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=bugfix */
|
||||
#define PNG_LIBPNG_VER 10002 /* 1.0.2 */
|
||||
|
||||
/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
|
||||
#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
|
||||
/* Version information for C files, stored in png.c. This had better match
|
||||
* the version above.
|
||||
*/
|
||||
extern char png_libpng_ver[5];
|
||||
extern char png_libpng_ver[12]; /* need room for 99.99.99aa */
|
||||
|
||||
/* Structures to facilitate easy interlacing. See png.c for more details */
|
||||
extern int FARDATA png_pass_start[7];
|
||||
@@ -581,7 +591,7 @@ struct png_struct_def
|
||||
png_byte sig_bytes; /* magic bytes read/written from start of file */
|
||||
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
png_byte filler; /* filler byte for 24->32-bit pixel expansion */
|
||||
png_uint_16 filler; /* filler bytes for pixel expansion */
|
||||
#endif /* PNG_READ_FILLER_SUPPORTED */
|
||||
#if defined(PNG_READ_bKGD_SUPPORTED)
|
||||
png_byte background_gamma_type;
|
||||
@@ -702,12 +712,12 @@ extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num));
|
||||
|
||||
/* Allocate and initialize png_ptr struct for reading, and any other memory. */
|
||||
extern PNG_EXPORT(png_structp,png_create_read_struct)
|
||||
PNGARG((png_const_charp user_png_ver, voidp error_ptr,
|
||||
PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
png_error_ptr error_fn, png_error_ptr warn_fn));
|
||||
|
||||
/* Allocate and initialize png_ptr struct for reading, and any other memory */
|
||||
extern PNG_EXPORT(png_structp,png_create_write_struct)
|
||||
PNGARG((png_const_charp user_png_ver, voidp error_ptr,
|
||||
PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
png_error_ptr error_fn, png_error_ptr warn_fn));
|
||||
|
||||
/* Write a PNG chunk - size, type, (optional) data, CRC. */
|
||||
@@ -1435,6 +1445,45 @@ extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
|
||||
#define png_debug2(l, m, p1, p2)
|
||||
#endif /* (PNG_DEBUG > 0) */
|
||||
|
||||
#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
|
||||
/* With these routines, we avoid an integer divide, which will be slower on
|
||||
* many machines. However, it does take more operations than the corresponding
|
||||
* divide method, so it may be slower on some RISC systems. There are two
|
||||
* shifts (by 8 or 16 bits) and an addition, versus a single integer divide.
|
||||
*
|
||||
* Note that the rounding factors are NOT supposed to be the same! 128 and
|
||||
* 32768 are correct for the NODIV code; 127 and 32767 are correct for the
|
||||
* standard method.
|
||||
*
|
||||
* [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]
|
||||
*/
|
||||
|
||||
/* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
|
||||
# define png_composite(composite, fg, alpha, bg) \
|
||||
{ png_uint_16 temp = ((png_uint_16)(fg) * (png_uint_16)(alpha) + \
|
||||
(png_uint_16)(bg)*(png_uint_16)(255 - \
|
||||
(png_uint_16)(alpha)) + (png_uint_16)128); \
|
||||
(composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
|
||||
# define png_composite_16(composite, fg, alpha, bg) \
|
||||
{ png_uint_32 temp = ((png_uint_32)(fg) * (png_uint_32)(alpha) + \
|
||||
(png_uint_32)(bg)*(png_uint_32)(65535L - \
|
||||
(png_uint_32)(alpha)) + (png_uint_32)32768L); \
|
||||
(composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
|
||||
|
||||
#else /* standard method using integer division */
|
||||
|
||||
/* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
|
||||
# define png_composite(composite, fg, alpha, bg) \
|
||||
(composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \
|
||||
(png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
|
||||
(png_uint_16)127) / 255)
|
||||
# define png_composite_16(composite, fg, alpha, bg) \
|
||||
(composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
|
||||
(png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \
|
||||
(png_uint_32)32767) / (png_uint_32)65535L)
|
||||
|
||||
#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
|
||||
|
||||
/* These next functions are used internally in the code. They generally
|
||||
* shouldn't be used unless you are writing code to add or replace some
|
||||
* functionality in libpng. More information about most functions can
|
||||
@@ -1517,6 +1566,7 @@ extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
|
||||
#define PNG_FLAG_FREE_HIST 0x4000
|
||||
#define PNG_FLAG_HAVE_CHUNK_HEADER 0x8000L
|
||||
#define PNG_FLAG_WROTE_tIME 0x10000L
|
||||
#define PNG_FLAG_BACKGROUND_IS_GRAY 0x20000L
|
||||
|
||||
#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
|
||||
PNG_FLAG_CRC_ANCILLARY_NOWARN)
|
||||
@@ -1582,7 +1632,7 @@ PNG_EXTERN png_int_32 png_get_int_32 PNGARG((png_bytep buf));
|
||||
#endif /* PNG_READ_pCAL_SUPPORTED */
|
||||
PNG_EXTERN png_uint_32 png_get_uint_32 PNGARG((png_bytep buf));
|
||||
PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf));
|
||||
#endif /* PNG_BIG_ENDIAN_GET_SUPPORTED */
|
||||
#endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */
|
||||
|
||||
/* Initialize png_ptr struct for reading, and allocate any other memory.
|
||||
* (old interface - NOT DLL EXPORTED).
|
||||
@@ -1834,7 +1884,7 @@ PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
|
||||
PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row));
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPOR)
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
||||
PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row));
|
||||
#endif
|
||||
|
||||
|
||||
156
pngconf.h
156
pngconf.h
@@ -1,12 +1,12 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng 1.00
|
||||
* libpng 1.0.1c
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
* May 9, 1998
|
||||
*/
|
||||
|
||||
/* Any machine specific code is near the front of this file, so if you
|
||||
@@ -237,72 +237,139 @@ __dont__ include it again
|
||||
/* Any transformations you will not be using can be undef'ed here */
|
||||
|
||||
/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user
|
||||
to turn it off with "*TRANSFORMS_NOT_SUPPORTED" 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
|
||||
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.
|
||||
typical installation of the library. (PNG_NO_* form added in version
|
||||
1.0.1c, for consistency)
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PNG_READ_TRANSFORMS_NOT_SUPPORTED
|
||||
#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
|
||||
!defined(PNG_NO_READ_TRANSFORMS)
|
||||
#define PNG_READ_TRANSFORMS_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_WRITE_TRANSFORMS_NOT_SUPPORTED
|
||||
#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
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_SHIFT
|
||||
#define PNG_READ_SHIFT_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_PACK
|
||||
#define PNG_READ_PACK_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_BGR
|
||||
#define PNG_READ_BGR_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_SWAP
|
||||
#define PNG_READ_SWAP_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_PACKSWAP
|
||||
#define PNG_READ_PACKSWAP_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_INVERT
|
||||
#define PNG_READ_INVERT_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_DITHER
|
||||
#define PNG_READ_DITHER_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_BACKGROUND
|
||||
#define PNG_READ_BACKGROUND_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_16_TO_8
|
||||
#define PNG_READ_16_TO_8_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_FILLER
|
||||
#define PNG_READ_FILLER_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_GAMMA
|
||||
#define PNG_READ_GAMMA_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_GRAY_TO_RGB
|
||||
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_SWAP_ALPHA
|
||||
#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
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_USER_TRANSFORM
|
||||
#define PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
#endif
|
||||
/* the following aren't implemented yet
|
||||
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
*/
|
||||
#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
|
||||
|
||||
#ifndef PNG_PROGRESSIVE_READ_NOT_SUPPORTED /* if you don't do progressive */
|
||||
#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
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_PACK
|
||||
#define PNG_WRITE_PACK_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_BGR
|
||||
#define PNG_WRITE_BGR_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_SWAP
|
||||
#define PNG_WRITE_SWAP_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_PACKSWAP
|
||||
#define PNG_WRITE_PACKSWAP_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_INVERT
|
||||
#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_FLUSH_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_SWAP_ALPHA
|
||||
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_INVERT_ALPHA
|
||||
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_WRITE_USER_TRANSFORM
|
||||
#define PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
#endif
|
||||
#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
|
||||
|
||||
#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant
|
||||
encoders, but can cause trouble
|
||||
if left undefined */
|
||||
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
#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
|
||||
|
||||
@@ -322,7 +389,7 @@ __dont__ include it again
|
||||
* png_get_x_offset_microns()
|
||||
* png_get_y_offset_microns()
|
||||
*/
|
||||
#if !defined(PNG_NO_EASY_ACCESS)
|
||||
#ifndef PNG_NO_EASY_ACCESS
|
||||
#define PNG_EASY_ACCESS_SUPPORTED
|
||||
#endif
|
||||
|
||||
@@ -351,45 +418,100 @@ __dont__ include it again
|
||||
* a bit smaller.
|
||||
*/
|
||||
|
||||
#ifndef PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED
|
||||
#if !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
|
||||
!defined(PNG_NO_READ_ANCILLARY_CHUNKS)
|
||||
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED
|
||||
#if !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
|
||||
!defined(PNG_NO_WRITE_ANCILLARY_CHUNKS)
|
||||
#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#ifndef PNG_NO_PNG_READ_bKGD
|
||||
#define PNG_READ_bKGD_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_READ_cHRM
|
||||
#define PNG_READ_cHRM_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_READ_gAMA
|
||||
#define PNG_READ_gAMA_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_READ_hIST
|
||||
#define PNG_READ_hIST_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_READ_oFFs
|
||||
#define PNG_READ_oFFs_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_READ_pCAL
|
||||
#define PNG_READ_pCAL_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_READ_pHYs
|
||||
#define PNG_READ_pHYs_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_sBIT
|
||||
#define PNG_READ_sBIT_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_READ_sRGB
|
||||
#define PNG_READ_sRGB_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_READ_tEXt
|
||||
#define PNG_READ_tEXt_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_READ_tIME
|
||||
#define PNG_READ_tIME_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_READ_tRNS
|
||||
#define PNG_READ_tRNS_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_READ_zTXt
|
||||
#define PNG_READ_zTXt_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_READ_OPT_PLTE
|
||||
#define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the optional */
|
||||
/* PLTE chunk in RGB and RGBA images */
|
||||
#endif /* PLTE chunk in RGB and RGBA images */
|
||||
#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
|
||||
|
||||
#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#ifndef PNG_NO_PNG_WRITE_bKGD
|
||||
#define PNG_WRITE_bKGD_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_WRITE_cHRM
|
||||
#define PNG_WRITE_cHRM_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_WRITE_gAMA
|
||||
#define PNG_WRITE_gAMA_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_WRITE_hIST
|
||||
#define PNG_WRITE_hIST_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_WRITE_oFFs
|
||||
#define PNG_WRITE_oFFs_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_WRITE_pCAL
|
||||
#define PNG_WRITE_pCAL_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_WRITE_pHYs
|
||||
#define PNG_WRITE_pHYs_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_WRITE_sBIT
|
||||
#define PNG_WRITE_sBIT_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_WRITE_sRGB
|
||||
#define PNG_WRITE_sRGB_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_WRITE_tEXt
|
||||
#define PNG_WRITE_tEXt_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_WRITE_tIME
|
||||
#define PNG_WRITE_tIME_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_WRITE_tRNS
|
||||
#define PNG_WRITE_tRNS_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_PNG_WRITE_zTXt
|
||||
#define PNG_WRITE_zTXt_SUPPORTED
|
||||
#endif
|
||||
#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
|
||||
|
||||
/* need the time information for reading tIME chunks */
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* libpng 1.00
|
||||
* libpng 1.0.1c
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
* May 9, 1998
|
||||
*
|
||||
* This file provides a location for all error handling. Users which
|
||||
* need special error handling are expected to write replacement functions
|
||||
|
||||
4
pngget.c
4
pngget.c
@@ -1,12 +1,12 @@
|
||||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* libpng 1.00
|
||||
* libpng 1.0.1c
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
* May 9, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
|
||||
6
pngmem.c
6
pngmem.c
@@ -1,14 +1,14 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* libpng 1.00
|
||||
* libpng 1.0.1c
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
* May 9, 1998
|
||||
*
|
||||
* 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
|
||||
* to meet their needs. See the instructions at each function.
|
||||
*/
|
||||
|
||||
10
pngpread.c
10
pngpread.c
@@ -1,12 +1,12 @@
|
||||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* libpng 1.00
|
||||
* 1.0.1c
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
* May 9, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@@ -446,13 +446,13 @@ png_push_save_buffer(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr->save_buffer_ptr != png_ptr->save_buffer)
|
||||
{
|
||||
png_size_t i;
|
||||
png_size_t i,istop;
|
||||
png_bytep sp;
|
||||
png_bytep dp;
|
||||
|
||||
istop = png_ptr->save_buffer_size;
|
||||
for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer;
|
||||
i < png_ptr->save_buffer_size;
|
||||
i++, sp++, dp++)
|
||||
i < istop; i++, sp++, dp++)
|
||||
{
|
||||
*dp = *sp;
|
||||
}
|
||||
|
||||
109
pngread.c
109
pngread.c
@@ -1,12 +1,12 @@
|
||||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* libpng 1.00
|
||||
* 1.0.1c
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
* May 9, 1998
|
||||
*
|
||||
* This file contains routines that an application calls directly to
|
||||
* read a PNG file or stream.
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
/* Create a PNG structure for reading, and allocate any memory needed. */
|
||||
png_structp
|
||||
png_create_read_struct(png_const_charp user_png_ver, 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_structp png_ptr;
|
||||
@@ -82,7 +82,7 @@ png_create_read_struct(png_const_charp user_png_ver, voidp error_ptr,
|
||||
}
|
||||
|
||||
/* 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. */
|
||||
void
|
||||
png_read_init(png_structp png_ptr)
|
||||
@@ -123,9 +123,9 @@ png_read_init(png_structp png_ptr)
|
||||
}
|
||||
|
||||
/* 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
|
||||
* 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
|
||||
* 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.
|
||||
@@ -279,6 +279,38 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
/* save jump buffer and error functions */
|
||||
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||
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 interlaced and we do not need a new row, combine row and return */
|
||||
@@ -488,25 +520,34 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
|
||||
/* save jump buffer and error functions */
|
||||
rp = row;
|
||||
dp = display_row;
|
||||
for (i = 0; i < num_rows; i++)
|
||||
{
|
||||
png_bytep rptr;
|
||||
png_bytep dptr;
|
||||
|
||||
if (rp != NULL)
|
||||
rptr = *rp;
|
||||
else
|
||||
rptr = NULL;
|
||||
if (dp != NULL)
|
||||
dptr = *dp;
|
||||
else
|
||||
dptr = NULL;
|
||||
png_read_row(png_ptr, rptr, dptr);
|
||||
if (row != NULL)
|
||||
rp++;
|
||||
if (display_row != NULL)
|
||||
dp++;
|
||||
}
|
||||
if(rp != NULL && dp != NULL)
|
||||
for (i = 0; i < num_rows; i++)
|
||||
{
|
||||
png_bytep rptr = *rp++;
|
||||
png_bytep dptr = *dp++;
|
||||
|
||||
png_read_row(png_ptr, rptr, dptr);
|
||||
}
|
||||
else
|
||||
for (i = 0; i < num_rows; i++)
|
||||
{
|
||||
png_bytep rptr;
|
||||
png_bytep dptr;
|
||||
|
||||
if (rp != NULL)
|
||||
rptr = *rp;
|
||||
else
|
||||
rptr = NULL;
|
||||
if (dp != NULL)
|
||||
dptr = *dp;
|
||||
else
|
||||
dptr = NULL;
|
||||
png_read_row(png_ptr, rptr, dptr);
|
||||
if (row != NULL)
|
||||
rp++;
|
||||
if (display_row != NULL)
|
||||
dp++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read the entire image. If the image has an alpha channel or a tRNS
|
||||
@@ -522,7 +563,7 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
|
||||
void
|
||||
png_read_image(png_structp png_ptr, png_bytepp image)
|
||||
{
|
||||
png_uint_32 i;
|
||||
png_uint_32 i,image_height;
|
||||
int pass, j;
|
||||
png_bytepp rp;
|
||||
|
||||
@@ -530,12 +571,13 @@ png_read_image(png_structp png_ptr, png_bytepp image)
|
||||
/* save jump buffer and error functions */
|
||||
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++)
|
||||
{
|
||||
rp = image;
|
||||
for (i = 0; i < png_ptr->height; i++)
|
||||
for (i = 0; i < image_height; i++)
|
||||
{
|
||||
png_read_row(png_ptr, *rp, NULL);
|
||||
rp++;
|
||||
@@ -719,10 +761,8 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
#endif
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_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)
|
||||
png_free(png_ptr, png_ptr->trans);
|
||||
#endif
|
||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_HIST)
|
||||
png_free(png_ptr, png_ptr->hist);
|
||||
@@ -731,7 +771,8 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
if (png_ptr->gamma_16_table != NULL)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (1 << (8 - png_ptr->gamma_shift)); 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]);
|
||||
}
|
||||
@@ -742,7 +783,8 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
if (png_ptr->gamma_16_from_1 != NULL)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (1 << (8 - png_ptr->gamma_shift)); 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]);
|
||||
}
|
||||
@@ -751,7 +793,8 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
if (png_ptr->gamma_16_to_1 != NULL)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (1 << (8 - png_ptr->gamma_shift)); 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]);
|
||||
}
|
||||
|
||||
4
pngrio.c
4
pngrio.c
@@ -1,12 +1,12 @@
|
||||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* libpng 1.00
|
||||
* libpng 1.0.1c
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
* May 9, 1998
|
||||
*
|
||||
* This file provides a location for all input. Users which need
|
||||
* special handling are expected to write a function which has the same
|
||||
|
||||
968
pngrtran.c
968
pngrtran.c
File diff suppressed because it is too large
Load Diff
323
pngrutil.c
323
pngrutil.c
@@ -1,12 +1,12 @@
|
||||
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* libpng 1.00
|
||||
* 1.0.1c
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
* May 9, 1998
|
||||
*
|
||||
* This file contains routines which are only called from within
|
||||
* libpng itself during the course of reading an image.
|
||||
@@ -20,9 +20,7 @@
|
||||
png_uint_32
|
||||
png_get_uint_32(png_bytep buf)
|
||||
{
|
||||
png_uint_32 i;
|
||||
|
||||
i = ((png_uint_32)(*buf) << 24) +
|
||||
png_uint_32 i = ((png_uint_32)(*buf) << 24) +
|
||||
((png_uint_32)(*(buf + 1)) << 16) +
|
||||
((png_uint_32)(*(buf + 2)) << 8) +
|
||||
(png_uint_32)(*(buf + 3));
|
||||
@@ -37,9 +35,7 @@ png_get_uint_32(png_bytep buf)
|
||||
png_int_32
|
||||
png_get_int_32(png_bytep buf)
|
||||
{
|
||||
png_int_32 i;
|
||||
|
||||
i = ((png_int_32)(*buf) << 24) +
|
||||
png_int_32 i = ((png_int_32)(*buf) << 24) +
|
||||
((png_int_32)(*(buf + 1)) << 16) +
|
||||
((png_int_32)(*(buf + 2)) << 8) +
|
||||
(png_int_32)(*(buf + 3));
|
||||
@@ -52,9 +48,7 @@ png_get_int_32(png_bytep buf)
|
||||
png_uint_16
|
||||
png_get_uint_16(png_bytep buf)
|
||||
{
|
||||
png_uint_16 i;
|
||||
|
||||
i = (png_uint_16)(((png_uint_16)(*buf) << 8) +
|
||||
png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) +
|
||||
(png_uint_16)(*(buf + 1)));
|
||||
|
||||
return (i);
|
||||
@@ -76,15 +70,16 @@ png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length)
|
||||
int
|
||||
png_crc_finish(png_structp png_ptr, png_uint_32 skip)
|
||||
{
|
||||
png_uint_32 i;
|
||||
png_size_t i;
|
||||
png_size_t istop = png_ptr->zbuf_size;
|
||||
|
||||
for (i = skip; i > (png_uint_32)png_ptr->zbuf_size; i -= png_ptr->zbuf_size)
|
||||
for (i = (png_size_t)skip; i > istop; i -= istop)
|
||||
{
|
||||
png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);
|
||||
}
|
||||
if (i)
|
||||
{
|
||||
png_crc_read(png_ptr, png_ptr->zbuf, (png_size_t)i);
|
||||
png_crc_read(png_ptr, png_ptr->zbuf, i);
|
||||
}
|
||||
|
||||
if (png_crc_error(png_ptr))
|
||||
@@ -258,20 +253,6 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
|
||||
png_ptr->mode |= PNG_HAVE_PLTE;
|
||||
|
||||
#if defined (PNG_READ_tRNS_SUPPORTED)
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_tRNS)
|
||||
{
|
||||
if (png_ptr->num_trans > png_ptr->num_palette)
|
||||
{
|
||||
png_warning(png_ptr, "Truncating incorrect tRNS chunk length");
|
||||
png_ptr->num_trans = png_ptr->num_palette;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(PNG_READ_OPT_PLTE_SUPPORTED)
|
||||
if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
@@ -349,6 +330,21 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
png_ptr->palette = palette;
|
||||
png_ptr->num_palette = (png_uint_16)num;
|
||||
png_set_PLTE(png_ptr, info_ptr, palette, num);
|
||||
|
||||
#if defined (PNG_READ_tRNS_SUPPORTED)
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_tRNS)
|
||||
{
|
||||
if (png_ptr->num_trans > png_ptr->num_palette)
|
||||
{
|
||||
png_warning(png_ptr, "Truncating incorrect tRNS chunk length");
|
||||
png_ptr->num_trans = png_ptr->num_palette;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@@ -758,6 +754,12 @@ png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
png_crc_finish(png_ptr, length);
|
||||
return;
|
||||
}
|
||||
if (length == 0)
|
||||
{
|
||||
png_warning(png_ptr, "Zero length tRNS chunk");
|
||||
png_crc_finish(png_ptr, length);
|
||||
return;
|
||||
}
|
||||
|
||||
png_ptr->trans = (png_bytep)png_malloc(png_ptr, length);
|
||||
png_ptr->flags |= PNG_FLAG_FREE_TRANS;
|
||||
@@ -1075,8 +1077,8 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
purpose[slength] = 0x00; /* null terminate the last string */
|
||||
|
||||
png_debug(3, "Finding end of pCAL purpose string\n");
|
||||
for (buf = purpose; *buf != '\0'; buf++)
|
||||
/* empty loop */;
|
||||
for (buf = purpose; *buf; buf++)
|
||||
/* empty loop */ ;
|
||||
|
||||
endptr = purpose + slength;
|
||||
|
||||
@@ -1113,8 +1115,8 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
png_warning(png_ptr, "Unrecognized equation type for pCAL chunk");
|
||||
}
|
||||
|
||||
/* Empty loop to move past the units string. */
|
||||
for (buf = units; *buf != 0x00; buf++);
|
||||
for (buf = units; *buf; buf++)
|
||||
/* Empty loop to move past the units string. */ ;
|
||||
|
||||
png_debug(3, "Allocating pCAL parameters array\n");
|
||||
params = (png_charpp)png_malloc(png_ptr, (png_uint_32)(nparams
|
||||
@@ -1126,8 +1128,8 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
buf++; /* Skip the null string terminator from previous parameter. */
|
||||
|
||||
png_debug1(3, "Reading pCAL parameter %d\n", i);
|
||||
/* Empty loop to move past each paramter string */
|
||||
for (params[i] = buf; *buf != 0x00 && buf <= endptr; buf++);
|
||||
for (params[i] = buf; *buf != 0x00 && buf <= endptr; buf++)
|
||||
/* Empty loop to move past each parameter string */ ;
|
||||
|
||||
/* Make sure we haven't run out of data yet */
|
||||
if (buf > endptr)
|
||||
@@ -1492,16 +1494,14 @@ png_combine_row(png_structp png_ptr, png_bytep row,
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
png_bytep sp;
|
||||
png_bytep dp;
|
||||
png_bytep sp = png_ptr->row_buf + 1;
|
||||
png_bytep dp = row;
|
||||
int s_inc, s_start, s_end;
|
||||
int m;
|
||||
int m = 0x80;
|
||||
int shift;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = png_ptr->width;
|
||||
|
||||
sp = png_ptr->row_buf + 1;
|
||||
dp = row;
|
||||
m = 0x80;
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_PACKSWAP)
|
||||
{
|
||||
@@ -1519,7 +1519,7 @@ png_combine_row(png_structp png_ptr, png_bytep row,
|
||||
|
||||
shift = s_start;
|
||||
|
||||
for (i = 0; i < png_ptr->width; i++)
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if (m & mask)
|
||||
{
|
||||
@@ -1548,17 +1548,15 @@ png_combine_row(png_structp png_ptr, png_bytep row,
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
png_bytep sp;
|
||||
png_bytep dp;
|
||||
png_bytep sp = png_ptr->row_buf + 1;
|
||||
png_bytep dp = row;
|
||||
int s_start, s_end, s_inc;
|
||||
int m;
|
||||
int m = 0x80;
|
||||
int shift;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = png_ptr->width;
|
||||
int value;
|
||||
|
||||
sp = png_ptr->row_buf + 1;
|
||||
dp = row;
|
||||
m = 0x80;
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_PACKSWAP)
|
||||
{
|
||||
@@ -1576,7 +1574,7 @@ png_combine_row(png_structp png_ptr, png_bytep row,
|
||||
|
||||
shift = s_start;
|
||||
|
||||
for (i = 0; i < png_ptr->width; i++)
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if (m & mask)
|
||||
{
|
||||
@@ -1602,17 +1600,15 @@ png_combine_row(png_structp png_ptr, png_bytep row,
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
png_bytep sp;
|
||||
png_bytep dp;
|
||||
png_bytep sp = png_ptr->row_buf + 1;
|
||||
png_bytep dp = row;
|
||||
int s_start, s_end, s_inc;
|
||||
int m;
|
||||
int m = 0x80;
|
||||
int shift;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = png_ptr->width;
|
||||
int value;
|
||||
|
||||
sp = png_ptr->row_buf + 1;
|
||||
dp = row;
|
||||
m = 0x80;
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_PACKSWAP)
|
||||
{
|
||||
@@ -1629,7 +1625,7 @@ png_combine_row(png_structp png_ptr, png_bytep row,
|
||||
}
|
||||
shift = s_start;
|
||||
|
||||
for (i = 0; i < png_ptr->width; i++)
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if (m & mask)
|
||||
{
|
||||
@@ -1655,18 +1651,15 @@ png_combine_row(png_structp png_ptr, png_bytep row,
|
||||
}
|
||||
default:
|
||||
{
|
||||
png_bytep sp;
|
||||
png_bytep dp;
|
||||
png_size_t pixel_bytes;
|
||||
png_bytep sp = png_ptr->row_buf + 1;
|
||||
png_bytep dp = row;
|
||||
png_size_t pixel_bytes = (png_ptr->row_info.pixel_depth >> 3);
|
||||
png_uint_32 i;
|
||||
png_byte m;
|
||||
png_uint_32 row_width = png_ptr->width;
|
||||
png_byte m = 0x80;
|
||||
|
||||
pixel_bytes = (png_ptr->row_info.pixel_depth >> 3);
|
||||
|
||||
sp = png_ptr->row_buf + 1;
|
||||
dp = row;
|
||||
m = 0x80;
|
||||
for (i = 0; i < png_ptr->width; i++)
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if (m & mask)
|
||||
{
|
||||
@@ -1703,15 +1696,15 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3);
|
||||
png_bytep dp = row + (png_size_t)((final_width - 1) >> 3);
|
||||
int sshift, dshift;
|
||||
int s_start, s_end, s_inc;
|
||||
int jstop = png_pass_inc[pass];
|
||||
png_byte v;
|
||||
png_uint_32 i;
|
||||
int j;
|
||||
|
||||
sp = row + (png_size_t)((row_info->width - 1) >> 3);
|
||||
dp = row + (png_size_t)((final_width - 1) >> 3);
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
|
||||
if (transformations & PNG_PACKSWAP)
|
||||
{
|
||||
@@ -1734,7 +1727,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
for (i = row_info->width; i; i--)
|
||||
{
|
||||
v = (png_byte)((*sp >> sshift) & 0x1);
|
||||
for (j = 0; j < png_pass_inc[pass]; j++)
|
||||
for (j = 0; j < jstop; j++)
|
||||
{
|
||||
*dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff);
|
||||
*dp |= (png_byte)(v << dshift);
|
||||
@@ -1758,13 +1751,13 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2);
|
||||
png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2);
|
||||
int sshift, dshift;
|
||||
int s_start, s_end, s_inc;
|
||||
int jstop = png_pass_inc[pass];
|
||||
png_uint_32 i;
|
||||
|
||||
sp = row + (png_uint_32)((row_info->width - 1) >> 2);
|
||||
dp = row + (png_uint_32)((final_width - 1) >> 2);
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
|
||||
if (transformations & PNG_PACKSWAP)
|
||||
{
|
||||
@@ -1790,7 +1783,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
int j;
|
||||
|
||||
v = (png_byte)((*sp >> sshift) & 0x3);
|
||||
for (j = 0; j < png_pass_inc[pass]; j++)
|
||||
for (j = 0; j < jstop; j++)
|
||||
{
|
||||
*dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff);
|
||||
*dp |= (png_byte)(v << dshift);
|
||||
@@ -1814,13 +1807,13 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1);
|
||||
png_bytep dp = row + (png_size_t)((final_width - 1) >> 1);
|
||||
int sshift, dshift;
|
||||
int s_start, s_end, s_inc;
|
||||
png_uint_32 i;
|
||||
int jstop = png_pass_inc[pass];
|
||||
|
||||
sp = row + (png_size_t)((row_info->width - 1) >> 1);
|
||||
dp = row + (png_size_t)((final_width - 1) >> 1);
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
|
||||
if (transformations & PNG_PACKSWAP)
|
||||
{
|
||||
@@ -1842,11 +1835,10 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
|
||||
for (i = row_info->width; i; i--)
|
||||
{
|
||||
png_byte v;
|
||||
png_byte v = (png_byte)((*sp >> sshift) & 0xf);
|
||||
int j;
|
||||
|
||||
v = (png_byte)((*sp >> sshift) & 0xf);
|
||||
for (j = 0; j < png_pass_inc[pass]; j++)
|
||||
for (j = 0; j < jstop; j++)
|
||||
{
|
||||
*dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff);
|
||||
*dp |= (png_byte)(v << dshift);
|
||||
@@ -1870,21 +1862,19 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
}
|
||||
default:
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_size_t pixel_bytes = (row_info->pixel_depth >> 3);
|
||||
png_bytep sp = row + (png_size_t)(row_info->width - 1) * pixel_bytes;
|
||||
png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes;
|
||||
int jstop = png_pass_inc[pass];
|
||||
png_uint_32 i;
|
||||
png_size_t pixel_bytes;
|
||||
|
||||
pixel_bytes = (row_info->pixel_depth >> 3);
|
||||
|
||||
sp = row + (png_size_t)(row_info->width - 1) * pixel_bytes;
|
||||
dp = row + (png_size_t)(final_width - 1) * pixel_bytes;
|
||||
for (i = row_info->width; i; i--)
|
||||
{
|
||||
png_byte v[8];
|
||||
int j;
|
||||
|
||||
png_memcpy(v, sp, pixel_bytes);
|
||||
for (j = 0; j < png_pass_inc[pass]; j++)
|
||||
for (j = 0; j < jstop; j++)
|
||||
{
|
||||
png_memcpy(dp, v, pixel_bytes);
|
||||
dp -= pixel_bytes;
|
||||
@@ -1901,6 +1891,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef PNG_READ_SLOW_FILTERING
|
||||
void
|
||||
png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
|
||||
png_bytep prev_row, int filter)
|
||||
@@ -1916,11 +1907,128 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
|
||||
case PNG_FILTER_VALUE_SUB:
|
||||
{
|
||||
png_uint_32 i;
|
||||
int bpp;
|
||||
png_uint_32 istop = row_info->rowbytes;
|
||||
png_uint_32 bpp = (row_info->pixel_depth + 7) / 8;
|
||||
png_bytep rp = row + bpp;
|
||||
png_bytep lp = row;
|
||||
|
||||
for (i = bpp; i < istop; i++)
|
||||
{
|
||||
*rp++ = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PNG_FILTER_VALUE_UP:
|
||||
{
|
||||
png_uint_32 i;
|
||||
png_uint_32 istop = row_info->rowbytes;
|
||||
png_bytep rp = row;
|
||||
png_bytep pp = prev_row;
|
||||
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
*rp++ = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PNG_FILTER_VALUE_AVG:
|
||||
{
|
||||
png_uint_32 i;
|
||||
png_bytep rp = row;
|
||||
png_bytep pp = prev_row;
|
||||
png_bytep lp = row;
|
||||
png_uint_32 bpp = (row_info->pixel_depth + 7) / 8;
|
||||
png_uint_32 istop = row_info->rowbytes;
|
||||
|
||||
for (i = 0; i < bpp; i++)
|
||||
{
|
||||
*rp++ = (png_byte)(((int)(*rp) +
|
||||
((int)(*pp++) / 2)) & 0xff);
|
||||
}
|
||||
|
||||
for (lp = row; i < istop; i++)
|
||||
{
|
||||
*rp++ = (png_byte)(((int)(*rp) +
|
||||
(int)(*pp++ + *lp++) / 2) & 0xff);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PNG_FILTER_VALUE_PAETH:
|
||||
{
|
||||
png_uint_32 i;
|
||||
png_bytep rp = row;
|
||||
png_bytep pp = prev_row;
|
||||
png_bytep lp = row;
|
||||
png_bytep cp = prev_row;
|
||||
png_uint_32 bpp = (row_info->pixel_depth + 7) / 8;
|
||||
png_uint_32 istop=row_info->rowbytes;
|
||||
|
||||
for (i = 0; i < bpp; i++)
|
||||
{
|
||||
*rp++ = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff);
|
||||
}
|
||||
|
||||
for ( ; i < istop; i++) /* use leftover i,rp,pp */
|
||||
{
|
||||
int a, b, c, pa, pb, pc, p;
|
||||
|
||||
a = *lp++;
|
||||
b = *pp++;
|
||||
c = *cp++;
|
||||
|
||||
p = b - c;
|
||||
pc = a - c;
|
||||
|
||||
#ifdef PNG_USE_ABS
|
||||
pa = abs(p);
|
||||
pb = abs(pc);
|
||||
pc = abs(p + pc);
|
||||
#else
|
||||
pa = p < 0 ? -p : p;
|
||||
pb = pc < 0 ? -pc : pc;
|
||||
pc = (p + pc) < 0 ? -(p + pc) : p + pc;
|
||||
#endif
|
||||
|
||||
/*
|
||||
if (pa <= pb && pa <= pc)
|
||||
p = a;
|
||||
else if (pb <= pc)
|
||||
p = b;
|
||||
else
|
||||
p = c;
|
||||
*/
|
||||
|
||||
p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
|
||||
|
||||
*rp++ = (png_byte)(((int)(*rp) + p) & 0xff);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
png_error(png_ptr, "Bad adaptive filter type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else /* PNG_READ_SLOW_FILTERING */
|
||||
void
|
||||
png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
|
||||
png_bytep prev_row, int filter)
|
||||
{
|
||||
png_debug(1, "in png_read_filter_row\n");
|
||||
png_debug2(2,"row = %d, filter = %d\n", png_ptr->row_number, filter);
|
||||
|
||||
|
||||
switch (filter)
|
||||
{
|
||||
case PNG_FILTER_VALUE_NONE:
|
||||
break;
|
||||
case PNG_FILTER_VALUE_SUB:
|
||||
{
|
||||
png_uint_32 i;
|
||||
int bpp = (row_info->pixel_depth + 7) / 8;
|
||||
png_bytep rp;
|
||||
png_bytep lp;
|
||||
|
||||
bpp = (row_info->pixel_depth + 7) / 8;
|
||||
for (i = (png_uint_32)bpp, rp = row + bpp, lp = row;
|
||||
i < row_info->rowbytes; i++, rp++, lp++)
|
||||
{
|
||||
@@ -1944,12 +2052,11 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
|
||||
case PNG_FILTER_VALUE_AVG:
|
||||
{
|
||||
png_uint_32 i;
|
||||
int bpp;
|
||||
int bpp = (row_info->pixel_depth + 7) / 8;
|
||||
png_bytep rp;
|
||||
png_bytep pp;
|
||||
png_bytep lp;
|
||||
|
||||
bpp = (row_info->pixel_depth + 7) / 8;
|
||||
for (i = 0, rp = row, pp = prev_row;
|
||||
i < (png_uint_32)bpp; i++, rp++, pp++)
|
||||
{
|
||||
@@ -1965,14 +2072,13 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
case PNG_FILTER_VALUE_PAETH:
|
||||
{
|
||||
int bpp;
|
||||
int bpp = (row_info->pixel_depth + 7) / 8;
|
||||
png_uint_32 i;
|
||||
png_bytep rp;
|
||||
png_bytep pp;
|
||||
png_bytep lp;
|
||||
png_bytep cp;
|
||||
|
||||
bpp = (row_info->pixel_depth + 7) / 8;
|
||||
for (i = 0, rp = row, pp = prev_row,
|
||||
lp = row - bpp, cp = prev_row - bpp;
|
||||
i < row_info->rowbytes; i++, rp++, pp++, lp++, cp++)
|
||||
@@ -2010,6 +2116,7 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_SLOW_FILTERING */
|
||||
|
||||
void
|
||||
png_read_finish_row(png_structp png_ptr)
|
||||
@@ -2118,7 +2225,7 @@ void
|
||||
png_read_start_row(png_structp png_ptr)
|
||||
{
|
||||
int max_pixel_depth;
|
||||
png_uint_32 rowbytes;
|
||||
png_uint_32 row_bytes;
|
||||
|
||||
png_debug(1, "in png_read_start_row\n");
|
||||
png_ptr->zstream.avail_in = 0;
|
||||
@@ -2136,10 +2243,10 @@ png_read_start_row(png_structp png_ptr)
|
||||
png_pass_start[png_ptr->pass]) /
|
||||
png_pass_inc[png_ptr->pass];
|
||||
|
||||
rowbytes = ((png_ptr->iwidth *
|
||||
row_bytes = ((png_ptr->iwidth *
|
||||
(png_uint_32)png_ptr->pixel_depth + 7) >> 3) +1;
|
||||
png_ptr->irowbytes = (png_size_t)rowbytes;
|
||||
if((png_uint_32)png_ptr->irowbytes != rowbytes)
|
||||
png_ptr->irowbytes = (png_size_t)row_bytes;
|
||||
if((png_uint_32)png_ptr->irowbytes != row_bytes)
|
||||
png_error(png_ptr, "Rowbytes overflow in png_read_start_row");
|
||||
}
|
||||
else
|
||||
@@ -2186,8 +2293,22 @@ png_read_start_row(png_structp png_ptr)
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED)
|
||||
if (png_ptr->transformations & (PNG_FILLER))
|
||||
{
|
||||
if (max_pixel_depth < 32)
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
max_pixel_depth = 32;
|
||||
else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)
|
||||
{
|
||||
if (max_pixel_depth <= 8)
|
||||
max_pixel_depth = 16;
|
||||
else
|
||||
max_pixel_depth = 32;
|
||||
}
|
||||
else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
|
||||
{
|
||||
if (max_pixel_depth <= 32)
|
||||
max_pixel_depth = 32;
|
||||
else
|
||||
max_pixel_depth = 64;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2214,16 +2335,16 @@ png_read_start_row(png_structp png_ptr)
|
||||
|
||||
/* align the width on the next larger 8 pixels. Mainly used
|
||||
for interlacing */
|
||||
rowbytes = ((png_ptr->width + 7) & ~((png_uint_32)7));
|
||||
row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7));
|
||||
/* calculate the maximum bytes needed, adding a byte and a pixel
|
||||
for safety sake */
|
||||
rowbytes = ((rowbytes * (png_uint_32)max_pixel_depth + 7) >> 3) +
|
||||
for safety's sake */
|
||||
row_bytes = ((row_bytes * (png_uint_32)max_pixel_depth + 7) >> 3) +
|
||||
1 + ((max_pixel_depth + 7) >> 3);
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
if (rowbytes > (png_uint_32)65536L)
|
||||
if (row_bytes > (png_uint_32)65536L)
|
||||
png_error(png_ptr, "This image requires a row greater than 64KB");
|
||||
#endif
|
||||
png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, rowbytes);
|
||||
png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, row_bytes);
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L)
|
||||
|
||||
7
pngset.c
7
pngset.c
@@ -1,12 +1,12 @@
|
||||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* libpng 1.00
|
||||
* 1.0.1c
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
* May 9, 1998
|
||||
*
|
||||
* The functions here are used during reads to store data from the file
|
||||
* into the info struct, and during writes to store application data
|
||||
@@ -108,13 +108,14 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
/* check for overflow */
|
||||
rowbytes_per_pixel = (info_ptr->pixel_depth + 7) >> 3;
|
||||
info_ptr->rowbytes = info_ptr->width * rowbytes_per_pixel;
|
||||
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)
|
||||
|
||||
54
pngtest.c
54
pngtest.c
@@ -1,12 +1,12 @@
|
||||
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
*
|
||||
* libpng 1.00
|
||||
* libpng 1.0.1c
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
* May 9, 1998
|
||||
*
|
||||
* 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
|
||||
@@ -81,12 +81,12 @@ write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
|
||||
|
||||
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
/* example of using user transform callback (we don't transform anything,
|
||||
but merely count the black pixels) */
|
||||
but merely count the zero samples) */
|
||||
|
||||
static png_uint_32 black_pixels;
|
||||
static png_uint_32 zero_samples;
|
||||
|
||||
void
|
||||
count_black_pixels(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||
count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||
{
|
||||
png_bytep dp = data;
|
||||
if(png_ptr == NULL)return;
|
||||
@@ -100,60 +100,66 @@ count_black_pixels(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||
* png_byte pixel_depth bits per pixel (depth*channels)
|
||||
*/
|
||||
|
||||
/* counts the number of black pixels (or zero pixels if color_type is 3 */
|
||||
/* 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;
|
||||
for (n=0; n<row_info->width; n++)
|
||||
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) black_pixels++;
|
||||
{
|
||||
if(((*dp << pos++ )& 0x80) == 0) zero_samples++;
|
||||
if(pos == 8)
|
||||
{
|
||||
pos=0;
|
||||
pos = 0;
|
||||
dp++;
|
||||
}
|
||||
}
|
||||
if(row_info->bit_depth == 2)
|
||||
if(((*dp << (pos+=2))& 0xc0) == 0) black_pixels++;
|
||||
{
|
||||
if(((*dp << (pos+=2))& 0xc0) == 0) zero_samples++;
|
||||
if(pos == 8)
|
||||
{
|
||||
pos=0;
|
||||
pos = 0;
|
||||
dp++;
|
||||
}
|
||||
}
|
||||
if(row_info->bit_depth == 4)
|
||||
if(((*dp << (pos+=4))& 0xf0) == 0) black_pixels++;
|
||||
{
|
||||
if(((*dp << (pos+=4))& 0xf0) == 0) zero_samples++;
|
||||
if(pos == 8)
|
||||
{
|
||||
pos=0;
|
||||
pos = 0;
|
||||
dp++;
|
||||
}
|
||||
}
|
||||
if(row_info->bit_depth == 8)
|
||||
if(*dp++ == 0) black_pixels++;
|
||||
if(*dp++ == 0) zero_samples++;
|
||||
if(row_info->bit_depth == 16)
|
||||
{
|
||||
if((*dp | *(dp+1)) == 0) black_pixels++;
|
||||
if((*dp | *(dp+1)) == 0) zero_samples++;
|
||||
dp+=2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* other color types */
|
||||
{
|
||||
png_uint_32 n;
|
||||
png_uint_32 n, nstop;
|
||||
int channel;
|
||||
int color_channels = row_info->channels;
|
||||
if(row_info->color_type > 3)color_channels--;
|
||||
|
||||
for (n=0; n<row_info->width; n++)
|
||||
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) black_pixels++;
|
||||
if(*dp++ == 0) zero_samples++;
|
||||
if(row_info->bit_depth == 16)
|
||||
{
|
||||
if((*dp | *(dp+1)) == 0) black_pixels++;
|
||||
if((*dp | *(dp+1)) == 0) zero_samples++;
|
||||
dp+=2;
|
||||
}
|
||||
}
|
||||
@@ -563,8 +569,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
}
|
||||
|
||||
# if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
black_pixels=0;
|
||||
png_set_write_user_transform_fn(write_ptr, count_black_pixels);
|
||||
zero_samples=0;
|
||||
png_set_write_user_transform_fn(write_ptr, count_zero_samples);
|
||||
# endif
|
||||
|
||||
png_debug(0, "Reading info struct\n");
|
||||
@@ -948,7 +954,7 @@ main(int argc, char *argv[])
|
||||
kerror = test_one_file(argv[i], outname);
|
||||
if (kerror == 0)
|
||||
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
fprintf(STDERR, " PASS (%lu black pixels)\n",black_pixels);
|
||||
fprintf(STDERR, " PASS (%lu zero samples)\n",zero_samples);
|
||||
#else
|
||||
fprintf(STDERR, " PASS\n");
|
||||
#endif
|
||||
@@ -994,7 +1000,7 @@ main(int argc, char *argv[])
|
||||
{
|
||||
if(verbose == 1 || i == 2)
|
||||
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
fprintf(STDERR, " PASS (%lu black pixels)\n",black_pixels);
|
||||
fprintf(STDERR, " PASS (%lu zero samples)\n",zero_samples);
|
||||
#else
|
||||
fprintf(STDERR, " PASS\n");
|
||||
#endif
|
||||
|
||||
119
pngtrans.c
119
pngtrans.c
@@ -1,12 +1,12 @@
|
||||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* libpng 1.00
|
||||
* 1.0.1c
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
* May 9, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@@ -100,12 +100,6 @@ png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
png_ptr->flags |= PNG_FLAG_FILLER_AFTER;
|
||||
else
|
||||
png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER;
|
||||
|
||||
/* This should probably go in the "do_filler" routine */
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_RGB && png_ptr->bit_depth == 8)
|
||||
{
|
||||
png_ptr->usr_channels = 4;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -148,12 +142,13 @@ png_do_invert(png_row_infop row_info, png_bytep row)
|
||||
#endif
|
||||
row_info->color_type == PNG_COLOR_TYPE_GRAY)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_bytep rp = row;
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -171,15 +166,13 @@ png_do_swap(png_row_infop row_info, png_bytep row)
|
||||
#endif
|
||||
row_info->bit_depth == 16)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_byte t;
|
||||
png_bytep rp = row;
|
||||
png_uint_32 i;
|
||||
png_uint_32 istop= row_info->width * row_info->channels;
|
||||
|
||||
for (i = 0, rp = row;
|
||||
i < row_info->width * row_info->channels;
|
||||
i++, rp += 2)
|
||||
for (i = 0; i < istop; i++, rp += 2)
|
||||
{
|
||||
t = *rp;
|
||||
png_byte t = *rp;
|
||||
*rp = *(rp + 1);
|
||||
*(rp + 1) = t;
|
||||
}
|
||||
@@ -338,6 +331,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 ||
|
||||
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->bit_depth == 8)
|
||||
@@ -345,10 +343,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 */
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 1, sp = row + 4, dp = row + 3; i < row_info->width; i++)
|
||||
dp+=3; sp+=4;
|
||||
for (i = 1; i < row_width; i++)
|
||||
{
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
@@ -359,10 +355,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 */
|
||||
else
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0, sp = row, dp = row; i < row_info->width; i++)
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
sp++;
|
||||
*dp++ = *sp++;
|
||||
@@ -371,17 +364,15 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
||||
}
|
||||
}
|
||||
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) */
|
||||
{
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
/* 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):
|
||||
png_memcpy(dp, sp, 6);
|
||||
@@ -399,17 +390,15 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
||||
}
|
||||
else
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
/* 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):
|
||||
png_memcpy(dp, sp, 6);
|
||||
sp += 8;
|
||||
dp += 6;
|
||||
*/
|
||||
sp+=2;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
@@ -419,9 +408,10 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
||||
}
|
||||
}
|
||||
row_info->pixel_depth = 48;
|
||||
row_info->rowbytes = row_info->width * 6;
|
||||
row_info->rowbytes = row_width * 6;
|
||||
}
|
||||
row_info->channels = 3;
|
||||
row_info->color_type &= ~PNG_COLOR_MASK_ALPHA;
|
||||
}
|
||||
/*
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY ||
|
||||
@@ -434,10 +424,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 */
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 1, sp = row + 2, dp = row + 1; i < row_info->width; i++)
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*dp++ = *sp++;
|
||||
sp++;
|
||||
@@ -446,27 +433,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 */
|
||||
else
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0, sp = row, dp = row; i < row_info->width; i++)
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
sp++;
|
||||
*dp++ = *sp++;
|
||||
}
|
||||
}
|
||||
row_info->pixel_depth = 8;
|
||||
row_info->rowbytes = row_info->width;
|
||||
row_info->rowbytes = row_width;
|
||||
}
|
||||
else /* if (row_info->bit_depth == 16) */
|
||||
{
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
/* 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++;
|
||||
@@ -475,11 +457,8 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
||||
}
|
||||
else
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
/* 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;
|
||||
*dp++ = *sp++;
|
||||
@@ -487,9 +466,10 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
||||
}
|
||||
}
|
||||
row_info->pixel_depth = 16;
|
||||
row_info->rowbytes = row_info->width * 2;
|
||||
row_info->rowbytes = row_width * 2;
|
||||
}
|
||||
row_info->channels = 1;
|
||||
row_info->color_type &= ~PNG_COLOR_MASK_ALPHA;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -507,17 +487,17 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||
#endif
|
||||
(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->color_type == PNG_COLOR_TYPE_RGB)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_byte save;
|
||||
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 + 2) = save;
|
||||
}
|
||||
@@ -525,12 +505,11 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_byte save;
|
||||
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 + 2) = save;
|
||||
}
|
||||
@@ -541,33 +520,31 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_byte save[2];
|
||||
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;
|
||||
save[1] = *(rp + 1);
|
||||
png_byte save = *rp;
|
||||
*rp = *(rp + 4);
|
||||
*(rp + 4) = save;
|
||||
save = *(rp + 1);
|
||||
*(rp + 1) = *(rp + 5);
|
||||
*(rp + 4) = save[0];
|
||||
*(rp + 5) = save[1];
|
||||
*(rp + 5) = save;
|
||||
}
|
||||
}
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_byte save[2];
|
||||
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;
|
||||
save[1] = *(rp + 1);
|
||||
png_byte save = *rp;
|
||||
*rp = *(rp + 4);
|
||||
*(rp + 4) = save;
|
||||
save = *(rp + 1);
|
||||
*(rp + 1) = *(rp + 5);
|
||||
*(rp + 4) = save[0];
|
||||
*(rp + 5) = save[1];
|
||||
*(rp + 5) = save;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
4
pngwio.c
4
pngwio.c
@@ -1,12 +1,12 @@
|
||||
|
||||
/* pngwio.c - functions for data output
|
||||
*
|
||||
* libpng 1.00
|
||||
* libpng 1.0.1c
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
* May 9, 1998
|
||||
*
|
||||
* This file provides a location for all output. Users which need
|
||||
* special handling are expected to write functions which have the same
|
||||
|
||||
40
pngwrite.c
40
pngwrite.c
@@ -1,12 +1,12 @@
|
||||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* libpng 1.00
|
||||
* 1.0.1c
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
* May 9, 1998
|
||||
*/
|
||||
|
||||
/* get internal access to png.h */
|
||||
@@ -239,7 +239,7 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
||||
{
|
||||
char near_time_buf[29];
|
||||
sprintf(near_time_buf, "%d %s %d %02d:%02d:%02d +0000",
|
||||
ptime->day % 31, short_months[ptime->month],
|
||||
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,
|
||||
@@ -247,7 +247,7 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
||||
}
|
||||
#else
|
||||
sprintf(png_ptr->time_buffer, "%d %s %d %02d:%02d:%02d +0000",
|
||||
ptime->day % 31, short_months[ptime->month],
|
||||
ptime->day % 32, short_months[(ptime->month - 1) % 12],
|
||||
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
||||
ptime->second % 61);
|
||||
#endif
|
||||
@@ -281,7 +281,7 @@ png_convert_from_time_t(png_timep ptime, time_t ttime)
|
||||
|
||||
/* Initialize png_ptr structure, and allocate any memory needed */
|
||||
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_structp png_ptr;
|
||||
@@ -422,6 +422,36 @@ png_write_row(png_structp png_ptr, png_bytep row)
|
||||
/* initialize transformations and other stuff if first time */
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
119
pngwtran.c
119
pngwtran.c
@@ -1,12 +1,12 @@
|
||||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* libpng 1.00
|
||||
* 1.0.1c
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
* May 9, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@@ -97,12 +97,14 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
png_bytep sp, dp;
|
||||
int mask, v;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
sp = row;
|
||||
dp = row;
|
||||
mask = 0x80;
|
||||
v = 0;
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if (*sp != 0)
|
||||
v |= mask;
|
||||
@@ -126,12 +128,13 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
png_bytep sp, dp;
|
||||
int shift, v;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
sp = row;
|
||||
dp = row;
|
||||
shift = 6;
|
||||
v = 0;
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
png_byte value;
|
||||
|
||||
@@ -157,12 +160,13 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
png_bytep sp, dp;
|
||||
int shift, v;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
sp = row;
|
||||
dp = row;
|
||||
shift = 4;
|
||||
v = 0;
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
png_byte value;
|
||||
|
||||
@@ -214,9 +218,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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
shift_start[channels] = row_info->bit_depth - bit_depth->red;
|
||||
@@ -245,9 +248,10 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
||||
/* with low row depths, could only be grayscale, so one channel */
|
||||
if (row_info->bit_depth < 8)
|
||||
{
|
||||
png_bytep bp;
|
||||
png_bytep bp = row;
|
||||
png_uint_32 i;
|
||||
png_byte mask;
|
||||
png_uint_32 row_bytes = row_info->rowbytes;
|
||||
|
||||
if (bit_depth->gray == 1 && row_info->bit_depth == 2)
|
||||
mask = 0x55;
|
||||
@@ -256,7 +260,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
||||
else
|
||||
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;
|
||||
int j;
|
||||
@@ -274,27 +278,25 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
||||
}
|
||||
else if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep bp;
|
||||
png_bytep bp = row;
|
||||
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++)
|
||||
{
|
||||
png_uint_32 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;
|
||||
int j;
|
||||
|
||||
v = *bp;
|
||||
*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);
|
||||
}
|
||||
if (j > 0)
|
||||
*bp |= (png_byte)((v << j) & 0xff);
|
||||
else
|
||||
*bp |= (png_byte)((v >> (-j)) & 0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -302,28 +304,25 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
||||
{
|
||||
png_bytep bp;
|
||||
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++)
|
||||
{
|
||||
png_uint_32 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;
|
||||
int j;
|
||||
|
||||
v = ((png_uint_16)(*bp) << 8) + *(bp + 1);
|
||||
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);
|
||||
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++ = (png_byte)(value & 0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -345,12 +344,11 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_byte save;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_info->width; i++)
|
||||
png_uint_32 row_width = row_info->width;
|
||||
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||
{
|
||||
save = *(sp++);
|
||||
png_byte save = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
@@ -361,11 +359,12 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
else
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_byte save[2];
|
||||
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[1] = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
@@ -385,12 +384,12 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_byte save;
|
||||
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++) = save;
|
||||
}
|
||||
@@ -399,11 +398,12 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
else
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_byte save[2];
|
||||
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[1] = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
@@ -433,8 +433,8 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_info->width; i++)
|
||||
png_uint_32 row_width = row_info->width;
|
||||
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||
{
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
@@ -447,8 +447,9 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
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++)
|
||||
{
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
@@ -468,8 +469,9 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
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++)
|
||||
{
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = 255 - *(sp++);
|
||||
@@ -480,8 +482,9 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
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++)
|
||||
{
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
|
||||
272
pngwutil.c
272
pngwutil.c
@@ -1,12 +1,12 @@
|
||||
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* libpng 1.00
|
||||
* 1.0.1c
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
* May 9, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@@ -340,7 +340,7 @@ png_write_gAMA(png_structp png_ptr, double file_gamma)
|
||||
png_byte buf[4];
|
||||
|
||||
png_debug(1, "in png_write_gAMA\n");
|
||||
/* file_gamma is saved in 1/100,000ths */
|
||||
/* file_gamma is saved in 1/1000000ths */
|
||||
igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5);
|
||||
png_save_uint_32(buf, igamma);
|
||||
png_write_chunk(png_ptr, png_gAMA, buf, (png_size_t)4);
|
||||
@@ -426,7 +426,7 @@ png_write_cHRM(png_structp png_ptr, double white_x, double white_y,
|
||||
png_byte buf[32];
|
||||
|
||||
png_debug(1, "in png_write_cHRM\n");
|
||||
/* each value is saved int 1/100,000ths */
|
||||
/* each value is saved int 1/1000000ths */
|
||||
if (white_x < 0 || white_x > 0.8 || white_y < 0 || white_y > 0.8 ||
|
||||
white_x + white_y > 1.0)
|
||||
{
|
||||
@@ -1241,7 +1241,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
if (pass < 6)
|
||||
#endif
|
||||
{
|
||||
/* each pixel depth is handled seperately */
|
||||
/* each pixel depth is handled separately */
|
||||
switch (row_info->pixel_depth)
|
||||
{
|
||||
case 1:
|
||||
@@ -1252,11 +1252,12 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
int d;
|
||||
int value;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
dp = row;
|
||||
d = 0;
|
||||
shift = 7;
|
||||
for (i = png_pass_start[pass]; i < row_info->width;
|
||||
for (i = png_pass_start[pass]; i < row_width;
|
||||
i += png_pass_inc[pass])
|
||||
{
|
||||
sp = row + (png_size_t)(i >> 3);
|
||||
@@ -1285,11 +1286,12 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
int d;
|
||||
int value;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
dp = row;
|
||||
shift = 6;
|
||||
d = 0;
|
||||
for (i = png_pass_start[pass]; i < row_info->width;
|
||||
for (i = png_pass_start[pass]; i < row_width;
|
||||
i += png_pass_inc[pass])
|
||||
{
|
||||
sp = row + (png_size_t)(i >> 2);
|
||||
@@ -1317,11 +1319,12 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
int d;
|
||||
int value;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
dp = row;
|
||||
shift = 4;
|
||||
d = 0;
|
||||
for (i = png_pass_start[pass]; i < row_info->width;
|
||||
for (i = png_pass_start[pass]; i < row_width;
|
||||
i += png_pass_inc[pass])
|
||||
{
|
||||
sp = row + (png_size_t)(i >> 1);
|
||||
@@ -1346,6 +1349,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
png_bytep sp;
|
||||
png_bytep dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
png_size_t pixel_bytes;
|
||||
|
||||
/* start at the beginning */
|
||||
@@ -1354,7 +1358,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
pixel_bytes = (row_info->pixel_depth >> 3);
|
||||
/* loop through the row, only looking at the pixels that
|
||||
matter */
|
||||
for (i = png_pass_start[pass]; i < row_info->width;
|
||||
for (i = png_pass_start[pass]; i < row_width;
|
||||
i += png_pass_inc[pass])
|
||||
{
|
||||
/* find out where the original pixel is */
|
||||
@@ -1392,6 +1396,11 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
{
|
||||
png_bytep prev_row, best_row, row_buf;
|
||||
png_uint_32 mins, bpp;
|
||||
png_byte filter_to_do = png_ptr->do_filter;
|
||||
png_uint_32 row_bytes = row_info->rowbytes;
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
int num_p_filters = (int)png_ptr->num_prev_filters;
|
||||
#endif
|
||||
|
||||
png_debug(1, "in png_write_find_filter\n");
|
||||
/* find out how many bytes offset each pixel is */
|
||||
@@ -1405,7 +1414,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
* smallest value when summing the absolute values of the distances
|
||||
* from zero using anything >= 128 as negative numbers. This is known
|
||||
* as the "minimum sum of absolute differences" heuristic. Other
|
||||
* heuristics are the "weighted minumum sum of absolute differences"
|
||||
* heuristics are the "weighted minimum sum of absolute differences"
|
||||
* (experimental and can in theory improve compression), and the "zlib
|
||||
* predictive" method (not implemented in libpng 0.95), which does test
|
||||
* compressions of lines using different filter methods, and then chooses
|
||||
@@ -1413,18 +1422,19 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
* computationally expensive).
|
||||
*/
|
||||
|
||||
|
||||
/* We don't need to test the 'no filter' case if this is the only filter
|
||||
* that has been chosen, as it doesn't actually do anything to the data.
|
||||
*/
|
||||
if (png_ptr->do_filter & PNG_FILTER_NONE &&
|
||||
png_ptr->do_filter != PNG_FILTER_NONE)
|
||||
if (filter_to_do & PNG_FILTER_NONE &&
|
||||
filter_to_do != PNG_FILTER_NONE)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_uint_32 sum = 0;
|
||||
png_uint_32 i;
|
||||
int v;
|
||||
|
||||
for (i = 0, rp = row_buf + 1; i < row_info->rowbytes; i++, rp++)
|
||||
for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)
|
||||
{
|
||||
v = *rp;
|
||||
sum += (v < 128) ? v : 256 - v;
|
||||
@@ -1434,17 +1444,18 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
||||
{
|
||||
png_uint_32 sumhi, sumlo;
|
||||
int j;
|
||||
sumlo = sum & PNG_LOMASK;
|
||||
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; /* Gives us some footroom */
|
||||
|
||||
/* Reduce the sum if we match any of the previous rows */
|
||||
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
|
||||
for (j = 0; j < num_p_filters; j++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_NONE)
|
||||
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE)
|
||||
{
|
||||
sumlo = (sumlo * png_ptr->filter_weights[i]) >>
|
||||
sumlo = (sumlo * png_ptr->filter_weights[j]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
sumhi = (sumhi * png_ptr->filter_weights[i]) >>
|
||||
sumhi = (sumhi * png_ptr->filter_weights[j]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
}
|
||||
}
|
||||
@@ -1468,7 +1479,25 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
}
|
||||
|
||||
/* sub filter */
|
||||
if (png_ptr->do_filter & PNG_FILTER_SUB)
|
||||
if (filter_to_do == PNG_FILTER_SUB)
|
||||
/* it's the only filter so no testing is needed */
|
||||
{
|
||||
png_bytep rp, lp, dp;
|
||||
png_uint_32 i;
|
||||
for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp;
|
||||
i++, rp++, dp++)
|
||||
{
|
||||
*dp = *rp;
|
||||
}
|
||||
for (lp = row_buf + 1; i < row_bytes;
|
||||
i++, rp++, lp++, dp++)
|
||||
{
|
||||
*dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);
|
||||
}
|
||||
best_row = png_ptr->sub_row;
|
||||
}
|
||||
|
||||
else if (filter_to_do & PNG_FILTER_SUB)
|
||||
{
|
||||
png_bytep rp, dp, lp;
|
||||
png_uint_32 sum = 0, lmins = mins;
|
||||
@@ -1476,23 +1505,24 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
int v;
|
||||
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
/* We temporarily increase the "minumum sum" by the factor we
|
||||
/* We temporarily increase the "minimum sum" by the factor we
|
||||
* would reduce the sum of this filter, so that we can do the
|
||||
* early exit comparison without scaling the sum each time.
|
||||
*/
|
||||
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
||||
{
|
||||
int j;
|
||||
png_uint_32 lmhi, lmlo;
|
||||
lmlo = lmins & PNG_LOMASK;
|
||||
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
|
||||
|
||||
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
|
||||
for (j = 0; j < num_p_filters; j++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_SUB)
|
||||
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB)
|
||||
{
|
||||
lmlo = (lmlo * png_ptr->inv_filter_weights[i]) >>
|
||||
lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
lmhi = (lmhi * png_ptr->inv_filter_weights[i]) >>
|
||||
lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
}
|
||||
}
|
||||
@@ -1530,17 +1560,18 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
||||
{
|
||||
int j;
|
||||
png_uint_32 sumhi, sumlo;
|
||||
sumlo = sum & PNG_LOMASK;
|
||||
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
|
||||
|
||||
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
|
||||
for (j = 0; j < num_p_filters; j++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_SUB)
|
||||
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB)
|
||||
{
|
||||
sumlo = (sumlo * png_ptr->inv_filter_weights[i]) >>
|
||||
sumlo = (sumlo * png_ptr->inv_filter_weights[j]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
sumhi = (sumhi * png_ptr->inv_filter_weights[i]) >>
|
||||
sumhi = (sumhi * png_ptr->inv_filter_weights[j]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
}
|
||||
}
|
||||
@@ -1565,27 +1596,43 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
}
|
||||
|
||||
/* up filter */
|
||||
if (png_ptr->do_filter & PNG_FILTER_UP)
|
||||
if (filter_to_do == PNG_FILTER_UP)
|
||||
{
|
||||
png_bytep rp, dp, pp;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,
|
||||
pp = prev_row + 1; i < row_bytes;
|
||||
i++, rp++, pp++, dp++)
|
||||
{
|
||||
*dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
|
||||
}
|
||||
best_row = png_ptr->up_row;
|
||||
}
|
||||
|
||||
else if (filter_to_do & PNG_FILTER_UP)
|
||||
{
|
||||
png_bytep rp, dp, pp;
|
||||
png_uint_32 sum = 0, lmins = mins;
|
||||
png_uint_32 i;
|
||||
int v;
|
||||
|
||||
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
||||
{
|
||||
int j;
|
||||
png_uint_32 lmhi, lmlo;
|
||||
lmlo = lmins & PNG_LOMASK;
|
||||
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
|
||||
|
||||
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
|
||||
for (j = 0; j < num_p_filters; j++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_UP)
|
||||
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP)
|
||||
{
|
||||
lmlo = (lmlo * png_ptr->inv_filter_weights[i]) >>
|
||||
lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
lmhi = (lmhi * png_ptr->inv_filter_weights[i]) >>
|
||||
lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
}
|
||||
}
|
||||
@@ -1603,10 +1650,9 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
#endif
|
||||
|
||||
for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,
|
||||
pp = prev_row + 1; i < row_info->rowbytes;
|
||||
i++, rp++, pp++, dp++)
|
||||
pp = prev_row + 1; i < row_bytes; i++)
|
||||
{
|
||||
v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
|
||||
v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
|
||||
|
||||
sum += (v < 128) ? v : 256 - v;
|
||||
|
||||
@@ -1617,17 +1663,18 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
||||
{
|
||||
int j;
|
||||
png_uint_32 sumhi, sumlo;
|
||||
sumlo = sum & PNG_LOMASK;
|
||||
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
|
||||
|
||||
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
|
||||
for (j = 0; j < num_p_filters; j++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_UP)
|
||||
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP)
|
||||
{
|
||||
sumlo = (sumlo * png_ptr->filter_weights[i]) >>
|
||||
sumlo = (sumlo * png_ptr->filter_weights[j]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
sumhi = (sumhi * png_ptr->filter_weights[i]) >>
|
||||
sumhi = (sumhi * png_ptr->filter_weights[j]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
}
|
||||
}
|
||||
@@ -1652,7 +1699,24 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
}
|
||||
|
||||
/* avg filter */
|
||||
if (png_ptr->do_filter & PNG_FILTER_AVG)
|
||||
if (filter_to_do == PNG_FILTER_AVG)
|
||||
{
|
||||
png_bytep rp, dp, pp, lp;
|
||||
png_uint_32 i;
|
||||
for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1,
|
||||
pp = prev_row + 1; i < bpp; i++)
|
||||
{
|
||||
*dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);
|
||||
}
|
||||
for (lp = row_buf + 1; i < row_bytes; i++)
|
||||
{
|
||||
*dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2))
|
||||
& 0xff);
|
||||
}
|
||||
best_row = png_ptr->avg_row;
|
||||
}
|
||||
|
||||
else if (filter_to_do & PNG_FILTER_AVG)
|
||||
{
|
||||
png_bytep rp, dp, pp, lp;
|
||||
png_uint_32 sum = 0, lmins = mins;
|
||||
@@ -1662,17 +1726,18 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
||||
{
|
||||
int j;
|
||||
png_uint_32 lmhi, lmlo;
|
||||
lmlo = lmins & PNG_LOMASK;
|
||||
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
|
||||
|
||||
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
|
||||
for (j = 0; j < num_p_filters; j++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_AVG)
|
||||
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_AVG)
|
||||
{
|
||||
lmlo = (lmlo * png_ptr->inv_filter_weights[i]) >>
|
||||
lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
lmhi = (lmhi * png_ptr->inv_filter_weights[i]) >>
|
||||
lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
}
|
||||
}
|
||||
@@ -1690,16 +1755,16 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
#endif
|
||||
|
||||
for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1,
|
||||
pp = prev_row + 1; i < bpp; i++, rp++, pp++, dp++)
|
||||
pp = prev_row + 1; i < bpp; i++)
|
||||
{
|
||||
v = *dp = (png_byte)(((int)*rp - ((int)*pp / 2)) & 0xff);
|
||||
v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);
|
||||
|
||||
sum += (v < 128) ? v : 256 - v;
|
||||
}
|
||||
for (lp = row_buf + 1; i < row_info->rowbytes;
|
||||
i++, rp++, pp++, lp++, dp++)
|
||||
for (lp = row_buf + 1; i < row_bytes; i++)
|
||||
{
|
||||
v = *dp = (png_byte)(((int)*rp - (((int)*pp + (int)*lp) / 2)) & 0xff);
|
||||
v = *dp++ =
|
||||
(png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) & 0xff);
|
||||
|
||||
sum += (v < 128) ? v : 256 - v;
|
||||
|
||||
@@ -1710,17 +1775,18 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
||||
{
|
||||
int j;
|
||||
png_uint_32 sumhi, sumlo;
|
||||
sumlo = sum & PNG_LOMASK;
|
||||
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
|
||||
|
||||
for (i = 0; i < png_ptr->num_prev_filters; i++)
|
||||
for (j = 0; j < num_p_filters; j++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_NONE)
|
||||
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE)
|
||||
{
|
||||
sumlo = (sumlo * png_ptr->filter_weights[i]) >>
|
||||
sumlo = (sumlo * png_ptr->filter_weights[j]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
sumhi = (sumhi * png_ptr->filter_weights[i]) >>
|
||||
sumhi = (sumhi * png_ptr->filter_weights[j]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
}
|
||||
}
|
||||
@@ -1745,7 +1811,45 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
}
|
||||
|
||||
/* Paeth filter */
|
||||
if (png_ptr->do_filter & PNG_FILTER_PAETH)
|
||||
if (filter_to_do == PNG_FILTER_PAETH)
|
||||
{
|
||||
png_bytep rp, dp, pp, cp, lp;
|
||||
png_uint_32 i;
|
||||
for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1,
|
||||
pp = prev_row + 1; i < bpp; i++)
|
||||
{
|
||||
*dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
|
||||
}
|
||||
|
||||
for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++)
|
||||
{
|
||||
int a, b, c, pa, pb, pc, p;
|
||||
|
||||
b = *pp++;
|
||||
c = *cp++;
|
||||
a = *lp++;
|
||||
|
||||
p = b - c;
|
||||
pc = a - c;
|
||||
|
||||
#ifdef PNG_USE_ABS
|
||||
pa = abs(p);
|
||||
pb = abs(pc);
|
||||
pc = abs(p + pc);
|
||||
#else
|
||||
pa = p < 0 ? -p : p;
|
||||
pb = pc < 0 ? -pc : pc;
|
||||
pc = (p + pc) < 0 ? -(p + pc) : p + pc;
|
||||
#endif
|
||||
|
||||
p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
|
||||
|
||||
*dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
|
||||
}
|
||||
best_row = png_ptr->paeth_row;
|
||||
}
|
||||
|
||||
else if (filter_to_do & PNG_FILTER_PAETH)
|
||||
{
|
||||
png_bytep rp, dp, pp, cp, lp;
|
||||
png_uint_32 sum = 0, lmins = mins;
|
||||
@@ -1755,17 +1859,18 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
||||
{
|
||||
int j;
|
||||
png_uint_32 lmhi, lmlo;
|
||||
lmlo = lmins & PNG_LOMASK;
|
||||
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
|
||||
|
||||
for (i = 0; i < png_ptr->num_prev_filters; i++)
|
||||
for (j = 0; j < num_p_filters; j++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_PAETH)
|
||||
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH)
|
||||
{
|
||||
lmlo = (lmlo * png_ptr->inv_filter_weights[i]) >>
|
||||
lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
lmhi = (lmhi * png_ptr->inv_filter_weights[i]) >>
|
||||
lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
}
|
||||
}
|
||||
@@ -1783,34 +1888,48 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
#endif
|
||||
|
||||
for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1,
|
||||
pp = prev_row + 1; (unsigned)i < bpp; i++, rp++, pp++, dp++)
|
||||
pp = prev_row + 1; i < bpp; i++)
|
||||
{
|
||||
v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
|
||||
v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
|
||||
|
||||
sum += (v < 128) ? v : 256 - v;
|
||||
}
|
||||
for (lp = row_buf + 1, cp = prev_row + 1; i < row_info->rowbytes;
|
||||
i++, rp++, pp++, lp++, dp++, cp++)
|
||||
|
||||
for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++)
|
||||
{
|
||||
int a, b, c, pa, pb, pc, p;
|
||||
|
||||
b = *pp;
|
||||
c = *cp;
|
||||
a = *lp;
|
||||
b = *pp++;
|
||||
c = *cp++;
|
||||
a = *lp++;
|
||||
|
||||
#ifndef PNG_SLOW_PAETH
|
||||
p = b - c;
|
||||
pc = a - c;
|
||||
#ifdef PNG_USE_ABS
|
||||
pa = abs(p);
|
||||
pb = abs(pc);
|
||||
pc = abs(p + pc);
|
||||
#else
|
||||
pa = p < 0 ? -p : p;
|
||||
pb = pc < 0 ? -pc : pc;
|
||||
pc = (p + pc) < 0 ? -(p + pc) : p + pc;
|
||||
#endif
|
||||
p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
|
||||
#else /* PNG_SLOW_PAETH */
|
||||
p = a + b - c;
|
||||
pa = abs(p - a);
|
||||
pb = abs(p - b);
|
||||
pc = abs(p - c);
|
||||
|
||||
if (pa <= pb && pa <= pc)
|
||||
p = a;
|
||||
else if (pb <= pc)
|
||||
p = b;
|
||||
else
|
||||
p = c;
|
||||
#endif /* PNG_SLOW_PAETH */
|
||||
|
||||
v = *dp = (png_byte)(((int)*rp - p) & 0xff);
|
||||
v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
|
||||
|
||||
sum += (v < 128) ? v : 256 - v;
|
||||
|
||||
@@ -1821,17 +1940,18 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
||||
{
|
||||
int j;
|
||||
png_uint_32 sumhi, sumlo;
|
||||
sumlo = sum & PNG_LOMASK;
|
||||
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
|
||||
|
||||
for (i = 0; i < png_ptr->num_prev_filters; i++)
|
||||
for (j = 0; j < num_p_filters; j++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_PAETH)
|
||||
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH)
|
||||
{
|
||||
sumlo = (sumlo * png_ptr->filter_weights[i]) >>
|
||||
sumlo = (sumlo * png_ptr->filter_weights[j]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
sumhi = (sumhi * png_ptr->filter_weights[i]) >>
|
||||
sumhi = (sumhi * png_ptr->filter_weights[j]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
}
|
||||
}
|
||||
@@ -1855,19 +1975,19 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
}
|
||||
|
||||
/* Do the actual writing of the filtered row data from the chosen filter. */
|
||||
|
||||
png_write_filtered_row(png_ptr, best_row);
|
||||
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
/* Save the type of filter we picked this time for future calculations */
|
||||
if (png_ptr->num_prev_filters > 0)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 1; i < (int)png_ptr->num_prev_filters; i++)
|
||||
int j;
|
||||
for (j = 1; j < num_p_filters; j++)
|
||||
{
|
||||
png_ptr->prev_filters[i] = png_ptr->prev_filters[i - 1];
|
||||
png_ptr->prev_filters[j] = png_ptr->prev_filters[j - 1];
|
||||
}
|
||||
png_ptr->prev_filters[i] = best_row[0];
|
||||
png_ptr->prev_filters[j] = best_row[0];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
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
|
||||
@@ -11,11 +11,16 @@ CC=gcc
|
||||
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 -malign-loops=2 \
|
||||
-malign-functions=2 #$(WARNMORE) -g -DPNG_DEBUG=5
|
||||
|
||||
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
|
||||
@@ -24,7 +29,7 @@ RANLIB=ranlib
|
||||
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
||||
# have to change it.
|
||||
PNGMAJ = 2
|
||||
PNGMIN = 1.00
|
||||
PNGMIN = 1.0.1c
|
||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||
|
||||
# where make install puts libpng.a, libpng.so*, and png.h
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
makefile for libpng on Solaris 2.x with gcc
|
||||
# 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
|
||||
@@ -7,14 +7,20 @@
|
||||
CC=gcc
|
||||
|
||||
# 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
|
||||
# $(WARNMORE) -g -DPNG_DEBUG=5
|
||||
LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng -lz -lm
|
||||
|
||||
#RANLIB=ranlib
|
||||
@@ -23,11 +29,11 @@ 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.00
|
||||
PNGMIN = 1.0.1c
|
||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||
|
||||
# where make install puts libpng.a, libpng.so*, and png.h
|
||||
prefix=/local
|
||||
prefix=/usr/local
|
||||
INCPATH=$(prefix)/include
|
||||
LIBPATH=$(prefix)/lib
|
||||
|
||||
@@ -55,7 +61,7 @@ libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
|
||||
ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
|
||||
|
||||
libpng.so.$(PNGVER): $(OBJSDLL)
|
||||
$(LD) -G -L$(LIBPATH) -R$(LIBPATH) -h libpng.so.$(PNGMAJ) \
|
||||
$(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h libpng.so.$(PNGMAJ) \
|
||||
-o libpng.so.$(PNGVER) $(OBJSDLL) -lz
|
||||
|
||||
pngtest: pngtest.o libpng.so
|
||||
|
||||
97
scripts/makefile.sco
Normal file
97
scripts/makefile.sco
Normal file
@@ -0,0 +1,97 @@
|
||||
# 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 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.1c
|
||||
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
|
||||
|
||||
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 -sf libpng.so.$(PNGMAJ) libpng.so
|
||||
|
||||
libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
|
||||
ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
|
||||
|
||||
libpng.so.$(PNGVER): $(OBJSDLL)
|
||||
$(CC) -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 -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
|
||||
ln -sf libpng.so.$(PNGMAJ) libpng.so)
|
||||
|
||||
clean:
|
||||
/bin/rm -f *.o libpng.a libpng.so* pngtest pngout.png
|
||||
|
||||
# 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
|
||||
@@ -10,7 +10,8 @@ ZLIBINC=../zlib
|
||||
|
||||
CC=cc
|
||||
|
||||
CFLAGS=-I$(ZLIBINC) -O -fullwarn # -g -DPNG_DEBUG=1
|
||||
WARNMORE=-fullwarn
|
||||
CFLAGS=-I$(ZLIBINC) -O $(WARNMORE) # -g -DPNG_DEBUG=5
|
||||
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
|
||||
|
||||
RANLIB=echo
|
||||
|
||||
@@ -9,7 +9,7 @@ ZLIBLIB=../zlib
|
||||
ZLIBINC=../zlib
|
||||
|
||||
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
|
||||
|
||||
#RANLIB=echo
|
||||
|
||||
@@ -13,7 +13,7 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow -Wconversion \
|
||||
-Wmissing-declarations -Wtraditional -Wcast-align \
|
||||
-Wstrict-prototypes -Wmissing-prototypes
|
||||
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
|
||||
|
||||
RANLIB=ranlib
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Makefile for libpng
|
||||
# Watcom 10a+ 32-bit protected mode flat memory model
|
||||
# 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
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
# To use, do "wmake -f makefile.wat"
|
||||
|
||||
# ------------- Watcom 10a+ -------------
|
||||
# ------------- Watcom 10.0a and later -------------
|
||||
MODEL=-mf
|
||||
CFLAGS= $(MODEL) -fpi87 -fp5 -5r -oaeilmnrt -s -zp4 -i=..\zlib
|
||||
CFLAGS= $(MODEL) -5r -fp5 -fpi87 -oneatx -zp8 -i=..\zlib
|
||||
CC=wcc386
|
||||
LD=wcl386
|
||||
LIB=wlib -b -c
|
||||
@@ -75,9 +75,9 @@ 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)
|
||||
$(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
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user