Imported from libpng-1.0.1a.tar
This commit is contained in:
parent
f9f2fe0ce7
commit
896239be20
26
ANNOUNCE
Normal file
26
ANNOUNCE
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
Libpng 1.0.1a April 21, 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 release:
|
||||
|
||||
Optimized Paeth calculations by replacing abs() function calls with intrinsics
|
||||
plus other loop optimizations. Improves avg decoding speed by about 20 percent.
|
||||
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).
|
||||
|
||||
Send comments/corrections/commendations to
|
||||
png-implement@dworkin.wustl.edu or to randeg@alumni.rpi.edu
|
||||
|
||||
Glenn R-P
|
519
CHANGES
519
CHANGES
@ -1,288 +1,303 @@
|
||||
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)
|
||||
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
|
||||
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
|
||||
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]
|
||||
Changes 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()
|
||||
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)
|
||||
|
4
INSTALL
4
INSTALL
@ -1,5 +1,5 @@
|
||||
|
||||
Installing libpng version 1.0.1 March 15, 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.0.1 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:
|
||||
|
113
KNOWNBUG
Normal file
113
KNOWNBUG
Normal file
@ -0,0 +1,113 @@
|
||||
|
||||
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
|
||||
|
||||
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, count;
|
||||
istop = s->a*s->b;
|
||||
for(i=0; i<istop; i++)
|
||||
|
||||
STATUS: Mostly done in libpng-1.0.1a, done for all important loops.
|
||||
|
||||
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: Will do in libpng-1.0.1b
|
||||
|
||||
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
|
2
README
2
README
@ -1,4 +1,4 @@
|
||||
README for libpng 1.0.1 (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.
|
||||
|
1
TODO
1
TODO
@ -2,7 +2,6 @@ TODO - list of things to do for libpng
|
||||
|
||||
fix problem with C++ and EXTERN "C"
|
||||
add "grayscale->palette" transformation and "palette->grayscale" detection
|
||||
add "grayscale" -> "grayscale+alpha" and "grayscale+FILLER" transformations
|
||||
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)
|
||||
|
34
libpng.3
34
libpng.3
@ -1,4 +1,4 @@
|
||||
.TH LIBPNG 3 "March 15, 1998"
|
||||
.TH LIBPNG 3 "April 21, 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.0.1 March 15, 1998
|
||||
libpng version 1.0.1a April 21, 1998
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<randeg@alumni.rpi.edu>
|
||||
Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
@ -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.
|
||||
@ -1412,6 +1415,8 @@ png_infop info_ptr;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
.SH IV. Writing
|
||||
|
||||
Much of this is very similar to reading. However, everything of
|
||||
@ -1504,9 +1509,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 +1785,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 +1905,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:
|
||||
|
||||
@ -2366,7 +2372,7 @@ possible without all of you.
|
||||
|
||||
Thanks to Frank J. T. Wojcik for helping with the documentation.
|
||||
|
||||
Libpng version 1.0.1 March 15, 1998:
|
||||
Libpng version 1.0.1a April 21, 1998:
|
||||
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
|
||||
Currently maintained by Glenn Randers-Pehrson (randeg@alumni.rpi.edu).
|
||||
|
||||
|
31
libpng.txt
31
libpng.txt
@ -1,6 +1,6 @@
|
||||
libpng.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.0.1 March 15, 1998
|
||||
libpng version 1.0.1a April 21, 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
|
||||
@ -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.
|
||||
@ -1110,9 +1113,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 +1389,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 +1509,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:
|
||||
|
||||
@ -1886,4 +1890,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 15, 1998"
|
||||
.TH LIBPNGPF 3 "April 21, 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 15, 1998"
|
||||
.TH PNG 5 "April 21, 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.0.1
|
||||
* libpng 1.0.1a
|
||||
* 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 15, 1998
|
||||
* April 21, 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[12] = "1.0.1";
|
||||
char png_libpng_ver[12] = "1.0.1a";
|
||||
|
||||
/* Place to hold the signature string for a PNG file. */
|
||||
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
|
18
png.h
18
png.h
@ -1,12 +1,12 @@
|
||||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng 1.0.1
|
||||
* libpng 1.0.1a
|
||||
* 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 15, 1998
|
||||
* April 21, 1998
|
||||
*
|
||||
* Note about libpng version numbers:
|
||||
*
|
||||
@ -31,6 +31,7 @@
|
||||
* 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
|
||||
*
|
||||
* Henceforth the source version will match the shared-library minor
|
||||
* and patch numbers; the shared-library major version number will be
|
||||
@ -39,9 +40,8 @@
|
||||
* 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:
|
||||
@ -118,14 +118,14 @@ extern "C" {
|
||||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.0.1"
|
||||
#define PNG_LIBPNG_VER_STRING "1.0.1a"
|
||||
|
||||
/* 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 10001 /* 1.0.1 */
|
||||
#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)
|
||||
@ -589,7 +589,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;
|
||||
@ -1590,7 +1590,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).
|
||||
|
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng 1.0.1
|
||||
* libpng 1.0.1a
|
||||
* 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 15, 1998
|
||||
* April 21, 1998
|
||||
*/
|
||||
|
||||
/* Any machine specific code is near the front of this file, so if you
|
||||
|
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* libpng 1.0.1
|
||||
* libpng 1.0.1a
|
||||
* 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 15, 1998
|
||||
* April 21, 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.0.1
|
||||
* libpng 1.0.1a
|
||||
* 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 15, 1998
|
||||
* April 21, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
|
6
pngmem.c
6
pngmem.c
@ -1,14 +1,14 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* libpng 1.0.1
|
||||
* libpng 1.0.1a
|
||||
* 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 15, 1998
|
||||
* April 21, 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.0.1
|
||||
* libpng 1.0.1a
|
||||
* 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 15, 1998
|
||||
* April 21, 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;
|
||||
}
|
||||
|
28
pngread.c
28
pngread.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* libpng 1.0.1
|
||||
* libpng 1.0.1a
|
||||
* 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 15, 1998
|
||||
* April 21, 1998
|
||||
*
|
||||
* This file contains routines that an application calls directly to
|
||||
* read a PNG file or stream.
|
||||
@ -125,7 +125,7 @@ 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 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.
|
||||
@ -522,7 +522,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 +530,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++;
|
||||
@ -728,8 +729,9 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
if (png_ptr->gamma_16_table != NULL)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (1 << (8 - png_ptr->gamma_shift)); i++)
|
||||
int i,istop;
|
||||
istop = (1 << (8 - png_ptr->gamma_shift));
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->gamma_16_table[i]);
|
||||
}
|
||||
@ -739,8 +741,9 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
png_free(png_ptr, png_ptr->gamma_16_table);
|
||||
if (png_ptr->gamma_16_from_1 != NULL)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (1 << (8 - png_ptr->gamma_shift)); i++)
|
||||
int i,istop;
|
||||
istop = (1 << (8 - png_ptr->gamma_shift));
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->gamma_16_from_1[i]);
|
||||
}
|
||||
@ -748,8 +751,9 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
png_free(png_ptr, png_ptr->gamma_16_from_1);
|
||||
if (png_ptr->gamma_16_to_1 != NULL)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (1 << (8 - png_ptr->gamma_shift)); i++)
|
||||
int i,istop;
|
||||
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.0.1
|
||||
* libpng 1.0.1a
|
||||
* 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 15, 1998
|
||||
* April 21, 1998
|
||||
*
|
||||
* This file provides a location for all input. Users which need
|
||||
* special handling are expected to write a function which has the same
|
||||
|
579
pngrtran.c
579
pngrtran.c
File diff suppressed because it is too large
Load Diff
263
pngrutil.c
263
pngrutil.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* libpng 1.0.1
|
||||
* libpng 1.0.1a
|
||||
* 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 15, 1998
|
||||
* April 21, 1998
|
||||
*
|
||||
* This file contains routines which are only called from within
|
||||
* libpng itself during the course of reading an image.
|
||||
@ -76,9 +76,10 @@ 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_uint_32 i,istop;
|
||||
|
||||
for (i = skip; i > (png_uint_32)png_ptr->zbuf_size; i -= png_ptr->zbuf_size)
|
||||
istop = (png_uint_32)png_ptr->zbuf_size;
|
||||
for (i = skip; i > istop; i -= istop)
|
||||
{
|
||||
png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);
|
||||
}
|
||||
@ -258,20 +259,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 +336,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 +760,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,7 +1083,7 @@ 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++)
|
||||
for (buf = purpose; *buf; buf++)
|
||||
/* empty loop */ ;
|
||||
|
||||
endptr = purpose + slength;
|
||||
@ -1113,7 +1121,7 @@ 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");
|
||||
}
|
||||
|
||||
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");
|
||||
@ -1497,7 +1505,7 @@ png_combine_row(png_structp png_ptr, png_bytep row,
|
||||
int s_inc, s_start, s_end;
|
||||
int m;
|
||||
int shift;
|
||||
png_uint_32 i;
|
||||
png_uint_32 i, istop;
|
||||
|
||||
sp = png_ptr->row_buf + 1;
|
||||
dp = row;
|
||||
@ -1519,7 +1527,8 @@ png_combine_row(png_structp png_ptr, png_bytep row,
|
||||
|
||||
shift = s_start;
|
||||
|
||||
for (i = 0; i < png_ptr->width; i++)
|
||||
istop = png_ptr->width;
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
if (m & mask)
|
||||
{
|
||||
@ -1553,7 +1562,7 @@ png_combine_row(png_structp png_ptr, png_bytep row,
|
||||
int s_start, s_end, s_inc;
|
||||
int m;
|
||||
int shift;
|
||||
png_uint_32 i;
|
||||
png_uint_32 i,istop;
|
||||
int value;
|
||||
|
||||
sp = png_ptr->row_buf + 1;
|
||||
@ -1576,7 +1585,8 @@ png_combine_row(png_structp png_ptr, png_bytep row,
|
||||
|
||||
shift = s_start;
|
||||
|
||||
for (i = 0; i < png_ptr->width; i++)
|
||||
istop = png_ptr->width;
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
if (m & mask)
|
||||
{
|
||||
@ -1607,7 +1617,7 @@ png_combine_row(png_structp png_ptr, png_bytep row,
|
||||
int s_start, s_end, s_inc;
|
||||
int m;
|
||||
int shift;
|
||||
png_uint_32 i;
|
||||
png_uint_32 i,istop;
|
||||
int value;
|
||||
|
||||
sp = png_ptr->row_buf + 1;
|
||||
@ -1629,7 +1639,8 @@ png_combine_row(png_structp png_ptr, png_bytep row,
|
||||
}
|
||||
shift = s_start;
|
||||
|
||||
for (i = 0; i < png_ptr->width; i++)
|
||||
istop = png_ptr->width;
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
if (m & mask)
|
||||
{
|
||||
@ -1658,7 +1669,7 @@ png_combine_row(png_structp png_ptr, png_bytep row,
|
||||
png_bytep sp;
|
||||
png_bytep dp;
|
||||
png_size_t pixel_bytes;
|
||||
png_uint_32 i;
|
||||
png_uint_32 i, istop;
|
||||
png_byte m;
|
||||
|
||||
pixel_bytes = (png_ptr->row_info.pixel_depth >> 3);
|
||||
@ -1666,7 +1677,8 @@ png_combine_row(png_structp png_ptr, png_bytep row,
|
||||
sp = png_ptr->row_buf + 1;
|
||||
dp = row;
|
||||
m = 0x80;
|
||||
for (i = 0; i < png_ptr->width; i++)
|
||||
istop = png_ptr->width;
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
if (m & mask)
|
||||
{
|
||||
@ -1708,7 +1720,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
int s_start, s_end, s_inc;
|
||||
png_byte v;
|
||||
png_uint_32 i;
|
||||
int j;
|
||||
int j, jstop;
|
||||
|
||||
sp = row + (png_size_t)((row_info->width - 1) >> 3);
|
||||
dp = row + (png_size_t)((final_width - 1) >> 3);
|
||||
@ -1731,10 +1743,11 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
s_inc = 1;
|
||||
}
|
||||
|
||||
jstop = png_pass_inc[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);
|
||||
@ -1762,6 +1775,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
int sshift, dshift;
|
||||
int s_start, s_end, s_inc;
|
||||
png_uint_32 i;
|
||||
int jstop;
|
||||
|
||||
sp = row + (png_uint_32)((row_info->width - 1) >> 2);
|
||||
dp = row + (png_uint_32)((final_width - 1) >> 2);
|
||||
@ -1784,13 +1798,14 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
s_inc = 2;
|
||||
}
|
||||
|
||||
jstop = png_pass_inc[pass];
|
||||
for (i = row_info->width; i; i--)
|
||||
{
|
||||
png_byte v;
|
||||
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);
|
||||
@ -1818,6 +1833,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
int sshift, dshift;
|
||||
int s_start, s_end, s_inc;
|
||||
png_uint_32 i;
|
||||
int jstop;
|
||||
|
||||
sp = row + (png_size_t)((row_info->width - 1) >> 1);
|
||||
dp = row + (png_size_t)((final_width - 1) >> 1);
|
||||
@ -1840,13 +1856,14 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
s_inc = 4;
|
||||
}
|
||||
|
||||
jstop = png_pass_inc[pass];
|
||||
for (i = row_info->width; i; i--)
|
||||
{
|
||||
png_byte v;
|
||||
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);
|
||||
@ -1872,19 +1889,21 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
int jstop;
|
||||
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;
|
||||
jstop = png_pass_inc[pass];
|
||||
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 +1920,165 @@ 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)
|
||||
{
|
||||
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, istop;
|
||||
int bpp;
|
||||
png_bytep rp;
|
||||
png_bytep lp;
|
||||
|
||||
bpp = (row_info->pixel_depth + 7) / 8;
|
||||
istop = row_info->rowbytes;
|
||||
for (i = (png_uint_32)bpp, rp = row + bpp, lp = row;
|
||||
i < istop; i++, rp++, lp++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) + (int)(*lp)) & 0xff);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PNG_FILTER_VALUE_UP:
|
||||
{
|
||||
png_uint_32 i, istop;
|
||||
png_bytep rp;
|
||||
png_bytep pp;
|
||||
|
||||
istop = row_info->rowbytes;
|
||||
for (i = 0, rp = row, pp = prev_row; i < istop; i++, rp++, pp++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) + (int)(*pp)) & 0xff);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PNG_FILTER_VALUE_AVG:
|
||||
{
|
||||
png_uint_32 i, istop;
|
||||
int bpp;
|
||||
png_bytep rp;
|
||||
png_bytep pp;
|
||||
png_bytep lp;
|
||||
|
||||
bpp = (row_info->pixel_depth + 7) / 8;
|
||||
istop = (png_uint_32)bpp;
|
||||
for (i = 0, rp = row, pp = prev_row; i < istop; i++, rp++, pp++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) +
|
||||
((int)(*pp) / 2)) & 0xff);
|
||||
}
|
||||
|
||||
istop = row_info->rowbytes;
|
||||
for (lp = row; i < istop; i++, rp++,
|
||||
lp++, pp++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) +
|
||||
(int)(*pp + *lp) / 2) & 0xff);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PNG_FILTER_VALUE_PAETH:
|
||||
{
|
||||
int bpp;
|
||||
png_uint_32 i, istop;
|
||||
png_bytep rp;
|
||||
png_bytep pp;
|
||||
png_bytep lp;
|
||||
png_bytep cp;
|
||||
|
||||
bpp = (row_info->pixel_depth + 7) / 8;
|
||||
#ifndef PNG_SLOW_PAETH
|
||||
istop=bpp;
|
||||
for (i = 0, rp = row, pp = prev_row; i < istop;
|
||||
i++, rp++, pp++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) + (int)(*pp)) & 0xff);
|
||||
}
|
||||
|
||||
istop=row_info->rowbytes;
|
||||
for (lp = row, cp = prev_row; i < istop; /* use leftover i,rp,pp */
|
||||
i++, rp++, pp++, lp++, cp++)
|
||||
{
|
||||
int a, b, c, pa, pb, pc, p;
|
||||
|
||||
a = *lp;
|
||||
b = *pp;
|
||||
c = *cp;
|
||||
|
||||
p = a + b - c;
|
||||
#ifdef PNG_USE_ABS
|
||||
pa = abs(p - a);
|
||||
pb = abs(p - b);
|
||||
pc = abs(p - c);
|
||||
#else
|
||||
pa = p > a ? p - a : a - p;
|
||||
pb = p > b ? p - b : b - p;
|
||||
pc = p > c ? p - c : c - p;
|
||||
#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);
|
||||
}
|
||||
#else /* PNG_SLOW_PAETH */
|
||||
for (i = 0, rp = row, pp = prev_row,
|
||||
lp = row - bpp, cp = prev_row - bpp,
|
||||
istop = row_info->rowbytes; i < istop; i++, rp++, pp++, lp++, cp++)
|
||||
{
|
||||
int a, b, c, pa, pb, pc, p;
|
||||
|
||||
b = *pp;
|
||||
if (i >= (png_uint_32)bpp)
|
||||
{
|
||||
c = *cp;
|
||||
a = *lp;
|
||||
}
|
||||
else
|
||||
{
|
||||
a = c = 0;
|
||||
}
|
||||
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;
|
||||
|
||||
*rp = (png_byte)(((int)(*rp) + p) & 0xff);
|
||||
}
|
||||
#endif /* PNG_SLOW_PAETH */
|
||||
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)
|
||||
@ -2010,6 +2188,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)
|
||||
@ -2186,8 +2365,20 @@ 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)
|
||||
max_pixel_depth = 32;
|
||||
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
|
||||
|
||||
@ -2216,7 +2407,7 @@ png_read_start_row(png_structp png_ptr)
|
||||
for interlacing */
|
||||
rowbytes = ((png_ptr->width + 7) & ~((png_uint_32)7));
|
||||
/* calculate the maximum bytes needed, adding a byte and a pixel
|
||||
for safety sake */
|
||||
for safety's sake */
|
||||
rowbytes = ((rowbytes * (png_uint_32)max_pixel_depth + 7) >> 3) +
|
||||
1 + ((max_pixel_depth + 7) >> 3);
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
|
7
pngset.c
7
pngset.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* libpng 1.0.1
|
||||
* libpng 1.0.1a
|
||||
* 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 15, 1998
|
||||
* April 21, 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.0.1
|
||||
* libpng 1.0.1a
|
||||
* 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 15, 1998
|
||||
* April 21, 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
|
||||
|
105
pngtrans.c
105
pngtrans.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* libpng 1.0.1
|
||||
* libpng 1.0.1a
|
||||
* 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 15, 1998
|
||||
* April 21, 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
|
||||
|
||||
@ -172,14 +166,13 @@ png_do_swap(png_row_infop row_info, png_bytep row)
|
||||
row_info->bit_depth == 16)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_byte t;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0, rp = row;
|
||||
i < row_info->width * row_info->channels;
|
||||
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 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 < 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 < 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 = 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 < 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 < 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 = 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 < 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 < width; i++)
|
||||
{
|
||||
sp++;
|
||||
*dp++ = *sp++;
|
||||
}
|
||||
}
|
||||
row_info->pixel_depth = 8;
|
||||
row_info->rowbytes = row_info->width;
|
||||
row_info->rowbytes = 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 < 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 < 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 = 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 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 < 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 < 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 < 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 < 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.0.1
|
||||
* libpng 1.0.1a
|
||||
* 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 15, 1998
|
||||
* April 21, 1998
|
||||
*
|
||||
* This file provides a location for all output. Users which need
|
||||
* special handling are expected to write functions which have the same
|
||||
|
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* libpng 1.0.1
|
||||
* libpng 1.0.1a
|
||||
* 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 15, 1998
|
||||
* April 21, 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 - 1],
|
||||
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 - 1],
|
||||
ptime->day % 32, short_months[(ptime->month - 1) % 12],
|
||||
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
||||
ptime->second % 61);
|
||||
#endif
|
||||
|
81
pngwtran.c
81
pngwtran.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* libpng 1.0.1
|
||||
* libpng 1.0.1a
|
||||
* 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 15, 1998
|
||||
* April 21, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@ -96,13 +96,15 @@ 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 i, istop;
|
||||
|
||||
sp = row;
|
||||
dp = row;
|
||||
mask = 0x80;
|
||||
v = 0;
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
|
||||
istop = row_info->width;
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
if (*sp != 0)
|
||||
v |= mask;
|
||||
@ -125,13 +127,14 @@ 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 i, istop;
|
||||
|
||||
sp = row;
|
||||
dp = row;
|
||||
shift = 6;
|
||||
v = 0;
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
istop = row_info->width;
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
png_byte value;
|
||||
|
||||
@ -156,13 +159,14 @@ 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 i, istop;
|
||||
|
||||
sp = row;
|
||||
dp = row;
|
||||
shift = 4;
|
||||
v = 0;
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
istop = row_info->width;
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
png_byte value;
|
||||
|
||||
@ -246,7 +250,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
||||
if (row_info->bit_depth < 8)
|
||||
{
|
||||
png_bytep bp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 i, istop;
|
||||
png_byte mask;
|
||||
|
||||
if (bit_depth->gray == 1 && row_info->bit_depth == 2)
|
||||
@ -256,7 +260,8 @@ 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++)
|
||||
istop = row_info->rowbytes;
|
||||
for (bp = row, i = 0; i < istop; i++, bp++)
|
||||
{
|
||||
png_uint_16 v;
|
||||
int j;
|
||||
@ -275,9 +280,10 @@ 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_uint_32 i;
|
||||
png_uint_32 i, istop;
|
||||
|
||||
for (bp = row, i = 0; i < row_info->width; i++)
|
||||
istop = row_info->width;
|
||||
for (bp = row, i = 0; i < istop; i++)
|
||||
{
|
||||
png_uint_32 c;
|
||||
|
||||
@ -301,9 +307,10 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
||||
else
|
||||
{
|
||||
png_bytep bp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 i, istop;
|
||||
|
||||
for (bp = row, i = 0; i < row_info->width * row_info->channels; i++)
|
||||
istop = row_info->width;
|
||||
for (bp = row, i = 0; i < istop; i++)
|
||||
{
|
||||
png_uint_32 c;
|
||||
|
||||
@ -345,12 +352,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 i, istop;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_info->width; i++)
|
||||
istop = row_info->width;
|
||||
for (i = 0, sp = dp = row; i < istop; i++)
|
||||
{
|
||||
save = *(sp++);
|
||||
png_byte save = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
@ -361,11 +368,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 i, istop;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_info->width; i++)
|
||||
istop = row_info->width;
|
||||
for (i = 0, sp = dp = row; i < istop; i++)
|
||||
{
|
||||
png_byte save[2];
|
||||
save[0] = *(sp++);
|
||||
save[1] = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
@ -385,12 +393,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;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_info->width; i++)
|
||||
istop = row_info->width;
|
||||
for (i = 0, sp = dp = row; i < istop; i++)
|
||||
{
|
||||
save = *(sp++);
|
||||
png_byte save = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = save;
|
||||
}
|
||||
@ -399,11 +407,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;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_info->width; i++)
|
||||
istop = row_info->width;
|
||||
for (i = 0, sp = dp = row; i < istop; i++)
|
||||
{
|
||||
png_byte save[2];
|
||||
save[0] = *(sp++);
|
||||
save[1] = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
@ -432,9 +441,10 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 i, istop;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_info->width; i++)
|
||||
istop = row_info->width;
|
||||
for (i = 0, sp = dp = row; i < istop; i++)
|
||||
{
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
@ -446,9 +456,10 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
else
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 i, istop;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_info->width; i++)
|
||||
istop = row_info->width;
|
||||
for (i = 0, sp = dp = row; i < istop; i++)
|
||||
{
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
@ -467,9 +478,10 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 i, istop;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_info->width; i++)
|
||||
istop = row_info->width;
|
||||
for (i = 0, sp = dp = row; i < istop; i++)
|
||||
{
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = 255 - *(sp++);
|
||||
@ -479,9 +491,10 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
else
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 i, istop;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_info->width; i++)
|
||||
istop = row_info->width;
|
||||
for (i = 0, sp = dp = row; i < istop; i++)
|
||||
{
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
|
216
pngwutil.c
216
pngwutil.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* libpng 1.0.1
|
||||
* libpng 1.0.1a
|
||||
* 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 15, 1998
|
||||
* April 21, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@ -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:
|
||||
@ -1251,12 +1251,13 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
int shift;
|
||||
int d;
|
||||
int value;
|
||||
png_uint_32 i;
|
||||
png_uint_32 i, istop;
|
||||
|
||||
dp = row;
|
||||
d = 0;
|
||||
shift = 7;
|
||||
for (i = png_pass_start[pass]; i < row_info->width;
|
||||
istop = row_info->width;
|
||||
for (i = png_pass_start[pass]; i < istop;
|
||||
i += png_pass_inc[pass])
|
||||
{
|
||||
sp = row + (png_size_t)(i >> 3);
|
||||
@ -1284,12 +1285,13 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
int shift;
|
||||
int d;
|
||||
int value;
|
||||
png_uint_32 i;
|
||||
png_uint_32 i, istop;
|
||||
|
||||
dp = row;
|
||||
shift = 6;
|
||||
d = 0;
|
||||
for (i = png_pass_start[pass]; i < row_info->width;
|
||||
istop = row_info->width;
|
||||
for (i = png_pass_start[pass]; i < istop;
|
||||
i += png_pass_inc[pass])
|
||||
{
|
||||
sp = row + (png_size_t)(i >> 2);
|
||||
@ -1316,12 +1318,13 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
int shift;
|
||||
int d;
|
||||
int value;
|
||||
png_uint_32 i;
|
||||
png_uint_32 i, istop;
|
||||
|
||||
dp = row;
|
||||
shift = 4;
|
||||
d = 0;
|
||||
for (i = png_pass_start[pass]; i < row_info->width;
|
||||
istop = row_info->width;
|
||||
for (i = png_pass_start[pass]; i < istop;
|
||||
i += png_pass_inc[pass])
|
||||
{
|
||||
sp = row + (png_size_t)(i >> 1);
|
||||
@ -1345,7 +1348,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 i, istop;
|
||||
png_size_t pixel_bytes;
|
||||
|
||||
/* start at the beginning */
|
||||
@ -1354,7 +1357,8 @@ 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;
|
||||
istop = row_info->width;
|
||||
for (i = png_pass_start[pass]; i < istop;
|
||||
i += png_pass_inc[pass])
|
||||
{
|
||||
/* find out where the original pixel is */
|
||||
@ -1392,6 +1396,7 @@ 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_debug(1, "in png_write_find_filter\n");
|
||||
/* find out how many bytes offset each pixel is */
|
||||
@ -1405,7 +1410,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 +1418,20 @@ 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;
|
||||
png_uint_32 i,istop;
|
||||
int v;
|
||||
|
||||
for (i = 0, rp = row_buf + 1; i < row_info->rowbytes; i++, rp++)
|
||||
istop = row_info->rowbytes;
|
||||
for (i = 0, rp = row_buf + 1; i < istop; i++, rp++)
|
||||
{
|
||||
v = *rp;
|
||||
sum += (v < 128) ? v : 256 - v;
|
||||
@ -1438,9 +1445,10 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
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++)
|
||||
istop = (png_uint_32)png_ptr->num_prev_filters;
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_NONE)
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_NONE)
|
||||
{
|
||||
sumlo = (sumlo * png_ptr->filter_weights[i]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
@ -1468,15 +1476,34 @@ 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,istop;
|
||||
for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp;
|
||||
i++, rp++, dp++)
|
||||
{
|
||||
*dp = *rp;
|
||||
}
|
||||
istop = row_info->rowbytes;
|
||||
for (lp = row_buf + 1; i < istop;
|
||||
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;
|
||||
png_uint_32 i;
|
||||
png_uint_32 i, istop;
|
||||
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.
|
||||
*/
|
||||
@ -1486,7 +1513,8 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
lmlo = lmins & PNG_LOMASK;
|
||||
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
|
||||
|
||||
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
|
||||
istop = (png_uint_32)png_ptr->num_prev_filters;
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_SUB)
|
||||
{
|
||||
@ -1534,7 +1562,8 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
sumlo = sum & PNG_LOMASK;
|
||||
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
|
||||
|
||||
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
|
||||
istop = (png_uint_32)png_ptr->num_prev_filters;
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_SUB)
|
||||
{
|
||||
@ -1565,13 +1594,29 @@ 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, istop;
|
||||
|
||||
istop = row_info->rowbytes;
|
||||
for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,
|
||||
pp = prev_row + 1; i < istop;
|
||||
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;
|
||||
png_uint_32 i, istop;
|
||||
int v;
|
||||
|
||||
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
||||
{
|
||||
@ -1579,7 +1624,8 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
lmlo = lmins & PNG_LOMASK;
|
||||
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
|
||||
|
||||
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
|
||||
istop = (png_uint_32)png_ptr->num_prev_filters;
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_UP)
|
||||
{
|
||||
@ -1602,8 +1648,9 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
}
|
||||
#endif
|
||||
|
||||
istop = row_info->rowbytes;
|
||||
for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,
|
||||
pp = prev_row + 1; i < row_info->rowbytes;
|
||||
pp = prev_row + 1; i < istop;
|
||||
i++, rp++, pp++, dp++)
|
||||
{
|
||||
v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
|
||||
@ -1621,9 +1668,10 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
sumlo = sum & PNG_LOMASK;
|
||||
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
|
||||
|
||||
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
|
||||
istop = (png_uint_32)png_ptr->num_prev_filters;
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_UP)
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_UP)
|
||||
{
|
||||
sumlo = (sumlo * png_ptr->filter_weights[i]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
@ -1652,11 +1700,28 @@ 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,istop;
|
||||
for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1,
|
||||
pp = prev_row + 1; i < bpp; i++, rp++, pp++, dp++)
|
||||
{
|
||||
*dp = (png_byte)(((int)*rp - ((int)*pp / 2)) & 0xff);
|
||||
}
|
||||
istop = row_info->rowbytes;
|
||||
for (lp = row_buf + 1; i < istop; i++, rp++, pp++, lp++, dp++)
|
||||
{
|
||||
*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;
|
||||
png_uint_32 i;
|
||||
png_uint_32 i,istop;
|
||||
int v;
|
||||
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
@ -1666,7 +1731,8 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
lmlo = lmins & PNG_LOMASK;
|
||||
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
|
||||
|
||||
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
|
||||
istop = (png_uint_32)png_ptr->num_prev_filters;
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_AVG)
|
||||
{
|
||||
@ -1696,8 +1762,8 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
|
||||
sum += (v < 128) ? v : 256 - v;
|
||||
}
|
||||
for (lp = row_buf + 1; i < row_info->rowbytes;
|
||||
i++, rp++, pp++, lp++, dp++)
|
||||
istop = row_info->rowbytes;
|
||||
for (lp = row_buf + 1; i < istop; i++, rp++, pp++, lp++, dp++)
|
||||
{
|
||||
v = *dp = (png_byte)(((int)*rp - (((int)*pp + (int)*lp) / 2)) & 0xff);
|
||||
|
||||
@ -1714,9 +1780,10 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
sumlo = sum & PNG_LOMASK;
|
||||
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
|
||||
|
||||
for (i = 0; i < png_ptr->num_prev_filters; i++)
|
||||
istop = png_ptr->num_prev_filters;
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_NONE)
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_NONE)
|
||||
{
|
||||
sumlo = (sumlo * png_ptr->filter_weights[i]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
@ -1745,11 +1812,50 @@ 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, istop;
|
||||
for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1,
|
||||
pp = prev_row + 1; i < bpp; i++, rp++, pp++, dp++)
|
||||
{
|
||||
*dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
|
||||
}
|
||||
|
||||
istop = row_info->rowbytes;
|
||||
for (lp = row_buf + 1, cp = prev_row + 1; i < istop;
|
||||
i++, rp++, pp++, lp++, dp++, cp++)
|
||||
{
|
||||
int a, b, c, pa, pb, pc, p;
|
||||
|
||||
b = *pp;
|
||||
c = *cp;
|
||||
a = *lp;
|
||||
|
||||
p = a + b - c;
|
||||
|
||||
#ifdef PNG_USE_ABS
|
||||
pa = abs(p - a);
|
||||
pb = abs(p - b);
|
||||
pc = abs(p - c);
|
||||
#else
|
||||
pa = p > a ? p - a : a - p;
|
||||
pb = p > b ? p - b : b - p;
|
||||
pc = p > c ? p - c : c - p;
|
||||
#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;
|
||||
png_uint_32 i;
|
||||
png_uint_32 i, istop;
|
||||
int v;
|
||||
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
@ -1759,7 +1865,8 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
lmlo = lmins & PNG_LOMASK;
|
||||
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
|
||||
|
||||
for (i = 0; i < png_ptr->num_prev_filters; i++)
|
||||
istop = png_ptr->num_prev_filters;
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_PAETH)
|
||||
{
|
||||
@ -1783,13 +1890,15 @@ 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++, rp++, pp++, dp++)
|
||||
{
|
||||
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;
|
||||
|
||||
istop = row_info->rowbytes;
|
||||
for (lp = row_buf + 1, cp = prev_row + 1; i < istop;
|
||||
i++, rp++, pp++, lp++, dp++, cp++)
|
||||
{
|
||||
int a, b, c, pa, pb, pc, p;
|
||||
@ -1799,16 +1908,30 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
a = *lp;
|
||||
|
||||
p = a + b - c;
|
||||
|
||||
#ifndef PNG_SLOW_PAETH
|
||||
#ifdef PNG_USE_ABS
|
||||
pa = abs(p - a);
|
||||
pb = abs(p - b);
|
||||
pc = abs(p - c);
|
||||
#else
|
||||
pa = p > a ? p - a : a - p;
|
||||
pb = p > b ? p - b : b - p;
|
||||
pc = p > c ? p - c : c - p;
|
||||
#endif
|
||||
|
||||
p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
|
||||
#else /* PNG_SLOW_PAETH */
|
||||
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);
|
||||
|
||||
@ -1825,9 +1948,10 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
sumlo = sum & PNG_LOMASK;
|
||||
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
|
||||
|
||||
for (i = 0; i < png_ptr->num_prev_filters; i++)
|
||||
istop = png_ptr->num_prev_filters;
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_PAETH)
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_PAETH)
|
||||
{
|
||||
sumlo = (sumlo * png_ptr->filter_weights[i]) >>
|
||||
PNG_WEIGHT_SHIFT;
|
||||
@ -1855,15 +1979,17 @@ 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;
|
||||
int i, istop;
|
||||
|
||||
for (i = 1; i < (int)png_ptr->num_prev_filters; i++)
|
||||
istop = (int)png_ptr->num_prev_filters;
|
||||
for (i = 1; i < istop; i++)
|
||||
{
|
||||
png_ptr->prev_filters[i] = png_ptr->prev_filters[i - 1];
|
||||
}
|
||||
|
@ -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.0
|
||||
PNGMIN = 1.0.1a
|
||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||
|
||||
# where make install puts libpng.a, libpng.so*, and png.h
|
||||
|
@ -20,7 +20,7 @@ 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
|
||||
@ -29,7 +29,7 @@ RANLIB=echo
|
||||
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
||||
# have to change it.
|
||||
PNGMAJ = 2
|
||||
PNGMIN = 1.0
|
||||
PNGMIN = 1.0.1a
|
||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||
|
||||
# where make install puts libpng.a, libpng.so*, and png.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 and later 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 and later -------------
|
||||
# ------------- 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
|
||||
|
Reference in New Issue
Block a user