Skip to content

Commit

Permalink
Update to PNG 1.5.7.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Dec 29, 2011
1 parent 94f7c8f commit 406bebf
Show file tree
Hide file tree
Showing 35 changed files with 19,688 additions and 10,526 deletions.
53 changes: 26 additions & 27 deletions htmldoc/image-png.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ hdPNGImage::real_load(int img, // I - 1 = load image data, 0 = just info
int i, j; // Looping vars
png_structp pp; // PNG read pointer
png_infop info; // PNG info pointers
int info_width, info_height;// Dimensions of image
int d; // Depth of image
png_bytep *rows; // PNG row pointers
png_bytep local; // Local image data...
Expand All @@ -107,15 +108,25 @@ hdPNGImage::real_load(int img, // I - 1 = load image data, 0 = just info
// Get the image dimensions and convert to grayscale or RGB...
png_read_info(pp, info);

if (info->color_type == PNG_COLOR_TYPE_PALETTE)
info_width = (int)png_get_image_width(pp, info);
info_height = (int)png_get_image_height(pp, info);

if (png_get_color_type(pp, info) & PNG_COLOR_MASK_PALETTE)
png_set_expand(pp);
else if (png_get_bit_depth(pp, info) < 8)
{
png_set_packing(pp);
png_set_expand(pp);
}
else if (png_get_bit_depth(pp, info) == 16)
png_set_strip_16(pp);

if (info->color_type & PNG_COLOR_MASK_COLOR)
if (png_get_color_type(pp, info) & PNG_COLOR_MASK_COLOR)
d = 3;
else
d = 1;

set_size(info->width, info->height, gs ? 1 : d);
set_size(info_width, info_height, gs ? 1 : d);

if (!img)
{
Expand All @@ -126,70 +137,58 @@ hdPNGImage::real_load(int img, // I - 1 = load image data, 0 = just info

alloc_pixels();

if ((info->color_type & PNG_COLOR_MASK_ALPHA) || info->num_trans)
if (png_get_color_type(pp, info) & PNG_COLOR_MASK_ALPHA)
d ++;

if (!(d & 1))
alloc_mask();

if (info->bit_depth < 8)
{
png_set_packing(pp);
png_set_expand(pp);
}
else if (info->bit_depth == 16)
png_set_strip_16(pp);

// Handle transparency...
if (png_get_valid(pp, info, PNG_INFO_tRNS))
png_set_tRNS_to_alpha(pp);

// Allocate a local copy of the image as needed...
if (depth() != d)
local = new png_byte[info->width * info->height * d];
local = new png_byte[info_width * info_height * d];
else
local = (png_bytep)pixels();

// Allocate memory and setup the pointers for the whole image...
rows = new png_bytep[info->height];
rows = new png_bytep[info_height];

for (i = 0; i < (int)info->height; i ++)
rows[i] = local + i * info->width * d;
for (i = 0; i < (int)info_height; i ++)
rows[i] = local + i * info_width * d;

// Read the image, handling interlacing as needed...
for (i = png_set_interlace_handling(pp); i > 0; i --)
png_read_rows(pp, rows, NULL, info->height);
png_read_rows(pp, rows, NULL, info_height);

// Reformat the data as necessary for the reader...
if (local != pixels())
{
if (d == 3)
{
// Convert to grayscale...
for (i = (int)info->height, pixelptr = pixels(), localptr = local;
i > 0;
i --)
for (j = (int)info->width; j > 0; j --, localptr += 3)
for (i = info_height, pixelptr = pixels(), localptr = local; i > 0; i --)
for (j = info_width; j > 0; j --, localptr += 3)
*pixelptr++ = (31 * localptr[0] + 61 * localptr[1] +
8 * localptr[2]) / 100;
}
else
{
// Handle transparency and possibly convert to grayscale...
for (i = 0, pixelptr = pixels(), localptr = local;
i < (int)info->height;
i ++)
for (i = 0, pixelptr = pixels(), localptr = local; i < info_height; i ++)
if (d == 2)
{
for (j = 0; j < (int)info->width; j ++, localptr += 2)
for (j = 0; j < info_width; j ++, localptr += 2)
{
*pixelptr++ = localptr[0];
set_mask(j, i, localptr[1]);
}
}
else if (gs)
{
for (j = 0; j < (int)info->width; j ++, localptr += 4)
for (j = 0; j < info_width; j ++, localptr += 4)
{
*pixelptr++ = (31 * localptr[0] + 61 * localptr[1] +
8 * localptr[2]) / 100;
Expand All @@ -198,7 +197,7 @@ hdPNGImage::real_load(int img, // I - 1 = load image data, 0 = just info
}
else
{
for (j = 0; j < (int)info->width; j ++)
for (j = 0; j < info_width; j ++)
{
*pixelptr++ = *localptr++;
*pixelptr++ = *localptr++;
Expand Down
118 changes: 76 additions & 42 deletions png/ANNOUNCE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Libpng 1.4.1 - February 25, 2010
Libpng 1.5.7 - December 15, 2011

This is a public release of libpng, intended for use in production codes.

Expand All @@ -8,57 +8,91 @@ Files available for download:
Source files with LF line endings (for Unix/Linux) and with a
"configure" script

libpng-1.4.1.tar.xz (LZMA-compressed, recommended)
libpng-1.4.1.tar.gz
libpng-1.4.1.tar.bz2
libpng-1.5.7.tar.xz (LZMA-compressed, recommended)
libpng-1.5.7.tar.gz
libpng-1.5.7.tar.bz2

Source files with CRLF line endings (for Windows), without the
"configure" script

lpng141.zip
lpng141.7z
lpng157.7z (LZMA-compressed, recommended)
lpng157.zip

Other information:

libpng-1.4.1-README.txt
libpng-1.4.1-LICENSE.txt
libpng-1.5.7-README.txt
libpng-1.5.7-LICENSE.txt

Changes since the last public release (1.4.0):

version 1.4.1 [February 25, 2010]

Updated CMakeLists.txt for consistent indentation and to avoid an
unclosed if-statement warning (Philip Lowman).
Revised Makefile.am and Makefile.in to remove references to Y2KINFO,
KNOWNBUG, and libpng.la (Robert Schwebel).
Revised the makefiles to install the same files and symbolic
except for libpng.la and libpng14.la.
Make png_set|get_compression_buffer_size() available even when
PNG_WRITE_SUPPORTED is not enabled.
Revised Makefile.am and Makefile.in to simplify their maintenance.
Revised the makefiles to install a link to libpng14.so.14.1
Removed png_set_premultiply_alpha() from scripts/*.def
Revised png_decompress_chunk() to improve speed and memory usage when
decoding large chunks, using a two-pass method suggested by John Bowler.
Added png_set|get_chunk_malloc_max() functions.
Relocated "int k" declaration in pngtest.c to minimize its scope.
Folded some long lines in the source files.
Added defineable PNG_USER_CHUNK_CACHE_MAX and PNG_USER_CHUNK_MALLOC_MAX
Eliminated use of png_ptr->irowbytes and reused the slot in png_ptr as
png_ptr->png_user_chunk_malloc_max.
Return allocated "old_buffer" in png_push_save_buffer() before calling
png_error(), to avoid a potential memory leak.
Removed the cbuilder5 project, which has not been updated to 1.4.0.
Complete rewrite of two-pass png_decompress_chunk() by John Bowler.
Removed obsolete unused MMX-querying support from contrib/gregbook
Removed the AIX redefinition of jmpbuf in png.h
Define _ALL_SOURCE in configure.ac, makefile.aix, and CMakeLists.txt
when using AIX compiler.
Removed unused gzio.c from contrib/pngminim gather and makefile scripts
Changes since the last public release (1.5.6):
Added support for ARM processor (Mans Rullgard)
Fixed bug in pngvalid on early allocation failure; fixed type cast in
pngmem.c; pngvalid would attempt to call png_error() if the allocation
of a png_struct or png_info failed. This would probably have led to a
crash. The pngmem.c implementation of png_malloc() included a cast
to png_size_t which would fail on large allocations on 16-bit systems.
Fix for the preprocessor of the Intel C compiler. The preprocessor
splits adjacent @ signs with a space; this changes the concatentation
token from @-@-@ to PNG_JOIN; that should work with all compiler
preprocessors.
Paeth filter speed improvements from work by Siarhei Siamashka. This
changes the 'Paeth' reconstruction function to improve the GCC code
generation on x86. The changes are only part of the suggested ones;
just the changes that definitely improve speed and remain simple.
The changes also slightly increase the clarity of the code.
Check compression_type parameter in png_get_iCCP and remove spurious
casts. The compression_type parameter is always assigned to, so must
be non-NULL. The cast of the profile length potentially truncated the
value unnecessarily on a 16-bit int system, so the cast of the (byte)
compression type to (int) is specified by ANSI-C anyway.
Fixed FP division by zero in pngvalid.c; the 'test_pixel' code left
the sBIT fields in the test pixel as 0, which resulted in a floating
point division by zero which was irrelevant but causes systems where
FP exceptions cause a crash. Added code to pngvalid to turn on FP
exceptions if the appropriate glibc support is there to ensure this is
tested in the future.
Added versioning to pnglibconf.h comments.
Installed more accurate linear to sRGB conversion tables. The slightly
modified tables reduce the number of 16-bit values that
convert to an off-by-one 8-bit value. The "makesRGB.c" code that was used
to generate the tables is now in a contrib/sRGBtables sub-directory.
Added run-time detection of NEON support.
Multiple transform bug fixes plus a work-round for double gamma correction.
libpng does not support more than one transform that requires linear data
at once - if this is tried typically the results is double gamma
correction. Since the simplified APIs can need rgb to gray combined with
a compose operation it is necessary to do one of these outside the main
libpng transform code. This check-in also contains fixes to various bugs
in compose and rgb to gray (on palette).
Fixes for C++ compilation using g++ When libpng source is compiled
using g++. The compiler imposes C++ rules on the C source; thus it
is desireable to make the source work with either C or C++ rules
without throwing away useful error information. This change adds
png_voidcast to allow C semantic (void*) cases or the corresponding
C++ static_cast operation, as appropriate.
Added --noexecstack to assembler file compilation. GCC does not set
this on assembler compilation, even though it does on C compilation.
This creates security issues if assembler code is enabled; the
work-around is to set it by default in the flags for $(CCAS)
Removed "zTXt" from warning in generic chunk decompression function.
Validate time settings passed to pngset() and png_convert_to_rfc1123()
(Frank Busse).
Added MINGW support to CMakeLists.txt
Reject invalid compression flag or method when reading the iTXt chunk.
Moved pngvalid.c into contrib/libtests
Rebuilt Makefile.in, configure, etc., with autoconf-2.68
Replaced an "#if" with "#ifdef" in pngrtran.c
Revised #if PNG_DO_BC block in png.c (use #ifdef and add #else)
Revised pngconf.h to use " __declspec(restrict)" only when MSC_VER >= 1400,
as in libpng-1.5.4.
Put CRLF line endings in the owatcom project files.
Updated CMakeLists.txt to account for the relocation of pngvalid.c
Minor fixes to pngvalid.c for gcc 4.6.2 compatibility to remove warnings
reported by earlier versions.

Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
to subscribe) or to glennrp at users.sourceforge.net
to subscribe)
or to glennrp at users.sourceforge.net

Glenn R-P
Loading

0 comments on commit 406bebf

Please sign in to comment.