Skip to content

Commit 406bebf

Browse files
committed
Update to PNG 1.5.7.
1 parent 94f7c8f commit 406bebf

35 files changed

+19688
-10526
lines changed

htmldoc/image-png.cxx

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ hdPNGImage::real_load(int img, // I - 1 = load image data, 0 = just info
8686
int i, j; // Looping vars
8787
png_structp pp; // PNG read pointer
8888
png_infop info; // PNG info pointers
89+
int info_width, info_height;// Dimensions of image
8990
int d; // Depth of image
9091
png_bytep *rows; // PNG row pointers
9192
png_bytep local; // Local image data...
@@ -107,15 +108,25 @@ hdPNGImage::real_load(int img, // I - 1 = load image data, 0 = just info
107108
// Get the image dimensions and convert to grayscale or RGB...
108109
png_read_info(pp, info);
109110

110-
if (info->color_type == PNG_COLOR_TYPE_PALETTE)
111+
info_width = (int)png_get_image_width(pp, info);
112+
info_height = (int)png_get_image_height(pp, info);
113+
114+
if (png_get_color_type(pp, info) & PNG_COLOR_MASK_PALETTE)
115+
png_set_expand(pp);
116+
else if (png_get_bit_depth(pp, info) < 8)
117+
{
118+
png_set_packing(pp);
111119
png_set_expand(pp);
120+
}
121+
else if (png_get_bit_depth(pp, info) == 16)
122+
png_set_strip_16(pp);
112123

113-
if (info->color_type & PNG_COLOR_MASK_COLOR)
124+
if (png_get_color_type(pp, info) & PNG_COLOR_MASK_COLOR)
114125
d = 3;
115126
else
116127
d = 1;
117128

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

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

127138
alloc_pixels();
128139

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

132143
if (!(d & 1))
133144
alloc_mask();
134145

135-
if (info->bit_depth < 8)
136-
{
137-
png_set_packing(pp);
138-
png_set_expand(pp);
139-
}
140-
else if (info->bit_depth == 16)
141-
png_set_strip_16(pp);
142-
143146
// Handle transparency...
144147
if (png_get_valid(pp, info, PNG_INFO_tRNS))
145148
png_set_tRNS_to_alpha(pp);
146149

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

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

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

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

163166
// Reformat the data as necessary for the reader...
164167
if (local != pixels())
165168
{
166169
if (d == 3)
167170
{
168171
// Convert to grayscale...
169-
for (i = (int)info->height, pixelptr = pixels(), localptr = local;
170-
i > 0;
171-
i --)
172-
for (j = (int)info->width; j > 0; j --, localptr += 3)
172+
for (i = info_height, pixelptr = pixels(), localptr = local; i > 0; i --)
173+
for (j = info_width; j > 0; j --, localptr += 3)
173174
*pixelptr++ = (31 * localptr[0] + 61 * localptr[1] +
174175
8 * localptr[2]) / 100;
175176
}
176177
else
177178
{
178179
// Handle transparency and possibly convert to grayscale...
179-
for (i = 0, pixelptr = pixels(), localptr = local;
180-
i < (int)info->height;
181-
i ++)
180+
for (i = 0, pixelptr = pixels(), localptr = local; i < info_height; i ++)
182181
if (d == 2)
183182
{
184-
for (j = 0; j < (int)info->width; j ++, localptr += 2)
183+
for (j = 0; j < info_width; j ++, localptr += 2)
185184
{
186185
*pixelptr++ = localptr[0];
187186
set_mask(j, i, localptr[1]);
188187
}
189188
}
190189
else if (gs)
191190
{
192-
for (j = 0; j < (int)info->width; j ++, localptr += 4)
191+
for (j = 0; j < info_width; j ++, localptr += 4)
193192
{
194193
*pixelptr++ = (31 * localptr[0] + 61 * localptr[1] +
195194
8 * localptr[2]) / 100;
@@ -198,7 +197,7 @@ hdPNGImage::real_load(int img, // I - 1 = load image data, 0 = just info
198197
}
199198
else
200199
{
201-
for (j = 0; j < (int)info->width; j ++)
200+
for (j = 0; j < info_width; j ++)
202201
{
203202
*pixelptr++ = *localptr++;
204203
*pixelptr++ = *localptr++;

png/ANNOUNCE

Lines changed: 76 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
Libpng 1.4.1 - February 25, 2010
2+
Libpng 1.5.7 - December 15, 2011
33

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

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

11-
libpng-1.4.1.tar.xz (LZMA-compressed, recommended)
12-
libpng-1.4.1.tar.gz
13-
libpng-1.4.1.tar.bz2
11+
libpng-1.5.7.tar.xz (LZMA-compressed, recommended)
12+
libpng-1.5.7.tar.gz
13+
libpng-1.5.7.tar.bz2
1414

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

18-
lpng141.zip
19-
lpng141.7z
18+
lpng157.7z (LZMA-compressed, recommended)
19+
lpng157.zip
2020

2121
Other information:
2222

23-
libpng-1.4.1-README.txt
24-
libpng-1.4.1-LICENSE.txt
23+
libpng-1.5.7-README.txt
24+
libpng-1.5.7-LICENSE.txt
2525

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

5992
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
60-
(subscription required; visit
93+
(subscription required; visit
6194
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
62-
to subscribe) or to glennrp at users.sourceforge.net
95+
to subscribe)
96+
or to glennrp at users.sourceforge.net
6397

6498
Glenn R-P

0 commit comments

Comments
 (0)