Compare commits
493 Commits
v1.5.1
...
v1.6.0beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ead660ae1e | ||
|
|
04afaab56a | ||
|
|
781a90b358 | ||
|
|
61d7058b5b | ||
|
|
db6850b389 | ||
|
|
eda298bc01 | ||
|
|
516c9c97a6 | ||
|
|
0d4d0b4d32 | ||
|
|
5bffd6c6d5 | ||
|
|
816ff328d2 | ||
|
|
34dca8f8e8 | ||
|
|
3167541570 | ||
|
|
6437604a5e | ||
|
|
2dd49fbeae | ||
|
|
f1c0678c16 | ||
|
|
42369ccd85 | ||
|
|
572b078d8c | ||
|
|
40ca77a721 | ||
|
|
05cbe5ae28 | ||
|
|
5cdff4144e | ||
|
|
feecc898d9 | ||
|
|
3a1d63dc69 | ||
|
|
573a51143a | ||
|
|
6690011811 | ||
|
|
dde1f98626 | ||
|
|
aaf1179ec1 | ||
|
|
e044649282 | ||
|
|
a23f3dbcb6 | ||
|
|
a12d2328b4 | ||
|
|
95a8a665e4 | ||
|
|
da2194c0d5 | ||
|
|
1eb2c48458 | ||
|
|
8fb6c6a9b3 | ||
|
|
9c7f99c9cb | ||
|
|
99c7ad2904 | ||
|
|
e7b4d26ec1 | ||
|
|
c35f888c46 | ||
|
|
5635573cfc | ||
|
|
fea2a877c8 | ||
|
|
5bc90389bf | ||
|
|
2312167d51 | ||
|
|
edbcd02133 | ||
|
|
04336ba10f | ||
|
|
da1c5ca65a | ||
|
|
00c6a9a62c | ||
|
|
665031e834 | ||
|
|
0501c1c570 | ||
|
|
1531bd61a0 | ||
|
|
d9fc0622a1 | ||
|
|
6e4184249c | ||
|
|
04ab33560f | ||
|
|
0522f269e0 | ||
|
|
fcd301daed | ||
|
|
4f67e40898 | ||
|
|
f87ef8bcb5 | ||
|
|
a5bf4e3767 | ||
|
|
5d56786eff | ||
|
|
d7c22fb7ec | ||
|
|
939310bac1 | ||
|
|
29fca0d497 | ||
|
|
df477e4652 | ||
|
|
5a956a7a58 | ||
|
|
67ee8cee39 | ||
|
|
28d9339777 | ||
|
|
bc79d70965 | ||
|
|
40b2603687 | ||
|
|
ad41b8838a | ||
|
|
1d7f56ab64 | ||
|
|
3c1c95399b | ||
|
|
d332c67da7 | ||
|
|
b74fb4e49c | ||
|
|
a6f369b150 | ||
|
|
13831bc06e | ||
|
|
adf049e435 | ||
|
|
681c1fc02a | ||
|
|
ba6fbc57ba | ||
|
|
d1dceee2f7 | ||
|
|
94531034cc | ||
|
|
751a93f3ec | ||
|
|
0b3634bcc4 | ||
|
|
efaeadaa86 | ||
|
|
c4f94cbd08 | ||
|
|
26aad85204 | ||
|
|
c4081f05c8 | ||
|
|
eb26ee6602 | ||
|
|
90a87c8853 | ||
|
|
12924f33bd | ||
|
|
ec6d6fa51b | ||
|
|
1f0eaa046c | ||
|
|
6bdefdd977 | ||
|
|
405a398b3e | ||
|
|
8888ea4479 | ||
|
|
0b26ac5dee | ||
|
|
414769b415 | ||
|
|
5e934ba900 | ||
|
|
b72bc15e22 | ||
|
|
4c7e8208b6 | ||
|
|
baeb6d1e92 | ||
|
|
2ddb252d07 | ||
|
|
7455cbf47e | ||
|
|
87fadd5eee | ||
|
|
5b79cd52f4 | ||
|
|
36082cffcd | ||
|
|
e1bb124baa | ||
|
|
15ea1fa337 | ||
|
|
12fb29f951 | ||
|
|
8500b7720b | ||
|
|
e7ad104ac3 | ||
|
|
3b1f03084e | ||
|
|
680da02ade | ||
|
|
8e83631361 | ||
|
|
8501129c17 | ||
|
|
3706d730d1 | ||
|
|
925a60278e | ||
|
|
29fca795b9 | ||
|
|
bd2fa5def6 | ||
|
|
36251d3f76 | ||
|
|
d92c1fcd55 | ||
|
|
4af7710f94 | ||
|
|
7e97c182a8 | ||
|
|
e0bcbfd0fd | ||
|
|
17878c6e65 | ||
|
|
7006dc4c6a | ||
|
|
c4253c4683 | ||
|
|
4fa96a42f7 | ||
|
|
c2d8399581 | ||
|
|
18c5cfafeb | ||
|
|
36f5884359 | ||
|
|
e7acc6ac3d | ||
|
|
76b0459fdd | ||
|
|
ae41dc55a2 | ||
|
|
45bb9a62ba | ||
|
|
89c2f84287 | ||
|
|
ed9f84475d | ||
|
|
1eb188932b | ||
|
|
8596468e51 | ||
|
|
c32de8c64d | ||
|
|
6d8e090419 | ||
|
|
816e687de8 | ||
|
|
0a521d3785 | ||
|
|
d3feb52955 | ||
|
|
65f3ac192b | ||
|
|
4be12aa1e3 | ||
|
|
84b0da9c94 | ||
|
|
e6fb691c49 | ||
|
|
d4973837b2 | ||
|
|
dd81915d5b | ||
|
|
3615d03e05 | ||
|
|
e0a6c06bfd | ||
|
|
efc4b69767 | ||
|
|
7875d534cb | ||
|
|
92a1d46c8d | ||
|
|
7de02e722f | ||
|
|
61bd4f76ad | ||
|
|
8b67ee5d3d | ||
|
|
fc45f68623 | ||
|
|
a004e23a4c | ||
|
|
88bcdc269b | ||
|
|
aad7c828b2 | ||
|
|
5a9aca17df | ||
|
|
55e85c24b4 | ||
|
|
fcc0263191 | ||
|
|
1d8b75550f | ||
|
|
aff44028ba | ||
|
|
6d7705eedf | ||
|
|
d3a94802d8 | ||
|
|
2b7d730e27 | ||
|
|
bc6726bc04 | ||
|
|
1876366b17 | ||
|
|
c94b996af8 | ||
|
|
0e9f8ced1e | ||
|
|
7342fcaf92 | ||
|
|
92ef313c77 | ||
|
|
cb75699dff | ||
|
|
122a525c83 | ||
|
|
5e823c1fd5 | ||
|
|
8db19980fa | ||
|
|
ef02d563a3 | ||
|
|
b2068640d1 | ||
|
|
93254f66fc | ||
|
|
52093f1776 | ||
|
|
0654d63196 | ||
|
|
4e8aa822dc | ||
|
|
1c42276a39 | ||
|
|
c9e27d026d | ||
|
|
e7db181e5d | ||
|
|
f5c5e53bf5 | ||
|
|
ecb3ad035a | ||
|
|
fb5b3ac013 | ||
|
|
5b84901c55 | ||
|
|
57cbcf6b8f | ||
|
|
07772cba07 | ||
|
|
5c1905caae | ||
|
|
d58251b47e | ||
|
|
d3dcb463d6 | ||
|
|
3dbfd300ff | ||
|
|
ff36991ca2 | ||
|
|
5b3b54e3f6 | ||
|
|
ba55c0770b | ||
|
|
4e68aa7e40 | ||
|
|
76b62317b5 | ||
|
|
4dd0dc6399 | ||
|
|
8be28e3eb6 | ||
|
|
ac8375d000 | ||
|
|
65c0339b5c | ||
|
|
4daae30174 | ||
|
|
d5bc89ef11 | ||
|
|
fa7d7934f6 | ||
|
|
a92a212925 | ||
|
|
435cf87469 | ||
|
|
e51916c0f9 | ||
|
|
997b193f63 | ||
|
|
e29c4b9b93 | ||
|
|
8e25a61277 | ||
|
|
f573ff7792 | ||
|
|
1a16735ce7 | ||
|
|
d02d6a1c7d | ||
|
|
968c231cc8 | ||
|
|
bb5cb1476b | ||
|
|
115020d985 | ||
|
|
3e2263abf2 | ||
|
|
d71f09df4d | ||
|
|
0a456b5d16 | ||
|
|
d3261115a8 | ||
|
|
673a1166fe | ||
|
|
853afe631c | ||
|
|
fe85bafedf | ||
|
|
751561218f | ||
|
|
f0c19e6455 | ||
|
|
ccff383d44 | ||
|
|
f3f7e14727 | ||
|
|
3c2ae60f46 | ||
|
|
95ba417c82 | ||
|
|
b6e4d58e4b | ||
|
|
ef43c17bfe | ||
|
|
ad8b7b71b4 | ||
|
|
83bd94f1f4 | ||
|
|
63071acbd9 | ||
|
|
44271398bd | ||
|
|
90cd362a87 | ||
|
|
b293334e7a | ||
|
|
4ae297867d | ||
|
|
ec3ff78f70 | ||
|
|
6d62ef108a | ||
|
|
b6874f8062 | ||
|
|
8b8aacde83 | ||
|
|
bbd17bd7c4 | ||
|
|
b5cebba675 | ||
|
|
736f40f459 | ||
|
|
0c03fc6f75 | ||
|
|
e61e403d20 | ||
|
|
9d824eb166 | ||
|
|
75d5bfda5b | ||
|
|
9b979b177b | ||
|
|
7b9796539d | ||
|
|
0bc79772c8 | ||
|
|
a45ffbefb9 | ||
|
|
99ffac0838 | ||
|
|
6c98897a64 | ||
|
|
b17c75b222 | ||
|
|
d4e1ddb631 | ||
|
|
aab2aa196d | ||
|
|
03d6b482b5 | ||
|
|
4dcce66295 | ||
|
|
7a28724e6b | ||
|
|
a5bcab7854 | ||
|
|
0a007b743e | ||
|
|
e9ef47f69e | ||
|
|
0532aca928 | ||
|
|
5a77e672e1 | ||
|
|
c2891d0011 | ||
|
|
25e0f55586 | ||
|
|
ce775cc851 | ||
|
|
d0797f5b53 | ||
|
|
a5e5547679 | ||
|
|
4164c6f949 | ||
|
|
4b2237a6a4 | ||
|
|
cb47e20509 | ||
|
|
d3a0b23c1b | ||
|
|
ab38979670 | ||
|
|
628b632419 | ||
|
|
d404b6d488 | ||
|
|
38404a5996 | ||
|
|
05fc4ccd30 | ||
|
|
78bb9dafe1 | ||
|
|
4fca25504e | ||
|
|
9daf91ed5c | ||
|
|
fcd7c13ffd | ||
|
|
5bcd0a8c14 | ||
|
|
8d261262d9 | ||
|
|
c4a8214b77 | ||
|
|
4e47be74e9 | ||
|
|
314ef3e72b | ||
|
|
aee83b43d6 | ||
|
|
9a1e2232ba | ||
|
|
6da2f2d92a | ||
|
|
24145c8869 | ||
|
|
e6a8060a71 | ||
|
|
98f053edbd | ||
|
|
581d29d4c9 | ||
|
|
66b942ce16 | ||
|
|
86cf9b2e89 | ||
|
|
fb29e51dbd | ||
|
|
ab63dd0892 | ||
|
|
a7428d443c | ||
|
|
857dbbe7cc | ||
|
|
3fb7c07ea5 | ||
|
|
60d7c022e5 | ||
|
|
850769f787 | ||
|
|
5f0b9276ec | ||
|
|
733b131545 | ||
|
|
ef217b76a3 | ||
|
|
b0791f75ad | ||
|
|
039ad872fe | ||
|
|
903c64dce8 | ||
|
|
8f4edd07be | ||
|
|
be720edba7 | ||
|
|
140504b11a | ||
|
|
cd3b0cc4d9 | ||
|
|
06a9684cfa | ||
|
|
45599ad00f | ||
|
|
677819fe66 | ||
|
|
2232baa41b | ||
|
|
7dffa41643 | ||
|
|
550bab03fb | ||
|
|
413138a5ca | ||
|
|
74945f2f04 | ||
|
|
97039baa88 | ||
|
|
fd73d04515 | ||
|
|
141d9e3c20 | ||
|
|
0cb906d804 | ||
|
|
b704036531 | ||
|
|
6f55ee2ec5 | ||
|
|
6a1dc2329a | ||
|
|
59a6c379dd | ||
|
|
d2f0bc2d13 | ||
|
|
b011fe1c12 | ||
|
|
0eadc27cd6 | ||
|
|
700c55036c | ||
|
|
b2bee3374c | ||
|
|
cc2770850a | ||
|
|
fb27873021 | ||
|
|
590fb8c481 | ||
|
|
4e8d7ec5fc | ||
|
|
254a513fd1 | ||
|
|
ab1a573768 | ||
|
|
38a9d2763c | ||
|
|
07e1d34a84 | ||
|
|
36edbb5eee | ||
|
|
3fceee058f | ||
|
|
0640cc3d3a | ||
|
|
3f68453d4a | ||
|
|
0a048923ae | ||
|
|
5441e18988 | ||
|
|
db0ed3e62d | ||
|
|
8a7ec52c8b | ||
|
|
66e1b3abba | ||
|
|
cd116fa248 | ||
|
|
c261077788 | ||
|
|
55fbff358a | ||
|
|
1921e6db90 | ||
|
|
bb4f77cd95 | ||
|
|
5ca62c9f35 | ||
|
|
1591a4c9dc | ||
|
|
c36074e85a | ||
|
|
73904f52b4 | ||
|
|
0e128dfa2f | ||
|
|
9994f25733 | ||
|
|
593fc04096 | ||
|
|
cb0b29631f | ||
|
|
ed4d32baa4 | ||
|
|
d83530f45d | ||
|
|
cb3f42123f | ||
|
|
36fa2a0abd | ||
|
|
2d3fc1ca3b | ||
|
|
f70c7d02e9 | ||
|
|
d768d103cf | ||
|
|
44e26d4149 | ||
|
|
96cec0e1a3 | ||
|
|
a9b34191ae | ||
|
|
e9eeb743cb | ||
|
|
8ba34667a1 | ||
|
|
87952f0623 | ||
|
|
d12c02f020 | ||
|
|
f3d737dad1 | ||
|
|
492ef9c964 | ||
|
|
c7822514cc | ||
|
|
d273ad2d0f | ||
|
|
af855e415d | ||
|
|
6ee0edf880 | ||
|
|
00015a81dd | ||
|
|
e1018a5bbb | ||
|
|
c5bef946b1 | ||
|
|
c559bb58ed | ||
|
|
4753906826 | ||
|
|
88b77cc6f3 | ||
|
|
b3b7168077 | ||
|
|
1384c048e4 | ||
|
|
24fde6e00f | ||
|
|
33ced44f9e | ||
|
|
e6dc85bb0b | ||
|
|
20786be695 | ||
|
|
99778e17af | ||
|
|
cf78aee1c4 | ||
|
|
6cd31bbfce | ||
|
|
4bc9f8472c | ||
|
|
4a12f4a22a | ||
|
|
a1f9426399 | ||
|
|
9f1cd70774 | ||
|
|
d2795b7909 | ||
|
|
b75b24103d | ||
|
|
cb1aee2506 | ||
|
|
8d4ce1fed5 | ||
|
|
7abc130a81 | ||
|
|
5adc5a2ff8 | ||
|
|
b302c4721a | ||
|
|
537c146082 | ||
|
|
b6743ea08e | ||
|
|
61365b6d15 | ||
|
|
1b491cbda0 | ||
|
|
8abcf141fa | ||
|
|
b8e314072f | ||
|
|
6785856858 | ||
|
|
e99107b1aa | ||
|
|
f30f0e04e3 | ||
|
|
c3b3240a03 | ||
|
|
65a24d0638 | ||
|
|
a45f47c225 | ||
|
|
c683100e31 | ||
|
|
ec8296ab81 | ||
|
|
bdb0130aea | ||
|
|
5975f31ff0 | ||
|
|
205483d592 | ||
|
|
3bb8683a79 | ||
|
|
bef60dc624 | ||
|
|
8eb8833b74 | ||
|
|
b0525f83e1 | ||
|
|
ee1369b853 | ||
|
|
ea0c7b699e | ||
|
|
f83783115f | ||
|
|
ed8aab4d85 | ||
|
|
6bdea98992 | ||
|
|
4a392c74cf | ||
|
|
1ecd786d95 | ||
|
|
1345cbeea8 | ||
|
|
ab23d34dd9 | ||
|
|
907333884f | ||
|
|
6b3d50b2cd | ||
|
|
dcc3505c7b | ||
|
|
0d00d83ef0 | ||
|
|
47dc5f7b54 | ||
|
|
f2598a8b60 | ||
|
|
80de04e560 | ||
|
|
77fd083041 | ||
|
|
22b9a84314 | ||
|
|
f27592a0cd | ||
|
|
3f2339b551 | ||
|
|
eceff8b3c3 | ||
|
|
f3dd1cc51e | ||
|
|
d32a671dff | ||
|
|
ffc9e9503d | ||
|
|
38734eeb45 | ||
|
|
41b1ffdf36 | ||
|
|
eb7d7955e5 | ||
|
|
4411742328 | ||
|
|
7c969f347f | ||
|
|
d08b6bdbf7 | ||
|
|
0b5b4b456c | ||
|
|
1faed9c234 | ||
|
|
59010e53f4 | ||
|
|
cd11345693 | ||
|
|
9616ad9828 | ||
|
|
8ea598b1d1 | ||
|
|
93215674db | ||
|
|
67703b11fe | ||
|
|
a3791aabaa | ||
|
|
cad6798a8c | ||
|
|
c85f5f6db0 | ||
|
|
c36bb79352 | ||
|
|
63d059ab0b | ||
|
|
3aa94d69fb | ||
|
|
4d56296443 | ||
|
|
9b872f4cf9 | ||
|
|
5432c01ffd | ||
|
|
9c69360e97 | ||
|
|
6a6d79fc00 | ||
|
|
c83d421d9e | ||
|
|
2438825d77 | ||
|
|
a257f80d95 | ||
|
|
973c493e1b | ||
|
|
58bd925acc | ||
|
|
8625b394b5 | ||
|
|
47a007a945 |
234
ANNOUNCE
@@ -1,96 +1,184 @@
|
||||
|
||||
Libpng 1.5.1 - February 3, 2011
|
||||
Libpng 1.6.0beta10 - February 3, 2012
|
||||
|
||||
This is a public release of libpng, intended for use in production codes.
|
||||
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.
|
||||
|
||||
Files available for download:
|
||||
|
||||
Source files with LF line endings (for Unix/Linux) and with a
|
||||
"configure" script
|
||||
|
||||
libpng-1.5.1.tar.xz (LZMA-compressed, recommended)
|
||||
libpng-1.5.1.tar.gz
|
||||
libpng-1.5.1.tar.bz2
|
||||
1.6.0beta10.tar.xz (LZMA-compressed, recommended)
|
||||
1.6.0beta10.tar.gz
|
||||
1.6.0beta10.tar.bz2
|
||||
|
||||
Source files with CRLF line endings (for Windows), without the
|
||||
"configure" script
|
||||
|
||||
lpng151.7z (LZMA-compressed, recommended)
|
||||
lpng151.zip
|
||||
lp160b10.7z (LZMA-compressed, recommended)
|
||||
lp160b10.zip
|
||||
|
||||
Other information:
|
||||
|
||||
libpng-1.5.1-README.txt
|
||||
libpng-1.5.1-LICENSE.txt
|
||||
1.6.0beta10-README.txt
|
||||
1.6.0beta10-LICENSE.txt
|
||||
|
||||
Changes since the last public release (1.5.0):
|
||||
Changes since the last public release (1.5.7):
|
||||
|
||||
Added description of png_set_crc_action() to the manual.
|
||||
Added a note in the manual that the type of the iCCP profile was changed
|
||||
from png_charpp to png_bytepp in png_get_iCCP(). Similarly,
|
||||
it was changed from png_charpp to png_const_bytepp in png_set_iCCP().
|
||||
Ensure that png_rgb_to_gray ignores palette mapped images, if libpng
|
||||
internally happens to call it with one.
|
||||
Fixed the failure to handle palette mapped images correctly.
|
||||
Fixed a bug in handling of interlaced images (bero at arklinux.org).
|
||||
Updated CMakeLists.txt (Clifford Yapp)
|
||||
Fixed typecasting of some png_debug() statements (Cosmin)
|
||||
Updated documentation of png_set|get_tRNS() (Thomas Klausner).
|
||||
Mentioned in the documentation that applications must #include "zlib.h"
|
||||
if they need access to anything in zlib.h, and that a number of
|
||||
macros such as png_memset() are no longer accessible by applications.
|
||||
Corrected pngvalid gamma test "sample" function to access all of the color
|
||||
samples of each pixel, instead of sampling the red channel three times.
|
||||
Changed variable names index, div, exp, and gamma to char_index, divisor,
|
||||
exp_b10, and gamma_val, respectively, to avoid "shadow" warnings.
|
||||
Prevent png_push_crc_skip() from hanging while reading an unknown chunk
|
||||
or an over-large compressed zTXt chunk with the progressive reader.
|
||||
Eliminated more GCC "shadow" warnings.
|
||||
Revised png_fixed() in png.c to avoid compiler warning about reaching the
|
||||
end without returning anything.
|
||||
In the manual, describe the png_get_IHDR() arguments in the correct order.
|
||||
Added const_png_structp and const_png_infop types, and used them in
|
||||
prototypes for most png_get_*() functions.
|
||||
Added png_get_io_chunk_type() and deprecated png_get_io_chunk_name()
|
||||
Added synopses for the IO_STATE functions and other missing synopses
|
||||
to the manual. Removed the synopses from libpngpf.3 because they
|
||||
were out of date and no longer useful. Better information can be
|
||||
obtained by reading the prototypes and comments in pngpriv.h
|
||||
Attempted to fix cpp on Solaris with S. Studio 12 cc, fix build
|
||||
Added a make macro DFNCPP that is a CPP that will accept the tokens in
|
||||
a .dfn file and adds configure stuff to test for such a CPP. ./configure
|
||||
should fail if one is not available.
|
||||
Corrected const_png_ in png.h to png_const_ to avoid polluting the namespace.
|
||||
Added png_get_current_row_number and png_get_current_pass_number for the
|
||||
benefit of the user transform callback.
|
||||
Added png_process_data_pause and png_process_data_skip for the benefit of
|
||||
progressive readers that need to stop data processing or want to optimize
|
||||
skipping of unread data (e.g. if the reader marks a chunk to be skipped.)
|
||||
Enhanced pngvalid, corrected an error in gray_to_rgb, corrected doc error.
|
||||
pngvalid contains tests of transforms, which tests are currently disabled
|
||||
because they are incompletely tested. gray_to_rgb was failing to expand
|
||||
the bit depth for smaller bit depth images; this seems to be a long
|
||||
standing error and resulted, apparently, in invalid output. The
|
||||
documentation did not accurately describe what libpng really does when
|
||||
converting RGB to gray.
|
||||
Fixed incorrect examples of callback prototypes in the manual, that were
|
||||
introduced in libpng-1.0.0.
|
||||
In addition the order of the png_get_uint macros with respect to the
|
||||
relevant function definitions has been reversed. This helps the
|
||||
preprocessing of the symbol files be more robust. Furthermore, the
|
||||
symbol file preprocessing now uses -DPNG_NO_USE_READ_MACROS even when
|
||||
the library may actually be built with PNG_USE_READ_MACROS; this stops
|
||||
the read macros interfering with the symbol file format.
|
||||
Made the manual, synopses, and function prototypes use the function
|
||||
argument names file_gamma, int_file_gamma, and srgb_intent consistently.
|
||||
Changed PNG_UNUSED from "param=param;" to "(void)param;".
|
||||
Added transform tests to pngvalid and simplified the arguments.
|
||||
Added a request in the manual that applications do not use "png_" or
|
||||
"PNG_" to begin any of their own symbols.
|
||||
Version 1.6.0beta01 [December 15, 2011]
|
||||
Removed machine-generated configure files from the GIT repository (they will
|
||||
continue to appear in the tarball distributions).
|
||||
Restored the new 'simplified' API, which was started in libpng-1.5.7beta02
|
||||
but later deleted from libpng-1.5.7beta05.
|
||||
Added example programs for the new 'simplified' API.
|
||||
Added ANSI-C (C90) headers and require them, and take advantage of the
|
||||
change. Also fixed some of the projects/* and contrib/* files that needed
|
||||
updates for libpng16 and the move of pngvalid.c.
|
||||
With this change the required ANSI-C header files are assumed to exist: the
|
||||
implementation must provide float.h, limits.h, stdarg.h and stddef.h and
|
||||
libpng relies on limits.h and stddef.h existing and behaving as defined
|
||||
(the other two required headers aren't used). Non-ANSI systems that don't
|
||||
have stddef.h or limits.h will have to provide an appropriate fake
|
||||
containing the relevant types and #defines.
|
||||
The use of FAR/far has been eliminated and the definition of png_alloc_size_t
|
||||
is now controlled by a flag so that 'small size_t' systems can select it
|
||||
if necessary. Libpng 1.6 may not currently work on such systems -- it
|
||||
seems likely that it will ask 'malloc' for more than 65535 bytes with any
|
||||
image that has a sufficiently large row size (rather than simply failing
|
||||
to read such images).
|
||||
New tools directory containing tools used to generate libpng code.
|
||||
Fixed race conditions in parallel make builds. With higher degrees of
|
||||
parallelism during 'make' the use of the same temporary file names such
|
||||
as 'dfn*' can result in a race where a temporary file from one arm of the
|
||||
build is deleted or overwritten in another arm. This changes the
|
||||
temporary files for suffix rules to always use $* and ensures that the
|
||||
non-suffix rules use unique file names.
|
||||
|
||||
Version 1.6.0beta02 [December 21, 2011]
|
||||
Correct configure builds where build and source directories are separate.
|
||||
The include path of 'config.h' was erroneously made relative in pngvalid.c
|
||||
in libpng 1.5.7.
|
||||
|
||||
Version 1.6.0beta03 [December 22, 2011]
|
||||
Start-up code size improvements, error handler flexibility. These changes
|
||||
alter how the tricky allocation of the initial png_struct and png_info
|
||||
structures are handled. png_info is now handled in pretty much the same
|
||||
way as everything else, except that the allocations handle NULL return
|
||||
silently. png_struct is changed in a similar way on allocation and on
|
||||
deallocation a 'safety' error handler is put in place (which should never
|
||||
be required). The error handler itself is changed to permit mismatches
|
||||
in the application and libpng error buffer size; however, this means a
|
||||
silent change to the API to return the jmp_buf if the size doesn't match
|
||||
the size from the libpng compilation; libpng now allocates the memory and
|
||||
this may fail. Overall these changes result in slight code size
|
||||
reductions; however, this is a reduction in code that is always executed
|
||||
so is particularly valuable. Overall on a 64-bit system the libpng DLL
|
||||
decreases in code size by 1733 bytes. pngerror.o increases in size by
|
||||
about 465 bytes because of the new functionality.
|
||||
|
||||
Version 1.6.0beta04 [December 30, 2011]
|
||||
Regenerated configure scripts with automake-1.11.2
|
||||
Eliminated png_info_destroy(). It is now used only in png.c and only calls
|
||||
one other internal function and memset().
|
||||
Enabled png_get_sCAL_fixed() if floating point APIs are enabled. Previously
|
||||
it was disabled whenever internal fixed point arithmetic was selected,
|
||||
which meant it didn't exist even on systems where FP was available but not
|
||||
preferred.
|
||||
Added pngvalid.c compile time checks for const APIs.
|
||||
Implemented 'restrict' for png_info and png_struct. Because of the way
|
||||
libpng works both png_info and png_struct are always accessed via a
|
||||
single pointer. This means adding C99 'restrict' to the pointer gives
|
||||
the compiler some opportunity to optimize the code. This change allows
|
||||
that.
|
||||
Moved AC_MSG_CHECKING([if libraries can be versioned]) later to the proper
|
||||
location in configure.ac (Gilles Espinasse).
|
||||
Changed png_memcpy to C assignment where appropriate. Changed all those
|
||||
uses of png_memcpy that were doing a simple assignment to assignments
|
||||
(all those cases where the thing being copied is a non-array C L-value).
|
||||
Added some error checking to png_set_*() routines.
|
||||
Removed the reference to the non-exported function png_memcpy() from
|
||||
example.c.
|
||||
Fixed the Visual C 64-bit build - it requires jmp_buf to be aligned, but
|
||||
it had become misaligned.
|
||||
Revised contrib/pngminus/pnm2png.c to avoid warnings when png_uint_32
|
||||
and unsigned long are of different sizes.
|
||||
|
||||
Version 1.6.0beta05 [January 15, 2012]
|
||||
Updated manual with description of the simplified API (copied from png.h)
|
||||
Fix bug in pngerror.c: some long warnings were being improperly truncated
|
||||
(CVE-2011-3464, bug introduced in libpng-1.5.3beta05).
|
||||
|
||||
Version 1.6.0beta06 [January 24, 2012]
|
||||
Added palette support to the simplified APIs. This commit
|
||||
changes some of the macro definitions in png.h, app code
|
||||
may need corresponding changes.
|
||||
Increased the formatted warning buffer to 192 bytes.
|
||||
Added color-map support to simplified API. This is an initial version for
|
||||
review; the documentation has not yet been updated.
|
||||
Fixed Min/GW uninstall to remove libpng.dll.a
|
||||
|
||||
Version 1.6.0beta07 [January 28, 2012]
|
||||
Eliminated Intel icc/icl compiler warnings. The Intel (GCC derived)
|
||||
compiler issues slightly different warnings from those issued by the
|
||||
current vesions of GCC. This eliminates those warnings by
|
||||
adding/removing casts and small code rewrites.
|
||||
Updated configure.ac from autoupdate: added --enable-werror option.
|
||||
Also some layout regularization and removal of introduced tab characters
|
||||
(replaced with 3-character indentation). Obsolete macros identified by
|
||||
autoupdate have been removed; the replacements are all in 2.59 so
|
||||
the pre-req hasn't been changed. --enable-werror checks for support
|
||||
for -Werror (or the given argument) in the compiler. This mimics the
|
||||
gcc configure option by allowing -Werror to be turned on safely; without
|
||||
the option the tests written in configure itself fail compilation because
|
||||
they cause compiler warnings.
|
||||
Rewrote autogen.sh to run autoreconf instead of running tools one-by-one.
|
||||
Conditionalize the install rules for MINGW and CYGWIN in CMakeLists.txt and
|
||||
set CMAKE_LIBRARY_OUTPUT_DIRECTORY to "lib" on all platforms (C. Yapp).
|
||||
Freeze libtool files in the 'scripts' directory. This version of autogen.sh
|
||||
attempts to dissuade people from running it when it is not, or should not,
|
||||
be necessary. In fact, autogen.sh does not work when run in a libpng
|
||||
directory extracted from atar distribution anymore. You must run it in
|
||||
a GIT clone instead.
|
||||
Added two images to contrib/pngsuite (1-bit and 2-bit transparent grayscale),
|
||||
and renamed three whose names were inconsistent with those in
|
||||
pngsuite/README.txt.
|
||||
|
||||
Version 1.6.0beta08 [February 1, 2012]
|
||||
Fixed Image::colormap misalignment in pngstest.c
|
||||
Check libtool/libtoolize version number (2.4.2) in configure.ac
|
||||
Divide test-pngstest.sh into separate pngstest runs for basic and
|
||||
transparent images.
|
||||
Moved automake options to AM_INIT_AUTOMAKE in configure.ac
|
||||
Added color-tests, silent-rules (Not yet implemented in Makefile.am) and
|
||||
version checking to configure.ac
|
||||
Improved pngstest speed by not doing redundant tests and add const to
|
||||
the background parameter of png_image_finish_read. The --background
|
||||
option is now done automagically only when required, so that commandline
|
||||
option no longer exists.
|
||||
Cleaned up pngpriv.h to consistently declare all functions and data.
|
||||
Also eliminated PNG_CONST_DATA, which is apparently not needed but we
|
||||
can't be sure until it is gone.
|
||||
Added symbol prefixing that allows all the libpng external symbols
|
||||
to be prefixed (suggested by Reuben Hawkins).
|
||||
Updated "ftbb*.png" list in the owatcom and vstudio projects.
|
||||
Fixed 'prefix' builds on clean systems. The generation of pngprefix.h
|
||||
should not require itself.
|
||||
Updated INSTALL to explain that autogen.sh must be run in a GIT clone,
|
||||
not in a libpng directory extracted from a tar distribution.
|
||||
|
||||
Version 1.6.0beta09 [February 1, 2011]
|
||||
Reverted the prebuilt configure files to libpng-1.6.0beta05 condition.
|
||||
|
||||
Version 1.6.0beta10 [February 3, 2012]
|
||||
Added Z_SOLO for zlib-1.2.6+ and correct pngstest tests
|
||||
Updated list of test images in CMakeLists.txt
|
||||
Updated the prebuilt configure files to current condition.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(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
|
||||
|
||||
719
CHANGES
@@ -1,5 +1,4 @@
|
||||
#if 0
|
||||
libpng_changes(){ /*
|
||||
CHANGES - changes for libpng
|
||||
|
||||
Version 0.2
|
||||
@@ -15,7 +14,7 @@ Version 0.3
|
||||
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 check for 64 KB blocks for 16-bit machines
|
||||
|
||||
Version 0.4
|
||||
cleaned up code and commented code
|
||||
@@ -74,7 +73,7 @@ Version 0.82 [September, 1995]
|
||||
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.)
|
||||
fixed some bugs (16-bit, 4-bit interlaced, etc.)
|
||||
added first run progressive reader (barely tested)
|
||||
|
||||
Version 0.86 [January, 1996]
|
||||
@@ -180,7 +179,7 @@ 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 "error" in pngconf.h for Linux setjmp() behavior
|
||||
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)
|
||||
@@ -197,18 +196,20 @@ Version 0.97 [January, 1998]
|
||||
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;
|
||||
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)
|
||||
Repaired PNG_NO_STDIO behavior
|
||||
Tested NODIV support and made it default behavior (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 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
|
||||
@@ -1778,7 +1779,7 @@ Version 1.2.13beta1 [October 2, 2006]
|
||||
Removed AC_FUNC_MALLOC from configure.ac
|
||||
Work around Intel-Mac compiler bug by setting PNG_NO_MMX_CODE in pngconf.h
|
||||
Change "logical" to "bitwise" throughout documentation.
|
||||
Detect and fix attempt to write wrong iCCP profile length.
|
||||
Detect and fix attempt to write wrong iCCP profile length (CVE-2006-7244)
|
||||
|
||||
Version 1.0.21, 1.2.13 [November 14, 2006]
|
||||
Fix potential buffer overflow in sPLT chunk handler.
|
||||
@@ -2361,7 +2362,7 @@ Version 1.4.0beta72 [August 1, 2009]
|
||||
|
||||
Version 1.4.0beta73 [August 1, 2009]
|
||||
Reject attempt to write iCCP chunk with negative embedded profile length
|
||||
(JD Chen)
|
||||
(JD Chen) (CVE-2009-5063).
|
||||
|
||||
Version 1.4.0beta74 [August 8, 2009]
|
||||
Changed png_ptr and info_ptr member "trans" to "trans_alpha".
|
||||
@@ -2935,7 +2936,7 @@ Version 1.5.0beta36 [July 29, 2010]
|
||||
PNG_INTERLACE transform and to get the number of rows in the current
|
||||
pass.
|
||||
A new test program, pngvalid.c, validates the gamma code.
|
||||
Errors in the 16 bit gamma correction (overflows) have been corrected.
|
||||
Errors in the 16-bit gamma correction (overflows) have been corrected.
|
||||
cHRM chunk testing is done consistently (previously the floating point
|
||||
API bypassed it, because the test really didn't work on FP, now the test
|
||||
is performed on the actual values to be stored in the PNG file so it
|
||||
@@ -3149,8 +3150,8 @@ version 1.5.1beta01 [January 8, 2011]
|
||||
in version 1.5.0beta36 but is not noted in the CHANGES. Similarly,
|
||||
it was changed from png_charpp to png_const_bytepp in png_set_iCCP().
|
||||
Ensure that png_rgb_to_gray ignores palette mapped images, if libpng
|
||||
internally happens to call it with one.
|
||||
Fixed a failure to handle palette mapped images correctly.
|
||||
internally happens to call it with one, and fixed a failure to handle
|
||||
palette mapped images correctly. This fixes CVE-2690.
|
||||
|
||||
Version 1.5.1beta02 [January 14, 2011]
|
||||
Fixed a bug in handling of interlaced images (bero at arklinux.org).
|
||||
@@ -3208,9 +3209,9 @@ Version 1.5.1beta09 [January 24, 2011]
|
||||
pngvalid contains tests of transforms, which tests are currently disabled
|
||||
because they are incompletely tested. gray_to_rgb was failing to expand
|
||||
the bit depth for smaller bit depth images; this seems to be a long
|
||||
standing error and resulted, apparently, in invalid output. The
|
||||
documentation did not accurately describe what libpng really does when
|
||||
converting RGB to gray.
|
||||
standing error and resulted, apparently, in invalid output
|
||||
(CVE-2011-0408, CERT VU#643140). The documentation did not accurately
|
||||
describe what libpng really does when converting RGB to gray.
|
||||
|
||||
Version 1.5.1beta10 [January 27, 2010]
|
||||
Fixed incorrect examples of callback prototypes in the manual, that were
|
||||
@@ -3227,7 +3228,7 @@ Version 1.5.1beta10 [January 27, 2010]
|
||||
Version 1.5.1beta11 [January 28, 2011]
|
||||
Changed PNG_UNUSED from "param=param;" to "{if(param){}}".
|
||||
Corrected local variable type in new API png_process_data_skip()
|
||||
The type was self-evidently incorrect but only causes problems on 64 bit
|
||||
The type was self-evidently incorrect but only causes problems on 64-bit
|
||||
architectures.
|
||||
Added transform tests to pngvalid and simplified the arguments.
|
||||
|
||||
@@ -3242,6 +3243,689 @@ Version 1.5.1rc02 [January 31, 2011]
|
||||
Version 1.5.1 [February 3, 2011]
|
||||
No changes.
|
||||
|
||||
Version 1.5.2beta01 [February 13, 2011]
|
||||
More -Wshadow fixes for older gcc compilers. Older gcc versions apparently
|
||||
check formal parameters names in function declarations (as well as
|
||||
definitions) to see if they match a name in the global namespace.
|
||||
Revised PNG_EXPORTA macro to not use an empty parameter, to accommodate the
|
||||
old VisualC++ preprocessor.
|
||||
Turned on interlace handling in png_read_png().
|
||||
Fixed gcc pendantic warnings.
|
||||
Handle longjmp in Cygwin.
|
||||
Fixed png_get_current_row_number() in the interlaced case.
|
||||
Cleaned up ALPHA flags and transformations.
|
||||
Implemented expansion to 16 bits.
|
||||
|
||||
Version 1.5.2beta02 [February 19, 2011]
|
||||
Fixed mistake in the descriptions of user read_transform and write_transform
|
||||
function prototypes in the manual. The row_info struct is png_row_infop.
|
||||
Reverted png_get_current_row_number() to previous (1.5.2beta01) behavior.
|
||||
Corrected png_get_current_row_number documentation
|
||||
Fixed the read/write row callback documentation.
|
||||
This documents the current behavior, where the callback is called after
|
||||
every row with information pertaining to the next row.
|
||||
|
||||
Version 1.5.2beta03 [March 3, 2011]
|
||||
Fixed scripts/makefile.vcwin32
|
||||
Updated contrib/pngsuite/README to add the word "modify".
|
||||
Define PNG_ALLOCATED to blank when _MSC_VER<1300.
|
||||
|
||||
Version 1.5.2rc01 [March 19, 2011]
|
||||
Define remaining attributes to blank when MSC_VER<1300.
|
||||
ifdef out mask arrays in pngread.c when interlacing is not supported.
|
||||
|
||||
Version 1.5.2rc02 [March 22, 2011]
|
||||
Added a hint to try CPP=/bin/cpp if "cpp -E" fails in scripts/pnglibconf.mak
|
||||
and in contrib/pngminim/*/makefile, eg., on SunOS 5.10, and removed "strip"
|
||||
from the makefiles.
|
||||
Fixed a bug (present since libpng-1.0.7) that makes png_handle_sPLT() fail
|
||||
to compile when PNG_NO_POINTER_INDEXING is defined (Chubanov Kirill)
|
||||
|
||||
Version 1.5.2rc03 [March 24, 2011]
|
||||
Don't include standard header files in png.h while building the symbol table,
|
||||
to avoid cpp failure on SunOS (introduced PNG_BUILDING_SYMBOL_TABLE macro).
|
||||
|
||||
Version 1.5.2 [March 31, 2011]
|
||||
No changes.
|
||||
|
||||
Version 1.5.3beta01 [April 1, 2011]
|
||||
Re-initialize the zlib compressor before compressing non-IDAT chunks.
|
||||
Added API functions (png_set_text_compression_level() and four others) to
|
||||
set parameters for zlib compression of non-IDAT chunks.
|
||||
|
||||
Version 1.5.3beta02 [April 3, 2011]
|
||||
Updated scripts/symbols.def with new API functions.
|
||||
Only compile the new zlib re-initializing code when text or iCCP is
|
||||
supported, using PNG_WRITE_COMPRESSED_TEXT_SUPPORTED macro.
|
||||
Improved the optimization of the zlib CMF byte (see libpng-1.2.6beta03).
|
||||
Optimize the zlib CMF byte in non-IDAT compressed chunks
|
||||
|
||||
Version 1.5.3beta03 [April 16, 2011]
|
||||
Fixed gcc -ansi -pedantic compile. A strict ANSI system does not have
|
||||
snprintf, and the "__STRICT_ANSI__" detects that condition more reliably
|
||||
than __STDC__ (John Bowler).
|
||||
Removed the PNG_PTR_NORETURN attribute because it too dangerous. It tells
|
||||
the compiler that a user supplied callback (the error handler) does not
|
||||
return, yet there is no guarantee in practice that the application code
|
||||
will correctly implement the error handler because the compiler only
|
||||
issues a warning if there is a mistake (John Bowler).
|
||||
Removed the no-longer-used PNG_DEPSTRUCT macro.
|
||||
Updated the zlib version to 1.2.5 in the VStudio project.
|
||||
Fixed 64-bit builds where png_uint_32 is smaller than png_size_t in
|
||||
pngwutil.c (John Bowler).
|
||||
Fixed bug with stripping the filler or alpha channel when writing, that
|
||||
was introduced in libpng-1.5.2beta01 (bug report by Andrew Church).
|
||||
|
||||
Version 1.5.3beta04 [April 27, 2011]
|
||||
Updated pngtest.png with the new zlib CMF optimization.
|
||||
Cleaned up conditional compilation code and of background/gamma handling
|
||||
Internal changes only except a new option to avoid compiling the
|
||||
png_build_grayscale_palette API (which is not used at all internally.)
|
||||
The main change is to move the transform tests (READ_TRANSFORMS,
|
||||
WRITE_TRANSFORMS) up one level to the caller of the APIs. This avoids
|
||||
calls to spurious functions if all transforms are disabled and slightly
|
||||
simplifies those functions. Pngvalid modified to handle this.
|
||||
A minor change is to stop the strip_16 and expand_16 interfaces from
|
||||
disabling each other; this allows the future alpha premultiplication
|
||||
code to use 16-bit intermediate values while still producing 8-bit output.
|
||||
png_do_background and png_do_gamma have been simplified to take a single
|
||||
pointer to the png_struct rather than pointers to every item required
|
||||
from the png_struct. This makes no practical difference to the internal
|
||||
code.
|
||||
A serious bug in the pngvalid internal routine 'standard_display_init' has
|
||||
been fixed - this failed to initialize the red channel and accidentally
|
||||
initialized the alpha channel twice.
|
||||
Changed png_struct jmp_buf member name from png_jmpbuf to tmp_jmpbuf to
|
||||
avoid a possible clash with the png_jmpbuf macro on some platforms.
|
||||
|
||||
Version 1.5.3beta05 [May 6, 2011]
|
||||
Added the "_POSIX_SOURCE" feature test macro to ensure libpng sees the
|
||||
correct API. _POSIX_SOURCE is defined in pngpriv.h, pngtest.c and
|
||||
pngvalid.c to ensure that POSIX conformant systems disable non-POSIX APIs.
|
||||
Removed png_snprintf and added formatted warning messages. This change adds
|
||||
internal APIs to allow png_warning messages to have parameters without
|
||||
requiring the host OS to implement snprintf. As a side effect the
|
||||
dependency of the tIME-supporting RFC1132 code on stdio is removed and
|
||||
PNG_NO_WARNINGS does actually work now.
|
||||
Pass "" instead of '\0' to png_default_error() in png_err(). This mistake
|
||||
was introduced in libpng-1.2.20beta01. This fixes CVE-2011-2691.
|
||||
Added PNG_WRITE_OPTIMIZE_CMF_SUPPORTED macro to make the zlib "CMF" byte
|
||||
optimization configureable.
|
||||
IDAT compression failed if preceded by a compressed text chunk (bug
|
||||
introduced in libpng-1.5.3beta01-02). This was because the attempt to
|
||||
reset the zlib stream in png_write_IDAT happened after the first IDAT
|
||||
chunk had been deflated - much too late. In this change internal
|
||||
functions were added to claim/release the z_stream and, hopefully, make
|
||||
the code more robust. Also deflateEnd checking is added - previously
|
||||
libpng would ignore an error at the end of the stream.
|
||||
|
||||
Version 1.5.3beta06 [May 8, 2011]
|
||||
Removed the -D_ALL_SOURCE from definitions for AIX in CMakeLists.txt
|
||||
Implemented premultiplied alpha support: png_set_alpha_mode API
|
||||
|
||||
Version 1.5.3beta07 [May 11, 2011]
|
||||
Added expand_16 support to the high level interface.
|
||||
Added named value and 'flag' gamma support to png_set_gamma. Made a minor
|
||||
change from the previous (unreleased) ABI/API to hide the exact value used
|
||||
for Macs - it's not a good idea to embed this in the ABI!
|
||||
Moved macro definitions for PNG_HAVE_IHDR, PNG_HAVE_PLTE, and PNG_AFTER_IDAT
|
||||
from pngpriv.h to png.h because they must be visible to applications
|
||||
that call png_set_unknown_chunks().
|
||||
Check for up->location !PNG_AFTER_IDAT when writing unknown chunks
|
||||
before IDAT.
|
||||
|
||||
Version 1.5.3beta08 [May 16, 2011]
|
||||
Improved "pngvalid --speed" to exclude more of pngvalid from the time.
|
||||
Documented png_set_alpha_mode(), other changes in libpng.3/libpng-manual.txt
|
||||
The cHRM chunk now sets the defaults for png_set_rgb_to_gray() (when negative
|
||||
parameters are supplied by the caller), while in the absence of cHRM
|
||||
sRGB/Rec 709 values are still used. This introduced a divide-by-zero
|
||||
bug in png_handle_cHRM().
|
||||
The bKGD chunk no longer overwrites the background value set by
|
||||
png_set_background(), allowing the latter to be used before the file
|
||||
header is read. It never performed any useful function to override
|
||||
the default anyway.
|
||||
Added memory overwrite and palette image checks to pngvalid.c
|
||||
Previously palette image code was poorly checked. Since the transformation
|
||||
code has a special palette path in most cases this was a severe weakness.
|
||||
Minor cleanup and some extra checking in pngrutil.c and pngrtran.c. When
|
||||
expanding an indexed image, always expand to RGBA if transparency is
|
||||
present.
|
||||
|
||||
Version 1.5.3beta09 [May 17, 2011]
|
||||
Reversed earlier 1.5.3 change of transformation order; move png_expand_16
|
||||
back where it was. The change doesn't work because it requires 16-bit
|
||||
gamma tables when the code only generates 8-bit ones. This fails
|
||||
silently; the libpng code just doesn't do any gamma correction. Moving
|
||||
the tests back leaves the old, inaccurate, 8-bit gamma calculations, but
|
||||
these are clearly better than none!
|
||||
|
||||
Version 1.5.3beta10 [May 20, 2011]
|
||||
|
||||
png_set_background() and png_expand_16() did not work together correctly.
|
||||
This problem is present in 1.5.2; if png_set_background is called with
|
||||
need_expand false and the matching 16 bit color libpng erroneously just
|
||||
treats it as an 8-bit color because of where png_do_expand_16 is in the
|
||||
transform list. This simple fix reduces the supplied colour to 8-bits,
|
||||
so it gets smashed, but this is better than the current behavior.
|
||||
Added tests for expand16, more fixes for palette image tests to pngvalid.
|
||||
Corrects the code for palette image tests and disables attempts to
|
||||
validate palette colors.
|
||||
|
||||
Version 1.5.3rc01 [June 3, 2011]
|
||||
No changes.
|
||||
|
||||
Version 1.5.3rc02 [June 8, 2011]
|
||||
Fixed uninitialized memory read in png_format_buffer() (Bug report by
|
||||
Frank Busse, CVE-2011-2501, related to CVE-2004-0421).
|
||||
|
||||
Version 1.5.3beta11 [June 11, 2011]
|
||||
Fixed png_handle_sCAL which is broken in 1.5. This fixes CVE 2011-2692.
|
||||
Added sCAL to pngtest.png
|
||||
Revised documentation about png_set_user_limits() to say that it also affects
|
||||
png writing.
|
||||
Revised handling of png_set_user_limits() so that it can increase the
|
||||
limit beyond the PNG_USER_WIDTH|HEIGHT_MAX; previously it could only
|
||||
reduce it.
|
||||
Make the 16-to-8 scaling accurate. Dividing by 256 with no rounding is
|
||||
wrong (high by one) 25% of the time. Dividing by 257 with rounding is
|
||||
wrong in 128 out of 65536 cases. Getting the right answer all the time
|
||||
without division is easy.
|
||||
Added "_SUPPORTED" to the PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION macro.
|
||||
Added projects/owatcom, an IDE project for OpenWatcom to replace
|
||||
scripts/makefile.watcom. This project works with OpenWatcom 1.9. The
|
||||
IDE autogenerates appropriate makefiles (libpng.mk) for batch processing.
|
||||
The project is configurable, unlike the Visual Studio project, so long
|
||||
as the developer has an awk.
|
||||
Changed png_set_gAMA to limit the gamma value range so that the inverse
|
||||
of the stored value cannot overflow the fixed point representation,
|
||||
and changed other things OpenWatcom warns about.
|
||||
Revised pngvalid.c to test PNG_ALPHA_MODE_SUPPORTED correctly. This allows
|
||||
pngvalid to build when ALPHA_MODE is not supported, which is required if
|
||||
it is to build on libpng 1.4.
|
||||
Removed string/memory macros that are no longer used and are not
|
||||
necessarily fully supportable, particularly png_strncpy and png_snprintf.
|
||||
Added log option to pngvalid.c and attempted to improve gamma messages.
|
||||
|
||||
Version 1.5.3 [omitted]
|
||||
People found the presence of a beta release following an rc release
|
||||
to be confusing; therefore we bump the version to libpng-1.5.4beta01
|
||||
and there will be no libpng-1.5.3 release.
|
||||
|
||||
Version 1.5.4beta01 [June 14, 2011]
|
||||
Made it possible to undefine PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
|
||||
to get the same (inaccurate) output as libpng-1.5.2 and earlier.
|
||||
Moved definitions of PNG_HAVE_IHDR, PNG_AFTER_IDAT, and PNG_HAVE_PLTE
|
||||
outside of an unknown-chunk block in png.h because they are also
|
||||
needed for other uses.
|
||||
|
||||
Version 1.5.4beta02 [June 14, 2011]
|
||||
Fixed and clarified LEGACY 16-to-8 scaling code.
|
||||
Added png_set_chop_16() API, to match inaccurate results from previous
|
||||
libpng versions.
|
||||
Removed the ACCURATE and LEGACY options (they are no longer useable)
|
||||
Use the old scaling method for background if png_set_chop_16() was
|
||||
called.
|
||||
Made png_set_chop_16() API removeable by disabling PNG_CHOP_16_TO_8_SUPPORTED
|
||||
|
||||
Version 1.5.4beta03 [June 15, 2011]
|
||||
Fixed a problem in png_do_expand_palette() exposed by optimization in
|
||||
1.5.3beta06
|
||||
Also removed a spurious and confusing "trans" member ("trans") from png_info.
|
||||
The palette expand optimization prevented expansion to an intermediate RGBA
|
||||
form if tRNS was present but alpha was marked to be stripped; this exposed
|
||||
a check for tRNS in png_do_expand_palette() which is inconsistent with the
|
||||
code elsewhere in libpng.
|
||||
Correction to the expand_16 code; removed extra instance of
|
||||
png_set_scale_16_to_8 from pngpriv.h
|
||||
|
||||
Version 1.5.4beta04 [June 16, 2011]
|
||||
Added a missing "#ifdef PNG_READ_BACKGROUND_SUPPORTED/#endif" in pngrtran.c
|
||||
Added PNG_TRANSFORM_CHOP_16 to the high-level read transforms.
|
||||
Made PNG_READ_16_TO_8_ACCURATE_SCALE configurable again. If this is
|
||||
not enabled, png_set_strip_16() and png_do_scale_16_to_8() aren't built.
|
||||
Revised contrib/visupng, gregbook, and pngminim to demonstrate chop_16_to_8
|
||||
|
||||
Version 1.5.4beta05 [June 16, 2011]
|
||||
Renamed png_set_strip_16() to png_set_scale_16() and renamed
|
||||
png_set_chop_16() to png_set_strip(16) in an attempt to minimize the
|
||||
behavior changes between libpng14 and libpng15.
|
||||
|
||||
Version 1.5.4beta06 [June 18, 2011]
|
||||
Fixed new bug that was causing both strip_16 and scale_16 to be applied.
|
||||
|
||||
Version 1.5.4beta07 [June 19, 2011]
|
||||
Fixed pngvalid, simplified macros, added checking for 0 in sCAL.
|
||||
The ACCURATE scale macro is no longer defined in 1.5 - call the
|
||||
png_scale_16_to_8 API. Made sure that PNG_READ_16_TO_8 is still defined
|
||||
if the png_strip_16_to_8 API is present. png_check_fp_number now
|
||||
maintains some state so that positive, negative and zero values are
|
||||
identified. sCAL uses these to be strictly spec conformant.
|
||||
|
||||
Version 1.5.4beta08 [June 23, 2011]
|
||||
Fixed pngvalid if ACCURATE_SCALE is defined.
|
||||
Updated scripts/pnglibconf.h.prebuilt.
|
||||
|
||||
Version 1.5.4rc01 [June 30, 2011]
|
||||
Define PNG_ALLOCATED to "restrict" only if MSC_VER >= 1400.
|
||||
|
||||
Version 1.5.4 [July 7, 2011]
|
||||
No changes.
|
||||
|
||||
Version 1.5.5beta01 [July 13, 2011]
|
||||
Fixed some typos and made other minor changes in the manual.
|
||||
Updated contrib/pngminus/makefile.std (Samuli Souminen)
|
||||
|
||||
Version 1.5.5beta02 [July 14, 2011]
|
||||
Revised Makefile.am and Makefile.in to look in the right directory for
|
||||
pnglibconf.h.prebuilt
|
||||
|
||||
Version 1.5.5beta03 [July 27, 2011]
|
||||
Enabled compilation with g++ compiler. This compiler does not recognize
|
||||
the file extension, so it always compiles with C++ rules. Made minor
|
||||
changes to pngrutil.c to cast results where C++ expects it but C does not.
|
||||
Minor editing of libpng.3 and libpng-manual.txt.
|
||||
|
||||
Version 1.5.5beta04 [July 29, 2011]
|
||||
Revised CMakeLists.txt (Clifford Yapp)
|
||||
Updated commentary about the png_rgb_to_gray() default coefficients
|
||||
in the manual and in pngrtran.c
|
||||
|
||||
Version 1.5.5beta05 [August 17, 2011]
|
||||
Prevent unexpected API exports from non-libpng DLLs on Windows. The "_DLL"
|
||||
is removed from the test of whether a DLL is being built (this erroneously
|
||||
caused the libpng APIs to be marked as DLL exports in static builds under
|
||||
Microsoft Visual Studio). Almost all of the libpng building configuration
|
||||
is moved from pngconf.h to pngpriv.h, but PNG_DLL_EXPORT remains in
|
||||
pngconf.h, though, so that it is colocated with the import definition (it
|
||||
is no longer used anywhere in the installed headers). The VStudio project
|
||||
definitions have been cleaned up: "_USRDLL" has been removed from the
|
||||
static library builds (this was incorrect), and PNG_USE_DLL has been added
|
||||
to pngvalid to test the functionality (pngtest does not supply it,
|
||||
deliberately). The spurious "_EXPORTS" has been removed from the
|
||||
libpng build (all these errors were a result of copy/paste between project
|
||||
configurations.)
|
||||
Added new types and internal functions for CIE RGB end point handling to
|
||||
pngpriv.h (functions yet to be implemented).
|
||||
|
||||
Version 1.5.5beta06 [August 26, 2011]
|
||||
Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set in CMakeLists.txt
|
||||
(Clifford Yap)
|
||||
Fixes to rgb_to_gray and cHRM XYZ APIs (John Bowler):
|
||||
The rgb_to_gray code had errors when combined with gamma correction.
|
||||
Some pixels were treated as true grey when they weren't and such pixels
|
||||
and true grey ones were not gamma corrected (the original value of the
|
||||
red component was used instead). APIs to get and set cHRM using color
|
||||
space end points have been added and the rgb_to_gray code that defaults
|
||||
based on cHRM, and the divide-by-zero bug in png_handle_cHRM (CERT
|
||||
VU#477046, CVE-2011-3328, introduced in 1.5.4) have been corrected.
|
||||
A considerable number of tests has been added to pngvalid for the
|
||||
rgb_to_gray transform.
|
||||
Arithmetic errors in rgb_to_gray whereby the calculated gray value was
|
||||
truncated to the bit depth rather than rounded have been fixed except in
|
||||
the 8-bit non-gamma-corrected case (where consistency seems more important
|
||||
than correctness.) The code still has considerable inaccuracies in the
|
||||
8-bit case because 8-bit linear arithmetic is used.
|
||||
|
||||
Version 1.5.5beta07 [September 7, 2011]
|
||||
Added "$(ARCH)" option to makefile.darwin
|
||||
Added SunOS support to configure.ac and Makefile.am
|
||||
Changed png_chunk_benign_error() to png_warning() in png.c, in
|
||||
png_XYZ_from_xy_checked().
|
||||
|
||||
Version 1.5.5beta08 [September 10, 2011]
|
||||
Fixed 64-bit compilation errors (gcc). The errors fixed relate
|
||||
to conditions where types that are 32 bits in the GCC 32-bit
|
||||
world (uLong and png_size_t) become 64 bits in the 64-bit
|
||||
world. This produces potential truncation errors which the
|
||||
compiler correctly flags.
|
||||
Relocated new HAVE_SOLARIS_LD definition in configure.ac
|
||||
Constant changes for 64-bit compatibility (removal of L suffixes). The
|
||||
16-bit cases still use "L" as we don't have a 16-bit test system.
|
||||
|
||||
Version 1.5.5rc01 [September 15, 2011]
|
||||
Removed "L" suffixes in pngpriv.h
|
||||
|
||||
Version 1.5.5 [September 22, 2011]
|
||||
No changes.
|
||||
|
||||
Version 1.5.6beta01 [September 22, 2011]
|
||||
Fixed some 64-bit type conversion warnings in pngrtran.c
|
||||
Moved row_info from png_struct to a local variable.
|
||||
The various interlace mask arrays have been made into arrays of
|
||||
bytes and made PNG_CONST and static (previously some arrays were
|
||||
marked PNG_CONST and some weren't).
|
||||
Additional checks have been added to the transform code to validate the
|
||||
pixel depths after the transforms on both read and write.
|
||||
Removed some redundant code from pngwrite.c, in png_destroy_write_struct().
|
||||
Changed chunk reading/writing code to use png_uint_32 instead of png_byte[4].
|
||||
This removes the need to allocate temporary strings for chunk names on
|
||||
the stack in the read/write code. Unknown chunk handling still uses the
|
||||
string form because this is exposed in the API.
|
||||
|
||||
Version 1.5.6beta02 [September 26, 2011]
|
||||
Added a note in the manual the png_read_update_info() must be called only
|
||||
once with a particular info_ptr.
|
||||
Fixed a typo in the definition of the new PNG_STRING_FROM_CHUNK(s,c) macro.
|
||||
|
||||
Version 1.5.6beta03 [September 28, 2011]
|
||||
Revised test-pngtest.sh to report FAIL when pngtest fails.
|
||||
Added "--strict" option to pngtest, to report FAIL when the failure is
|
||||
only because the resulting valid files are different.
|
||||
Revised CMakeLists.txt to work with mingw and removed some material from
|
||||
CMakeLists.txt that is no longer useful in libpng-1.5.
|
||||
|
||||
Version 1.5.6beta04 [October 5, 2011]
|
||||
Fixed typo in Makefile.in and Makefile.am ("-M Wl" should be "-M -Wl")."
|
||||
|
||||
Version 1.5.6beta05 [October 12, 2011]
|
||||
Speed up png_combine_row() for interlaced images. This reduces the generality
|
||||
of the code, allowing it to be optimized for Adam7 interlace. The masks
|
||||
passed to png_combine_row() are now generated internally, avoiding
|
||||
some code duplication and localizing the interlace handling somewhat.
|
||||
Align png_struct::row_buf - previously it was always unaligned, caused by
|
||||
a bug in the code that attempted to align it; the code needs to subtract
|
||||
one from the pointer to take account of the filter byte prepended to
|
||||
each row.
|
||||
Optimized png_combine_row() when rows are aligned. This gains a small
|
||||
percentage for 16-bit and 32-bit pixels in the typical case where the
|
||||
output row buffers are appropriately aligned. The optimization was not
|
||||
previously possible because the png_struct buffer was always misaligned.
|
||||
Fixed bug in png_write_chunk_header() debug print, introduced in 1.5.6beta01.
|
||||
|
||||
Version 1.5.6beta06 [October 17, 2011]
|
||||
Removed two redundant tests for unitialized row.
|
||||
Fixed a relatively harmless memory overwrite in compressed text writing
|
||||
with a 1 byte zlib buffer.
|
||||
Add ability to call png_read_update_info multiple times to pngvalid.c.
|
||||
Fixes for multiple calls to png_read_update_info. These fixes attend to
|
||||
most of the errors revealed in pngvalid, however doing the gamma work
|
||||
twice results in inaccuracies that can't be easily fixed. There is now
|
||||
a warning in the code if this is going to happen.
|
||||
Turned on multiple png_read_update_info in pngvalid transform tests.
|
||||
Prevent libpng from overwriting unused bits at the end of the image when
|
||||
it is not byte aligned, while reading. Prior to libpng-1.5.6 libpng would
|
||||
overwrite the partial byte at the end of each row if the row width was not
|
||||
an exact multiple of 8 bits and the image is not interlaced.
|
||||
|
||||
Version 1.5.6beta07 [October 21, 2011]
|
||||
Made png_ptr->prev_row an aligned pointer into png_ptr->big_prev_row
|
||||
(Mans Rullgard).
|
||||
|
||||
Version 1.5.6rc01 [October 26, 2011]
|
||||
Changed misleading "Missing PLTE before cHRM" warning to "Out of place cHRM"
|
||||
|
||||
Version 1.5.6rc02 [October 27, 2011]
|
||||
Added LSR() macro to defend against buggy compilers that evaluate non-taken
|
||||
code branches and complain about out-of-range shifts.
|
||||
|
||||
Version 1.5.6rc03 [October 28, 2011]
|
||||
Renamed the LSR() macro to PNG_LSR() and added PNG_LSL() macro.
|
||||
Fixed compiler warnings with Intel and MSYS compilers. The logical shift
|
||||
fix for Microsoft Visual C is required by other compilers, so this
|
||||
enables that fix for all compilers when using compile-time constants.
|
||||
Under MSYS 'byte' is a name declared in a system header file, so we
|
||||
changed the name of a local variable to avoid the warnings that result.
|
||||
Added #define PNG_ALIGN_TYPE PNG_ALIGN_NONE to contrib/pngminim/*/pngusr.h
|
||||
|
||||
Version 1.5.6 [November 3, 2011]
|
||||
No changes.
|
||||
|
||||
Version 1.5.7beta01 [November 4, 2011]
|
||||
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.
|
||||
|
||||
Version 1.5.7beta02 [November 11, 2011]
|
||||
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.
|
||||
Updated scripts/pnglibconf.mak and scripts/makefile.std to handle the
|
||||
new PNG_JOIN macro.
|
||||
Added versioning to pnglibconf.h comments.
|
||||
Simplified read/write API initial version; basic read/write tested on
|
||||
a variety of images, limited documentation (in the header file.)
|
||||
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.
|
||||
|
||||
Version 1.5.7beta03 [November 17, 2011]
|
||||
Removed PNG_CONST from the sRGB table declarations in pngpriv.h and png.c
|
||||
Added run-time detection of NEON support.
|
||||
Added contrib/libtests; includes simplified API test and timing test and
|
||||
a color conversion utility for rapid checking of failed 'pngstest' results.
|
||||
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 the simplified APIs themselves and to some bugs in compose and rgb to
|
||||
gray (on palette) itself.
|
||||
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)
|
||||
Work around compilers that don't support declaration of const data. Some
|
||||
compilers fault 'extern const' data declarations (because the data is
|
||||
not initialized); this turns on const-ness only for compilers where
|
||||
this is known to work.
|
||||
|
||||
Version 1.5.7beta04 [November 17, 2011]
|
||||
Since the gcc driver does not recognize the --noexecstack flag, we must
|
||||
use the -Wa prefix to have it passed through to the assembler.
|
||||
Also removed a duplicate setting of this flag.
|
||||
Added files that were omitted from the libpng-1.5.7beta03 zip distribution.
|
||||
|
||||
Version 1.5.7beta05 [November 25, 2011]
|
||||
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.
|
||||
Backed out 'simplified' API changes. The API seems too complex and there
|
||||
is a lack of consensus or enthusiasm for the proposals. The API also
|
||||
reveals significant bugs inside libpng (double gamma correction and the
|
||||
known bug of being unable to retrieve a corrected palette). It seems
|
||||
better to wait until the bugs, at least, are corrected.
|
||||
Moved pngvalid.c into contrib/libtests
|
||||
Rebuilt Makefile.in, configure, etc., with autoconf-2.68
|
||||
|
||||
Version 1.5.7rc01 [December 1, 2011]
|
||||
Replaced an "#if" with "#ifdef" in pngrtran.c
|
||||
Revised #if PNG_DO_BC block in png.c (use #ifdef and add #else)
|
||||
|
||||
Version 1.5.7rc02 [December 5, 2011]
|
||||
Revised project files and contrib/pngvalid/pngvalid.c to account for
|
||||
the relocation of pngvalid into contrib/libtests.
|
||||
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.
|
||||
|
||||
Version 1.5.7rc03 [December 7, 2011]
|
||||
Updated CMakeLists.txt to account for the relocation of pngvalid.c
|
||||
|
||||
Version 1.5.7 [December 15, 2011]
|
||||
Minor fixes to pngvalid.c for gcc 4.6.2 compatibility to remove warnings
|
||||
reported by earlier versions.
|
||||
Fixed minor memset/sizeof errors in pngvalid.c.
|
||||
|
||||
Version 1.6.0beta01 [December 15, 2011]
|
||||
Removed machine-generated configure files from the GIT repository (they will
|
||||
continue to appear in the tarball distributions).
|
||||
Restored the new 'simplified' API, which was started in libpng-1.5.7beta02
|
||||
but later deleted from libpng-1.5.7beta05.
|
||||
Added example programs for the new 'simplified' API.
|
||||
Added ANSI-C (C90) headers and require them, and take advantage of the
|
||||
change. Also fixed some of the projects/* and contrib/* files that needed
|
||||
updates for libpng16 and the move of pngvalid.c.
|
||||
With this change the required ANSI-C header files are assumed to exist: the
|
||||
implementation must provide float.h, limits.h, stdarg.h and stddef.h and
|
||||
libpng relies on limits.h and stddef.h existing and behaving as defined
|
||||
(the other two required headers aren't used). Non-ANSI systems that don't
|
||||
have stddef.h or limits.h will have to provide an appropriate fake
|
||||
containing the relevant types and #defines.
|
||||
The use of FAR/far has been eliminated and the definition of png_alloc_size_t
|
||||
is now controlled by a flag so that 'small size_t' systems can select it
|
||||
if necessary. Libpng 1.6 may not currently work on such systems -- it
|
||||
seems likely that it will ask 'malloc' for more than 65535 bytes with any
|
||||
image that has a sufficiently large row size (rather than simply failing
|
||||
to read such images).
|
||||
New tools directory containing tools used to generate libpng code.
|
||||
Fixed race conditions in parallel make builds. With higher degrees of
|
||||
parallelism during 'make' the use of the same temporary file names such
|
||||
as 'dfn*' can result in a race where a temporary file from one arm of the
|
||||
build is deleted or overwritten in another arm. This changes the
|
||||
temporary files for suffix rules to always use $* and ensures that the
|
||||
non-suffix rules use unique file names.
|
||||
|
||||
Version 1.6.0beta02 [December 21, 2011]
|
||||
Correct configure builds where build and source directories are separate.
|
||||
The include path of 'config.h' was erroneously made relative in pngvalid.c
|
||||
in libpng 1.5.7.
|
||||
|
||||
Version 1.6.0beta03 [December 22, 2011]
|
||||
Start-up code size improvements, error handler flexibility. These changes
|
||||
alter how the tricky allocation of the initial png_struct and png_info
|
||||
structures are handled. png_info is now handled in pretty much the same
|
||||
way as everything else, except that the allocations handle NULL return
|
||||
silently. png_struct is changed in a similar way on allocation and on
|
||||
deallocation a 'safety' error handler is put in place (which should never
|
||||
be required). The error handler itself is changed to permit mismatches
|
||||
in the application and libpng error buffer size; however, this means a
|
||||
silent change to the API to return the jmp_buf if the size doesn't match
|
||||
the size from the libpng compilation; libpng now allocates the memory and
|
||||
this may fail. Overall these changes result in slight code size
|
||||
reductions; however, this is a reduction in code that is always executed
|
||||
so is particularly valuable. Overall on a 64-bit system the libpng DLL
|
||||
decreases in code size by 1733 bytes. pngerror.o increases in size by
|
||||
about 465 bytes because of the new functionality.
|
||||
|
||||
Version 1.6.0beta04 [December 30, 2011]
|
||||
Regenerated configure scripts with automake-1.11.2
|
||||
Eliminated png_info_destroy(). It is now used only in png.c and only calls
|
||||
one other internal function and memset().
|
||||
Enabled png_get_sCAL_fixed() if floating point APIs are enabled. Previously
|
||||
it was disabled whenever internal fixed point arithmetic was selected,
|
||||
which meant it didn't exist even on systems where FP was available but not
|
||||
preferred.
|
||||
Added pngvalid.c compile time checks for const APIs.
|
||||
Implemented 'restrict' for png_info and png_struct. Because of the way
|
||||
libpng works both png_info and png_struct are always accessed via a
|
||||
single pointer. This means adding C99 'restrict' to the pointer gives
|
||||
the compiler some opportunity to optimize the code. This change allows
|
||||
that.
|
||||
Moved AC_MSG_CHECKING([if libraries can be versioned]) later to the proper
|
||||
location in configure.ac (Gilles Espinasse).
|
||||
Changed png_memcpy to C assignment where appropriate. Changed all those
|
||||
uses of png_memcpy that were doing a simple assignment to assignments
|
||||
(all those cases where the thing being copied is a non-array C L-value).
|
||||
Added some error checking to png_set_*() routines.
|
||||
Removed the reference to the non-exported function png_memcpy() from
|
||||
example.c.
|
||||
Fixed the Visual C 64-bit build - it requires jmp_buf to be aligned, but
|
||||
it had become misaligned.
|
||||
Revised contrib/pngminus/pnm2png.c to avoid warnings when png_uint_32
|
||||
and unsigned long are of different sizes.
|
||||
|
||||
Version 1.6.0beta05 [January 15, 2012]
|
||||
Updated manual with description of the simplified API (copied from png.h)
|
||||
Fix bug in pngerror.c: some long warnings were being improperly truncated
|
||||
(CVE-2011-3464, bug introduced in libpng-1.5.3beta05).
|
||||
|
||||
Version 1.6.0beta06 [January 24, 2012]
|
||||
Added palette support to the simplified APIs. This commit
|
||||
changes some of the macro definitions in png.h, app code
|
||||
may need corresponding changes.
|
||||
Increased the formatted warning buffer to 192 bytes.
|
||||
Added color-map support to simplified API. This is an initial version for
|
||||
review; the documentation has not yet been updated.
|
||||
Fixed Min/GW uninstall to remove libpng.dll.a
|
||||
|
||||
Version 1.6.0beta07 [January 28, 2012]
|
||||
Eliminated Intel icc/icl compiler warnings. The Intel (GCC derived)
|
||||
compiler issues slightly different warnings from those issued by the
|
||||
current vesions of GCC. This eliminates those warnings by
|
||||
adding/removing casts and small code rewrites.
|
||||
Updated configure.ac from autoupdate: added --enable-werror option.
|
||||
Also some layout regularization and removal of introduced tab characters
|
||||
(replaced with 3-character indentation). Obsolete macros identified by
|
||||
autoupdate have been removed; the replacements are all in 2.59 so
|
||||
the pre-req hasn't been changed. --enable-werror checks for support
|
||||
for -Werror (or the given argument) in the compiler. This mimics the
|
||||
gcc configure option by allowing -Werror to be turned on safely; without
|
||||
the option the tests written in configure itself fail compilation because
|
||||
they cause compiler warnings.
|
||||
Rewrote autogen.sh to run autoreconf instead of running tools one-by-one.
|
||||
Conditionalize the install rules for MINGW and CYGWIN in CMakeLists.txt and
|
||||
set CMAKE_LIBRARY_OUTPUT_DIRECTORY to "lib" on all platforms (C. Yapp).
|
||||
Freeze libtool files in the 'scripts' directory. This version of autogen.sh
|
||||
attempts to dissuade people from running it when it is not, or should not,
|
||||
be necessary. In fact, autogen.sh does not work when run in a libpng
|
||||
directory extracted from atar distribution anymore. You must run it in
|
||||
a GIT clone instead.
|
||||
Added two images to contrib/pngsuite (1-bit and 2-bit transparent grayscale),
|
||||
and renamed three whose names were inconsistent with those in
|
||||
pngsuite/README.txt.
|
||||
|
||||
Version 1.6.0beta08 [February 1, 2012]
|
||||
Fixed Image::colormap misalignment in pngstest.c
|
||||
Check libtool/libtoolize version number (2.4.2) in configure.ac
|
||||
Divide test-pngstest.sh into separate pngstest runs for basic and
|
||||
transparent images.
|
||||
Moved automake options to AM_INIT_AUTOMAKE in configure.ac
|
||||
Added color-tests, silent-rules (Not yet implemented in Makefile.am) and
|
||||
version checking to configure.ac
|
||||
Improved pngstest speed by not doing redundant tests and add const to
|
||||
the background parameter of png_image_finish_read. The --background
|
||||
option is now done automagically only when required, so that commandline
|
||||
option no longer exists.
|
||||
Cleaned up pngpriv.h to consistently declare all functions and data.
|
||||
Also eliminated PNG_CONST_DATA, which is apparently not needed but we
|
||||
can't be sure until it is gone.
|
||||
Added symbol prefixing that allows all the libpng external symbols
|
||||
to be prefixed (suggested by Reuben Hawkins).
|
||||
Updated "ftbb*.png" list in the owatcom and vstudio projects.
|
||||
Fixed 'prefix' builds on clean systems. The generation of pngprefix.h
|
||||
should not require itself.
|
||||
Updated INSTALL to explain that autogen.sh must be run in a GIT clone,
|
||||
not in a libpng directory extracted from a tar distribution.
|
||||
|
||||
Version 1.6.0beta09 [February 1, 2011]
|
||||
Reverted the prebuilt configure files to libpng-1.6.0beta05 condition.
|
||||
|
||||
Version 1.6.0beta10 [February 3, 2012]
|
||||
Added Z_SOLO for zlib-1.2.6+ and correct pngstest tests
|
||||
Updated list of test images in CMakeLists.txt
|
||||
Updated the prebuilt configure files to current condition.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
@@ -3249,5 +3933,4 @@ to subscribe)
|
||||
or to glennrp at users.sourceforge.net
|
||||
|
||||
Glenn R-P
|
||||
*/ }
|
||||
#endif
|
||||
|
||||
261
CMakeLists.txt
@@ -1,3 +1,11 @@
|
||||
# CMakeLists.txt
|
||||
|
||||
# Copyright (C) 2007-2011 Glenn Randers-Pehrson
|
||||
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
|
||||
cmake_minimum_required(VERSION 2.4.4)
|
||||
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
|
||||
|
||||
@@ -25,15 +33,9 @@ endif()
|
||||
project(libpng C)
|
||||
enable_testing()
|
||||
|
||||
# Copyright (C) 2007-2011 Glenn Randers-Pehrson
|
||||
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
|
||||
set(PNGLIB_MAJOR 1)
|
||||
set(PNGLIB_MINOR 5)
|
||||
set(PNGLIB_RELEASE 1)
|
||||
set(PNGLIB_MINOR 6)
|
||||
set(PNGLIB_RELEASE 0)
|
||||
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
||||
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
|
||||
|
||||
@@ -67,39 +69,11 @@ else()
|
||||
option(PNG_STATIC "Build static lib" ON)
|
||||
endif()
|
||||
|
||||
if(MINGW)
|
||||
option(PNG_TESTS "Build pngtest" NO)
|
||||
else()
|
||||
option(PNG_TESTS "Build pngtest" YES)
|
||||
endif()
|
||||
option(PNG_TESTS "Build libpng tests" YES)
|
||||
|
||||
option(PNG_NO_CONSOLE_IO "FIXME" YES)
|
||||
option(PNG_NO_STDIO "FIXME" YES)
|
||||
# Many more configuration options could be added here
|
||||
option(PNG_DEBUG "Build with debug output" NO)
|
||||
option(PNGARG "FIXME" YES)
|
||||
#TODO:
|
||||
# PNG_CONSOLE_IO_SUPPORTED
|
||||
|
||||
# maybe needs improving, but currently I don't know when we can enable what :)
|
||||
set(png_asm_tmp "OFF")
|
||||
if(NOT WIN32)
|
||||
find_program(uname_executable NAMES uname PATHS /bin /usr/bin /usr/local/bin)
|
||||
if(uname_executable)
|
||||
exec_program(${uname_executable}
|
||||
ARGS --machine OUTPUT_VARIABLE uname_output)
|
||||
if("uname_output" MATCHES "^.*i[1-9]86.*$")
|
||||
set(png_asm_tmp "ON")
|
||||
else("uname_output" MATCHES "^.*i[1-9]86.*$")
|
||||
set(png_asm_tmp "OFF")
|
||||
endif("uname_output" MATCHES "^.*i[1-9]86.*$")
|
||||
endif(uname_executable)
|
||||
else()
|
||||
# this env var is normally only set on win64
|
||||
set(TEXT "ProgramFiles(x86)")
|
||||
if("$ENV{${TEXT}}" STREQUAL "")
|
||||
set(png_asm_tmp "ON")
|
||||
endif("$ENV{${TEXT}}" STREQUAL "")
|
||||
endif()
|
||||
option(PNGARG "Disable ANSI-C prototypes" NO)
|
||||
|
||||
# SET LIBNAME
|
||||
set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
||||
@@ -108,6 +82,9 @@ set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
|
||||
# Use the prebuilt pnglibconf.h file from the scripts folder
|
||||
# TODO: fix this by building with awk; without this no cmake build can be
|
||||
# configured directly (to do so indirectly use your local awk to build a
|
||||
# pnglibconf.h in the build directory.)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
|
||||
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
@@ -143,44 +120,22 @@ set(libpng_sources
|
||||
set(pngtest_sources
|
||||
pngtest.c
|
||||
)
|
||||
set(pngvalid_sources
|
||||
contrib/libtests/pngvalid.c
|
||||
)
|
||||
set(pngstest_sources
|
||||
contrib/libtests/pngstest.c
|
||||
)
|
||||
# SOME NEEDED DEFINITIONS
|
||||
|
||||
add_definitions(-DPNG_CONFIGURE_LIBPNG)
|
||||
|
||||
if(_AIX)
|
||||
add_definitions(-D_ALL_SOURCE)
|
||||
endif(_AIX)
|
||||
|
||||
if(MSVC)
|
||||
add_definitions(-DPNG_NO_MODULEDEF -D_CRT_SECURE_NO_DEPRECATE)
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
endif(MSVC)
|
||||
|
||||
if(PNG_SHARED OR NOT MSVC)
|
||||
#if building msvc static this has NOT to be defined
|
||||
add_definitions(-DZLIB_DLL)
|
||||
endif()
|
||||
|
||||
|
||||
if(PNG_CONSOLE_IO_SUPPORTED)
|
||||
add_definitions(-DPNG_CONSOLE_IO_SUPPORTED)
|
||||
endif()
|
||||
|
||||
if(PNG_NO_CONSOLE_IO)
|
||||
add_definitions(-DPNG_NO_CONSOLE_IO)
|
||||
endif()
|
||||
|
||||
if(PNG_NO_STDIO)
|
||||
add_definitions(-DPNG_NO_STDIO)
|
||||
endif()
|
||||
|
||||
if(PNG_DEBUG)
|
||||
add_definitions(-DPNG_DEBUG)
|
||||
endif()
|
||||
|
||||
if(NOT M_LIBRARY AND NOT WIN32)
|
||||
add_definitions(-DPNG_NO_FLOATING_POINT_SUPPORTED)
|
||||
endif()
|
||||
|
||||
# NOW BUILD OUR TARGET
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR})
|
||||
|
||||
@@ -205,7 +160,6 @@ if(PNG_STATIC)
|
||||
target_link_libraries(${PNG_LIB_NAME_STATIC} ${ZLIB_LIBRARY} ${M_LIBRARY})
|
||||
endif()
|
||||
|
||||
|
||||
if(PNG_SHARED AND WIN32)
|
||||
set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
|
||||
endif()
|
||||
@@ -215,33 +169,80 @@ if(PNG_TESTS AND PNG_SHARED)
|
||||
add_executable(pngtest ${pngtest_sources})
|
||||
target_link_libraries(pngtest ${PNG_LIB_NAME})
|
||||
add_test(pngtest ./pngtest ${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png)
|
||||
#
|
||||
add_executable(pngvalid ${pngvalid_sources})
|
||||
target_link_libraries(pngvalid ${PNG_LIB_NAME})
|
||||
add_test(pngvalid ./pngvalid)
|
||||
add_executable(pngstest ${pngstest_sources})
|
||||
target_link_libraries(pngstest ${PNG_LIB_NAME})
|
||||
add_test(pngstest ./pngstest
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g01.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g02.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g04.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g16.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn2c08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn2c16.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p01.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p02.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p04.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn4a08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn4a16.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn6a08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn6a16.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn0g01.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn0g02.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn0g04.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn2c16.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn3p08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbgn2c16.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbgn3p08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbrn2c08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbwn0g16.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbwn3p08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbyn3p08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n0g08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n2c08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n3p08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp1n3p08.png
|
||||
)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set
|
||||
IF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "lib")
|
||||
ENDIF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
|
||||
# Set a variable with CMake code which:
|
||||
# Creates a symlink from src to dest (if possible) or alternatively
|
||||
# copies if different.
|
||||
macro(_png_generate_symlink_code CODE SRC DEST)
|
||||
if(WIN32 AND NOT CYGWIN)
|
||||
set(_png_gsc_message "Copying ${SRC} to ${DEST} if needed")
|
||||
set(_png_gsc_operation "copy_if_different")
|
||||
else()
|
||||
set(_png_gsc_message "Symlinking ${SRC} to ${DEST}")
|
||||
set(_png_gsc_operation "create_symlink")
|
||||
endif()
|
||||
|
||||
set(${CODE} "
|
||||
message(STATUS \"${_png_gsc_message}\")
|
||||
execute_process(COMMAND \${CMAKE_COMMAND} -E ${_png_gsc_operation}
|
||||
\"${SRC}\" \"${DEST}\")
|
||||
")
|
||||
macro(CREATE_SYMLINK SRC_FILE DEST_FILE)
|
||||
FILE(REMOVE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
|
||||
if(WIN32 AND NOT CYGWIN AND NOT MINGW)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
|
||||
DEPENDS ${PNG_LIB_NAME} ${PNG_LIB_NAME_STATIC}
|
||||
)
|
||||
ADD_CUSTOM_TARGET(${DEST_FILE}_COPY ALL DEPENDS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
|
||||
else(WIN32 AND NOT CYGWIN AND NOT MINGW)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC_FILE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC_FILE} ${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif(WIN32 AND NOT CYGWIN AND NOT MINGW)
|
||||
endmacro()
|
||||
|
||||
# CREATE PKGCONFIG FILES
|
||||
# we use the same files like ./configure, so we have to set its vars
|
||||
# libpng is a library so default to 'lib'
|
||||
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
set(CMAKE_INSTALL_LIBDIR lib)
|
||||
endif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
|
||||
# CREATE PKGCONFIG FILES
|
||||
# we use the same files like ./configure, so we have to set its vars
|
||||
# Only do this on Windows for Cygwin - the files don't make much sense outside
|
||||
# a UNIX look alike
|
||||
if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
set(prefix ${CMAKE_INSTALL_PREFIX})
|
||||
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
|
||||
set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
|
||||
@@ -249,24 +250,19 @@ set(includedir ${CMAKE_INSTALL_PREFIX}/include)
|
||||
set(LIBS "-lz -lm")
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY)
|
||||
_png_generate_symlink_code(PNG_PC_INSTALL_CODE
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libpng.pc)
|
||||
install(CODE ${PNG_PC_INSTALL_CODE})
|
||||
CREATE_SYMLINK(${PNGLIB_NAME}.pc libpng.pc)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY)
|
||||
_png_generate_symlink_code(PNG_CONFIG_INSTALL_CODE
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libpng-config)
|
||||
install(CODE ${PNG_CONFIG_INSTALL_CODE})
|
||||
CREATE_SYMLINK(${PNGLIB_NAME}-config libpng-config)
|
||||
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
|
||||
# SET UP LINKS
|
||||
if(PNG_SHARED)
|
||||
set_target_properties(${PNG_LIB_NAME} PROPERTIES
|
||||
# VERSION 15.${PNGLIB_RELEASE}.1.5.1
|
||||
VERSION 15.${PNGLIB_RELEASE}.0
|
||||
SOVERSION 15
|
||||
# VERSION 16.${PNGLIB_RELEASE}.1.6.0beta10
|
||||
VERSION 16.${PNGLIB_RELEASE}.0
|
||||
SOVERSION 16
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
endif()
|
||||
if(PNG_STATIC)
|
||||
@@ -298,62 +294,36 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
# Create a symlink for libpng.dll.a => libpng15.dll.a on Cygwin
|
||||
if(CYGWIN)
|
||||
_png_generate_symlink_code(PNG_SHARED_IMPLIB_INSTALL_CODE
|
||||
${PNGLIB_NAME}${CMAKE_IMPORT_LIBRARY_SUFFIX}
|
||||
libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
|
||||
install(CODE ${PNG_SHARED_IMPLIB_INSTALL_CODE})
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}
|
||||
# Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
|
||||
if(CYGWIN OR MINGW)
|
||||
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
|
||||
get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)
|
||||
CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
endif(CYGWIN OR MINGW)
|
||||
|
||||
if(NOT WIN32)
|
||||
IF(CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
_png_generate_symlink_code(PNG_SHARED_INSTALL_CODE
|
||||
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PNGLIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
install(CODE ${PNG_SHARED_INSTALL_CODE})
|
||||
install(FILES
|
||||
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
|
||||
get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)
|
||||
CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
ELSE(CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
_png_generate_symlink_code(PNG_SHARED_INSTALL_CODE
|
||||
${PNGLIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
install(CODE ${PNG_SHARED_INSTALL_CODE})
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
ENDIF(CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
endif()
|
||||
endif()
|
||||
endif(NOT WIN32)
|
||||
endif(PNG_SHARED)
|
||||
|
||||
if(PNG_STATIC)
|
||||
install(TARGETS ${PNG_LIB_NAME_STATIC}
|
||||
${PNG_EXPORT_RULE}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
if(NOT WIN32 OR CYGWIN)
|
||||
IF(CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
|
||||
_png_generate_symlink_code(PNG_STATIC_INSTALL_CODE
|
||||
${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${PNGLIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
install(CODE ${PNG_STATIC_INSTALL_CODE})
|
||||
install(FILES
|
||||
${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME_STATIC} LOCATION_${CMAKE_BUILD_TYPE})
|
||||
get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)
|
||||
CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
ELSE(CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
|
||||
_png_generate_symlink_code(PNG_STATIC_INSTALL_CODE
|
||||
${PNGLIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
install(CODE ${PNG_STATIC_INSTALL_CODE})
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
ENDIF(CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
|
||||
endif()
|
||||
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -362,10 +332,13 @@ if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
|
||||
install(FILES ${libpng_public_hdrs} DESTINATION include/${PNGLIB_NAME})
|
||||
endif()
|
||||
if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL )
|
||||
if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin)
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
|
||||
DESTINATION bin)
|
||||
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
|
||||
# Install man pages
|
||||
if(NOT PNG_MAN_DIR)
|
||||
@@ -374,6 +347,7 @@ if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
|
||||
install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3)
|
||||
install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5)
|
||||
# Install pkg-config files
|
||||
if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config
|
||||
@@ -382,6 +356,7 @@ if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
|
||||
DESTINATION bin)
|
||||
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
endif()
|
||||
|
||||
# On versions of CMake that support it, create an export file CMake
|
||||
@@ -392,11 +367,9 @@ endif()
|
||||
|
||||
# what's with libpng-$VER%.txt and all the extra files?
|
||||
|
||||
|
||||
# UNINSTALL
|
||||
# do we need this?
|
||||
|
||||
|
||||
# DIST
|
||||
# do we need this?
|
||||
|
||||
|
||||
34
INSTALL
@@ -9,16 +9,16 @@ On Unix/Linux and similar systems, you can simply type
|
||||
|
||||
and ignore the rest of this document.
|
||||
|
||||
If configure does not work on your system and you have a reasonably
|
||||
up-to-date set of tools, running ./autogen.sh before running ./configure
|
||||
may fix the problem. You can also run the individual commands in
|
||||
autogen.sh with the --force option, if supported by your version of
|
||||
the tools. To be really sure that you aren't using any of the included
|
||||
pre-built scripts, you can do this:
|
||||
If configure does not work on your system, or if you have a need to
|
||||
change configure.ac or Makefile.am, and you have a reasonably
|
||||
up-to-date set of tools, running ./autogen.sh in a git clone before
|
||||
running ./configure may fix the problem. To be really sure that you
|
||||
aren't using any of the included pre-built scripts, you can do this:
|
||||
|
||||
./configure --enable-maintainer-mode
|
||||
make maintainer-clean
|
||||
./autogen.sh
|
||||
./autogen.sh --maintainer --clean
|
||||
./autogen.sh --maintainer
|
||||
./configure [--prefix=/path] [other options]
|
||||
make
|
||||
make install
|
||||
@@ -133,3 +133,23 @@ run "make install".
|
||||
Further information can be found in the README and libpng-manual.txt
|
||||
files, in the individual makefiles, in png.h, and the manual pages
|
||||
libpng.3 and png.5.
|
||||
|
||||
Using the ./configure script -- 16 December 2002.
|
||||
=================================================
|
||||
|
||||
The ./configure script should work compatibly with what scripts/makefile.*
|
||||
did, however there are some options you might need to add to configure
|
||||
explicitly, which previously was done semi-automatically (if you didn't edit
|
||||
scripts/makefile.* yourself, that is)
|
||||
|
||||
CFLAGS="-Wall -O -funroll-loops \
|
||||
-malign-loops=2 -malign-functions=2" ./configure --prefix=/usr/include \
|
||||
--with-pkgconfigdir=/usr/lib/pkgconfig --includedir=/usr/include
|
||||
|
||||
You can alternatively specify --includedir=/usr/include, /usr/local/include,
|
||||
/usr/include/libpng%NN%, or whatever.
|
||||
|
||||
If you find that the configure script is out-of-date or is not supporting
|
||||
your platform properly, try running autogen.sh to regenerate "configure",
|
||||
"Makefile.in", and the other configuration files. Then try configure again.
|
||||
|
||||
|
||||
4
LICENSE
@@ -10,7 +10,7 @@ this sentence.
|
||||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.5.1, February 3, 2011, are
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.6.0beta10, February 3, 2012, are
|
||||
Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-1.2.5
|
||||
with the following individual added to the list of Contributing Authors
|
||||
@@ -108,4 +108,4 @@ certification mark of the Open Source Initiative.
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
February 3, 2011
|
||||
February 3, 2012
|
||||
|
||||
144
Makefile.am
@@ -4,21 +4,22 @@
|
||||
|
||||
PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
|
||||
|
||||
# libpng does not follow GNU file name conventions
|
||||
|
||||
# "color-tests" requires automake 1.11.1 or later. Enable it if you like,
|
||||
# to get red "FAIL" and green "PASS" notations during tests.
|
||||
# AUTOMAKE_OPTIONS = foreign color-tests
|
||||
AUTOMAKE_OPTIONS = foreign
|
||||
ACLOCAL_AMFLAGS = -I scripts
|
||||
|
||||
# test programs - run on make check, make distcheck
|
||||
check_PROGRAMS= pngtest pngvalid
|
||||
TESTS_ENVIRONMENT= srcdir=$(srcdir)
|
||||
check_PROGRAMS= pngtest
|
||||
pngtest_SOURCES = pngtest.c
|
||||
pngtest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
pngvalid_SOURCES = pngvalid.c
|
||||
TESTS = test-pngtest.sh
|
||||
|
||||
# Only do the following if the contrib directory is present.
|
||||
check_PROGRAMS+= pngvalid pngstest
|
||||
pngvalid_SOURCES = contrib/libtests/pngvalid.c
|
||||
pngstest_SOURCES = contrib/libtests/pngstest.c
|
||||
pngvalid_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
TESTS = test-pngtest.sh test-pngvalid-simple.sh test-pngvalid-full.sh
|
||||
TESTS_ENVIRONMENT= srcdir=$(srcdir)
|
||||
pngstest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
TESTS += test-pngvalid-simple.sh test-pngvalid-full.sh test-pngstest.sh
|
||||
|
||||
# man pages
|
||||
dist_man_MANS= libpng.3 libpngpf.3 png.5
|
||||
@@ -36,16 +37,23 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\
|
||||
pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c\
|
||||
png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h
|
||||
|
||||
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
|
||||
if PNG_ARM_NEON
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/filter_neon.S
|
||||
endif
|
||||
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_CPPFLAGS = @LIBPNG_DEFINES@
|
||||
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
|
||||
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined -export-dynamic \
|
||||
-version-number @PNGLIB_MAJOR@@PNGLIB_MINOR@:@PNGLIB_RELEASE@:0
|
||||
|
||||
if HAVE_LD_VERSION_SCRIPT
|
||||
# Versioned symbols and restricted exports
|
||||
if HAVE_SOLARIS_LD
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -Wl,-M -Wl,libpng.vers
|
||||
else
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -Wl,--version-script=libpng.vers
|
||||
endif
|
||||
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.vers
|
||||
else
|
||||
# Only restricted exports when possible
|
||||
@@ -73,14 +81,20 @@ EXTRA_DIST= \
|
||||
|
||||
SCRIPT_CLEANFILES=scripts/*.out scripts/*.chk scripts/pnglibconf.dfn
|
||||
|
||||
CLEANFILES= dfn.c dfn?.out pngout.png libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc \
|
||||
CLEANFILES= *.tf? pngout.png libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc \
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config libpng.vers libpng.sym \
|
||||
check.new pnglibconf.* symbols.new pngtest-log.txt \
|
||||
check.new pnglibconf.* pngprefix.h symbols.new pngtest-log.txt \
|
||||
$(SCRIPT_CLEANFILES)
|
||||
|
||||
MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in \
|
||||
config.sub configure depcomp install-sh ltmain.sh missing
|
||||
|
||||
# PNG_COPTS give extra options for the C compiler to be used on all compilation
|
||||
# steps (unless targe_CFLAGS is specified; that will take precedence over
|
||||
# AM_CFLAGS)
|
||||
PNG_COPTS = @PNG_COPTS@
|
||||
AM_CFLAGS = ${PNG_COPTS}
|
||||
|
||||
# DFNCPP is normally just CPP - the C preprocessor - but on Solaris and maybe
|
||||
# other operating systems (NeXT?) the C preprocessor selected by configure
|
||||
# checks input tokens for validity - effectively it performs part of the ANSI-C
|
||||
@@ -97,7 +111,8 @@ $(PNGLIB_BASENAME)-config: libpng-config
|
||||
cp libpng-config $@
|
||||
|
||||
scripts/sym.out scripts/vers.out: png.h pngconf.h pnglibconf.h
|
||||
scripts/symbols.out: png.h pngconf.h scripts/pnglibconf.h.prebuilt
|
||||
scripts/prefix.out: png.h pngconf.h pnglibconf.out
|
||||
scripts/symbols.out: png.h pngconf.h $(srcdir)/scripts/pnglibconf.h.prebuilt
|
||||
|
||||
libpng.sym: scripts/sym.out
|
||||
rm -f $@
|
||||
@@ -105,10 +120,36 @@ libpng.sym: scripts/sym.out
|
||||
libpng.vers: scripts/vers.out
|
||||
rm -f $@
|
||||
cp $? $@
|
||||
|
||||
if DO_PNG_PREFIX
|
||||
# Rename functions in scripts/prefix.out with a PNG_PREFIX prefix.
|
||||
# Rename macros in scripts/macro.lst from PNG_PREFIXpng_ to PNG_ (the actual
|
||||
# implementation of the macro).
|
||||
pnglibconf.h: pnglibconf.out scripts/prefix.out scripts/macro.lst
|
||||
rm -f $@
|
||||
$(AWK) 's==0 && NR>1{print prev}\
|
||||
s==0{prev=$$0}\
|
||||
s==1{print "#define", $$1, "@PNG_PREFIX@" $$1}\
|
||||
s==2{print "#define @PNG_PREFIX@png_" $$1, "PNG_" $$1}\
|
||||
END{print prev}' s=0 pnglibconf.out s=1 scripts/prefix.out\
|
||||
s=2 ${srcdir}/scripts/macro.lst >pnglibconf.tf8
|
||||
mv pnglibconf.tf8 $@
|
||||
|
||||
pngprefix.h: scripts/intprefix.out
|
||||
rm -f pngprefix.tf1
|
||||
$(AWK) '{print "#define", $$1, "@PNG_PREFIX@" $$1}' $? >pngprefix.tf1
|
||||
mv pngprefix.tf1 $@
|
||||
else
|
||||
pnglibconf.h: pnglibconf.out
|
||||
rm -f $@
|
||||
cp $? $@
|
||||
scripts/pnglibconf.h.prebuilt:
|
||||
|
||||
pngprefix.h: # is empty
|
||||
:>$@
|
||||
endif
|
||||
|
||||
$(srcdir)/scripts/pnglibconf.h.prebuilt:
|
||||
@echo "Attempting to build $@" >&2
|
||||
@echo "This is a machine generated file, but if you want to make" >&2
|
||||
@echo "a new one simply make 'scripts/pnglibconf.out' and copy that" >&2
|
||||
@exit 1
|
||||
@@ -116,59 +157,67 @@ scripts/pnglibconf.h.prebuilt:
|
||||
# The following is necessary to ensure that the local pnglibconf.h is used, not
|
||||
# an installed one (this can happen immediately after on a clean system if
|
||||
# 'make test' is the first thing the user does.)
|
||||
pngvalid.o pngtest.o: pnglibconf.h
|
||||
contrib/libtests/pngstest.o contrib/libtests/pngvalid.o pngtest.o: pnglibconf.h
|
||||
|
||||
# We must use -DPNG_NO_USE_READ_MACROS here even when the library may actually
|
||||
# be built with PNG_USE_READ_MACROS; this stops the read macros interfering
|
||||
# with the symbol file format.
|
||||
# be built with PNG_USE_READ_MACROS; this prevents the read macros from
|
||||
# interfering with the symbol file format.
|
||||
SYMBOL_CFLAGS = -DPNGLIB_LIBNAME='PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0'\
|
||||
-DPNGLIB_VERSION='@PNGLIB_VERSION@'\
|
||||
-DSYMBOL_PREFIX='$(SYMBOL_PREFIX)'\
|
||||
-DPNG_NO_USE_READ_MACROS
|
||||
-DPNG_NO_USE_READ_MACROS -DPNG_BUILDING_SYMBOL_TABLE
|
||||
|
||||
if DO_PNG_PREFIX
|
||||
SYMBOL_CFLAGS += -DPNG_PREFIX='@PNG_PREFIX@'
|
||||
endif
|
||||
|
||||
.dfn.out:
|
||||
rm -f $@ dfn.c dfn?.out
|
||||
rm -f $@ $*.c $*.tf[123]
|
||||
test -d scripts || mkdir scripts
|
||||
echo '#include "$<"' >dfn.c
|
||||
$(DFNCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) @LIBPNG_DEFINES@\
|
||||
$(CPPFLAGS) $(SYMBOL_CFLAGS) dfn.c > dfn1.out
|
||||
$(SED) -n -e 's|^.*PNG_DEFN_MAGIC-\(.*\)-PNG_DEFN_END.*$$|\1|p'\
|
||||
dfn1.out >dfn2.out
|
||||
$(SED) -e 's| *@@@ *||g' -e 's| *$$||' dfn2.out >dfn3.out
|
||||
rm -f dfn.c dfn[12].out
|
||||
mv dfn3.out $@
|
||||
echo '#include "$<"' >$*.c
|
||||
$(DFNCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)\
|
||||
$(CPPFLAGS) $(SYMBOL_CFLAGS) $*.c > $*.tf1
|
||||
$(SED) -n -e 's|^.*PNG_DEFN_MAGIC *-\(.*\)- *PNG_DEFN_END.*$$|\1|p'\
|
||||
$*.tf1 >$*.tf2
|
||||
$(SED) -e 's| *PNG_JOIN *||g' -e 's| *$$||' $*.tf2 >$*.tf3
|
||||
rm -f $*.c $*.tf[12]
|
||||
mv $*.tf3 $@
|
||||
|
||||
# The .dfn file for pnglibconf.h is machine generated
|
||||
pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk
|
||||
rm -f $@ dfn?.out
|
||||
$(AWK) -f ${srcdir}/scripts/options.awk out=dfn1.out\
|
||||
${srcdir}/scripts/pnglibconf.dfa $(DFA_XTRA) 1>&2
|
||||
$(AWK) -f ${srcdir}/scripts/options.awk out=dfn2.out dfn1.out 1>&2
|
||||
rm dfn1.out
|
||||
mv dfn2.out $@
|
||||
pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h
|
||||
rm -f $@ $*.tf[45]
|
||||
$(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf4 version=search\
|
||||
${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
|
||||
$(DFA_XTRA) 1>&2
|
||||
$(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf5 $*.tf4 1>&2
|
||||
rm $*.tf4
|
||||
mv $*.tf5 $@
|
||||
|
||||
# Symbol checks (.def and .out files should match)
|
||||
scripts/symbols.chk: scripts/checksym.awk scripts/symbols.def scripts/symbols.out
|
||||
|
||||
.out.chk:
|
||||
rm -f $@ symbols.new
|
||||
rm -f $@ $*.new
|
||||
$(AWK) -f ${srcdir}/scripts/checksym.awk ${srcdir}/scripts/${*F}.def\
|
||||
$< >&2
|
||||
mv symbols.new $@
|
||||
of="$*.new" $< >&2
|
||||
mv $*.new $@
|
||||
|
||||
# used on demand to regenerate the standard header, CPPFLAGS should
|
||||
# be empty - no non-standard defines
|
||||
scripts/pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk
|
||||
rm -f $@ dfn?.out
|
||||
scripts/pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h
|
||||
rm -f $@ pnglibconf.tf[67]
|
||||
test -z "$(CPPFLAGS)"
|
||||
echo "com @PNGLIB_VERSION@ STANDARD API DEFINITION" |\
|
||||
$(AWK) -f ${srcdir}/scripts/options.awk out=dfn1.out\
|
||||
logunsupported=1 - ${srcdir}/scripts/pnglibconf.dfa 1>&2
|
||||
$(AWK) -f ${srcdir}/scripts/options.awk out=dfn2.out dfn1.out 1>&2
|
||||
rm dfn1.out
|
||||
mv dfn2.out $@
|
||||
$(AWK) -f ${srcdir}/scripts/options.awk out=pnglibconf.tf6\
|
||||
logunsupported=1 version=search ${srcdir}/pngconf.h -\
|
||||
${srcdir}/scripts/pnglibconf.dfa 1>&2
|
||||
$(AWK) -f ${srcdir}/scripts/options.awk out=pnglibconf.tf7\
|
||||
pnglibconf.tf6 1>&2
|
||||
rm pnglibconf.tf6
|
||||
mv pnglibconf.tf7 $@
|
||||
|
||||
$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS): png.h pngconf.h \
|
||||
pnglibconf.h pngpriv.h pngdebug.h pnginfo.h pngstruct.h
|
||||
pnglibconf.h pngpriv.h pngdebug.h pnginfo.h pngstruct.h pngprefix.h
|
||||
|
||||
test: check-am
|
||||
|
||||
@@ -209,3 +258,4 @@ uninstall-hook:
|
||||
rm -f $(DESTDIR)$(bindir)/libpng-config
|
||||
rm -f $(DESTDIR)$(libdir)/libpng.a
|
||||
rm -f $(DESTDIR)$(libdir)/libpng.la
|
||||
rm -f $(DESTDIR)$(libdir)/libpng.dll.a
|
||||
|
||||
1375
Makefile.in
13
README
@@ -1,4 +1,4 @@
|
||||
README for libpng version 1.5.1 - February 3, 2011 (shared library 15.0)
|
||||
README for libpng version 1.6.0beta10 - February 3, 2012 (shared library 16.0)
|
||||
See the note about version numbers near the top of png.h
|
||||
|
||||
See INSTALL for instructions on how to install libpng.
|
||||
@@ -114,19 +114,16 @@ given in previous versions of this document. He and Andreas will
|
||||
read mail addressed to the png-implement list, however.
|
||||
|
||||
Please do not send general questions about PNG. Send them to
|
||||
the (png-list at ccrc.wustl.edu, subscription required, write to
|
||||
majordomo at ccrc.wustl.edu with "subscribe png-list" in your message).
|
||||
On the other hand,
|
||||
please do not send libpng questions to that address, send them to me
|
||||
or to the png-implement list. I'll
|
||||
get them in the end anyway. If you have a question about something
|
||||
png-mng-misc at lists.sf.net (subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-misc to
|
||||
subscribe). If you have a question about something
|
||||
in the PNG specification that is related to using libpng, send it
|
||||
to me. Send me any questions that start with "I was using libpng,
|
||||
and ...". If in doubt, send questions to me. I'll bounce them
|
||||
to others, if necessary.
|
||||
|
||||
Please do not send suggestions on how to change PNG. We have
|
||||
been discussing PNG for nine years now, and it is official and
|
||||
been discussing PNG for sixteen years now, and it is official and
|
||||
finished. If you have suggestions for libpng, however, I'll
|
||||
gladly listen. Even if your suggestion is not used immediately,
|
||||
it may be used later.
|
||||
|
||||
9430
aclocal.m4
vendored
225
arm/filter_neon.S
Normal file
@@ -0,0 +1,225 @@
|
||||
|
||||
/* filter_neon.S - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2011 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
|
||||
#endif
|
||||
|
||||
#ifdef __ELF__
|
||||
# define ELF
|
||||
#else
|
||||
# define ELF @
|
||||
#endif
|
||||
|
||||
.arch armv7-a
|
||||
.fpu neon
|
||||
|
||||
.macro func name, export=0
|
||||
.macro endfunc
|
||||
ELF .size \name, . - \name
|
||||
.endfunc
|
||||
.purgem endfunc
|
||||
.endm
|
||||
.text
|
||||
.if \export
|
||||
.global \name
|
||||
.endif
|
||||
ELF .type \name, STT_FUNC
|
||||
.func \name
|
||||
\name:
|
||||
.endm
|
||||
|
||||
func png_read_filter_row_sub4_neon, export=1
|
||||
ldr r3, [r0, #4] @ rowbytes
|
||||
vmov.i8 d3, #0
|
||||
1:
|
||||
vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128]
|
||||
vadd.u8 d0, d3, d4
|
||||
vadd.u8 d1, d0, d5
|
||||
vadd.u8 d2, d1, d6
|
||||
vadd.u8 d3, d2, d7
|
||||
vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]!
|
||||
subs r3, r3, #16
|
||||
bgt 1b
|
||||
|
||||
bx lr
|
||||
endfunc
|
||||
|
||||
func png_read_filter_row_sub3_neon, export=1
|
||||
ldr r3, [r0, #4] @ rowbytes
|
||||
vmov.i8 d3, #0
|
||||
mov r0, r1
|
||||
mov r2, #3
|
||||
mov r12, #12
|
||||
vld1.8 {q11}, [r0], r12
|
||||
1:
|
||||
vext.8 d5, d22, d23, #3
|
||||
vadd.u8 d0, d3, d22
|
||||
vext.8 d6, d22, d23, #6
|
||||
vadd.u8 d1, d0, d5
|
||||
vext.8 d7, d23, d23, #1
|
||||
vld1.8 {q11}, [r0], r12
|
||||
vst1.32 {d0[0]}, [r1,:32], r2
|
||||
vadd.u8 d2, d1, d6
|
||||
vst1.32 {d1[0]}, [r1], r2
|
||||
vadd.u8 d3, d2, d7
|
||||
vst1.32 {d2[0]}, [r1], r2
|
||||
vst1.32 {d3[0]}, [r1], r2
|
||||
subs r3, r3, #12
|
||||
bgt 1b
|
||||
|
||||
bx lr
|
||||
endfunc
|
||||
|
||||
func png_read_filter_row_up_neon, export=1
|
||||
ldr r3, [r0, #4] @ rowbytes
|
||||
1:
|
||||
vld1.8 {q0}, [r1,:128]
|
||||
vld1.8 {q1}, [r2,:128]!
|
||||
vadd.u8 q0, q0, q1
|
||||
vst1.8 {q0}, [r1,:128]!
|
||||
subs r3, r3, #16
|
||||
bgt 1b
|
||||
|
||||
bx lr
|
||||
endfunc
|
||||
|
||||
func png_read_filter_row_avg4_neon, export=1
|
||||
ldr r12, [r0, #4] @ rowbytes
|
||||
vmov.i8 d3, #0
|
||||
1:
|
||||
vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128]
|
||||
vld4.32 {d16[],d17[],d18[],d19[]},[r2,:128]!
|
||||
vhadd.u8 d0, d3, d16
|
||||
vadd.u8 d0, d0, d4
|
||||
vhadd.u8 d1, d0, d17
|
||||
vadd.u8 d1, d1, d5
|
||||
vhadd.u8 d2, d1, d18
|
||||
vadd.u8 d2, d2, d6
|
||||
vhadd.u8 d3, d2, d19
|
||||
vadd.u8 d3, d3, d7
|
||||
vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]!
|
||||
subs r12, r12, #16
|
||||
bgt 1b
|
||||
|
||||
bx lr
|
||||
endfunc
|
||||
|
||||
func png_read_filter_row_avg3_neon, export=1
|
||||
push {r4,lr}
|
||||
ldr r12, [r0, #4] @ rowbytes
|
||||
vmov.i8 d3, #0
|
||||
mov r0, r1
|
||||
mov r4, #3
|
||||
mov lr, #12
|
||||
vld1.8 {q11}, [r0], lr
|
||||
1:
|
||||
vld1.8 {q10}, [r2], lr
|
||||
vext.8 d5, d22, d23, #3
|
||||
vhadd.u8 d0, d3, d20
|
||||
vext.8 d17, d20, d21, #3
|
||||
vadd.u8 d0, d0, d22
|
||||
vext.8 d6, d22, d23, #6
|
||||
vhadd.u8 d1, d0, d17
|
||||
vext.8 d18, d20, d21, #6
|
||||
vadd.u8 d1, d1, d5
|
||||
vext.8 d7, d23, d23, #1
|
||||
vld1.8 {q11}, [r0], lr
|
||||
vst1.32 {d0[0]}, [r1,:32], r4
|
||||
vhadd.u8 d2, d1, d18
|
||||
vst1.32 {d1[0]}, [r1], r4
|
||||
vext.8 d19, d21, d21, #1
|
||||
vadd.u8 d2, d2, d6
|
||||
vhadd.u8 d3, d2, d19
|
||||
vst1.32 {d2[0]}, [r1], r4
|
||||
vadd.u8 d3, d3, d7
|
||||
vst1.32 {d3[0]}, [r1], r4
|
||||
subs r12, r12, #12
|
||||
bgt 1b
|
||||
|
||||
pop {r4,pc}
|
||||
endfunc
|
||||
|
||||
.macro paeth rx, ra, rb, rc
|
||||
vaddl.u8 q12, \ra, \rb @ a + b
|
||||
vaddl.u8 q15, \rc, \rc @ 2*c
|
||||
vabdl.u8 q13, \rb, \rc @ pa
|
||||
vabdl.u8 q14, \ra, \rc @ pb
|
||||
vabd.u16 q15, q12, q15 @ pc
|
||||
vcle.u16 q12, q13, q14 @ pa <= pb
|
||||
vcle.u16 q13, q13, q15 @ pa <= pc
|
||||
vcle.u16 q14, q14, q15 @ pb <= pc
|
||||
vand q12, q12, q13 @ pa <= pb && pa <= pc
|
||||
vmovn.u16 d28, q14
|
||||
vmovn.u16 \rx, q12
|
||||
vbsl d28, \rb, \rc
|
||||
vbsl \rx, \ra, d28
|
||||
.endm
|
||||
|
||||
func png_read_filter_row_paeth4_neon, export=1
|
||||
ldr r12, [r0, #4] @ rowbytes
|
||||
vmov.i8 d3, #0
|
||||
vmov.i8 d20, #0
|
||||
1:
|
||||
vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128]
|
||||
vld4.32 {d16[],d17[],d18[],d19[]},[r2,:128]!
|
||||
paeth d0, d3, d16, d20
|
||||
vadd.u8 d0, d0, d4
|
||||
paeth d1, d0, d17, d16
|
||||
vadd.u8 d1, d1, d5
|
||||
paeth d2, d1, d18, d17
|
||||
vadd.u8 d2, d2, d6
|
||||
paeth d3, d2, d19, d18
|
||||
vmov d20, d19
|
||||
vadd.u8 d3, d3, d7
|
||||
vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]!
|
||||
subs r12, r12, #16
|
||||
bgt 1b
|
||||
|
||||
bx lr
|
||||
endfunc
|
||||
|
||||
func png_read_filter_row_paeth3_neon, export=1
|
||||
push {r4,lr}
|
||||
ldr r12, [r0, #4] @ rowbytes
|
||||
vmov.i8 d3, #0
|
||||
vmov.i8 d4, #0
|
||||
mov r0, r1
|
||||
mov r4, #3
|
||||
mov lr, #12
|
||||
vld1.8 {q11}, [r0], lr
|
||||
1:
|
||||
vld1.8 {q10}, [r2], lr
|
||||
paeth d0, d3, d20, d4
|
||||
vext.8 d5, d22, d23, #3
|
||||
vadd.u8 d0, d0, d22
|
||||
vext.8 d17, d20, d21, #3
|
||||
paeth d1, d0, d17, d20
|
||||
vst1.32 {d0[0]}, [r1,:32], r4
|
||||
vext.8 d6, d22, d23, #6
|
||||
vadd.u8 d1, d1, d5
|
||||
vext.8 d18, d20, d21, #6
|
||||
paeth d2, d1, d18, d17
|
||||
vext.8 d7, d23, d23, #1
|
||||
vld1.8 {q11}, [r0], lr
|
||||
vst1.32 {d1[0]}, [r1], r4
|
||||
vadd.u8 d2, d2, d6
|
||||
vext.8 d19, d21, d21, #1
|
||||
paeth d3, d2, d19, d18
|
||||
vst1.32 {d2[0]}, [r1], r4
|
||||
vmov d4, d19
|
||||
vadd.u8 d3, d3, d7
|
||||
vst1.32 {d3[0]}, [r1], r4
|
||||
subs r12, r12, #12
|
||||
bgt 1b
|
||||
|
||||
pop {r4,pc}
|
||||
endfunc
|
||||
245
autogen.sh
@@ -1,34 +1,219 @@
|
||||
#! /bin/sh
|
||||
# a quick hack script to generate necessary files from
|
||||
# auto* tools.
|
||||
#
|
||||
# WARNING: if you run this you will change the versions
|
||||
# of the tools which are used and, maybe, required!
|
||||
# Run 'autoreconf' to build 'configure', 'Makefile.in' and other configure
|
||||
# control files.
|
||||
#
|
||||
# The first time this is run on a GIT checkout the only files that exist are
|
||||
# configure.ac and Makefile.am; all of the autotools support scripts are
|
||||
# missing. They are instantiated with autoreconf --force --install.
|
||||
#
|
||||
# For regular ("tarball") distributions all the files should exist. We do not
|
||||
# want them to be updated *under any circumstances*. It should never be
|
||||
# necessary to rune autogen.sh because ./configure --enable-maintainer-mode says
|
||||
# what to do if Makeile.am or configure.ac are changed.
|
||||
#
|
||||
# It is *probably* OK to update the files on a GIT checkout, because they have
|
||||
# come from the local tools, but leave that to the user who is assumed to know
|
||||
# whether it is ok or required.
|
||||
#
|
||||
# This script is intended to work without arguments, there are, however, hidden
|
||||
# arguments for (a) use while testing the script and (b) to fix up systems that
|
||||
# have been broken. If (b) is required the script prompts for the correct
|
||||
# options. For this reason the options are *NOT* documented in the help; this
|
||||
# is deliberate; UTSL.
|
||||
#
|
||||
clean=
|
||||
maintainer=
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
--maintainer)
|
||||
maintainer=1;;
|
||||
|
||||
# You can define your own replacements in your environment.
|
||||
# $AUTOCONF, $AUTOMAKE, $AUTOHEADER, $AUTOPOINT, $ACLOCAL and $LIBTOOLIZE
|
||||
--clean)
|
||||
clean=1;;
|
||||
|
||||
touch Makefile.am configure.ac
|
||||
{
|
||||
LT=${LIBTOOLIZE-libtoolize}
|
||||
echo "running $LT" >&2
|
||||
$LT --force --copy --automake
|
||||
} && {
|
||||
AL=${ACLOCAL-aclocal}
|
||||
echo "running $AL" >&2
|
||||
$AL
|
||||
} && {
|
||||
AH=${AUTOHEADER-autoheader}
|
||||
echo "running $AH [ignore the warnings]" >&2
|
||||
$AH
|
||||
} && {
|
||||
AM=${AUTOMAKE-automake}
|
||||
echo "running $AM" >&2
|
||||
$AM --force-missing --foreign -a -c
|
||||
} && {
|
||||
AC=${AUTOCONF-autoconf}
|
||||
echo "running $AC" >&2
|
||||
$AC
|
||||
} &&
|
||||
echo "autogen complete" >&2 ||
|
||||
echo "ERROR: autogen.sh failed, autogen is incomplete" >&2
|
||||
*)
|
||||
exec >&2
|
||||
echo "$0: usage: ./autogen.sh"
|
||||
if test -d .git
|
||||
then
|
||||
echo " ./autogen.sh generates the configure script and"
|
||||
echo " Makefile.in, or refreshes them after changes to Makefile.am"
|
||||
echo " or configure.ac. You may prefer to just run autoreconf."
|
||||
elif test -z "$maintainer"
|
||||
then
|
||||
echo " DO NOT RUN THIS SCRIPT."
|
||||
echo " If you need to change Makefile.am or configure.ac then you"
|
||||
echo " also need to run ./configure --enable-maintainer-mode and"
|
||||
echo " use the appropriate autotools, *NOT* this script, to update"
|
||||
echo " everything, please check the documentation of autoreconf."
|
||||
echo " WARNING: libpng is intentionally generated with a known,"
|
||||
echo " fixed, set of autotools. It is known *NOT* to work with"
|
||||
echo " the collection of autotools distributed on highly reputable"
|
||||
echo " operating systems."
|
||||
echo " Remember: autotools is GNU software, you are expected to"
|
||||
echo " pay for support."
|
||||
else
|
||||
echo " You have run autogen.sh with --maintainer enabled and you"
|
||||
echo " are not using a GIT distribution, then you have given an"
|
||||
echo " unrecognized argument. This is not good. --maintainer"
|
||||
echo " switches off any assumptions that you might not know what"
|
||||
echo " you are doing."
|
||||
fi
|
||||
exit 1;;
|
||||
esac
|
||||
|
||||
shift
|
||||
done
|
||||
#
|
||||
# First check for a set of the autotools files; if absent then this is assumed
|
||||
# to be a GIT version and the local autotools must be used. If present this
|
||||
# is a tarball distribution and the script should not be used. If partially
|
||||
# present bad things are happening.
|
||||
#
|
||||
# The autotools generated files:
|
||||
libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in\
|
||||
config.sub configure depcomp install-sh ltmain.sh missing"
|
||||
#
|
||||
# These are separate because 'maintainer-clean' does not remove them.
|
||||
libpng_libtool_files="scripts/libtool.m4 scripts/ltoptions.m4\
|
||||
scripts/ltsugar.m4 scripts/ltversion.m4 scripts/lt~obsolete.m4"
|
||||
|
||||
libpng_autotools_dirs="autom4te.cache" # not required
|
||||
#
|
||||
# The configure generated files:
|
||||
libpng_configure_files="Makefile config.h config.log config.status\
|
||||
libpng-config libpng.pc libtool stamp-h1"
|
||||
|
||||
libpng_configure_dirs=".deps"
|
||||
#
|
||||
# We must remove the configure generated files as well as the autotools
|
||||
# generated files if autotools are regenerated because otherwise if configure
|
||||
# has been run without "--enable-maintainer-mode" make can do a partial update
|
||||
# of Makefile. These functions do the two bits of cleaning.
|
||||
clean_autotools(){
|
||||
rm -rf $libpng_autotools_files $libpng_libtool_files $libpng_autotools_dirs
|
||||
}
|
||||
|
||||
clean_configure(){
|
||||
rm -rf $libpng_configure_files $libpng_configure_dirs
|
||||
}
|
||||
#
|
||||
# Clean: remove everything (this is to help with testing)
|
||||
if test -n "$clean"
|
||||
then
|
||||
clean_configure
|
||||
if test -n "$maintainer"
|
||||
then
|
||||
clean_autotools
|
||||
fi
|
||||
|
||||
exit 0
|
||||
fi
|
||||
#
|
||||
# Validate the distribution.
|
||||
libpng_autotools_file_found=
|
||||
libpng_autotools_file_missing=
|
||||
for file in $libpng_autotools_files
|
||||
do
|
||||
if test -f "$file"
|
||||
then
|
||||
libpng_autotools_file_found=1
|
||||
else
|
||||
libpng_autotools_file_missing=1
|
||||
fi
|
||||
done
|
||||
#
|
||||
# Presence of one of these does not *invalidate* missing, but absence
|
||||
# invalidates found.
|
||||
for file in $libpng_libtool_files
|
||||
do
|
||||
if test ! -f "$file"
|
||||
then
|
||||
libpng_autotools_file_missing=1
|
||||
fi
|
||||
done
|
||||
#
|
||||
# The cache directory doesn't matter - it will be regenerated and does not exist
|
||||
# anyway in a tarball.
|
||||
#
|
||||
# Either everything is missing or everything is there, the --maintainer option
|
||||
# just changes this so that the mode is set to generate all the files.
|
||||
mode=
|
||||
if test -z "$libpng_autotools_file_found" -o -n "$maintainer"
|
||||
then
|
||||
mode="autoreconf"
|
||||
else
|
||||
if test -n "$libpng_autotools_file_missing"
|
||||
then
|
||||
mode="broken"
|
||||
else
|
||||
mode="configure"
|
||||
fi
|
||||
fi
|
||||
#
|
||||
# So:
|
||||
case "$mode" in
|
||||
autoreconf)
|
||||
# Clean in case configure files exist
|
||||
clean_configure
|
||||
clean_autotools
|
||||
# Everything must be initialized, so use --force
|
||||
if autoreconf --warnings=all --force --install
|
||||
then
|
||||
missing=
|
||||
for file in $libpng_autotools_files
|
||||
do
|
||||
test -f "$file" || missing=1
|
||||
done
|
||||
# ignore the cache directory
|
||||
test -z "$missing" || {
|
||||
exec >&2
|
||||
echo "autoreconf was run, but did not produce all the expected"
|
||||
echo "files. It is likely that your autotools installation is"
|
||||
echo "not compatible with that expected by libpng."
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
exec >&2
|
||||
echo "autoreconf failed: your version of autotools is incompatible"
|
||||
echo "with this libpng version. Please use a distributed archive"
|
||||
echo "(which includes the autotools generated files) and run configure"
|
||||
echo "instead."
|
||||
exit 1
|
||||
fi;;
|
||||
|
||||
configure)
|
||||
if test -d .git
|
||||
then
|
||||
exec >&2
|
||||
echo "ERROR: running autoreconf on an initialized sytem"
|
||||
echo " This is not necessary; it is only necessary to remake the"
|
||||
echo " autotools generated files if Makefile.am or configure.ac"
|
||||
echo " change and make does the right thing with:"
|
||||
echo
|
||||
echo " ./configure --enable-maintainer-mode."
|
||||
echo
|
||||
echo " You can run autoreconf yourself if you don't like maintainer"
|
||||
echo " mode and you can also just run autoreconf -f -i to initialize"
|
||||
echo " everything in the first place; this script is only for"
|
||||
echo " compatiblity with prior releases."
|
||||
exit 1
|
||||
else
|
||||
exec >&2
|
||||
echo "autogen.sh is intended only to generate 'configure' on systems"
|
||||
echo "that do not have it. You have a complete 'configure', if you"
|
||||
echo "need to change Makefile.am or configure.ac you also need to"
|
||||
echo "run configure with the --enable-maintainer-mode option."
|
||||
exit 1
|
||||
fi;;
|
||||
|
||||
broken)
|
||||
exec >&2
|
||||
echo "Your system has a partial set of autotools generated files."
|
||||
echo "autogen.sh is unable to proceed. The full set of files is"
|
||||
echo "contained in the distribution archive and you do not need to run"
|
||||
echo "autogen.sh if you use it."
|
||||
exit 1;;
|
||||
esac
|
||||
|
||||
1501
config.guess
vendored
86
config.h.in
@@ -1,86 +0,0 @@
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `m' library (-lm). */
|
||||
#undef HAVE_LIBM
|
||||
|
||||
/* Define to 1 if you have the `z' library (-lz). */
|
||||
#undef HAVE_LIBZ
|
||||
|
||||
/* Define to 1 if you have the <malloc.h> header file. */
|
||||
#undef HAVE_MALLOC_H
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#undef HAVE_MEMSET
|
||||
|
||||
/* Define to 1 if you have the `pow' function. */
|
||||
#undef HAVE_POW
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#undef LT_OBJDIR
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
|
||||
#undef TM_IN_SYS_TIME
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
#undef const
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
1705
config.sub
vendored
139
configure.ac
@@ -14,52 +14,73 @@ dnl Makefile.am to upgrade the package name.
|
||||
dnl This is here to prevent earlier autoconf from being used, it
|
||||
dnl should not be necessary to regenerate configure if the time
|
||||
dnl stamps are correct
|
||||
AC_PREREQ(2.59)
|
||||
AC_PREREQ([2.68])
|
||||
|
||||
dnl Version number stuff here:
|
||||
|
||||
AC_INIT([libpng], [1.5.1], [png-mng-implement@lists.sourceforge.net])
|
||||
AM_INIT_AUTOMAKE
|
||||
dnl stop configure from automagically running automake
|
||||
AC_INIT([libpng],[1.6.0beta10],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_CONFIG_MACRO_DIR([scripts])
|
||||
|
||||
# libpng does not follow GNU file name conventions (hence 'foreign')
|
||||
# color-tests requires automake 1.11 or later
|
||||
# silent-rules requires automake 1.11 or later
|
||||
# dist-xz requires automake 1.11 or later
|
||||
# 1.11.1 fixes a security issue in 1.11
|
||||
AM_INIT_AUTOMAKE([1.11.1 foreign dist-xz dist-bzip2 color-tests silent-rules])
|
||||
# was:
|
||||
# AM_INIT_AUTOMAKE
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
PNGLIB_VERSION=1.5.1
|
||||
dnl configure.ac and Makefile.am expect automake 1.11.2 or a compatible later
|
||||
dnl version; aclocal.m4 will generate a failure if you use a prior version of
|
||||
dnl automake, so the following is not necessary (and is not defined anyway):
|
||||
dnl AM_PREREQ([1.11.2])
|
||||
dnl stop configure from automagically running automake
|
||||
|
||||
PNGLIB_VERSION=1.6.0beta10
|
||||
PNGLIB_MAJOR=1
|
||||
PNGLIB_MINOR=5
|
||||
PNGLIB_RELEASE=1
|
||||
PNGLIB_MINOR=6
|
||||
PNGLIB_RELEASE=0
|
||||
|
||||
dnl End of version number stuff
|
||||
|
||||
AC_CONFIG_SRCDIR([pngget.c])
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
|
||||
# Checks for programs.
|
||||
AC_LANG([C])
|
||||
AC_PROG_CC
|
||||
AC_PROG_LD
|
||||
AM_PROG_AS
|
||||
LT_PATH_LD
|
||||
AC_PROG_CPP
|
||||
AC_CHECK_TOOL(SED, sed, :)
|
||||
AC_CHECK_TOOL(AWK, awk, :)
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_MAKE_SET
|
||||
|
||||
dnl libtool/libtoolize; version 2.4.2 is the tested version, this or any
|
||||
dnl compatible later version may be used
|
||||
LT_INIT([win32-dll])
|
||||
LT_PREREQ([2.4.2])
|
||||
|
||||
# On Solaris 10 and 12 CPP gets set to cc -E, however this still
|
||||
# does some input parsing. We need strict ANSI-C style tokenization,
|
||||
# check this:
|
||||
AC_REQUIRE_CPP
|
||||
AC_MSG_CHECKING([for a C preprocessor that does not parse its input])
|
||||
AC_TRY_CPP([1.5.0 16BIT],
|
||||
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[1.1.1 16BIT]])],
|
||||
[DFNCPP="$CPP"],
|
||||
[ DFNCPP=""
|
||||
sav_CPP="$CPP"
|
||||
for CPP in "${CC-cc} -E" "${CC-cc} -E -traditional-cpp" "/lib/cpp" "cpp"; do
|
||||
AC_TRY_CPP([1.5.0 16BIT],
|
||||
for CPP in "${CC-cc} -E" "${CC-cc} -E -traditional-cpp" "/lib/cpp" "cpp"
|
||||
do
|
||||
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[1.1.1 16BIT]])],
|
||||
[DFNCPP="$CPP"]
|
||||
[break],,)
|
||||
done
|
||||
CPP="$sav_CPP"])
|
||||
CPP="$sav_CPP"
|
||||
])
|
||||
if test -n "$DFNCPP"; then
|
||||
AC_MSG_RESULT([$DFNCPP])
|
||||
AC_SUBST(DFNCPP)
|
||||
@@ -67,6 +88,31 @@ else
|
||||
AC_MSG_FAILURE([not found], 1)
|
||||
fi
|
||||
|
||||
# -Werror cannot be passed to GCC in CFLAGS because configure will fail (it
|
||||
# checks the compiler with a program that generates a warning), add the
|
||||
# following option to deal with this
|
||||
AC_ARG_VAR(PNG_COPTS,
|
||||
[additional flags for the C compiler, use this for options that would]
|
||||
[cause configure itself to fail])
|
||||
AC_ARG_ENABLE(werror,
|
||||
AS_HELP_STRING([[[--enable-werror[=OPT]]]],
|
||||
[Pass -Werror or the given argument to the compiler if it is supported]),
|
||||
[test "$enable_werror" = "yes" && enable_werror="-Werror"
|
||||
if test "$enable_werror" != "no"; then
|
||||
sav_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$enable_werror $CFLAGS"
|
||||
AC_MSG_CHECKING([if the compiler allows $enable_werror])
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_SOURCE([
|
||||
[int main(int argc, char **argv){]
|
||||
[return argv[argc-1][0];]
|
||||
[}]])],
|
||||
AC_MSG_RESULT(yes)
|
||||
PNG_COPTS="$PNG_COPTS $enable_werror",
|
||||
AC_MSG_RESULT(no))
|
||||
CFLAGS="$sav_CFLAGS"
|
||||
fi],)
|
||||
|
||||
# Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS([malloc.h stdlib.h string.h strings.h])
|
||||
@@ -75,24 +121,36 @@ AC_CHECK_HEADERS([malloc.h stdlib.h string.h strings.h])
|
||||
AC_C_CONST
|
||||
AC_TYPE_SIZE_T
|
||||
AC_STRUCT_TM
|
||||
AC_C_RESTRICT
|
||||
|
||||
# Checks for library functions.
|
||||
AC_FUNC_STRTOD
|
||||
AC_CHECK_FUNCS([memset], , AC_ERROR([memset not found in libc]))
|
||||
AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_ERROR([cannot find pow])) )
|
||||
AC_CHECK_FUNCS([memset], , AC_MSG_ERROR(memset not found in libc))
|
||||
AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_MSG_ERROR(cannot find pow)) )
|
||||
AC_ARG_WITH(zlib-prefix,
|
||||
AC_HELP_STRING([--with-zlib-prefix],
|
||||
AS_HELP_STRING([[[--with-zlib-prefix]]],
|
||||
[prefix that may have been used in installed zlib]),
|
||||
[ZPREFIX=${withval}],
|
||||
[ZPREFIX='z_'])
|
||||
AC_CHECK_LIB(z, zlibVersion, ,
|
||||
AC_CHECK_LIB(z, ${ZPREFIX}zlibVersion, ,
|
||||
AC_ERROR([zlib not installed])))
|
||||
AC_CHECK_LIB(z, ${ZPREFIX}zlibVersion, , AC_MSG_ERROR(zlib not installed)))
|
||||
|
||||
# The following is for pngvalid, to ensure it catches FP errors even on
|
||||
# platforms that don't enable FP exceptions, the function appears in the math
|
||||
# library (typically), it's not an error if it is not found.
|
||||
AC_CHECK_LIB([m], [feenableexcept])
|
||||
AC_CHECK_FUNCS([feenableexcept])
|
||||
|
||||
LIBPNG_DEFINES=-DPNG_CONFIGURE_LIBPNG
|
||||
LIBPNG_DEFINES=$LIBPNG_DEFINES
|
||||
AC_SUBST(LIBPNG_DEFINES)
|
||||
AC_MSG_CHECKING([if using Solaris linker])
|
||||
SLD=`$LD --version 2>&1 | grep Solaris`
|
||||
if test "$SLD"; then
|
||||
have_solaris_ld=yes
|
||||
AC_MSG_RESULT(yes)
|
||||
else
|
||||
have_solaris_ld=no
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
AM_CONDITIONAL(HAVE_SOLARIS_LD, test "$have_solaris_ld" = "yes")
|
||||
|
||||
AC_MSG_CHECKING([if libraries can be versioned])
|
||||
# Special case for PE/COFF platforms: ld reports
|
||||
@@ -104,7 +162,13 @@ case $host in
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
* )
|
||||
|
||||
if test "$have_solaris_ld" = "yes"; then
|
||||
GLD=`$LD --help < /dev/null 2>&1 | grep 'M mapfile'`
|
||||
else
|
||||
GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
|
||||
fi
|
||||
|
||||
if test "$GLD"; then
|
||||
have_ld_version_script=yes
|
||||
AC_MSG_RESULT(yes)
|
||||
@@ -137,28 +201,53 @@ AC_SUBST(PNGLIB_RELEASE)
|
||||
# Additional arguments (and substitutions)
|
||||
# Allow the pkg-config directory to be set
|
||||
AC_ARG_WITH(pkgconfigdir,
|
||||
AC_HELP_STRING([--with-pkgconfigdir],
|
||||
AS_HELP_STRING([[[--with-pkgconfigdir]]],
|
||||
[Use the specified pkgconfig dir (default is libdir/pkgconfig)]),
|
||||
[pkgconfigdir=${withval}],
|
||||
[pkgconfigdir='${libdir}/pkgconfig'])
|
||||
|
||||
AC_SUBST([pkgconfigdir])
|
||||
AC_MSG_NOTICE([pkgconfig directory is ${pkgconfigdir}])
|
||||
AC_MSG_NOTICE([[pkgconfig directory is ${pkgconfigdir}]])
|
||||
|
||||
# Make the *-config binary config scripts optional
|
||||
AC_ARG_WITH(binconfigs,
|
||||
AC_HELP_STRING([--with-binconfigs],
|
||||
AS_HELP_STRING([[[--with-binconfigs]]],
|
||||
[Generate shell libpng-config scripts as well as pkg-config data]
|
||||
[@<:@default=yes@:>@]),
|
||||
[if test "${withval}" = no; then
|
||||
binconfigs=
|
||||
AC_MSG_NOTICE([libpng-config scripts will not be built])
|
||||
AC_MSG_NOTICE([[libpng-config scripts will not be built]])
|
||||
else
|
||||
binconfigs='${binconfigs}'
|
||||
fi],
|
||||
[binconfigs='${binconfigs}'])
|
||||
AC_SUBST([binconfigs])
|
||||
|
||||
# Support for prefixes to the API function names; this will generate defines
|
||||
# at the start of the build to rename exported library functions
|
||||
AC_ARG_WITH(libpng-prefix,
|
||||
AS_HELP_STRING([[[--with-libpng-prefix]]],
|
||||
[prefix libpng exported function (API) names with the given value]),
|
||||
[if test "${withval:-no}" != "no"; then
|
||||
AC_SUBST([PNG_PREFIX], [${withval}])
|
||||
fi])
|
||||
AM_CONDITIONAL([DO_PNG_PREFIX], [test "${with_libpng_prefix:-no}" != "no"])
|
||||
|
||||
# Because GCC by default assembles code with an executable stack, even though it
|
||||
# compiles C code with a non-executable stack, it is necessary to do a fixup
|
||||
# here (this may by GCC specific)
|
||||
AC_SUBST([AM_CCASFLAGS], [-Wa,--noexecstack])
|
||||
|
||||
AC_ARG_ENABLE([arm-neon],
|
||||
AS_HELP_STRING([[[--enable-arm-neon]]], [Enable ARM NEON optimizations]),
|
||||
[if test "${enableval}" = "yes"; then
|
||||
AC_DEFINE([PNG_ARM_NEON], [1], [Enable ARM NEON optimizations])
|
||||
AC_DEFINE([PNG_ALIGNED_MEMORY_SUPPORTED], [1], [Align row buffers])
|
||||
fi])
|
||||
AM_CONDITIONAL([PNG_ARM_NEON], [test "${enable_arm_neon:-no}" = yes])
|
||||
|
||||
AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
|
||||
|
||||
# Config files, substituting as above
|
||||
AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in])
|
||||
AC_CONFIG_FILES([libpng-config:libpng-config.in],
|
||||
|
||||
4
contrib/README.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
This "contrib" directory contains contributions which are not necessarily under
|
||||
the libpng license, although all are open source. They are not part of
|
||||
libpng proper and are not used for building the library.
|
||||
24
contrib/examples/README.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
This directory (contrib/examples) contains examples of libpng usage.
|
||||
|
||||
NO COPYRIGHT RIGHTS ARE CLAIMED TO ANY OF THE FILES IN THIS DIRECTORY.
|
||||
|
||||
To the extent possible under law, the authors have waived all copyright and
|
||||
related or neighboring rights to this work. This work is published from:
|
||||
United States.
|
||||
|
||||
The files may be used freely in any way. The intention is that appropriate
|
||||
parts of the files be used in other libpng-using programs without any need for
|
||||
the authors of the using code to seek copyright or license from the original
|
||||
authors.
|
||||
|
||||
The source code and comments in this directory are the original work of the
|
||||
people named below. No other person or organization has made contributions to
|
||||
the work in this directory.
|
||||
|
||||
ORIGINAL AUTHORS
|
||||
The following people have contributed to the code in this directory. None
|
||||
of the people below claim any rights with regard to the contents of this
|
||||
directory.
|
||||
|
||||
John Bowler <jbowler@acm.org>
|
||||
180
contrib/examples/iccfrompng.c
Normal file
@@ -0,0 +1,180 @@
|
||||
/*- iccfrompng
|
||||
*
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2011.
|
||||
* To the extent possible under law, the author has waived all copyright and
|
||||
* related or neighboring rights to this work. This work is published from:
|
||||
* United States.
|
||||
*
|
||||
* Extract any icc profiles found in the given PNG files. This is a simple
|
||||
* example of a program which extracts information from the header of a PNG file
|
||||
* without processing the image. Notice that some header information may occur
|
||||
* after the image data, textual data and comments are an example; the approach
|
||||
* in this file won't work reliably for such data because it only looks for the
|
||||
* information in the section of the file that preceeds the image data.
|
||||
*
|
||||
* Compile and link against libpng and zlib, plus anything else required on the
|
||||
* system you use.
|
||||
*
|
||||
* To use supply a list of PNG files containing iCCP chunks, the chunks will be
|
||||
* extracted to a similarly named file with the extension replaced by 'icc',
|
||||
* which will be overwritten without warning.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <png.h>
|
||||
|
||||
static int verbose = 1;
|
||||
static png_byte no_profile[] = "no profile";
|
||||
|
||||
static png_bytep
|
||||
extract(FILE *fp, png_uint_32 *proflen)
|
||||
{
|
||||
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0);
|
||||
png_infop info_ptr = NULL;
|
||||
png_bytep result = NULL;
|
||||
|
||||
/* Initialize for error or no profile: */
|
||||
*proflen = 0;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
{
|
||||
fprintf(stderr, "iccfrompng: version library mismatch?\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (setjmp(png_jmpbuf(png_ptr)))
|
||||
{
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
png_init_io(png_ptr, fp);
|
||||
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (info_ptr == NULL)
|
||||
png_error(png_ptr, "OOM allocating info structure");
|
||||
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
{
|
||||
png_charp name;
|
||||
int compression_type;
|
||||
png_bytep profile;
|
||||
|
||||
if (png_get_iCCP(png_ptr, info_ptr, &name, &compression_type, &profile,
|
||||
proflen) & PNG_INFO_iCCP)
|
||||
{
|
||||
result = malloc(*proflen);
|
||||
if (result != NULL)
|
||||
memcpy(result, profile, *proflen);
|
||||
|
||||
else
|
||||
png_error(png_ptr, "OOM allocating profile buffer");
|
||||
}
|
||||
|
||||
else
|
||||
result = no_profile;
|
||||
}
|
||||
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
return result;
|
||||
}
|
||||
|
||||
static int
|
||||
extract_one_file(const char *filename)
|
||||
{
|
||||
int result = 0;
|
||||
FILE *fp = fopen(filename, "rb");
|
||||
|
||||
if (fp != NULL)
|
||||
{
|
||||
png_uint_32 proflen = 0;
|
||||
png_bytep profile = extract(fp, &proflen);
|
||||
|
||||
if (profile != NULL && profile != no_profile)
|
||||
{
|
||||
size_t len;
|
||||
char *output;
|
||||
|
||||
{
|
||||
const char *ep = strrchr(filename, '.');
|
||||
|
||||
if (ep != NULL)
|
||||
len = ep-filename;
|
||||
|
||||
else
|
||||
len = strlen(filename);
|
||||
}
|
||||
|
||||
output = malloc(len + 5);
|
||||
if (output != NULL)
|
||||
{
|
||||
FILE *of;
|
||||
|
||||
memcpy(output, filename, len);
|
||||
strcpy(output+len, ".icc");
|
||||
|
||||
of = fopen(output, "wb");
|
||||
if (of != NULL)
|
||||
{
|
||||
if (fwrite(profile, proflen, 1, of) == 1 &&
|
||||
fflush(of) == 0 &&
|
||||
fclose(of) == 0)
|
||||
{
|
||||
if (verbose)
|
||||
printf("%s -> %s\n", filename, output);
|
||||
/* Success return */
|
||||
result = 1;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s: error writing profile\n", output);
|
||||
if (remove(output))
|
||||
fprintf(stderr, "%s: could not remove file\n", output);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
fprintf(stderr, "%s: failed to open output file\n", output);
|
||||
|
||||
free(output);
|
||||
}
|
||||
|
||||
else
|
||||
fprintf(stderr, "%s: OOM allocating string!\n", filename);
|
||||
|
||||
free(profile);
|
||||
}
|
||||
|
||||
else if (verbose && profile == no_profile)
|
||||
printf("%s has no profile\n", filename);
|
||||
}
|
||||
|
||||
else
|
||||
fprintf(stderr, "%s: could not open file\n", filename);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int extracted = 0;
|
||||
|
||||
for (i=1; i<argc; ++i)
|
||||
{
|
||||
if (strcmp(argv[i], "-q") == 0)
|
||||
verbose = 0;
|
||||
|
||||
else if (extract_one_file(argv[i]))
|
||||
extracted = 1;
|
||||
}
|
||||
|
||||
/* Exit code is true if any extract succeeds */
|
||||
return extracted == 0;
|
||||
}
|
||||
367
contrib/examples/pngpixel.c
Normal file
@@ -0,0 +1,367 @@
|
||||
/*- pngpixel
|
||||
*
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2011.
|
||||
* To the extent possible under law, the author has waived all copyright and
|
||||
* related or neighboring rights to this work. This work is published from:
|
||||
* United States.
|
||||
*
|
||||
* Read a single pixel value from a PNG file.
|
||||
*
|
||||
* This code illustrates basic 'by-row' reading of a PNG file using libpng.
|
||||
* Rows are read until a particular pixel is found, the value of this pixel is
|
||||
* then printed on stdout.
|
||||
*
|
||||
* The code illustrates how to do this on interlaced as well as non-interlaced
|
||||
* images. Normally you would call png_set_interlace_handling() to have libpng
|
||||
* deal with the interlace for you, but that obliges you to buffer half of the
|
||||
* image to assemble the interlaced rows. In this code
|
||||
* png_set_interlace_handling() is not called and, instead, the code handles the
|
||||
* interlace passes directly looking for the required pixel.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <setjmp.h> /* required for error handling */
|
||||
|
||||
/* Normally use <png.h> here to get the installed libpng, but this is done to
|
||||
* ensure the code picks up the local libpng implementation:
|
||||
*/
|
||||
#include "../../png.h"
|
||||
|
||||
/* Return component 'c' of pixel 'x' from the given row. */
|
||||
static unsigned int
|
||||
component(png_const_bytep row, png_uint_32 x, unsigned int c,
|
||||
unsigned int bit_depth, unsigned int channels)
|
||||
{
|
||||
/* PNG images can be up to 2^31 pixels wide, but this means they can be up to
|
||||
* 2^37 bits wide (for a 64-bit pixel - the largest possible) and hence 2^34
|
||||
* bytes wide. Since the row fitted into memory, however, the following must
|
||||
* work:
|
||||
*/
|
||||
png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels + c);
|
||||
png_uint_32 bit_offset_lo = bit_depth * ((x & 0x3f) * channels + c);
|
||||
|
||||
row = (png_const_bytep)(((PNG_CONST png_byte (*)[8])row) + bit_offset_hi);
|
||||
row += bit_offset_lo >> 3;
|
||||
bit_offset_lo &= 0x07;
|
||||
|
||||
/* PNG pixels are packed into bytes to put the first pixel in the highest
|
||||
* bits of the byte and into two bytes for 16-bit values with the high 8 bits
|
||||
* first, so:
|
||||
*/
|
||||
switch (bit_depth)
|
||||
{
|
||||
case 1: return (row[0] >> (7-bit_offset_lo)) & 0x01;
|
||||
case 2: return (row[0] >> (6-bit_offset_lo)) & 0x03;
|
||||
case 4: return (row[0] >> (4-bit_offset_lo)) & 0x0f;
|
||||
case 8: return row[0];
|
||||
case 16: return (row[0] << 8) + row[1];
|
||||
default:
|
||||
/* This should never happen, it indicates a bug in this program or in
|
||||
* libpng itself:
|
||||
*/
|
||||
fprintf(stderr, "pngpixel: invalid bit depth %u\n", bit_depth);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Print a pixel from a row returned by libpng; determine the row format, find
|
||||
* the pixel, and print the relevant information to stdout.
|
||||
*/
|
||||
static void
|
||||
print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
|
||||
png_uint_32 x)
|
||||
{
|
||||
PNG_CONST unsigned int bit_depth = png_get_bit_depth(png_ptr, info_ptr);
|
||||
|
||||
switch (png_get_color_type(png_ptr, info_ptr))
|
||||
{
|
||||
case PNG_COLOR_TYPE_GRAY:
|
||||
printf("GRAY %u\n", component(row, x, 0, bit_depth, 1));
|
||||
return;
|
||||
|
||||
/* The palette case is slightly more difficult - the palette and, if
|
||||
* present, the tRNS ('transparency', though the values are really
|
||||
* opacity) data must be read to give the full picture:
|
||||
*/
|
||||
case PNG_COLOR_TYPE_PALETTE:
|
||||
{
|
||||
PNG_CONST unsigned int index = component(row, x, 0, bit_depth, 1);
|
||||
png_colorp palette = NULL;
|
||||
int num_palette = 0;
|
||||
|
||||
if ((png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette) &
|
||||
PNG_INFO_PLTE) && num_palette > 0 && palette != NULL)
|
||||
{
|
||||
png_bytep trans_alpha = NULL;
|
||||
int num_trans = 0;
|
||||
if ((png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans,
|
||||
NULL) & PNG_INFO_tRNS) && num_trans > 0 &&
|
||||
trans_alpha != NULL)
|
||||
printf("INDEXED %u = %d %d %d %d\n", index,
|
||||
palette[index].red, palette[index].green,
|
||||
palette[index].blue,
|
||||
index < num_trans ? trans_alpha[index] : 255);
|
||||
|
||||
else /* no transparency */
|
||||
printf("INDEXED %u = %d %d %d\n", index,
|
||||
palette[index].red, palette[index].green,
|
||||
palette[index].blue);
|
||||
}
|
||||
|
||||
else
|
||||
printf("INDEXED %u = invalid index\n", index);
|
||||
}
|
||||
return;
|
||||
|
||||
case PNG_COLOR_TYPE_RGB:
|
||||
printf("RGB %u %u %u\n", component(row, x, 0, bit_depth, 3),
|
||||
component(row, x, 1, bit_depth, 3),
|
||||
component(row, x, 2, bit_depth, 3));
|
||||
return;
|
||||
|
||||
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
||||
printf("GRAY+ALPHA %u %u\n", component(row, x, 0, bit_depth, 2),
|
||||
component(row, x, 1, bit_depth, 2));
|
||||
return;
|
||||
|
||||
case PNG_COLOR_TYPE_RGB_ALPHA:
|
||||
printf("RGBA %u %u %u %u\n", component(row, x, 0, bit_depth, 4),
|
||||
component(row, x, 1, bit_depth, 4),
|
||||
component(row, x, 2, bit_depth, 4),
|
||||
component(row, x, 3, bit_depth, 4));
|
||||
return;
|
||||
|
||||
default:
|
||||
png_error(png_ptr, "invalid color type");
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
/* This program uses the default, <setjmp.h> based, libpng error handling
|
||||
* mechanism, therefore any local variable that exists before the call to
|
||||
* setjmp and is changed after the call to setjmp returns successfully must
|
||||
* be declared with 'volatile' to ensure that their values don't get
|
||||
* destroyed by longjmp:
|
||||
*/
|
||||
volatile int result = 1/*fail*/;
|
||||
|
||||
if (argc == 4)
|
||||
{
|
||||
long x = atol(argv[1]);
|
||||
long y = atol(argv[2]);
|
||||
FILE *f = fopen(argv[3], "rb");
|
||||
volatile png_bytep row = NULL;
|
||||
|
||||
if (f != NULL)
|
||||
{
|
||||
/* libpng requires a callback function for handling errors; this
|
||||
* callback must not return. The default callback function uses a
|
||||
* stored <setjmp.h> style jmp_buf which is held in a png_struct and
|
||||
* writes error messages to stderr. Creating the png_struct is a
|
||||
* little tricky; just copy the following code.
|
||||
*/
|
||||
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
png_infop info_ptr = png_create_info_struct(png_ptr);
|
||||
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
/* Declare stack variables to hold pointers to locally allocated
|
||||
* data.
|
||||
*/
|
||||
|
||||
/* Initialize the error control buffer: */
|
||||
if (setjmp(png_jmpbuf(png_ptr)) == 0)
|
||||
{
|
||||
png_uint_32 width, height;
|
||||
int bit_depth, color_type, interlace_method,
|
||||
compression_method, filter_method;
|
||||
png_bytep row_tmp;
|
||||
|
||||
/* Now associate the recently opened (FILE*) with the default
|
||||
* libpng initialization functions. Sometimes libpng is
|
||||
* compiled without stdio support (it can be difficult to do
|
||||
* in some environments); in that case you will have to write
|
||||
* your own read callback to read data from the (FILE*).
|
||||
*/
|
||||
png_init_io(png_ptr, f);
|
||||
|
||||
/* And read the first part of the PNG file - the header and
|
||||
* all the information up to the first pixel.
|
||||
*/
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
/* This fills in enough information to tell us the width of
|
||||
* each row in bytes, allocate the appropriate amount of
|
||||
* space. In this case png_malloc is used - it will not
|
||||
* return if memory isn't available.
|
||||
*/
|
||||
row = png_malloc(png_ptr, png_get_rowbytes(png_ptr,
|
||||
info_ptr));
|
||||
|
||||
/* To avoid the overhead of using a volatile auto copy row_tmp
|
||||
* to a local here - just use row for the png_free below.
|
||||
*/
|
||||
row_tmp = row;
|
||||
|
||||
/* All the information we need is in the header is returned by
|
||||
* png_get_IHDR, if this fails we can now use 'png_error' to
|
||||
* signal the error and return control to the setjmp above.
|
||||
*/
|
||||
if (png_get_IHDR(png_ptr, info_ptr, &width, &height,
|
||||
&bit_depth, &color_type, &interlace_method,
|
||||
&compression_method, &filter_method))
|
||||
{
|
||||
int passes, pass;
|
||||
|
||||
/* png_set_interlace_handling returns the number of
|
||||
* passes required as well as turning on libpng's
|
||||
* handling, but since we do it ourselves this is
|
||||
* necessary:
|
||||
*/
|
||||
switch (interlace_method)
|
||||
{
|
||||
case PNG_INTERLACE_NONE:
|
||||
passes = 1;
|
||||
break;
|
||||
|
||||
case PNG_INTERLACE_ADAM7:
|
||||
passes = PNG_INTERLACE_ADAM7_PASSES;
|
||||
break;
|
||||
|
||||
default:
|
||||
png_error(png_ptr, "pngpixel: unknown interlace");
|
||||
}
|
||||
|
||||
/* Now read the pixels, pass-by-pass, row-by-row: */
|
||||
png_start_read_image(png_ptr);
|
||||
|
||||
for (pass=0; pass<passes; ++pass)
|
||||
{
|
||||
png_uint_32 ystart, xstart, ystep, xstep;
|
||||
png_uint_32 py;
|
||||
|
||||
if (interlace_method == PNG_INTERLACE_ADAM7)
|
||||
{
|
||||
/* Sometimes the whole pass is empty because the
|
||||
* image is too narrow or too short. libpng
|
||||
* expects to be called for each row that is
|
||||
* present in the pass, so it may be necessary to
|
||||
* skip the loop below (over py) if the image is
|
||||
* too narrow.
|
||||
*/
|
||||
if (PNG_PASS_COLS(width, pass) == 0)
|
||||
continue;
|
||||
|
||||
/* We need the starting pixel and the offset
|
||||
* between each pixel in this pass; use the macros
|
||||
* in png.h:
|
||||
*/
|
||||
xstart = PNG_PASS_START_COL(pass);
|
||||
ystart = PNG_PASS_START_ROW(pass);
|
||||
xstep = PNG_PASS_COL_OFFSET(pass);
|
||||
ystep = PNG_PASS_ROW_OFFSET(pass);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
ystart = xstart = 0;
|
||||
ystep = xstep = 1;
|
||||
}
|
||||
|
||||
/* To find the pixel loop over 'py' for each pass
|
||||
* reading a row and then checking to see if it
|
||||
* contains the pixel.
|
||||
*/
|
||||
for (py = ystart; py < height; py += ystep)
|
||||
{
|
||||
png_uint_32 px, ppx;
|
||||
|
||||
/* png_read_row takes two pointers. When libpng
|
||||
* handles the interlace the first is filled in
|
||||
* pixel-by-pixel, the second receives the same
|
||||
* pixels but they are replicated across the
|
||||
* unwritten pixels so far for each pass. When we
|
||||
* do the interlace, however, they just contain
|
||||
* the pixels from the interlace pass - giving
|
||||
* both is wasteful and pointless.
|
||||
*/
|
||||
png_read_row(png_ptr, row_tmp, NULL);
|
||||
|
||||
/* Now find the pixel if it is in this row; there
|
||||
* are, of course, much better ways of doing this
|
||||
* than using a for loop:
|
||||
*/
|
||||
if (y == py) for (px = xstart, ppx = 0;
|
||||
px < width; px += xstep, ++ppx) if (x == px)
|
||||
{
|
||||
/* 'ppx' is the index of the pixel in the row
|
||||
* buffer.
|
||||
*/
|
||||
print_pixel(png_ptr, info_ptr, row_tmp, ppx);
|
||||
|
||||
/* Now terminate the loops early - we have
|
||||
* found and handled the required data.
|
||||
*/
|
||||
goto pass_loop_end;
|
||||
} /* x loop */
|
||||
} /* y loop */
|
||||
} /* pass loop */
|
||||
|
||||
/* Finally free the temporary buffer: */
|
||||
pass_loop_end:
|
||||
row = NULL;
|
||||
png_free(png_ptr, row_tmp);
|
||||
}
|
||||
|
||||
else
|
||||
png_error(png_ptr, "pngpixel: png_get_IHDR failed");
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* Else libpng has raised an error. An error message has
|
||||
* already been output, it is only necessary to clean up
|
||||
* locally allocated data:
|
||||
*/
|
||||
if (row != NULL)
|
||||
{
|
||||
/* The default implementation of png_free never errors out
|
||||
* (it just crashes if something goes wrong), but the safe
|
||||
* way of using it is still to clear 'row' before calling
|
||||
* png_free:
|
||||
*/
|
||||
png_bytep row_tmp = row;
|
||||
row = NULL;
|
||||
png_free(png_ptr, row_tmp);
|
||||
}
|
||||
}
|
||||
|
||||
png_destroy_info_struct(png_ptr, &info_ptr);
|
||||
}
|
||||
|
||||
else
|
||||
fprintf(stderr, "pngpixel: out of memory allocating png_info\n");
|
||||
|
||||
png_destroy_read_struct(&png_ptr, NULL, NULL);
|
||||
}
|
||||
|
||||
else
|
||||
fprintf(stderr, "pngpixel: out of memory allocating png_struct\n");
|
||||
}
|
||||
|
||||
else
|
||||
fprintf(stderr, "pngpixel: %s: could not open file\n", argv[3]);
|
||||
}
|
||||
|
||||
else
|
||||
/* Wrong number of arguments */
|
||||
fprintf(stderr, "pngpixel: usage: pngpixel x y png-file\n");
|
||||
|
||||
return result;
|
||||
}
|
||||
87
contrib/examples/pngtopng.c
Normal file
@@ -0,0 +1,87 @@
|
||||
/*- pngtopng
|
||||
*
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2011.
|
||||
* To the extent possible under law, the author has waived all copyright and
|
||||
* related or neighboring rights to this work. This work is published from:
|
||||
* United States.
|
||||
*
|
||||
* Read a PNG and write it out in a fixed format, using the 'simplified API'
|
||||
* that was introduced in libpng-1.6.0.
|
||||
*
|
||||
* This sample code is just the code from the top of 'example.c' with some error
|
||||
* handling added. See example.c for more comments.
|
||||
*/
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* Normally use <png.h> here to get the installed libpng, but this is done to
|
||||
* ensure the code picks up the local libpng implementation:
|
||||
*/
|
||||
#include "../../png.h"
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
int result = 1;
|
||||
|
||||
if (argc == 3)
|
||||
{
|
||||
png_image image;
|
||||
|
||||
memset(&image, 0, sizeof image);
|
||||
|
||||
if (png_image_begin_read_from_file(&image, argv[1]))
|
||||
{
|
||||
png_bytep buffer;
|
||||
|
||||
/* Change this to try different formats! */
|
||||
image.format = PNG_FORMAT_RGBA;
|
||||
|
||||
buffer = malloc(PNG_IMAGE_SIZE(image));
|
||||
|
||||
if (buffer != NULL)
|
||||
{
|
||||
if (png_image_finish_read(&image, NULL/*background*/, buffer,
|
||||
0/*row_stride*/))
|
||||
{
|
||||
if (png_image_write_to_file(&image, argv[2],
|
||||
0/*convert_to_8bit*/, buffer, 0/*row_stride*/))
|
||||
result = 0;
|
||||
|
||||
else
|
||||
fprintf(stderr, "pngtopng: write %s: %s\n", argv[2],
|
||||
image.message);
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "pngtopng: read %s: %s\n", argv[1],
|
||||
image.message);
|
||||
|
||||
/* This is the only place where a 'free' is required; libpng does
|
||||
* the cleanup on error and success, but in this case we couldn't
|
||||
* complete the read because of running out of memory.
|
||||
*/
|
||||
png_image_free(&image);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
fprintf(stderr, "pngtopng: out of memory: %lu bytes\n",
|
||||
(unsigned long)PNG_IMAGE_SIZE(image));
|
||||
}
|
||||
|
||||
else
|
||||
/* Failed to read the first argument: */
|
||||
fprintf(stderr, "pngtopng: %s: %s\n", argv[1], image.message);
|
||||
}
|
||||
|
||||
else
|
||||
/* Wrong number of arguments */
|
||||
fprintf(stderr, "pngtopng: usage: pngtopng input-file output-file\n");
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -23,9 +23,9 @@
|
||||
|
||||
# macros --------------------------------------------------------------------
|
||||
|
||||
PNGINC = -I/usr/local/include/libpng15
|
||||
PNGLIB = -L/usr/local/lib -lpng15 # dynamically linked against libpng
|
||||
#PNGLIB = /usr/local/lib/libpng15.a # statically linked against libpng
|
||||
PNGINC = -I/usr/local/include/libpng16
|
||||
PNGLIB = -L/usr/local/lib -lpng16 # dynamically linked against libpng
|
||||
#PNGLIB = /usr/local/lib/libpng16.a # statically linked against libpng
|
||||
# or:
|
||||
#PNGINC = -I../..
|
||||
#PNGLIB = -L../.. -lpng
|
||||
|
||||
@@ -26,14 +26,14 @@
|
||||
# macros --------------------------------------------------------------------
|
||||
|
||||
#PNGDIR = /usr/local/lib
|
||||
#PNGINC = -I/usr/local/include/libpng15
|
||||
#PNGLIBd = -L$(PNGDIR) -lpng15 # dynamically linked, installed libpng
|
||||
#PNGLIBs = $(PNGDIR)/libpng15.a # statically linked, installed libpng
|
||||
#PNGINC = -I/usr/local/include/libpng16
|
||||
#PNGLIBd = -L$(PNGDIR) -lpng16 # dynamically linked, installed libpng
|
||||
#PNGLIBs = $(PNGDIR)/libpng16.a # statically linked, installed libpng
|
||||
# or:
|
||||
PNGDIR = ../..# this one is for libpng-x.y.z/contrib/gregbook builds
|
||||
#PNGDIR = ../libpng
|
||||
PNGINC = -I$(PNGDIR)
|
||||
PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng15 # dynamically linked
|
||||
PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng16 # dynamically linked
|
||||
PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng
|
||||
|
||||
ZDIR = /usr/local/lib
|
||||
|
||||
@@ -55,8 +55,9 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#include "png.h" /* libpng header; includes zlib.h */
|
||||
#include "png.h" /* libpng header */
|
||||
#include "readpng.h" /* typedefs, common macros, public prototypes */
|
||||
|
||||
/* future versions of libpng will provide this macro: */
|
||||
@@ -229,8 +230,14 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
|
||||
png_set_expand(png_ptr);
|
||||
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
|
||||
png_set_expand(png_ptr);
|
||||
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
||||
if (bit_depth == 16)
|
||||
# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
png_set_scale_16(png_ptr);
|
||||
# else
|
||||
png_set_strip_16(png_ptr);
|
||||
# endif
|
||||
#endif
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY ||
|
||||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
png_set_gray_to_rgb(png_ptr);
|
||||
|
||||
@@ -311,8 +311,14 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
|
||||
png_set_expand(png_ptr);
|
||||
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
|
||||
png_set_expand(png_ptr);
|
||||
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
||||
if (bit_depth == 16)
|
||||
# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
png_set_scale_16(png_ptr);
|
||||
# else
|
||||
png_set_strip_16(png_ptr);
|
||||
# endif
|
||||
#endif
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY ||
|
||||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
png_set_gray_to_rgb(png_ptr);
|
||||
|
||||
@@ -590,7 +590,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
"(unexpectedly) while reading PNG image file\n");
|
||||
exit(3);
|
||||
} else /* if (error) */ {
|
||||
// will print error message below
|
||||
/* will print error message below */
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -591,7 +591,7 @@ int main(int argc, char **argv)
|
||||
"(unexpectedly) while reading PNG image file\n");
|
||||
exit(3);
|
||||
} else /* if (error) */ {
|
||||
// will print error message below
|
||||
/* will print error message below */
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -55,8 +55,9 @@
|
||||
|
||||
|
||||
#include <stdlib.h> /* for exit() prototype */
|
||||
#include <zlib.h>
|
||||
|
||||
#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
|
||||
#include "png.h" /* libpng header, includes setjmp.h */
|
||||
#include "writepng.h" /* typedefs, common macros, public prototypes */
|
||||
|
||||
|
||||
|
||||
2543
contrib/libtests/pngstest.c
Normal file
303
contrib/libtests/timepng.c
Normal file
@@ -0,0 +1,303 @@
|
||||
/* timepng.c
|
||||
*
|
||||
* Copyright (c) 2012 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* Load an arbitrary number of PNG files (from the command line, or, if there
|
||||
* are no arguments on the command line, from stdin) then run a time test by
|
||||
* reading each file by row. The test does nothing with the read result and
|
||||
* does no transforms. The only output is a time as a floating point number of
|
||||
* seconds with 9 decimal digits.
|
||||
*/
|
||||
#define _POSIX_C_SOURCE 199309L /* for clock_gettime */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
/* Define the following to use this test against your installed libpng, rather
|
||||
* than the one being built here:
|
||||
*/
|
||||
#ifdef PNG_FREESTANDING_TESTS
|
||||
# include <png.h>
|
||||
#else
|
||||
# include "../../png.h"
|
||||
#endif
|
||||
|
||||
static int read_png(FILE *fp)
|
||||
{
|
||||
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0);
|
||||
png_infop info_ptr = NULL;
|
||||
png_bytep row = NULL, display = NULL;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return 0;
|
||||
|
||||
if (setjmp(png_jmpbuf(png_ptr)))
|
||||
{
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
if (row != NULL) free(row);
|
||||
if (display != NULL) free(display);
|
||||
return 0;
|
||||
}
|
||||
|
||||
png_init_io(png_ptr, fp);
|
||||
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (info_ptr == NULL)
|
||||
png_error(png_ptr, "OOM allocating info structure");
|
||||
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
{
|
||||
png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
|
||||
row = malloc(rowbytes);
|
||||
display = malloc(rowbytes);
|
||||
|
||||
if (row == NULL || display == NULL)
|
||||
png_error(png_ptr, "OOM allocating row buffers");
|
||||
|
||||
{
|
||||
png_uint_32 height = png_get_image_height(png_ptr, info_ptr);
|
||||
int passes = png_set_interlace_handling(png_ptr);
|
||||
int pass;
|
||||
|
||||
png_start_read_image(png_ptr);
|
||||
|
||||
for (pass = 0; pass < passes; ++pass)
|
||||
{
|
||||
png_uint_32 y = height;
|
||||
|
||||
/* NOTE: this trashes the row each time; interlace handling won't
|
||||
* work, but this avoids memory thrashing for speed testing.
|
||||
*/
|
||||
while (y-- > 0)
|
||||
png_read_row(png_ptr, row, display);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure to read to the end of the file: */
|
||||
png_read_end(png_ptr, info_ptr);
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
free(row);
|
||||
free(display);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int mytime(struct timespec *t)
|
||||
{
|
||||
/* Do the timing using clock_gettime and the per-process timer. */
|
||||
if (!clock_gettime(CLOCK_PROCESS_CPUTIME_ID, t))
|
||||
return 1;
|
||||
|
||||
perror("CLOCK_PROCESS_CPUTIME_ID");
|
||||
fprintf(stderr, "timepng: could not get the time\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int perform_one_test(FILE *fp, int nfiles)
|
||||
{
|
||||
int i;
|
||||
struct timespec before, after;
|
||||
|
||||
/* Clear out all errors: */
|
||||
rewind(fp);
|
||||
|
||||
if (mytime(&before))
|
||||
{
|
||||
for (i=0; i<nfiles; ++i)
|
||||
{
|
||||
if (read_png(fp))
|
||||
{
|
||||
if (ferror(fp))
|
||||
{
|
||||
perror("temporary file");
|
||||
fprintf(stderr, "file %d: error reading PNG data\n", i);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
perror("temporary file");
|
||||
fprintf(stderr, "file %d: error from libpng\n", i);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
return 0;
|
||||
|
||||
if (mytime(&after))
|
||||
{
|
||||
/* Work out the time difference and print it - this is the only output,
|
||||
* so flush it immediately.
|
||||
*/
|
||||
unsigned long s = after.tv_sec - before.tv_sec;
|
||||
long ns = after.tv_nsec - before.tv_nsec;
|
||||
|
||||
if (ns < 0)
|
||||
{
|
||||
--s;
|
||||
ns += 1000000000;
|
||||
|
||||
if (ns < 0)
|
||||
{
|
||||
fprintf(stderr, "timepng: bad clock from kernel\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
printf("%lu.%.9ld\n", s, ns);
|
||||
fflush(stdout);
|
||||
if (ferror(stdout))
|
||||
{
|
||||
fprintf(stderr, "timepng: error writing output\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Successful return */
|
||||
return 1;
|
||||
}
|
||||
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int add_one_file(FILE *fp, char *name)
|
||||
{
|
||||
FILE *ip = fopen(name, "rb");
|
||||
|
||||
if (ip != NULL)
|
||||
{
|
||||
int ch;
|
||||
for (;;)
|
||||
{
|
||||
ch = getc(ip);
|
||||
if (ch == EOF) break;
|
||||
putc(ch, fp);
|
||||
}
|
||||
|
||||
if (ferror(ip))
|
||||
{
|
||||
perror(name);
|
||||
fprintf(stderr, "%s: read error\n", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
(void)fclose(ip);
|
||||
|
||||
if (ferror(fp))
|
||||
{
|
||||
perror("temporary file");
|
||||
fprintf(stderr, "temporary file write error\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
perror(name);
|
||||
fprintf(stderr, "%s: open failed\n", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ok = 0;
|
||||
FILE *fp = tmpfile();
|
||||
|
||||
if (fp != NULL)
|
||||
{
|
||||
int err = 0;
|
||||
int nfiles = 0;
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=1; i<argc; ++i)
|
||||
{
|
||||
if (add_one_file(fp, argv[i]))
|
||||
++nfiles;
|
||||
|
||||
else
|
||||
{
|
||||
err = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
char filename[FILENAME_MAX+1];
|
||||
|
||||
while (fgets(filename, FILENAME_MAX+1, stdin))
|
||||
{
|
||||
int len = strlen(filename);
|
||||
|
||||
if (filename[len-1] == '\n')
|
||||
{
|
||||
filename[len-1] = 0;
|
||||
if (add_one_file(fp, filename))
|
||||
++nfiles;
|
||||
|
||||
else
|
||||
{
|
||||
err = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "timepng: truncated file name ...%s\n",
|
||||
filename+len-32);
|
||||
err = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ferror(stdin))
|
||||
{
|
||||
fprintf(stderr, "timepng: stdin: read error\n");
|
||||
err = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!err)
|
||||
{
|
||||
if (nfiles > 0)
|
||||
ok = perform_one_test(fp, nfiles);
|
||||
|
||||
else
|
||||
fprintf(stderr, "usage: timepng {files} or ls files | timepng\n");
|
||||
}
|
||||
|
||||
(void)fclose(fp);
|
||||
}
|
||||
|
||||
else
|
||||
fprintf(stderr, "timepng: could not open temporary file\n");
|
||||
|
||||
/* Exit code 0 on success. */
|
||||
return ok == 0;
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
This demonstrates the use of PNG_USER_CONFIG, pngusr.h and pngusr.dfa
|
||||
to build minimal decoder, encoder, and progressive reader applications.
|
||||
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
#CC=cc
|
||||
CC=gcc
|
||||
LD=$(CC)
|
||||
STRIP=strip
|
||||
|
||||
# If awk fails try
|
||||
# make AWK=nawk
|
||||
|
||||
# If cpp fails try
|
||||
# make CPP=/lib/cpp
|
||||
|
||||
RM=rm -f
|
||||
COPY=cp
|
||||
|
||||
@@ -87,7 +89,6 @@ all: pngm2pnm$(E)
|
||||
|
||||
pngm2pnm$(E): $(OBJS)
|
||||
$(LD) -o pngm2pnm$(E) $(OBJS)
|
||||
$(STRIP) pngm2pnm$(E)
|
||||
|
||||
# The DFA_XTRA setting turns all libpng options off then
|
||||
# turns on those required for this minimal build.
|
||||
|
||||
@@ -36,4 +36,4 @@ option FLOATING_ARITHMETIC off
|
||||
option SETJMP on
|
||||
option STDIO on
|
||||
option READ_EXPAND on
|
||||
option READ_16_TO_8 on
|
||||
option READ_STRIP_16_TO_8 on
|
||||
|
||||
@@ -19,5 +19,6 @@
|
||||
*/
|
||||
|
||||
#define PNG_NO_WARNINGS
|
||||
#define PNG_ALIGN_TYPE PNG_ALIGN_NONE
|
||||
|
||||
#endif /* MINRDPNGCONF_H */
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
#CC=cc
|
||||
CC=gcc
|
||||
LD=$(CC)
|
||||
STRIP=strip
|
||||
|
||||
# If awk fails try
|
||||
# make AWK=nawk
|
||||
|
||||
# If cpp fails try
|
||||
# make CPP=/lib/cpp
|
||||
|
||||
RM=rm -f
|
||||
COPY=cp
|
||||
|
||||
@@ -86,7 +88,6 @@ all: pnm2pngm$(E)
|
||||
|
||||
pnm2pngm$(E): $(OBJS)
|
||||
$(LD) -o pnm2pngm$(E) $(OBJS)
|
||||
$(STRIP) pnm2pngm$(E)
|
||||
|
||||
# The DFA_XTRA setting turns all libpng options off then
|
||||
# turns on those required for this minimal build.
|
||||
|
||||
@@ -19,5 +19,6 @@
|
||||
*/
|
||||
|
||||
#define PNG_NO_WARNINGS
|
||||
#define PNG_ALIGN_TYPE PNG_ALIGN_NONE
|
||||
|
||||
#endif /* MINWRPNGCONF_H */
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
#CC=cc
|
||||
CC=gcc
|
||||
LD=$(CC)
|
||||
STRIP=strip
|
||||
|
||||
# If awk fails try
|
||||
# make AWK=nawk
|
||||
|
||||
# If cpp fails try
|
||||
# make CPP=/lib/cpp
|
||||
|
||||
RM=rm -f
|
||||
COPY=cp
|
||||
|
||||
@@ -102,7 +104,6 @@ all: $(PROGDOCS) rpng2-x$(E)
|
||||
|
||||
rpng2-x$(E): $(OBJS)
|
||||
$(LD) -o rpng2-x$(E) $(OBJS) $(LIBS)
|
||||
$(STRIP) rpng2-x$(E)
|
||||
|
||||
# The DFA_XTRA setting turns all libpng options off then
|
||||
# turns on those required for this minimal build.
|
||||
|
||||
@@ -36,5 +36,5 @@ option STDIO on
|
||||
option READ_bKGD on
|
||||
option READ_GAMMA on
|
||||
option READ_EXPAND on
|
||||
option READ_16_TO_8 on
|
||||
option READ_STRIP_16_TO_8 on
|
||||
option READ_GRAY_TO_RGB on
|
||||
|
||||
@@ -19,5 +19,6 @@
|
||||
*/
|
||||
|
||||
#define PNG_NO_WARNINGS
|
||||
#define PNG_ALIGN_TYPE PNG_ALIGN_NONE
|
||||
|
||||
#endif /* MINPRDPNGCONF_H */
|
||||
|
||||
@@ -8,9 +8,9 @@ LD=$(CC)
|
||||
RM=rm -f
|
||||
|
||||
#PNGPATH = /usr/local
|
||||
#PNGINC = -I$(PNGPATH)/include/libpng12
|
||||
#PNGLIB = -L$(PNGPATH)/lib -lpng12
|
||||
#PNGLIBS = $(PNGPATH)/lib/libpng12.a
|
||||
#PNGINC = -I$(PNGPATH)/include/libpng16
|
||||
#PNGLIB = -L$(PNGPATH)/lib -lpng16
|
||||
#PNGLIBS = $(PNGPATH)/lib/libpng16.a
|
||||
PNGINC = -I../..
|
||||
PNGLIB = -L../.. -lpng
|
||||
PNGLIBS = ../../libpng.a
|
||||
@@ -23,9 +23,9 @@ ZINC = -I../../../zlib
|
||||
ZLIB = -L../../../zlib -lz
|
||||
ZLIBS = ../../../zlib/libz.a
|
||||
|
||||
CFLAGS=-O3 $(PNGINC) $(ZINC)
|
||||
LDFLAGS=$(PNGLIB) $(ZLIB)
|
||||
LDFLAGSS=$(PNGLIBS) $(ZLIBS)
|
||||
CFLAGS=$(PNGINC) $(ZINC)
|
||||
LDLIBS=$(PNGLIB) $(ZLIB)
|
||||
LDLIBSS=$(PNGLIBS) $(ZLIBS)
|
||||
C=.c
|
||||
O=.o
|
||||
L=.a
|
||||
@@ -40,19 +40,19 @@ png2pnm$(O): png2pnm$(C)
|
||||
$(CC) -c $(CFLAGS) png2pnm$(C)
|
||||
|
||||
png2pnm$(E): png2pnm$(O)
|
||||
$(LD) -o png2pnm$(E) png2pnm$(O) $(LDFLAGS) -lm
|
||||
$(LD) $(LDFLAGS) -o png2pnm$(E) png2pnm$(O) $(LDLIBS) -lm
|
||||
|
||||
png2pnm-static$(E): png2pnm$(O)
|
||||
$(LD) -o png2pnm-static$(E) png2pnm$(O) $(LDFLAGSS) -lm
|
||||
$(LD) $(LDFLAGS) -o png2pnm-static$(E) png2pnm$(O) $(LDLIBSS) -lm
|
||||
|
||||
pnm2png$(O): pnm2png$(C)
|
||||
$(CC) -c $(CFLAGS) pnm2png$(C)
|
||||
|
||||
pnm2png$(E): pnm2png$(O)
|
||||
$(LD) -o pnm2png$(E) pnm2png$(O) $(LDFLAGS) -lm
|
||||
$(LD) $(LDFLAGS) -o pnm2png$(E) pnm2png$(O) $(LDLIBS) -lm
|
||||
|
||||
pnm2png-static$(E): pnm2png$(O)
|
||||
$(LD) -o pnm2png-static$(E) pnm2png$(O) $(LDFLAGSS) -lm
|
||||
$(LD) $(LDFLAGS) -o pnm2png-static$(E) pnm2png$(O) $(LDLIBSS) -lm
|
||||
|
||||
clean:
|
||||
$(RM) png2pnm$(O)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <mem.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include <zlib.h>
|
||||
|
||||
#ifndef BOOL
|
||||
#define BOOL unsigned char
|
||||
@@ -144,7 +145,7 @@ int main(int argc, char *argv[])
|
||||
if (png2pnm (fp_rd, fp_wr, fp_al, raw, alpha) == FALSE)
|
||||
{
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, "Error: unsuccessful convertion of PNG-image\n");
|
||||
fprintf (stderr, "Error: unsuccessful conversion of PNG-image\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <mem.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include <zlib.h>
|
||||
|
||||
#ifndef BOOL
|
||||
#define BOOL unsigned char
|
||||
@@ -197,6 +198,9 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
char height_token[16];
|
||||
char maxval_token[16];
|
||||
int color_type;
|
||||
unsigned long ul_width, ul_alpha_width;
|
||||
unsigned long ul_height, ul_alpha_height;
|
||||
unsigned long ul_maxval;
|
||||
png_uint_32 width, alpha_width;
|
||||
png_uint_32 height, alpha_height;
|
||||
png_uint_32 maxval;
|
||||
@@ -227,11 +231,15 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
raw = (type_token[1] == '5');
|
||||
color_type = PNG_COLOR_TYPE_GRAY;
|
||||
get_token(pnm_file, width_token);
|
||||
sscanf (width_token, "%lu", &width);
|
||||
sscanf (width_token, "%lu", &ul_width);
|
||||
width = (png_uint_32) ul_width;
|
||||
get_token(pnm_file, height_token);
|
||||
sscanf (height_token, "%lu", &height);
|
||||
sscanf (height_token, "%lu", &ul_height);
|
||||
height = (png_uint_32) ul_height;
|
||||
get_token(pnm_file, maxval_token);
|
||||
sscanf (maxval_token, "%lu", &maxval);
|
||||
sscanf (maxval_token, "%lu", &ul_maxval);
|
||||
maxval = (png_uint_32) ul_maxval;
|
||||
|
||||
if (maxval <= 1)
|
||||
bit_depth = 1;
|
||||
else if (maxval <= 3)
|
||||
@@ -248,11 +256,14 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
raw = (type_token[1] == '6');
|
||||
color_type = PNG_COLOR_TYPE_RGB;
|
||||
get_token(pnm_file, width_token);
|
||||
sscanf (width_token, "%lu", &width);
|
||||
sscanf (width_token, "%lu", &ul_width);
|
||||
width = (png_uint_32) ul_width;
|
||||
get_token(pnm_file, height_token);
|
||||
sscanf (height_token, "%lu", &height);
|
||||
sscanf (height_token, "%lu", &ul_height);
|
||||
height = (png_uint_32) ul_height;
|
||||
get_token(pnm_file, maxval_token);
|
||||
sscanf (maxval_token, "%lu", &maxval);
|
||||
sscanf (maxval_token, "%lu", &ul_maxval);
|
||||
maxval = (png_uint_32) ul_maxval;
|
||||
if (maxval <= 1)
|
||||
bit_depth = 1;
|
||||
else if (maxval <= 3)
|
||||
@@ -287,15 +298,18 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
{
|
||||
alpha_raw = (type_token[1] == '5');
|
||||
get_token(alpha_file, width_token);
|
||||
sscanf (width_token, "%lu", &alpha_width);
|
||||
sscanf (width_token, "%lu", &ul_alpha_width);
|
||||
alpha_width=(png_uint_32) ul_alpha_width;
|
||||
if (alpha_width != width)
|
||||
return FALSE;
|
||||
get_token(alpha_file, height_token);
|
||||
sscanf (height_token, "%lu", &alpha_height);
|
||||
sscanf (height_token, "%lu", &ul_alpha_height);
|
||||
alpha_height = (png_uint_32) ul_alpha_height;
|
||||
if (alpha_height != height)
|
||||
return FALSE;
|
||||
get_token(alpha_file, maxval_token);
|
||||
sscanf (maxval_token, "%lu", &maxval);
|
||||
sscanf (maxval_token, "%lu", &ul_maxval);
|
||||
maxval = (png_uint_32) ul_maxval;
|
||||
if (maxval <= 1)
|
||||
alpha_depth = 1;
|
||||
else if (maxval <= 3)
|
||||
@@ -510,6 +524,7 @@ png_uint_32 get_value (FILE *pnm_file, int depth)
|
||||
{
|
||||
static png_uint_32 mask = 0;
|
||||
png_byte token[16];
|
||||
unsigned long ul_ret_value;
|
||||
png_uint_32 ret_value;
|
||||
int i = 0;
|
||||
|
||||
@@ -518,7 +533,8 @@ png_uint_32 get_value (FILE *pnm_file, int depth)
|
||||
mask = (mask << 1) | 0x01;
|
||||
|
||||
get_token (pnm_file, (char *) token);
|
||||
sscanf ((const char *) token, "%lu", &ret_value);
|
||||
sscanf ((const char *) token, "%lu", &ul_ret_value);
|
||||
ret_value = (png_uint_32) ul_ret_value;
|
||||
|
||||
ret_value &= mask;
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
|
||||
pngsuite
|
||||
--------
|
||||
(c) Willem van Schaik, 1999
|
||||
(c) Willem van Schaik, 1999, 2011, 2012
|
||||
Two images are by Glenn Randers-Pehrson, 2012
|
||||
|
||||
Permission to use, copy, and distribute these images for any purpose and
|
||||
without fee is hereby granted.
|
||||
Permission to use, copy, modify, and distribute these images for any
|
||||
purpose and without fee is hereby granted.
|
||||
|
||||
The 15 "bas*.png" images are part of the much larger PngSuite test-set of
|
||||
images, available for developers of PNG supporting software. The
|
||||
@@ -38,6 +39,8 @@ can use them to test the proper functioning of PNG software.
|
||||
basn6a08.png 8-bit RGBA
|
||||
basn6a16.png 16-bit RGBA
|
||||
|
||||
ftbbn0g01.png 1-bit grayscale, black bKGD
|
||||
ftbbn0g02.png 2-bit grayscale, black bKGD
|
||||
ftbbn0g04.png 4-bit grayscale, black bKGD
|
||||
ftbbn2c16.png 16-bit truecolor, black bKGD
|
||||
ftbbn3p08.png 8-bit paletted, black bKGD
|
||||
@@ -52,7 +55,7 @@ can use them to test the proper functioning of PNG software.
|
||||
ftp0n3p08.png 8-bit paletted, opaque
|
||||
ftp1n3p08.png 8-bit paletted, no bKGD
|
||||
|
||||
Here is the correct result of typing "pngtest -m *.png" in
|
||||
Here is the correct result of typing "pngtest -m bas*.png" in
|
||||
this directory:
|
||||
|
||||
Testing basn0g01.png: PASS (524 zero samples)
|
||||
|
||||
BIN
contrib/pngsuite/ftbbn0g01.png
Normal file
|
After Width: | Height: | Size: 176 B |
BIN
contrib/pngsuite/ftbbn0g02.png
Normal file
|
After Width: | Height: | Size: 197 B |
|
Before Width: | Height: | Size: 429 B After Width: | Height: | Size: 429 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 719 B After Width: | Height: | Size: 719 B |
26
contrib/tools/README.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
This directory (contrib/tools) contains tools used by the authors of libpng.
|
||||
|
||||
Code and data placed in this directory is not required to build libpng,
|
||||
however the code in this directory has been used to generate data or code in
|
||||
the body of the libpng source. The source code identifies where this has
|
||||
been done. Code in this directory may not compile on all operating systems
|
||||
that libpng supports.
|
||||
|
||||
NO COPYRIGHT RIGHTS ARE CLAIMED TO ANY OF THE FILES IN THIS DIRECTORY.
|
||||
|
||||
To the extent possible under law, the authors have waived all copyright and
|
||||
related or neighboring rights to this work. This work is published from:
|
||||
United States.
|
||||
|
||||
The files may be used freely in any way.
|
||||
|
||||
The source code and comments in this directory are the original work of the
|
||||
people named below. No other person or organization has made contributions to
|
||||
the work in this directory.
|
||||
|
||||
ORIGINAL AUTHORS
|
||||
The following people have contributed to the code in this directory. None
|
||||
of the people below claim any rights with regard to the contents of this
|
||||
directory.
|
||||
|
||||
John Bowler <jbowler@acm.org>
|
||||
188
contrib/tools/cvtcolor.c
Normal file
@@ -0,0 +1,188 @@
|
||||
/*-
|
||||
* convert.c
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
*
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2012.
|
||||
* To the extent possible under law, the author has waived all copyright and
|
||||
* related or neighboring rights to this work. This work is published from:
|
||||
* United States.
|
||||
*
|
||||
* Convert 8-bit sRGB or 16-bit linear values to another format.
|
||||
*/
|
||||
#define _ISOC99_SOURCE 1
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <fenv.h>
|
||||
|
||||
#include "sRGB.h"
|
||||
|
||||
static void
|
||||
usage(const char *prog)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: usage: %s [-linear|-sRGB] [-gray|-color] component{1,4}\n",
|
||||
prog, prog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
unsigned long
|
||||
component(const char *prog, const char *arg, int issRGB)
|
||||
{
|
||||
char *ep;
|
||||
unsigned long c = strtoul(arg, &ep, 0);
|
||||
|
||||
if (ep <= arg || *ep || c > 65535 || (issRGB && c > 255))
|
||||
{
|
||||
fprintf(stderr, "%s: %s: invalid component value (%lu)\n", prog, arg, c);
|
||||
usage(prog);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, const char **argv)
|
||||
{
|
||||
const char *prog = *argv++;
|
||||
int to_linear = 0, to_gray = 0, to_color = 0;
|
||||
int channels = 0;
|
||||
double c[4];
|
||||
|
||||
/* FE_TONEAREST is the IEEE754 round to nearest, preferring even, mode; i.e.
|
||||
* everything rounds to the nearest value except that '.5' rounds to the
|
||||
* nearest even value.
|
||||
*/
|
||||
fesetround(FE_TONEAREST);
|
||||
|
||||
c[3] = c[2] = c[1] = c[0] = 0;
|
||||
|
||||
while (--argc > 0 && **argv == '-')
|
||||
{
|
||||
const char *arg = 1+*argv++;
|
||||
|
||||
if (strcmp(arg, "sRGB") == 0)
|
||||
to_linear = 0;
|
||||
|
||||
else if (strcmp(arg, "linear") == 0)
|
||||
to_linear = 1;
|
||||
|
||||
else if (strcmp(arg, "gray") == 0)
|
||||
to_gray = 1, to_color = 0;
|
||||
|
||||
else if (strcmp(arg, "color") == 0)
|
||||
to_gray = 0, to_color = 1;
|
||||
|
||||
else
|
||||
usage(prog);
|
||||
}
|
||||
|
||||
switch (argc)
|
||||
{
|
||||
default:
|
||||
usage(prog);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
c[3] = component(prog, argv[3], to_linear);
|
||||
++channels;
|
||||
case 3:
|
||||
c[2] = component(prog, argv[2], to_linear);
|
||||
++channels;
|
||||
case 2:
|
||||
c[1] = component(prog, argv[1], to_linear);
|
||||
++channels;
|
||||
case 1:
|
||||
c[0] = component(prog, argv[0], to_linear);
|
||||
++channels;
|
||||
break;
|
||||
}
|
||||
|
||||
if (to_linear)
|
||||
{
|
||||
int i;
|
||||
int components = channels;
|
||||
|
||||
if ((components & 1) == 0)
|
||||
--components;
|
||||
|
||||
for (i=0; i<components; ++i) c[i] = linear_from_sRGB(c[i] / 255);
|
||||
if (components < channels)
|
||||
c[components] = c[components] / 255;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<4; ++i) c[i] /= 65535;
|
||||
|
||||
if ((channels & 1) == 0)
|
||||
{
|
||||
double alpha = c[channels-1];
|
||||
|
||||
if (alpha > 0)
|
||||
for (i=0; i<channels-1; ++i) c[i] /= alpha;
|
||||
else
|
||||
for (i=0; i<channels-1; ++i) c[i] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (to_gray)
|
||||
{
|
||||
if (channels < 3)
|
||||
{
|
||||
fprintf(stderr, "%s: too few channels (%d) for -gray\n",
|
||||
prog, channels);
|
||||
usage(prog);
|
||||
}
|
||||
|
||||
c[0] = YfromRGB(c[0], c[1], c[2]);
|
||||
channels -= 2;
|
||||
}
|
||||
|
||||
if (to_color)
|
||||
{
|
||||
if (channels > 2)
|
||||
{
|
||||
fprintf(stderr, "%s: too many channels (%d) for -color\n",
|
||||
prog, channels);
|
||||
usage(prog);
|
||||
}
|
||||
|
||||
c[3] = c[1]; /* alpha, if present */
|
||||
c[2] = c[1] = c[0];
|
||||
}
|
||||
|
||||
if (to_linear)
|
||||
{
|
||||
int i;
|
||||
if ((channels & 1) == 0)
|
||||
{
|
||||
double alpha = c[channels-1];
|
||||
for (i=0; i<channels-1; ++i) c[i] *= alpha;
|
||||
}
|
||||
|
||||
for (i=0; i<channels; ++i) c[i] = nearbyint(c[i] * 65535);
|
||||
}
|
||||
|
||||
else /* to sRGB */
|
||||
{
|
||||
int i = (channels+1)&~1;
|
||||
while (--i >= 0)
|
||||
c[i] = sRGB_from_linear(c[i]);
|
||||
|
||||
for (i=0; i<channels; ++i) c[i] = nearbyint(c[i] * 255);
|
||||
}
|
||||
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<channels; ++i) printf(" %g", c[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
110
contrib/tools/intgamma.sh
Normal file
@@ -0,0 +1,110 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# intgamma.sh
|
||||
#
|
||||
# Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
#
|
||||
# COPYRIGHT: Written by John Cunningham Bowler, 2012.
|
||||
# To the extent possible under law, the author has waived all copyright and
|
||||
# related or neighboring rights to this work. This work is published from:
|
||||
# United States.
|
||||
#
|
||||
# Shell script to generate png.c 8-bit and 16-bit log tables (see the code in
|
||||
# png.c for details).
|
||||
#
|
||||
# This script uses the "bc" arbitrary precision calculator to calculate 32-bit
|
||||
# fixed point values of logarithms appropriate to finding the log of an 8-bit
|
||||
# (0..255) value and a similar table for the exponent calculation.
|
||||
#
|
||||
# "bc" must be on the path when the script is executed, and the math library
|
||||
# (-lm) must be available
|
||||
#
|
||||
# function to print out a list of numbers as integers; the function truncates
|
||||
# the integers which must be one-per-line
|
||||
function print(){
|
||||
awk 'BEGIN{
|
||||
str = ""
|
||||
}
|
||||
{
|
||||
sub("\\.[0-9]*$", "")
|
||||
if ($0 == "")
|
||||
$0 = "0"
|
||||
|
||||
if (str == "")
|
||||
t = " " $0 "U"
|
||||
else
|
||||
t = str ", " $0 "U"
|
||||
|
||||
if (length(t) >= 80) {
|
||||
print str ","
|
||||
str = " " $0 "U"
|
||||
} else
|
||||
str = t
|
||||
}
|
||||
END{
|
||||
print str
|
||||
}'
|
||||
}
|
||||
#
|
||||
# The logarithm table.
|
||||
cat <<END
|
||||
/* 8-bit log table: png_8bit_l2[128]
|
||||
* This is a table of -log(value/255)/log(2) for 'value' in the range 128 to
|
||||
* 255, so it's the base 2 logarithm of a normalized 8-bit floating point
|
||||
* mantissa. The numbers are 32-bit fractions.
|
||||
*/
|
||||
static const png_uint_32
|
||||
png_8bit_l2[128] =
|
||||
{
|
||||
END
|
||||
#
|
||||
bc -lqws <<END | print
|
||||
f=65536*65536/l(2)
|
||||
for (i=128;i<256;++i) { .5 - l(i/255)*f; }
|
||||
END
|
||||
echo '};'
|
||||
echo
|
||||
#
|
||||
# The exponent table.
|
||||
cat <<END
|
||||
/* The 'exp()' case must invert the above, taking a 20-bit fixed point
|
||||
* logarithmic value and returning a 16 or 8-bit number as appropriate. In
|
||||
* each case only the low 16 bits are relevant - the fraction - since the
|
||||
* integer bits (the top 4) simply determine a shift.
|
||||
*
|
||||
* The worst case is the 16-bit distinction between 65535 and 65534; this
|
||||
* requires perhaps spurious accuracy in the decoding of the logarithm to
|
||||
* distinguish log2(65535/65534.5) - 10^-5 or 17 bits. There is little chance
|
||||
* of getting this accuracy in practice.
|
||||
*
|
||||
* To deal with this the following exp() function works out the exponent of the
|
||||
* frational part of the logarithm by using an accurate 32-bit value from the
|
||||
* top four fractional bits then multiplying in the remaining bits.
|
||||
*/
|
||||
static const png_uint_32
|
||||
png_32bit_exp[16] =
|
||||
{
|
||||
END
|
||||
#
|
||||
bc -lqws <<END | print
|
||||
f=l(2)/16
|
||||
for (i=0;i<16;++i) {
|
||||
x = .5 + e(-i*f)*2^32;
|
||||
if (x >= 2^32) x = 2^32-1;
|
||||
x;
|
||||
}
|
||||
END
|
||||
echo '};'
|
||||
echo
|
||||
#
|
||||
# And the table of adjustment values.
|
||||
cat <<END
|
||||
/* Adjustment table; provided to explain the numbers in the code below. */
|
||||
#if 0
|
||||
END
|
||||
bc -lqws <<END | awk '{ printf "%5d %s\n", 12-NR, $0 }'
|
||||
for (i=11;i>=0;--i){
|
||||
(1 - e(-(2^i)/65536*l(2))) * 2^(32-i)
|
||||
}
|
||||
END
|
||||
echo '#endif'
|
||||
430
contrib/tools/makesRGB.c
Normal file
@@ -0,0 +1,430 @@
|
||||
/* makesRGB.c -- build sRGB-to-linear and linear-to-sRGB conversion tables
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
*
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2012.
|
||||
* To the extent possible under law, the author has waived all copyright and
|
||||
* related or neighboring rights to this work. This work is published from:
|
||||
* United States.
|
||||
*
|
||||
* Make a table to convert 8-bit sRGB encoding values into the closest 16-bit
|
||||
* linear value.
|
||||
*
|
||||
* Make two tables to take a linear value scaled to 255*65535 and return an
|
||||
* approximation to the 8-bit sRGB encoded value. Calculate the error in these
|
||||
* tables and display it.
|
||||
*/
|
||||
#define _C99_SOURCE 1
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* pngpriv.h includes the definition of 'PNG_sRGB_FROM_LINEAR' which is required
|
||||
* to verify the actual code.
|
||||
*/
|
||||
#include "../../pngpriv.h"
|
||||
|
||||
#include "sRGB.h"
|
||||
|
||||
/* The tables are declared 'const' in pngpriv.h, so this redefines the tables to
|
||||
* be used.
|
||||
*/
|
||||
#define png_sRGB_table sRGB_table
|
||||
#define png_sRGB_base sRGB_base
|
||||
#define png_sRGB_delta sRGB_delta
|
||||
|
||||
static png_uint_16 png_sRGB_table[256];
|
||||
static png_uint_16 png_sRGB_base[512];
|
||||
static png_byte png_sRGB_delta[512];
|
||||
|
||||
static const unsigned int max_input = 255*65535;
|
||||
|
||||
double
|
||||
fsRGB(double l)
|
||||
{
|
||||
return sRGB_from_linear(l/max_input);
|
||||
}
|
||||
|
||||
double
|
||||
sRGB(unsigned int i)
|
||||
{
|
||||
return fsRGB(i);
|
||||
}
|
||||
|
||||
double
|
||||
finvsRGB(unsigned int i)
|
||||
{
|
||||
return 65535 * linear_from_sRGB(i/255.);
|
||||
}
|
||||
|
||||
png_uint_16
|
||||
invsRGB(unsigned int i)
|
||||
{
|
||||
unsigned int x = nearbyint(finvsRGB(i));
|
||||
|
||||
if (x > 65535)
|
||||
{
|
||||
fprintf(stderr, "invsRGB(%u) overflows to %u\n", i, x);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return (png_uint_16)x;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
unsigned int i, i16, ibase;
|
||||
double min_error = 0;
|
||||
double max_error = 0;
|
||||
double min_error16 = 0;
|
||||
double max_error16 = 0;
|
||||
double adjust;
|
||||
double adjust_lo = 0.4, adjust_hi = 0.6, adjust_mid = 0.5;
|
||||
unsigned int ec_lo = 0, ec_hi = 0, ec_mid = 0;
|
||||
unsigned int error_count = 0;
|
||||
unsigned int error_count16 = 0;
|
||||
int test_only = 0;
|
||||
|
||||
if (argc > 1)
|
||||
test_only = strcmp("--test", argv[1]) == 0;
|
||||
|
||||
/* Initialize the encoding table first. */
|
||||
for (i=0; i<256; ++i)
|
||||
{
|
||||
png_sRGB_table[i] = invsRGB(i);
|
||||
}
|
||||
|
||||
/* Now work out the decoding tables (this is where the error comes in because
|
||||
* there are 512 set points and 512 straight lines between them.)
|
||||
*/
|
||||
for (;;)
|
||||
{
|
||||
if (ec_lo == 0)
|
||||
adjust = adjust_lo;
|
||||
|
||||
else if (ec_hi == 0)
|
||||
adjust = adjust_hi;
|
||||
|
||||
else if (ec_mid == 0)
|
||||
adjust = adjust_mid;
|
||||
|
||||
else if (ec_mid < ec_hi)
|
||||
adjust = (adjust_mid + adjust_hi)/2;
|
||||
|
||||
else if (ec_mid < ec_lo)
|
||||
adjust = (adjust_mid + adjust_lo)/2;
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "not reached: %u .. %u .. %u\n", ec_lo, ec_mid, ec_hi);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Calculate the table using the current 'adjust' */
|
||||
for (i=0; i<=511; ++i)
|
||||
{
|
||||
double lo = 255 * sRGB(i << 15);
|
||||
double hi = 255 * sRGB((i+1) << 15);
|
||||
unsigned int calc;
|
||||
|
||||
calc = nearbyint((lo+adjust) * 256);
|
||||
if (calc > 65535)
|
||||
{
|
||||
fprintf(stderr, "table[%d][0]: overflow %08x (%d)\n", i, calc,
|
||||
calc);
|
||||
exit(1);
|
||||
}
|
||||
png_sRGB_base[i] = calc;
|
||||
|
||||
calc = nearbyint((hi-lo) * 32);
|
||||
if (calc > 255)
|
||||
{
|
||||
fprintf(stderr, "table[%d][1]: overflow %08x (%d)\n", i, calc,
|
||||
calc);
|
||||
exit(1);
|
||||
}
|
||||
png_sRGB_delta[i] = calc;
|
||||
}
|
||||
|
||||
/* Check the 16-bit linear values alone: */
|
||||
error_count16 = 0;
|
||||
for (i16=0; i16 <= 65535; ++i16)
|
||||
{
|
||||
unsigned int i = 255*i16;
|
||||
unsigned int iexact = nearbyint(255*sRGB(i));
|
||||
unsigned int icalc = PNG_sRGB_FROM_LINEAR(i);
|
||||
|
||||
if (icalc != iexact)
|
||||
++error_count16;
|
||||
}
|
||||
|
||||
/* Now try changing the adjustment. */
|
||||
if (ec_lo == 0)
|
||||
ec_lo = error_count16;
|
||||
|
||||
else if (ec_hi == 0)
|
||||
ec_hi = error_count16;
|
||||
|
||||
else if (ec_mid == 0)
|
||||
{
|
||||
ec_mid = error_count16;
|
||||
printf("/* initial error counts: %u .. %u .. %u */\n", ec_lo, ec_mid,
|
||||
ec_hi);
|
||||
}
|
||||
|
||||
else if (error_count16 < ec_mid)
|
||||
{
|
||||
printf("/* adjust (mid ): %f: %u -> %u */\n", adjust, ec_mid,
|
||||
error_count16);
|
||||
ec_mid = error_count16;
|
||||
adjust_mid = adjust;
|
||||
}
|
||||
|
||||
else if (adjust < adjust_mid && error_count16 < ec_lo)
|
||||
{
|
||||
printf("/* adjust (low ): %f: %u -> %u */\n", adjust, ec_lo,
|
||||
error_count16);
|
||||
ec_lo = error_count16;
|
||||
adjust_lo = adjust;
|
||||
}
|
||||
|
||||
else if (adjust > adjust_mid && error_count16 < ec_hi)
|
||||
{
|
||||
printf("/* adjust (high): %f: %u -> %u */\n", adjust, ec_hi,
|
||||
error_count16);
|
||||
ec_hi = error_count16;
|
||||
adjust_hi = adjust;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
adjust = adjust_mid;
|
||||
printf("/* adjust: %f: %u */\n", adjust, ec_mid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* For each entry in the table try to adjust it to minimize the error count
|
||||
* in that entry. Each entry corresponds to 128 input values.
|
||||
*/
|
||||
for (ibase=0; ibase<65536; ibase+=128)
|
||||
{
|
||||
png_uint_16 base = png_sRGB_base[ibase >> 7], trybase = base, ob=base;
|
||||
png_byte delta = png_sRGB_delta[ibase >> 7], trydelta = delta, od=delta;
|
||||
unsigned int ecbase = 0, eco;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
png_sRGB_base[ibase >> 7] = trybase;
|
||||
png_sRGB_delta[ibase >> 7] = trydelta;
|
||||
|
||||
/* Check the 16-bit linear values alone: */
|
||||
error_count16 = 0;
|
||||
for (i16=ibase; i16 < ibase+128; ++i16)
|
||||
{
|
||||
unsigned int i = 255*i16;
|
||||
unsigned int iexact = nearbyint(255*sRGB(i));
|
||||
unsigned int icalc = PNG_sRGB_FROM_LINEAR(i);
|
||||
|
||||
if (icalc != iexact)
|
||||
++error_count16;
|
||||
}
|
||||
|
||||
if (error_count16 == 0)
|
||||
break;
|
||||
|
||||
if (ecbase == 0)
|
||||
{
|
||||
eco = ecbase = error_count16;
|
||||
++trybase; /* First test */
|
||||
}
|
||||
|
||||
else if (error_count16 < ecbase)
|
||||
{
|
||||
if (trybase > base)
|
||||
{
|
||||
base = trybase;
|
||||
++trybase;
|
||||
}
|
||||
else if (trybase < base)
|
||||
{
|
||||
base = trybase;
|
||||
--trybase;
|
||||
}
|
||||
else if (trydelta > delta)
|
||||
{
|
||||
delta = trydelta;
|
||||
++trydelta;
|
||||
}
|
||||
else if (trydelta < delta)
|
||||
{
|
||||
delta = trydelta;
|
||||
--trydelta;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "makesRGB: impossible\n");
|
||||
exit(1);
|
||||
}
|
||||
ecbase = error_count16;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (trybase > base)
|
||||
trybase = base-1;
|
||||
else if (trybase < base)
|
||||
{
|
||||
trybase = base;
|
||||
++trydelta;
|
||||
}
|
||||
else if (trydelta > delta)
|
||||
trydelta = delta-1;
|
||||
else if (trydelta < delta)
|
||||
break; /* end of tests */
|
||||
}
|
||||
}
|
||||
|
||||
png_sRGB_base[ibase >> 7] = base;
|
||||
png_sRGB_delta[ibase >> 7] = delta;
|
||||
if (base != ob || delta != od)
|
||||
{
|
||||
printf("/* table[%u]={%u,%u} -> {%u,%u} %u -> %u errors */\n",
|
||||
ibase>>7, ob, od, base, delta, eco, ecbase);
|
||||
}
|
||||
else if (0)
|
||||
printf("/* table[%u]={%u,%u} %u errors */\n", ibase>>7, ob, od,
|
||||
ecbase);
|
||||
}
|
||||
|
||||
/* Only do the full (slow) test at the end: */
|
||||
min_error = -.4999;
|
||||
max_error = .4999;
|
||||
error_count = 0;
|
||||
|
||||
for (i=0; i <= max_input; ++i)
|
||||
{
|
||||
unsigned int iexact = nearbyint(255*sRGB(i));
|
||||
unsigned int icalc = PNG_sRGB_FROM_LINEAR(i);
|
||||
|
||||
if (icalc != iexact)
|
||||
{
|
||||
double err = 255*sRGB(i) - icalc;
|
||||
|
||||
if (err > (max_error+.001) || err < (min_error-.001))
|
||||
{
|
||||
printf(
|
||||
"/* 0x%08x: exact: %3d, got: %3d [tables: %08x, %08x] (%f) */\n",
|
||||
i, iexact, icalc, png_sRGB_base[i>>15],
|
||||
png_sRGB_delta[i>>15], err);
|
||||
}
|
||||
|
||||
++error_count;
|
||||
if (err > max_error)
|
||||
max_error = err;
|
||||
else if (err < min_error)
|
||||
min_error = err;
|
||||
}
|
||||
}
|
||||
|
||||
/* Re-check the 16-bit cases too, including the warning if there is an error
|
||||
* bigger than 1.
|
||||
*/
|
||||
error_count16 = 0;
|
||||
max_error16 = 0;
|
||||
min_error16 = 0;
|
||||
for (i16=0; i16 <= 65535; ++i16)
|
||||
{
|
||||
unsigned int i = 255*i16;
|
||||
unsigned int iexact = nearbyint(255*sRGB(i));
|
||||
unsigned int icalc = PNG_sRGB_FROM_LINEAR(i);
|
||||
|
||||
if (icalc != iexact)
|
||||
{
|
||||
double err = 255*sRGB(i) - icalc;
|
||||
|
||||
++error_count16;
|
||||
if (err > max_error16)
|
||||
max_error16 = err;
|
||||
else if (err < min_error16)
|
||||
min_error16 = err;
|
||||
|
||||
if (abs(icalc - iexact) > 1)
|
||||
printf(
|
||||
"/* 0x%04x: exact: %3d, got: %3d [tables: %08x, %08x] (%f) */\n",
|
||||
i16, iexact, icalc, png_sRGB_base[i>>15],
|
||||
png_sRGB_delta[i>>15], err);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check the round trip for each 8-bit sRGB value. */
|
||||
for (i16=0; i16 <= 255; ++i16)
|
||||
{
|
||||
unsigned int i = 255 * png_sRGB_table[i16];
|
||||
unsigned int iexact = nearbyint(255*sRGB(i));
|
||||
unsigned int icalc = PNG_sRGB_FROM_LINEAR(i);
|
||||
|
||||
if (i16 != iexact)
|
||||
{
|
||||
fprintf(stderr, "8-bit rounding error: %d -> %d\n", i16, iexact);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (icalc != i16)
|
||||
{
|
||||
double finv = finvsRGB(i16);
|
||||
|
||||
printf("/* 8-bit roundtrip error: %d -> %f -> %d(%f) */\n",
|
||||
i16, finv, icalc, fsRGB(255*finv));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("/* error: %g - %g, %u (%g%%) of readings inexact */\n",
|
||||
min_error, max_error, error_count, (100.*error_count)/max_input);
|
||||
printf("/* 16-bit error: %g - %g, %u (%g%%) of readings inexact */\n",
|
||||
min_error16, max_error16, error_count16, (100.*error_count16)/65535);
|
||||
|
||||
if (!test_only)
|
||||
{
|
||||
printf("PNG_CONST png_uint_16 png_sRGB_table[256] =\n{\n ");
|
||||
for (i=0; i<255; )
|
||||
{
|
||||
do
|
||||
{
|
||||
printf("%d,", png_sRGB_table[i++]);
|
||||
}
|
||||
while ((i & 0x7) != 0 && i<255);
|
||||
if (i<255) printf("\n ");
|
||||
}
|
||||
printf("%d\n};\n\n", png_sRGB_table[i]);
|
||||
|
||||
|
||||
printf("PNG_CONST png_uint_16 png_sRGB_base[512] =\n{\n ");
|
||||
for (i=0; i<511; )
|
||||
{
|
||||
do
|
||||
{
|
||||
printf("%d,", png_sRGB_base[i++]);
|
||||
}
|
||||
while ((i & 0x7) != 0 && i<511);
|
||||
if (i<511) printf("\n ");
|
||||
}
|
||||
printf("%d\n};\n\n", png_sRGB_base[i]);
|
||||
|
||||
printf("PNG_CONST png_byte png_sRGB_delta[512] =\n{\n ");
|
||||
for (i=0; i<511; )
|
||||
{
|
||||
do
|
||||
{
|
||||
printf("%d,", png_sRGB_delta[i++]);
|
||||
}
|
||||
while ((i & 0xf) != 0 && i<511);
|
||||
if (i<511) printf("\n ");
|
||||
}
|
||||
printf("%d\n};\n\n", png_sRGB_delta[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
48
contrib/tools/sRGB.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*-
|
||||
* sRGB.h
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
*
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2012.
|
||||
* To the extent possible under law, the author has waived all copyright and
|
||||
* related or neighboring rights to this work. This work is published from:
|
||||
* United States.
|
||||
*
|
||||
* Utility file; not actually a header, this contains definitions of sRGB
|
||||
* calculation functions for inclusion in those test programs that need them.
|
||||
*
|
||||
* All routines take and return a floating point value in the range
|
||||
* 0 to 1.0, doing a calculation according to the sRGB specification
|
||||
* (in fact the source of the numbers is the wikipedia article at
|
||||
* http://en.wikipedia.org/wiki/SRGB).
|
||||
*/
|
||||
static double
|
||||
sRGB_from_linear(double l)
|
||||
{
|
||||
if (l <= 0.0031308)
|
||||
l *= 12.92;
|
||||
|
||||
else
|
||||
l = 1.055 * pow(l, 1/2.4) - 0.055;
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
static double
|
||||
linear_from_sRGB(double s)
|
||||
{
|
||||
if (s <= 0.04045)
|
||||
return s / 12.92;
|
||||
|
||||
else
|
||||
return pow((s+0.055)/1.055, 2.4);
|
||||
}
|
||||
|
||||
static double
|
||||
YfromRGB(double r, double g, double b)
|
||||
{
|
||||
/* Use the sRGB (rounded) coefficients for Rlinear, Glinear, Blinear to get
|
||||
* the CIE Y value (also linear).
|
||||
*/
|
||||
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
||||
}
|
||||
@@ -1,17 +1,19 @@
|
||||
//-------------------------------------
|
||||
// PNGFILE.C -- Image File Functions
|
||||
//-------------------------------------
|
||||
|
||||
// Copyright 2000, Willem van Schaik.
|
||||
//
|
||||
// This code is released under the libpng license.
|
||||
// For conditions of distribution and use, see the disclaimer
|
||||
// and license in png.h
|
||||
/*-------------------------------------
|
||||
* PNGFILE.C -- Image File Functions
|
||||
*-------------------------------------
|
||||
*
|
||||
* Copyright 2000, Willem van Schaik.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <commdlg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#include "png.h"
|
||||
#include "pngfile.h"
|
||||
@@ -28,7 +30,7 @@ static png_structp png_ptr = NULL;
|
||||
static png_infop info_ptr = NULL;
|
||||
|
||||
|
||||
// cexcept interface
|
||||
/* cexcept interface */
|
||||
|
||||
static void
|
||||
png_cexcept_error(png_structp png_ptr, png_const_charp msg)
|
||||
@@ -43,7 +45,7 @@ png_cexcept_error(png_structp png_ptr, png_const_charp msg)
|
||||
}
|
||||
}
|
||||
|
||||
// Windows open-file functions
|
||||
/* Windows open-file functions */
|
||||
|
||||
void PngFileInitialize (HWND hwnd)
|
||||
{
|
||||
@@ -57,13 +59,13 @@ void PngFileInitialize (HWND hwnd)
|
||||
ofn.lpstrCustomFilter = NULL;
|
||||
ofn.nMaxCustFilter = 0;
|
||||
ofn.nFilterIndex = 0;
|
||||
ofn.lpstrFile = NULL; // Set in Open and Close functions
|
||||
ofn.lpstrFile = NULL; /* Set in Open and Close functions */
|
||||
ofn.nMaxFile = MAX_PATH;
|
||||
ofn.lpstrFileTitle = NULL; // Set in Open and Close functions
|
||||
ofn.lpstrFileTitle = NULL; /* Set in Open and Close functions */
|
||||
ofn.nMaxFileTitle = MAX_PATH;
|
||||
ofn.lpstrInitialDir = NULL;
|
||||
ofn.lpstrTitle = NULL;
|
||||
ofn.Flags = 0; // Set in Open and Close functions
|
||||
ofn.Flags = 0; /* Set in Open and Close functions */
|
||||
ofn.nFileOffset = 0;
|
||||
ofn.nFileExtension = 0;
|
||||
ofn.lpstrDefExt = TEXT ("png");
|
||||
@@ -92,7 +94,7 @@ BOOL PngFileSaveDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName)
|
||||
return GetSaveFileName (&ofn);
|
||||
}
|
||||
|
||||
// PNG image handler functions
|
||||
/* PNG image handler functions */
|
||||
|
||||
BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
|
||||
int *piWidth, int *piHeight, int *piChannels, png_color *pBkgColor)
|
||||
@@ -109,7 +111,7 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
|
||||
static png_byte **ppbRowPointers = NULL;
|
||||
int i;
|
||||
|
||||
// open the PNG input file
|
||||
/* open the PNG input file */
|
||||
|
||||
if (!pstrFileName)
|
||||
{
|
||||
@@ -123,7 +125,7 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// first check the eight byte PNG signature
|
||||
/* first check the eight byte PNG signature */
|
||||
|
||||
fread(pbSig, 1, 8, pfFile);
|
||||
if (png_sig_cmp(pbSig, 0, 8))
|
||||
@@ -132,7 +134,7 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// create the two png(-info) structures
|
||||
/* create the two png(-info) structures */
|
||||
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
|
||||
(png_error_ptr)png_cexcept_error, (png_error_ptr)NULL);
|
||||
@@ -153,7 +155,7 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
|
||||
Try
|
||||
{
|
||||
|
||||
// initialize the png structure
|
||||
/* initialize the png structure */
|
||||
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
png_init_io(png_ptr, pfFile);
|
||||
@@ -163,20 +165,26 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
|
||||
|
||||
png_set_sig_bytes(png_ptr, 8);
|
||||
|
||||
// read all PNG info up to image data
|
||||
/* read all PNG info up to image data */
|
||||
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
// get width, height, bit-depth and color-type
|
||||
/* get width, height, bit-depth and color-type */
|
||||
|
||||
png_get_IHDR(png_ptr, info_ptr, piWidth, piHeight, &iBitDepth,
|
||||
&iColorType, NULL, NULL, NULL);
|
||||
|
||||
// expand images of all color-type and bit-depth to 3x8 bit RGB images
|
||||
// let the library process things like alpha, transparency, background
|
||||
/* expand images of all color-type and bit-depth to 3x8-bit RGB */
|
||||
/* let the library process alpha, transparency, background, etc. */
|
||||
|
||||
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
||||
if (iBitDepth == 16)
|
||||
# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
png_set_scale_16(png_ptr);
|
||||
# else
|
||||
png_set_strip_16(png_ptr);
|
||||
# endif
|
||||
#endif
|
||||
if (iColorType == PNG_COLOR_TYPE_PALETTE)
|
||||
png_set_expand(png_ptr);
|
||||
if (iBitDepth < 8)
|
||||
@@ -187,7 +195,7 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
|
||||
iColorType == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
png_set_gray_to_rgb(png_ptr);
|
||||
|
||||
// set the background color to draw transparent and alpha images over.
|
||||
/* set the background color to draw transparent and alpha images over */
|
||||
if (png_get_bKGD(png_ptr, info_ptr, &pBackground))
|
||||
{
|
||||
png_set_background(png_ptr, pBackground, PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
|
||||
@@ -200,28 +208,28 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
|
||||
pBkgColor = NULL;
|
||||
}
|
||||
|
||||
// if required set gamma conversion
|
||||
/* if required set gamma conversion */
|
||||
if (png_get_gAMA(png_ptr, info_ptr, &dGamma))
|
||||
png_set_gamma(png_ptr, (double) 2.2, dGamma);
|
||||
|
||||
// after the transformations have been registered update info_ptr data
|
||||
/* after the transformations are registered, update info_ptr data */
|
||||
|
||||
png_read_update_info(png_ptr, info_ptr);
|
||||
|
||||
// get again width, height and the new bit-depth and color-type
|
||||
/* get again width, height and the new bit-depth and color-type */
|
||||
|
||||
png_get_IHDR(png_ptr, info_ptr, piWidth, piHeight, &iBitDepth,
|
||||
&iColorType, NULL, NULL, NULL);
|
||||
|
||||
|
||||
// row_bytes is the width x number of channels
|
||||
/* row_bytes is the width x number of channels */
|
||||
|
||||
ulRowBytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
ulChannels = png_get_channels(png_ptr, info_ptr);
|
||||
|
||||
*piChannels = ulChannels;
|
||||
|
||||
// now we can allocate memory to store the image
|
||||
/* now we can allocate memory to store the image */
|
||||
|
||||
if (pbImageData)
|
||||
{
|
||||
@@ -235,7 +243,7 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
|
||||
}
|
||||
*ppbImageData = pbImageData;
|
||||
|
||||
// and allocate memory for an array of row-pointers
|
||||
/* and allocate memory for an array of row-pointers */
|
||||
|
||||
if ((ppbRowPointers = (png_bytepp) malloc((*piHeight)
|
||||
* sizeof(png_bytep))) == NULL)
|
||||
@@ -243,25 +251,25 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
|
||||
png_error(png_ptr, "Visual PNG: out of memory");
|
||||
}
|
||||
|
||||
// set the individual row-pointers to point at the correct offsets
|
||||
/* set the individual row-pointers to point at the correct offsets */
|
||||
|
||||
for (i = 0; i < (*piHeight); i++)
|
||||
ppbRowPointers[i] = pbImageData + i * ulRowBytes;
|
||||
|
||||
// now we can go ahead and just read the whole image
|
||||
/* now we can go ahead and just read the whole image */
|
||||
|
||||
png_read_image(png_ptr, ppbRowPointers);
|
||||
|
||||
// read the additional chunks in the PNG file (not really needed)
|
||||
/* read the additional chunks in the PNG file (not really needed) */
|
||||
|
||||
png_read_end(png_ptr, NULL);
|
||||
|
||||
// and we're done
|
||||
/* and we're done */
|
||||
|
||||
free (ppbRowPointers);
|
||||
ppbRowPointers = NULL;
|
||||
|
||||
// yepp, done
|
||||
/* yepp, done */
|
||||
}
|
||||
|
||||
Catch (msg)
|
||||
@@ -295,7 +303,7 @@ BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData,
|
||||
static png_byte **ppbRowPointers = NULL;
|
||||
int i;
|
||||
|
||||
// open the PNG output file
|
||||
/* open the PNG output file */
|
||||
|
||||
if (!pstrFileName)
|
||||
return FALSE;
|
||||
@@ -303,7 +311,7 @@ BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData,
|
||||
if (!(pfFile = fopen(pstrFileName, "wb")))
|
||||
return FALSE;
|
||||
|
||||
// prepare the standard PNG structures
|
||||
/* prepare the standard PNG structures */
|
||||
|
||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL,
|
||||
(png_error_ptr)png_cexcept_error, (png_error_ptr)NULL);
|
||||
@@ -322,7 +330,7 @@ BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData,
|
||||
|
||||
Try
|
||||
{
|
||||
// initialize the png structure
|
||||
/* initialize the png structure */
|
||||
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
png_init_io(png_ptr, pfFile);
|
||||
@@ -330,52 +338,52 @@ BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData,
|
||||
png_set_write_fn(png_ptr, (png_voidp)pfFile, png_write_data, png_flush);
|
||||
#endif
|
||||
|
||||
// we're going to write a very simple 3x8 bit RGB image
|
||||
/* we're going to write a very simple 3x8-bit RGB image */
|
||||
|
||||
png_set_IHDR(png_ptr, info_ptr, iWidth, iHeight, ciBitDepth,
|
||||
PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE,
|
||||
PNG_FILTER_TYPE_BASE);
|
||||
|
||||
// write the file header information
|
||||
/* write the file header information */
|
||||
|
||||
png_write_info(png_ptr, info_ptr);
|
||||
|
||||
// swap the BGR pixels in the DiData structure to RGB
|
||||
/* swap the BGR pixels in the DiData structure to RGB */
|
||||
|
||||
png_set_bgr(png_ptr);
|
||||
|
||||
// row_bytes is the width x number of channels
|
||||
/* row_bytes is the width x number of channels */
|
||||
|
||||
ulRowBytes = iWidth * ciChannels;
|
||||
|
||||
// we can allocate memory for an array of row-pointers
|
||||
/* we can allocate memory for an array of row-pointers */
|
||||
|
||||
if ((ppbRowPointers = (png_bytepp) malloc(iHeight * sizeof(png_bytep))) == NULL)
|
||||
Throw "Visualpng: Out of memory";
|
||||
|
||||
// set the individual row-pointers to point at the correct offsets
|
||||
/* set the individual row-pointers to point at the correct offsets */
|
||||
|
||||
for (i = 0; i < iHeight; i++)
|
||||
ppbRowPointers[i] = pDiData + i * (((ulRowBytes + 3) >> 2) << 2);
|
||||
|
||||
// write out the entire image data in one call
|
||||
/* write out the entire image data in one call */
|
||||
|
||||
png_write_image (png_ptr, ppbRowPointers);
|
||||
|
||||
// write the additional chunks to the PNG file (not really needed)
|
||||
/* write the additional chunks to the PNG file (not really needed) */
|
||||
|
||||
png_write_end(png_ptr, info_ptr);
|
||||
|
||||
// and we're done
|
||||
/* and we're done */
|
||||
|
||||
free (ppbRowPointers);
|
||||
ppbRowPointers = NULL;
|
||||
|
||||
// clean up after the write, and free any memory allocated
|
||||
/* clean up after the write, and free any memory allocated */
|
||||
|
||||
png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
|
||||
|
||||
// yepp, done
|
||||
/* yepp, done */
|
||||
}
|
||||
|
||||
Catch (msg)
|
||||
@@ -437,6 +445,7 @@ png_flush(png_structp png_ptr)
|
||||
|
||||
#endif
|
||||
|
||||
//-----------------
|
||||
// end of source
|
||||
//-----------------
|
||||
/*-----------------
|
||||
* end of source
|
||||
*-----------------
|
||||
*/
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
//------------------------------------------
|
||||
// PNGFILE.H -- Header File for pngfile.c
|
||||
//------------------------------------------
|
||||
/*------------------------------------------*/
|
||||
/* PNGFILE.H -- Header File for pngfile.c*/
|
||||
/*------------------------------------------*/
|
||||
|
||||
// Copyright 2000, Willem van Schaik.
|
||||
/* Copyright 2000, Willem van Schaik.*/
|
||||
|
||||
// This code is released under the libpng license.
|
||||
// For conditions of distribution and use, see the disclaimer
|
||||
// and license in png.h
|
||||
/* This code is released under the libpng license.*/
|
||||
/* For conditions of distribution and use, see the disclaimer*/
|
||||
/* and license in png.h*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -1,41 +1,43 @@
|
||||
//------------------------------------
|
||||
// VisualPng.C -- Shows a PNG image
|
||||
//------------------------------------
|
||||
/*------------------------------------
|
||||
* VisualPng.C -- Shows a PNG image
|
||||
*------------------------------------
|
||||
*
|
||||
* Copyright 2000, Willem van Schaik.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
// Copyright 2000, Willem van Schaik.
|
||||
/* switches */
|
||||
|
||||
// This code is released under the libpng license.
|
||||
// For conditions of distribution and use, see the disclaimer
|
||||
// and license in png.h
|
||||
|
||||
// switches
|
||||
|
||||
// defines
|
||||
/* defines */
|
||||
|
||||
#define PROGNAME "VisualPng"
|
||||
#define LONGNAME "Win32 Viewer for PNG-files"
|
||||
#define VERSION "1.0 of 2000 June 07"
|
||||
|
||||
// constants
|
||||
/* constants */
|
||||
|
||||
#define MARGIN 8
|
||||
|
||||
// standard includes
|
||||
/* standard includes */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
#include <zlib.h>
|
||||
|
||||
// application includes
|
||||
/* application includes */
|
||||
|
||||
#include "png.h"
|
||||
#include "pngfile.h"
|
||||
#include "resource.h"
|
||||
|
||||
// macros
|
||||
/* macros */
|
||||
|
||||
// function prototypes
|
||||
/* function prototypes */
|
||||
|
||||
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
|
||||
BOOL CALLBACK AboutDlgProc (HWND, UINT, WPARAM, LPARAM) ;
|
||||
@@ -65,14 +67,14 @@ BOOL FillBitmap (
|
||||
BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels,
|
||||
BOOL bStretched);
|
||||
|
||||
// a few global variables
|
||||
/* a few global variables */
|
||||
|
||||
static char *szProgName = PROGNAME;
|
||||
static char *szAppName = LONGNAME;
|
||||
static char *szIconName = PROGNAME;
|
||||
static char szCmdFileName [MAX_PATH];
|
||||
|
||||
// MAIN routine
|
||||
/* MAIN routine */
|
||||
|
||||
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
PSTR szCmdLine, int iCmdShow)
|
||||
@@ -90,7 +92,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
wndclass.hInstance = hInstance;
|
||||
wndclass.hIcon = LoadIcon (hInstance, szIconName) ;
|
||||
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
|
||||
wndclass.hbrBackground = NULL; // (HBRUSH) GetStockObject (GRAY_BRUSH);
|
||||
wndclass.hbrBackground = NULL; /* (HBRUSH) GetStockObject (GRAY_BRUSH); */
|
||||
wndclass.lpszMenuName = szProgName;
|
||||
wndclass.lpszClassName = szProgName;
|
||||
|
||||
@@ -101,7 +103,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
return 0;
|
||||
}
|
||||
|
||||
// if filename given on commandline, store it
|
||||
/* if filename given on commandline, store it */
|
||||
if ((szCmdLine != NULL) && (*szCmdLine != '\0'))
|
||||
if (szCmdLine[0] == '"')
|
||||
strncpy (szCmdFileName, szCmdLine + 1, strlen(szCmdLine) - 2);
|
||||
@@ -110,7 +112,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
else
|
||||
strcpy (szCmdFileName, "");
|
||||
|
||||
// calculate size of window-borders
|
||||
/* calculate size of window-borders */
|
||||
ixBorders = 2 * (GetSystemMetrics (SM_CXBORDER) +
|
||||
GetSystemMetrics (SM_CXDLGFRAME));
|
||||
iyBorders = 2 * (GetSystemMetrics (SM_CYBORDER) +
|
||||
@@ -123,7 +125,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
512 + 2 * MARGIN + ixBorders, 384 + 2 * MARGIN + iyBorders,
|
||||
// CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
/* CW_USEDEFAULT, CW_USEDEFAULT, */
|
||||
NULL, NULL, hInstance, NULL);
|
||||
|
||||
ShowWindow (hwnd, iCmdShow);
|
||||
@@ -180,29 +182,29 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam,
|
||||
|
||||
strcpy (szImgPathName, "");
|
||||
|
||||
// in case we process file given on command-line
|
||||
/* in case we process file given on command-line */
|
||||
|
||||
if (szCmdFileName[0] != '\0')
|
||||
{
|
||||
strcpy (szImgPathName, szCmdFileName);
|
||||
|
||||
// read the other png-files in the directory for later
|
||||
// next/previous commands
|
||||
/* read the other png-files in the directory for later */
|
||||
/* next/previous commands */
|
||||
|
||||
BuildPngList (szImgPathName, &pPngFileList, &iPngFileCount,
|
||||
&iPngFileIndex);
|
||||
|
||||
// load the image from file
|
||||
/* load the image from file */
|
||||
|
||||
if (!LoadImageFile (hwnd, szImgPathName,
|
||||
&pbImage, &cxImgSize, &cyImgSize, &cImgChannels, &bkgColor))
|
||||
return 0;
|
||||
|
||||
// invalidate the client area for later update
|
||||
/* invalidate the client area for later update */
|
||||
|
||||
InvalidateRect (hwnd, NULL, TRUE);
|
||||
|
||||
// display the PNG into the DIBitmap
|
||||
/* display the PNG into the DIBitmap */
|
||||
|
||||
DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize,
|
||||
pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched);
|
||||
@@ -214,11 +216,11 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam,
|
||||
cxWinSize = LOWORD (lParam);
|
||||
cyWinSize = HIWORD (lParam);
|
||||
|
||||
// invalidate the client area for later update
|
||||
/* invalidate the client area for later update */
|
||||
|
||||
InvalidateRect (hwnd, NULL, TRUE);
|
||||
|
||||
// display the PNG into the DIBitmap
|
||||
/* display the PNG into the DIBitmap */
|
||||
|
||||
DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize,
|
||||
pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched);
|
||||
@@ -242,28 +244,28 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam,
|
||||
{
|
||||
case IDM_FILE_OPEN:
|
||||
|
||||
// show the File Open dialog box
|
||||
/* show the File Open dialog box */
|
||||
|
||||
if (!PngFileOpenDlg (hwnd, szImgPathName, szTitleName))
|
||||
return 0;
|
||||
|
||||
// read the other png-files in the directory for later
|
||||
// next/previous commands
|
||||
/* read the other png-files in the directory for later */
|
||||
/* next/previous commands */
|
||||
|
||||
BuildPngList (szImgPathName, &pPngFileList, &iPngFileCount,
|
||||
&iPngFileIndex);
|
||||
|
||||
// load the image from file
|
||||
/* load the image from file */
|
||||
|
||||
if (!LoadImageFile (hwnd, szImgPathName,
|
||||
&pbImage, &cxImgSize, &cyImgSize, &cImgChannels, &bkgColor))
|
||||
return 0;
|
||||
|
||||
// invalidate the client area for later update
|
||||
/* invalidate the client area for later update */
|
||||
|
||||
InvalidateRect (hwnd, NULL, TRUE);
|
||||
|
||||
// display the PNG into the DIBitmap
|
||||
/* display the PNG into the DIBitmap */
|
||||
|
||||
DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize,
|
||||
pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched);
|
||||
@@ -272,12 +274,12 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam,
|
||||
|
||||
case IDM_FILE_SAVE:
|
||||
|
||||
// show the File Save dialog box
|
||||
/* show the File Save dialog box */
|
||||
|
||||
if (!PngFileSaveDlg (hwnd, szImgPathName, szTitleName))
|
||||
return 0;
|
||||
|
||||
// save the PNG to a disk file
|
||||
/* save the PNG to a disk file */
|
||||
|
||||
SetCursor (LoadCursor (NULL, IDC_WAIT));
|
||||
ShowCursor (TRUE);
|
||||
@@ -295,7 +297,7 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam,
|
||||
|
||||
case IDM_FILE_NEXT:
|
||||
|
||||
// read next entry in the directory
|
||||
/* read next entry in the directory */
|
||||
|
||||
if (SearchPngList (pPngFileList, iPngFileCount, &iPngFileIndex,
|
||||
NULL, szImgPathName))
|
||||
@@ -303,17 +305,17 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam,
|
||||
if (strcmp (szImgPathName, "") == 0)
|
||||
return 0;
|
||||
|
||||
// load the image from file
|
||||
/* load the image from file */
|
||||
|
||||
if (!LoadImageFile (hwnd, szImgPathName, &pbImage,
|
||||
&cxImgSize, &cyImgSize, &cImgChannels, &bkgColor))
|
||||
return 0;
|
||||
|
||||
// invalidate the client area for later update
|
||||
/* invalidate the client area for later update */
|
||||
|
||||
InvalidateRect (hwnd, NULL, TRUE);
|
||||
|
||||
// display the PNG into the DIBitmap
|
||||
/* display the PNG into the DIBitmap */
|
||||
|
||||
DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize,
|
||||
pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched);
|
||||
@@ -323,7 +325,7 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam,
|
||||
|
||||
case IDM_FILE_PREVIOUS:
|
||||
|
||||
// read previous entry in the directory
|
||||
/* read previous entry in the directory */
|
||||
|
||||
if (SearchPngList (pPngFileList, iPngFileCount, &iPngFileIndex,
|
||||
szImgPathName, NULL))
|
||||
@@ -332,17 +334,17 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam,
|
||||
if (strcmp (szImgPathName, "") == 0)
|
||||
return 0;
|
||||
|
||||
// load the image from file
|
||||
/* load the image from file */
|
||||
|
||||
if (!LoadImageFile (hwnd, szImgPathName, &pbImage, &cxImgSize,
|
||||
&cyImgSize, &cImgChannels, &bkgColor))
|
||||
return 0;
|
||||
|
||||
// invalidate the client area for later update
|
||||
/* invalidate the client area for later update */
|
||||
|
||||
InvalidateRect (hwnd, NULL, TRUE);
|
||||
|
||||
// display the PNG into the DIBitmap
|
||||
/* display the PNG into the DIBitmap */
|
||||
|
||||
DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize,
|
||||
pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched);
|
||||
@@ -352,9 +354,9 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam,
|
||||
|
||||
case IDM_FILE_EXIT:
|
||||
|
||||
// more cleanup needed...
|
||||
/* more cleanup needed... */
|
||||
|
||||
// free image buffer
|
||||
/* free image buffer */
|
||||
|
||||
if (pDib != NULL)
|
||||
{
|
||||
@@ -362,7 +364,7 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam,
|
||||
pDib = NULL;
|
||||
}
|
||||
|
||||
// free file-list
|
||||
/* free file-list */
|
||||
|
||||
if (pPngFileList != NULL)
|
||||
{
|
||||
@@ -370,7 +372,7 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam,
|
||||
pPngFileList = NULL;
|
||||
}
|
||||
|
||||
// let's go ...
|
||||
/* let's go ... */
|
||||
|
||||
exit (0);
|
||||
|
||||
@@ -383,11 +385,11 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam,
|
||||
else
|
||||
CheckMenuItem (hMenu, IDM_OPTIONS_STRETCH, MF_UNCHECKED);
|
||||
|
||||
// invalidate the client area for later update
|
||||
/* invalidate the client area for later update */
|
||||
|
||||
InvalidateRect (hwnd, NULL, TRUE);
|
||||
|
||||
// display the PNG into the DIBitmap
|
||||
/* display the PNG into the DIBitmap */
|
||||
|
||||
DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize,
|
||||
pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched);
|
||||
@@ -398,7 +400,7 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam,
|
||||
DialogBox (hInstance, TEXT ("AboutBox"), hwnd, AboutDlgProc) ;
|
||||
return 0;
|
||||
|
||||
} // end switch
|
||||
} /* end switch */
|
||||
|
||||
break;
|
||||
|
||||
@@ -450,10 +452,10 @@ BOOL CALLBACK AboutDlgProc (HWND hDlg, UINT message,
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
//---------------
|
||||
// CenterAbout
|
||||
//---------------
|
||||
|
||||
/*---------------
|
||||
* CenterAbout
|
||||
*---------------
|
||||
*/
|
||||
BOOL CenterAbout (HWND hwndChild, HWND hwndParent)
|
||||
{
|
||||
RECT rChild, rParent, rWorkArea;
|
||||
@@ -461,19 +463,19 @@ BOOL CenterAbout (HWND hwndChild, HWND hwndParent)
|
||||
int xNew, yNew;
|
||||
BOOL bResult;
|
||||
|
||||
// Get the Height and Width of the child window
|
||||
/* Get the Height and Width of the child window */
|
||||
GetWindowRect (hwndChild, &rChild);
|
||||
wChild = rChild.right - rChild.left;
|
||||
hChild = rChild.bottom - rChild.top;
|
||||
|
||||
// Get the Height and Width of the parent window
|
||||
/* Get the Height and Width of the parent window */
|
||||
GetWindowRect (hwndParent, &rParent);
|
||||
wParent = rParent.right - rParent.left;
|
||||
hParent = rParent.bottom - rParent.top;
|
||||
|
||||
// Get the limits of the 'workarea'
|
||||
/* Get the limits of the 'workarea' */
|
||||
bResult = SystemParametersInfo(
|
||||
SPI_GETWORKAREA, // system parameter to query or set
|
||||
SPI_GETWORKAREA, /* system parameter to query or set */
|
||||
sizeof(RECT),
|
||||
&rWorkArea,
|
||||
0);
|
||||
@@ -483,7 +485,7 @@ BOOL CenterAbout (HWND hwndChild, HWND hwndParent)
|
||||
rWorkArea.bottom = GetSystemMetrics(SM_CYSCREEN);
|
||||
}
|
||||
|
||||
// Calculate new X position, then adjust for workarea
|
||||
/* Calculate new X position, then adjust for workarea */
|
||||
xNew = rParent.left + ((wParent - wChild) /2);
|
||||
if (xNew < rWorkArea.left) {
|
||||
xNew = rWorkArea.left;
|
||||
@@ -491,7 +493,7 @@ BOOL CenterAbout (HWND hwndChild, HWND hwndParent)
|
||||
xNew = rWorkArea.right - wChild;
|
||||
}
|
||||
|
||||
// Calculate new Y position, then adjust for workarea
|
||||
/* Calculate new Y position, then adjust for workarea */
|
||||
yNew = rParent.top + ((hParent - hChild) /2);
|
||||
if (yNew < rWorkArea.top) {
|
||||
yNew = rWorkArea.top;
|
||||
@@ -499,15 +501,15 @@ BOOL CenterAbout (HWND hwndChild, HWND hwndParent)
|
||||
yNew = rWorkArea.bottom - hChild;
|
||||
}
|
||||
|
||||
// Set it, and return
|
||||
/* Set it, and return */
|
||||
return SetWindowPos (hwndChild, NULL, xNew, yNew, 0, 0, SWP_NOSIZE |
|
||||
SWP_NOZORDER);
|
||||
}
|
||||
|
||||
//----------------
|
||||
// BuildPngList
|
||||
//----------------
|
||||
|
||||
/*----------------
|
||||
* BuildPngList
|
||||
*----------------
|
||||
*/
|
||||
BOOL BuildPngList (PTSTR pstrPathName, TCHAR **ppFileList, int *pFileCount,
|
||||
int *pFileIndex)
|
||||
{
|
||||
@@ -523,7 +525,7 @@ BOOL BuildPngList (PTSTR pstrPathName, TCHAR **ppFileList, int *pFileCount,
|
||||
int i, ii;
|
||||
int j, jj;
|
||||
|
||||
// free previous file-list
|
||||
/* free previous file-list */
|
||||
|
||||
if (*ppFileList != NULL)
|
||||
{
|
||||
@@ -531,7 +533,7 @@ BOOL BuildPngList (PTSTR pstrPathName, TCHAR **ppFileList, int *pFileCount,
|
||||
*ppFileList = NULL;
|
||||
}
|
||||
|
||||
// extract foldername, filename and search-name
|
||||
/* extract foldername, filename and search-name */
|
||||
|
||||
strcpy (szImgPathName, pstrPathName);
|
||||
strcpy (szImgFileName, strrchr (pstrPathName, '\\') + 1);
|
||||
@@ -540,7 +542,7 @@ BOOL BuildPngList (PTSTR pstrPathName, TCHAR **ppFileList, int *pFileCount,
|
||||
*(strrchr (szImgFindName, '\\') + 1) = '\0';
|
||||
strcat (szImgFindName, "*.png");
|
||||
|
||||
// first cycle: count number of files in directory for memory allocation
|
||||
/* first cycle: count number of files in directory for memory allocation */
|
||||
|
||||
*pFileCount = 0;
|
||||
|
||||
@@ -554,11 +556,11 @@ BOOL BuildPngList (PTSTR pstrPathName, TCHAR **ppFileList, int *pFileCount,
|
||||
}
|
||||
FindClose(hFind);
|
||||
|
||||
// allocation memory for file-list
|
||||
/* allocation memory for file-list */
|
||||
|
||||
*ppFileList = (TCHAR *) malloc (*pFileCount * MAX_PATH);
|
||||
|
||||
// second cycle: read directory and store filenames in file-list
|
||||
/* second cycle: read directory and store filenames in file-list */
|
||||
|
||||
hFind = FindFirstFile(szImgFindName, &finddata);
|
||||
bOk = (hFind != (HANDLE) -1);
|
||||
@@ -580,7 +582,7 @@ BOOL BuildPngList (PTSTR pstrPathName, TCHAR **ppFileList, int *pFileCount,
|
||||
}
|
||||
FindClose(hFind);
|
||||
|
||||
// finally we must sort the file-list
|
||||
/* finally we must sort the file-list */
|
||||
|
||||
for (i = 0; i < *pFileCount - 1; i++)
|
||||
{
|
||||
@@ -594,7 +596,7 @@ BOOL BuildPngList (PTSTR pstrPathName, TCHAR **ppFileList, int *pFileCount,
|
||||
strcpy (*ppFileList + jj, *ppFileList + ii);
|
||||
strcpy (*ppFileList + ii, szTmp);
|
||||
|
||||
// check if this was the current image that we moved
|
||||
/* check if this was the current image that we moved */
|
||||
|
||||
if (*pFileIndex == i)
|
||||
*pFileIndex = j;
|
||||
@@ -608,9 +610,10 @@ BOOL BuildPngList (PTSTR pstrPathName, TCHAR **ppFileList, int *pFileCount,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//----------------
|
||||
// SearchPngList
|
||||
//----------------
|
||||
/*----------------
|
||||
* SearchPngList
|
||||
*----------------
|
||||
*/
|
||||
|
||||
BOOL SearchPngList (
|
||||
TCHAR *pFileList, int FileCount, int *pFileIndex,
|
||||
@@ -618,7 +621,7 @@ BOOL SearchPngList (
|
||||
{
|
||||
if (FileCount > 0)
|
||||
{
|
||||
// get previous entry
|
||||
/* get previous entry */
|
||||
|
||||
if (pstrPrevName != NULL)
|
||||
{
|
||||
@@ -630,7 +633,7 @@ BOOL SearchPngList (
|
||||
strcpy (pstrPrevName, pFileList + (*pFileIndex * MAX_PATH));
|
||||
}
|
||||
|
||||
// get next entry
|
||||
/* get next entry */
|
||||
|
||||
if (pstrNextName != NULL)
|
||||
{
|
||||
@@ -650,9 +653,10 @@ BOOL SearchPngList (
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------
|
||||
// LoadImageFile
|
||||
//-----------------
|
||||
/*-----------------
|
||||
* LoadImageFile
|
||||
*-----------------
|
||||
*/
|
||||
|
||||
BOOL LoadImageFile (HWND hwnd, PTSTR pstrPathName,
|
||||
png_byte **ppbImage, int *pxImgSize, int *pyImgSize,
|
||||
@@ -660,7 +664,7 @@ BOOL LoadImageFile (HWND hwnd, PTSTR pstrPathName,
|
||||
{
|
||||
static TCHAR szTmp [MAX_PATH];
|
||||
|
||||
// if there's an existing PNG, free the memory
|
||||
/* if there's an existing PNG, free the memory */
|
||||
|
||||
if (*ppbImage)
|
||||
{
|
||||
@@ -668,7 +672,7 @@ BOOL LoadImageFile (HWND hwnd, PTSTR pstrPathName,
|
||||
*ppbImage = NULL;
|
||||
}
|
||||
|
||||
// Load the entire PNG into memory
|
||||
/* Load the entire PNG into memory */
|
||||
|
||||
SetCursor (LoadCursor (NULL, IDC_WAIT));
|
||||
ShowCursor (TRUE);
|
||||
@@ -694,10 +698,10 @@ BOOL LoadImageFile (HWND hwnd, PTSTR pstrPathName,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//----------------
|
||||
// DisplayImage
|
||||
//----------------
|
||||
|
||||
/*----------------
|
||||
* DisplayImage
|
||||
*----------------
|
||||
*/
|
||||
BOOL DisplayImage (HWND hwnd, BYTE **ppDib,
|
||||
BYTE **ppDiData, int cxWinSize, int cyWinSize,
|
||||
BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels,
|
||||
@@ -705,14 +709,14 @@ BOOL DisplayImage (HWND hwnd, BYTE **ppDib,
|
||||
{
|
||||
BYTE *pDib = *ppDib;
|
||||
BYTE *pDiData = *ppDiData;
|
||||
// BITMAPFILEHEADER *pbmfh;
|
||||
/* BITMAPFILEHEADER *pbmfh; */
|
||||
BITMAPINFOHEADER *pbmih;
|
||||
WORD wDIRowBytes;
|
||||
png_color bkgBlack = {0, 0, 0};
|
||||
png_color bkgGray = {127, 127, 127};
|
||||
png_color bkgWhite = {255, 255, 255};
|
||||
|
||||
// allocate memory for the Device Independant bitmap
|
||||
/* allocate memory for the Device Independant bitmap */
|
||||
|
||||
wDIRowBytes = (WORD) ((3 * cxWinSize + 3L) >> 2) << 2;
|
||||
|
||||
@@ -733,7 +737,7 @@ BOOL DisplayImage (HWND hwnd, BYTE **ppDib,
|
||||
*ppDib = pDib;
|
||||
memset (pDib, 0, sizeof(BITMAPINFOHEADER));
|
||||
|
||||
// initialize the dib-structure
|
||||
/* initialize the dib-structure */
|
||||
|
||||
pbmih = (BITMAPINFOHEADER *) pDib;
|
||||
pbmih->biSize = sizeof(BITMAPINFOHEADER);
|
||||
@@ -745,11 +749,11 @@ BOOL DisplayImage (HWND hwnd, BYTE **ppDib,
|
||||
pDiData = pDib + sizeof(BITMAPINFOHEADER);
|
||||
*ppDiData = pDiData;
|
||||
|
||||
// first fill bitmap with gray and image border
|
||||
/* first fill bitmap with gray and image border */
|
||||
|
||||
InitBitmap (pDiData, cxWinSize, cyWinSize);
|
||||
|
||||
// then fill bitmap with image
|
||||
/* then fill bitmap with image */
|
||||
|
||||
if (pbImage)
|
||||
{
|
||||
@@ -762,16 +766,16 @@ BOOL DisplayImage (HWND hwnd, BYTE **ppDib,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//--------------
|
||||
// InitBitmap
|
||||
//--------------
|
||||
|
||||
/*--------------
|
||||
* InitBitmap
|
||||
*--------------
|
||||
*/
|
||||
BOOL InitBitmap (BYTE *pDiData, int cxWinSize, int cyWinSize)
|
||||
{
|
||||
BYTE *dst;
|
||||
int x, y, col;
|
||||
|
||||
// initialize the background with gray
|
||||
/* initialize the background with gray */
|
||||
|
||||
dst = pDiData;
|
||||
for (y = 0; y < cyWinSize; y++)
|
||||
@@ -779,13 +783,13 @@ BOOL InitBitmap (BYTE *pDiData, int cxWinSize, int cyWinSize)
|
||||
col = 0;
|
||||
for (x = 0; x < cxWinSize; x++)
|
||||
{
|
||||
// fill with GRAY
|
||||
/* fill with GRAY */
|
||||
*dst++ = 127;
|
||||
*dst++ = 127;
|
||||
*dst++ = 127;
|
||||
col += 3;
|
||||
}
|
||||
// rows start on 4 byte boundaries
|
||||
/* rows start on 4 byte boundaries */
|
||||
while ((col % 4) != 0)
|
||||
{
|
||||
dst++;
|
||||
@@ -796,10 +800,10 @@ BOOL InitBitmap (BYTE *pDiData, int cxWinSize, int cyWinSize)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//--------------
|
||||
// FillBitmap
|
||||
//--------------
|
||||
|
||||
/*--------------
|
||||
* FillBitmap
|
||||
*--------------
|
||||
*/
|
||||
BOOL FillBitmap (
|
||||
BYTE *pDiData, int cxWinSize, int cyWinSize,
|
||||
BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels,
|
||||
@@ -824,11 +828,12 @@ BOOL FillBitmap (
|
||||
cxNewSize = cxWinSize - 2 * MARGIN;
|
||||
cyNewSize = cyWinSize - 2 * MARGIN;
|
||||
|
||||
// stretch the image to it's window determined size
|
||||
/* stretch the image to it's window determined size */
|
||||
|
||||
// the following two are the same, but the first has side-effects
|
||||
// because of rounding
|
||||
// if ((cyNewSize / cxNewSize) > (cyImgSize / cxImgSize))
|
||||
/* the following two are mathematically the same, but the first
|
||||
* has side-effects because of rounding
|
||||
*/
|
||||
/* if ((cyNewSize / cxNewSize) > (cyImgSize / cxImgSize)) */
|
||||
if ((cyNewSize * cxImgSize) > (cyImgSize * cxNewSize))
|
||||
{
|
||||
cyNewSize = cxNewSize * cyImgSize / cxImgSize;
|
||||
@@ -867,12 +872,12 @@ BOOL FillBitmap (
|
||||
}
|
||||
}
|
||||
|
||||
// calculate row-bytes
|
||||
/* calculate row-bytes */
|
||||
|
||||
wImgRowBytes = cImgChannels * cxNewSize;
|
||||
wDIRowBytes = (WORD) ((cDIChannels * cxWinSize + 3L) >> 2) << 2;
|
||||
|
||||
// copy image to screen
|
||||
/* copy image to screen */
|
||||
|
||||
for (yImg = 0, yWin = cyImgPos; yImg < cyNewSize; yImg++, yWin++)
|
||||
{
|
||||
@@ -898,7 +903,7 @@ BOOL FillBitmap (
|
||||
}
|
||||
}
|
||||
|
||||
// free memory
|
||||
/* free memory */
|
||||
|
||||
if (pStretchedImage != NULL)
|
||||
{
|
||||
@@ -908,28 +913,28 @@ BOOL FillBitmap (
|
||||
|
||||
}
|
||||
|
||||
// process the image not-stretched
|
||||
/* process the image not-stretched */
|
||||
|
||||
else
|
||||
{
|
||||
// calculate the central position
|
||||
/* calculate the central position */
|
||||
|
||||
cxImgPos = (cxWinSize - cxImgSize) / 2;
|
||||
cyImgPos = (cyWinSize - cyImgSize) / 2;
|
||||
|
||||
// check for image larger than window
|
||||
/* check for image larger than window */
|
||||
|
||||
if (cxImgPos < MARGIN)
|
||||
cxImgPos = MARGIN;
|
||||
if (cyImgPos < MARGIN)
|
||||
cyImgPos = MARGIN;
|
||||
|
||||
// calculate both row-bytes
|
||||
/* calculate both row-bytes */
|
||||
|
||||
wImgRowBytes = cImgChannels * cxImgSize;
|
||||
wDIRowBytes = (WORD) ((cDIChannels * cxWinSize + 3L) >> 2) << 2;
|
||||
|
||||
// copy image to screen
|
||||
/* copy image to screen */
|
||||
|
||||
for (yImg = 0, yWin = cyImgPos; yImg < cyImgSize; yImg++, yWin++)
|
||||
{
|
||||
@@ -959,6 +964,7 @@ BOOL FillBitmap (
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//-----------------
|
||||
// end of source
|
||||
//-----------------
|
||||
/*-----------------
|
||||
* end of source
|
||||
*-----------------
|
||||
*/
|
||||
|
||||
630
depcomp
@@ -1,630 +0,0 @@
|
||||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2009-04-28.21; # UTC
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
|
||||
# Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Run PROGRAMS ARGS to compile a file, generating dependencies
|
||||
as side-effects.
|
||||
|
||||
Environment variables:
|
||||
depmode Dependency tracking mode.
|
||||
source Source file read by `PROGRAMS ARGS'.
|
||||
object Object file output by `PROGRAMS ARGS'.
|
||||
DEPDIR directory where to store dependencies.
|
||||
depfile Dependency file to output.
|
||||
tmpdepfile Temporary file to use when outputing dependencies.
|
||||
libtool Whether libtool is used (yes/no).
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "depcomp $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
|
||||
echo "depcomp: Variables source, object and depmode must be set" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
|
||||
depfile=${depfile-`echo "$object" |
|
||||
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
|
||||
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||
|
||||
rm -f "$tmpdepfile"
|
||||
|
||||
# Some modes work just like other modes, but use different flags. We
|
||||
# parameterize here, but still list the modes in the big case below,
|
||||
# to make depend.m4 easier to write. Note that we *cannot* use a case
|
||||
# here, because this file can only contain one case statement.
|
||||
if test "$depmode" = hp; then
|
||||
# HP compiler uses -M and no extra arg.
|
||||
gccflag=-M
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
if test "$depmode" = dashXmstdout; then
|
||||
# This is just like dashmstdout with a different argument.
|
||||
dashmflag=-xM
|
||||
depmode=dashmstdout
|
||||
fi
|
||||
|
||||
cygpath_u="cygpath -u -f -"
|
||||
if test "$depmode" = msvcmsys; then
|
||||
# This is just like msvisualcpp but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u="sed s,\\\\\\\\,/,g"
|
||||
depmode=msvisualcpp
|
||||
fi
|
||||
|
||||
case "$depmode" in
|
||||
gcc3)
|
||||
## gcc 3 implements dependency tracking that does exactly what
|
||||
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
|
||||
## it if -MD -MP comes after the -MF stuff. Hmm.
|
||||
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
|
||||
## the command line argument order; so add the flags where they
|
||||
## appear in depend2.am. Note that the slowdown incurred here
|
||||
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
|
||||
*) set fnord "$@" "$arg" ;;
|
||||
esac
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
done
|
||||
"$@"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
mv "$tmpdepfile" "$depfile"
|
||||
;;
|
||||
|
||||
gcc)
|
||||
## There are various ways to get dependency output from gcc. Here's
|
||||
## why we pick this rather obscure method:
|
||||
## - Don't want to use -MD because we'd like the dependencies to end
|
||||
## up in a subdir. Having to rename by hand is ugly.
|
||||
## (We might end up doing this anyway to support other compilers.)
|
||||
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
|
||||
## -MM, not -M (despite what the docs say).
|
||||
## - Using -M directly means running the compiler twice (even worse
|
||||
## than renaming).
|
||||
if test -z "$gccflag"; then
|
||||
gccflag=-MD,
|
||||
fi
|
||||
"$@" -Wp,"$gccflag$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
||||
## The second -e expression handles DOS-style file names with drive letters.
|
||||
sed -e 's/^[^:]*: / /' \
|
||||
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
|
||||
## This next piece of magic avoids the `deleted header file' problem.
|
||||
## The problem is that when a header file which appears in a .P file
|
||||
## is deleted, the dependency causes make to die (because there is
|
||||
## typically no way to rebuild the header). We avoid this by adding
|
||||
## dummy dependencies for each header file. Too bad gcc doesn't do
|
||||
## this for us directly.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" |
|
||||
## Some versions of gcc put a space before the `:'. On the theory
|
||||
## that the space means something, we add a space to the output as
|
||||
## well.
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
sgi)
|
||||
if test "$libtool" = yes; then
|
||||
"$@" "-Wp,-MDupdate,$tmpdepfile"
|
||||
else
|
||||
"$@" -MDupdate "$tmpdepfile"
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
|
||||
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
|
||||
echo "$object : \\" > "$depfile"
|
||||
|
||||
# Clip off the initial element (the dependent). Don't try to be
|
||||
# clever and replace this with sed code, as IRIX sed won't handle
|
||||
# lines with more than a fixed number of characters (4096 in
|
||||
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
|
||||
# the IRIX cc adds comments like `#:fec' to the end of the
|
||||
# dependency line.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
|
||||
tr '
|
||||
' ' ' >> "$depfile"
|
||||
echo >> "$depfile"
|
||||
|
||||
# The second pass generates a dummy entry for each header file.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||
>> "$depfile"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
aix)
|
||||
# The C for AIX Compiler uses -M and outputs the dependencies
|
||||
# in a .u file. In older versions, this file always lives in the
|
||||
# current directory. Also, the AIX compiler puts `$object:' at the
|
||||
# start of each line; $object doesn't have directory information.
|
||||
# Version 6 uses the directory in both cases.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$base.u
|
||||
tmpdepfile3=$dir.libs/$base.u
|
||||
"$@" -Wc,-M
|
||||
else
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$dir$base.u
|
||||
tmpdepfile3=$dir$base.u
|
||||
"$@" -M
|
||||
fi
|
||||
stat=$?
|
||||
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
# Each line is of the form `foo.o: dependent.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
|
||||
# That's a tab and a space in the [].
|
||||
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
icc)
|
||||
# Intel's C compiler understands `-MD -MF file'. However on
|
||||
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
|
||||
# ICC 7.0 will fill foo.d with something like
|
||||
# foo.o: sub/foo.c
|
||||
# foo.o: sub/foo.h
|
||||
# which is wrong. We want:
|
||||
# sub/foo.o: sub/foo.c
|
||||
# sub/foo.o: sub/foo.h
|
||||
# sub/foo.c:
|
||||
# sub/foo.h:
|
||||
# ICC 7.1 will output
|
||||
# foo.o: sub/foo.c sub/foo.h
|
||||
# and will wrap long lines using \ :
|
||||
# foo.o: sub/foo.c ... \
|
||||
# sub/foo.h ... \
|
||||
# ...
|
||||
|
||||
"$@" -MD -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each line is of the form `foo.o: dependent.h',
|
||||
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
|
||||
sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp2)
|
||||
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
|
||||
# compilers, which have integrated preprocessors. The correct option
|
||||
# to use with these is +Maked; it writes dependencies to a file named
|
||||
# 'foo.d', which lands next to the object file, wherever that
|
||||
# happens to be.
|
||||
# Much of this is similar to the tru64 case; see comments there.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir.libs/$base.d
|
||||
"$@" -Wc,+Maked
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
"$@" +Maked
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
|
||||
# Add `dependent.h:' lines.
|
||||
sed -ne '2,${
|
||||
s/^ *//
|
||||
s/ \\*$//
|
||||
s/$/:/
|
||||
p
|
||||
}' "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile" "$tmpdepfile2"
|
||||
;;
|
||||
|
||||
tru64)
|
||||
# The Tru64 compiler uses -MD to generate dependencies as a side
|
||||
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
|
||||
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
|
||||
# dependencies in `foo.d' instead, so we check for that too.
|
||||
# Subdirectories are respected.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
|
||||
if test "$libtool" = yes; then
|
||||
# With Tru64 cc, shared objects can also be used to make a
|
||||
# static library. This mechanism is used in libtool 1.4 series to
|
||||
# handle both shared and static libraries in a single compilation.
|
||||
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
|
||||
#
|
||||
# With libtool 1.5 this exception was removed, and libtool now
|
||||
# generates 2 separate objects for the 2 libraries. These two
|
||||
# compilations output dependencies in $dir.libs/$base.o.d and
|
||||
# in $dir$base.o.d. We have to check for both files, because
|
||||
# one of the two compilations can be disabled. We should prefer
|
||||
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
|
||||
# automatically cleaned when .libs/ is deleted, while ignoring
|
||||
# the former would cause a distcleancheck panic.
|
||||
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
|
||||
tmpdepfile2=$dir$base.o.d # libtool 1.5
|
||||
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
|
||||
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
tmpdepfile1=$dir$base.o.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
tmpdepfile3=$dir$base.d
|
||||
tmpdepfile4=$dir$base.d
|
||||
"$@" -MD
|
||||
fi
|
||||
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
|
||||
# That's a tab and a space in the [].
|
||||
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
#nosideeffect)
|
||||
# This comment above is used by automake to tell side-effect
|
||||
# dependency tracking mechanisms from slower ones.
|
||||
|
||||
dashmstdout)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout, regardless of -o.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
# Require at least two characters before searching for `:'
|
||||
# in the target name. This is to cope with DOS-style filenames:
|
||||
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
|
||||
"$@" $dashmflag |
|
||||
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
dashXmstdout)
|
||||
# This case only exists to satisfy depend.m4. It is never actually
|
||||
# run, as this mode is specially recognized in the preamble.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
makedepend)
|
||||
"$@" || exit $?
|
||||
# Remove any Libtool call
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
# X makedepend
|
||||
shift
|
||||
cleared=no eat=no
|
||||
for arg
|
||||
do
|
||||
case $cleared in
|
||||
no)
|
||||
set ""; shift
|
||||
cleared=yes ;;
|
||||
esac
|
||||
if test $eat = yes; then
|
||||
eat=no
|
||||
continue
|
||||
fi
|
||||
case "$arg" in
|
||||
-D*|-I*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
# Strip any option that makedepend may not understand. Remove
|
||||
# the object too, otherwise makedepend will parse it as a source file.
|
||||
-arch)
|
||||
eat=yes ;;
|
||||
-*|$object)
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
esac
|
||||
done
|
||||
obj_suffix=`echo "$object" | sed 's/^.*\././'`
|
||||
touch "$tmpdepfile"
|
||||
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
sed '1,2d' "$tmpdepfile" | tr ' ' '
|
||||
' | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile" "$tmpdepfile".bak
|
||||
;;
|
||||
|
||||
cpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
"$@" -E |
|
||||
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
|
||||
sed '$ s: \\$::' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
cat < "$tmpdepfile" >> "$depfile"
|
||||
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvisualcpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||
set fnord "$@"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
"$@" -E 2>/dev/null |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
|
||||
echo " " >> "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvcmsys)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
none)
|
||||
exec "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown depmode $depmode" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
200
example.c
@@ -2,11 +2,13 @@
|
||||
#if 0 /* in case someone actually tries to compile this */
|
||||
|
||||
/* example.c - an example of using libpng
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
* This file has been placed in the public domain by the authors.
|
||||
* Maintained 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Maintained 1998-2012 Glenn Randers-Pehrson
|
||||
* Maintained 1996, 1997 Andreas Dilger)
|
||||
* Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
* To the extent possible under law, the authors have waived
|
||||
* all copyright and related or neighboring rights to this file.
|
||||
* This work is published from: United States.
|
||||
*/
|
||||
|
||||
/* This is an example of how to use libpng to read and write PNG files.
|
||||
@@ -22,7 +24,179 @@
|
||||
* see also the programs in the contrib directory.
|
||||
*/
|
||||
|
||||
#include "png.h"
|
||||
/* The simple, but restricted, approach to reading a PNG file or data stream
|
||||
* just requires two function calls, as in the following complete program.
|
||||
* Writing a file just needs one function call, so long as the data has an
|
||||
* appropriate layout.
|
||||
*
|
||||
* The following code reads PNG image data from a file and writes it, in a
|
||||
* potentially new format, to a new file. While this code will compile there is
|
||||
* minimal (insufficient) error checking; for a more realistic version look at
|
||||
* contrib/examples/pngtopng.c
|
||||
*/
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <png.h>
|
||||
#include <zlib.h>
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
if (argc == 3)
|
||||
{
|
||||
png_image image; /* The control structure used by libpng */
|
||||
|
||||
/* Initialize the 'png_image' structure. */
|
||||
memset(&image, 0, sizeof image);
|
||||
|
||||
/* The first argument is the file to read: */
|
||||
if (png_image_begin_read_from_file(&image, argv[1]))
|
||||
{
|
||||
png_bytep buffer;
|
||||
|
||||
/* Set the format in which to read the PNG file; this code chooses a
|
||||
* simple sRGB format with a non-associated alpha channel, adequate to
|
||||
* store most images.
|
||||
*/
|
||||
image.format = PNG_FORMAT_RGBA;
|
||||
|
||||
/* Now allocate enough memory to hold the image in this format; the
|
||||
* PNG_IMAGE_SIZE macro uses the information about the image (width,
|
||||
* height and format) stored in 'image'.
|
||||
*/
|
||||
buffer = malloc(PNG_IMAGE_SIZE(image));
|
||||
|
||||
/* If enough memory was available read the image in the desired format
|
||||
* then write the result out to the new file. 'background' is not
|
||||
* necessary when reading the image because the alpha channel is
|
||||
* preserved; if it were to be removed, for example if we requested
|
||||
* PNG_FORMAT_RGB, then either a solid background color would have to
|
||||
* be supplied or the output buffer would have to be initialized to the
|
||||
* actual background of the image.
|
||||
*
|
||||
* The final argument to png_image_finish_read is the 'row_stride' -
|
||||
* this is the number of components allocated for the image in each
|
||||
* row. It has to be at least as big as the value returned by
|
||||
* PNG_IMAGE_ROW_STRIDE, but if you just allocate space for the
|
||||
* default, minimum, size using PNG_IMAGE_SIZE as above you can pass
|
||||
* zero.
|
||||
*/
|
||||
if (buffer != NULL &&
|
||||
png_image_finish_read(&image, NULL/*background*/, buffer,
|
||||
0/*row_stride*/))
|
||||
{
|
||||
/* Now write the image out to the second argument. In the write
|
||||
* call 'convert_to_8bit' allows 16-bit data to be squashed down to
|
||||
* 8 bits; this isn't necessary here because the original read was
|
||||
* to the 8-bit format.
|
||||
*/
|
||||
if (png_image_write_to_file(&image, argv[2], 0/*convert_to_8bit*/,
|
||||
buffer, 0/*row_stride*/))
|
||||
{
|
||||
/* The image has been written successfully. */
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* Calling png_free_image is optional unless the simplified API was
|
||||
* not run to completion. In this case if there wasn't enough
|
||||
* memory for 'buffer' we didn't complete the read, so we must free
|
||||
* the image:
|
||||
*/
|
||||
if (buffer == NULL)
|
||||
png_free_image(&image);
|
||||
|
||||
else
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
/* Something went wrong reading or writing the image. libpng stores a
|
||||
* textual message in the 'png_image' structure:
|
||||
*/
|
||||
fprintf(stderr, "pngtopng: error: %s\n", image.message);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
fprintf(stderr, "pngtopng: usage: pngtopng input-file output-file\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* That's it ;-) Of course you probably want to do more with PNG files than
|
||||
* just converting them all to 32-bit RGBA PNG files; you can do that between
|
||||
* the call to png_image_finish_read and png_image_write_to_file. You can also
|
||||
* ask for the image data to be presented in a number of different formats. You
|
||||
* do this by simply changing the 'format' parameter set before allocating the
|
||||
* buffer.
|
||||
*
|
||||
* The format parameter consists of five flags that define various aspects of
|
||||
* the image, you can simply add these together to get the format or you can use
|
||||
* one of the predefined macros from png.h (as above):
|
||||
*
|
||||
* PNG_FORMAT_FLAG_COLOR: if set the image will have three color components per
|
||||
* pixel (red, green and blue), if not set the image will just have one
|
||||
* luminance (grayscale) component.
|
||||
*
|
||||
* PNG_FORMAT_FLAG_ALPHA: if set each pixel in the image will have an additional
|
||||
* alpha value; a linear value that describes the degree the image pixel
|
||||
* covers (overwrites) the contents of the existing pixel on the display.
|
||||
*
|
||||
* PNG_FORMAT_FLAG_LINEAR: if set the components of each pixel will be returned
|
||||
* as a series of 16-bit linear values, if not set the components will be
|
||||
* returned as a series of 8-bit values encoded according to the 'sRGB'
|
||||
* standard. The 8-bit format is the normal format for images intended for
|
||||
* direct display, because almost all display devices do the inverse of the
|
||||
* sRGB transformation to the data they receive. The 16-bit format is more
|
||||
* common for scientific data and image data that must be further processed;
|
||||
* because it is linear simple math can be done on the component values.
|
||||
* Regardless of the setting of this flag the alpha channel is always linear,
|
||||
* although it will be 8 bits or 16 bits wide as specified by the flag.
|
||||
*
|
||||
* PNG_FORMAT_FLAG_BGR: if set the components of a color pixel will be returned
|
||||
* in the order blue, then green, then red. If not set the pixel components
|
||||
* are in the order red, then green, then blue.
|
||||
*
|
||||
* PNG_FORMAT_FLAG_AFIRST: if set the alpha channel (if present) precedes the
|
||||
* color or grayscale components. If not set the alpha channel follows the
|
||||
* components.
|
||||
*
|
||||
* You do not have to read directly from a file. You can read from memory or,
|
||||
* on systems that support it, from a <stdio.h> FILE*. This is controlled by
|
||||
* the particular png_image_read_from_ function you call at the start. Likewise
|
||||
* on write you can write to a FILE* if your system supports it. Check the
|
||||
* macro PNG_STDIO_SUPPORTED to see if stdio support has been included in your
|
||||
* libpng build.
|
||||
*
|
||||
* If you read 16-bit (PNG_FORMAT_FLAG_LINEAR) data you may need to write it in
|
||||
* the 8-bit format for display. You do this by setting the convert_to_8bit
|
||||
* flag to 'true'.
|
||||
*
|
||||
* Don't repeatedly convert between the 8-bit and 16-bit forms. There is
|
||||
* significant data loss when 16-bit data is converted to the 8-bit encoding and
|
||||
* the current libpng implementation of convertion to 16-bit is also
|
||||
* significantly lossy. The latter will be fixed in the future, but the former
|
||||
* is unavoidable - the 8-bit format just doesn't have enough resolution.
|
||||
*/
|
||||
|
||||
/* If your program needs more information from the PNG data it reads, or if you
|
||||
* need to do more complex transformations, or minimise transformations, on the
|
||||
* data you read, then you must use one of the several lower level libpng
|
||||
* interfaces.
|
||||
*
|
||||
* All these interfaces require that you do your own error handling - your
|
||||
* program must be able to arrange for control to return to your own code any
|
||||
* time libpng encounters a problem. There are several ways to do this, but the
|
||||
* standard way is to use the ANSI-C (C90) <setjmp.h> interface to establish a
|
||||
* return point within your own code. You must do this if you do not use the
|
||||
* simplified interface (above).
|
||||
*
|
||||
* The first step is to include the header files you need, including the libpng
|
||||
* header file. Include any standard headers and feature test macros your
|
||||
* program requires before including png.h:
|
||||
*/
|
||||
#include <png.h>
|
||||
|
||||
/* The png_jmpbuf() macro, used in error handling, became available in
|
||||
* libpng version 1.0.6. If you want to be able to run your code with older
|
||||
@@ -183,8 +357,15 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
|
||||
* are mutually exclusive.
|
||||
*/
|
||||
|
||||
/* Tell libpng to strip 16 bit/color files down to 8 bits/color */
|
||||
/* Tell libpng to strip 16 bit/color files down to 8 bits/color.
|
||||
* Use accurate scaling if it's available, otherwise just chop off the
|
||||
* low byte.
|
||||
*/
|
||||
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
png_set_scale_16(png_ptr);
|
||||
#else
|
||||
png_set_strip_16(png_ptr);
|
||||
#endif
|
||||
|
||||
/* Strip alpha bytes from the input data without combining with the
|
||||
* background (not recommended).
|
||||
@@ -330,11 +511,16 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
|
||||
/* Add filler (or alpha) byte (before/after each RGB triplet) */
|
||||
png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
|
||||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
/* Turn on interlace handling. REQUIRED if you are not using
|
||||
* png_read_image(). To see how to handle interlacing passes,
|
||||
* see the png_read_row() method below:
|
||||
*/
|
||||
number_passes = png_set_interlace_handling(png_ptr);
|
||||
#else
|
||||
number_passes = 1;
|
||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
|
||||
|
||||
/* Optional call to gamma correct and add the background to the palette
|
||||
* and update info structure. REQUIRED if you are expecting libpng to
|
||||
@@ -516,6 +702,7 @@ row_callback(png_structp png_ptr, png_bytep new_row,
|
||||
*/
|
||||
png_bytep old_row = ((png_bytep *)our_data)[row_num];
|
||||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
/* If both rows are allocated then copy the new row
|
||||
* data to the corresponding row data.
|
||||
*/
|
||||
@@ -531,7 +718,7 @@ row_callback(png_structp png_ptr, png_bytep new_row,
|
||||
* png_progressive_combine_row() passing in the new row and the
|
||||
* old row, as demonstrated above. You can call this function for
|
||||
* NULL rows (it will just return) and for non-interlaced images
|
||||
* (it just does the png_memcpy for you) if it will make the code
|
||||
* (it just does the memcpy for you) if it will make the code
|
||||
* easier. Thus, you can just do this for all cases:
|
||||
*/
|
||||
|
||||
@@ -544,6 +731,7 @@ row_callback(png_structp png_ptr, png_bytep new_row,
|
||||
* to pass the current row as new_row, and the function will combine
|
||||
* the old row and the new row.
|
||||
*/
|
||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
}
|
||||
|
||||
end_callback(png_structp png_ptr, png_infop info)
|
||||
|
||||
520
install-sh
@@ -1,520 +0,0 @@
|
||||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2009-04-28.21; # UTC
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
# following copyright and license.
|
||||
#
|
||||
# Copyright (C) 1994 X Consortium
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the X Consortium shall not
|
||||
# be used in advertising or otherwise to promote the sale, use or other deal-
|
||||
# ings in this Software without prior written authorization from the X Consor-
|
||||
# tium.
|
||||
#
|
||||
#
|
||||
# FSF changes to this file are in the public domain.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
|
||||
nl='
|
||||
'
|
||||
IFS=" "" $nl"
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit=${DOITPROG-}
|
||||
if test -z "$doit"; then
|
||||
doit_exec=exec
|
||||
else
|
||||
doit_exec=$doit
|
||||
fi
|
||||
|
||||
# Put in absolute file names if you don't have them in your path;
|
||||
# or use environment vars.
|
||||
|
||||
chgrpprog=${CHGRPPROG-chgrp}
|
||||
chmodprog=${CHMODPROG-chmod}
|
||||
chownprog=${CHOWNPROG-chown}
|
||||
cmpprog=${CMPPROG-cmp}
|
||||
cpprog=${CPPROG-cp}
|
||||
mkdirprog=${MKDIRPROG-mkdir}
|
||||
mvprog=${MVPROG-mv}
|
||||
rmprog=${RMPROG-rm}
|
||||
stripprog=${STRIPPROG-strip}
|
||||
|
||||
posix_glob='?'
|
||||
initialize_posix_glob='
|
||||
test "$posix_glob" != "?" || {
|
||||
if (set -f) 2>/dev/null; then
|
||||
posix_glob=
|
||||
else
|
||||
posix_glob=:
|
||||
fi
|
||||
}
|
||||
'
|
||||
|
||||
posix_mkdir=
|
||||
|
||||
# Desired mode of installed file.
|
||||
mode=0755
|
||||
|
||||
chgrpcmd=
|
||||
chmodcmd=$chmodprog
|
||||
chowncmd=
|
||||
mvcmd=$mvprog
|
||||
rmcmd="$rmprog -f"
|
||||
stripcmd=
|
||||
|
||||
src=
|
||||
dst=
|
||||
dir_arg=
|
||||
dst_arg=
|
||||
|
||||
copy_on_change=false
|
||||
no_target_directory=
|
||||
|
||||
usage="\
|
||||
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
||||
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
||||
or: $0 [OPTION]... -d DIRECTORIES...
|
||||
|
||||
In the 1st form, copy SRCFILE to DSTFILE.
|
||||
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
||||
In the 4th, create DIRECTORIES.
|
||||
|
||||
Options:
|
||||
--help display this help and exit.
|
||||
--version display version info and exit.
|
||||
|
||||
-c (ignored)
|
||||
-C install only if different (preserve the last data modification time)
|
||||
-d create directories instead of installing files.
|
||||
-g GROUP $chgrpprog installed files to GROUP.
|
||||
-m MODE $chmodprog installed files to MODE.
|
||||
-o USER $chownprog installed files to USER.
|
||||
-s $stripprog installed files.
|
||||
-t DIRECTORY install into DIRECTORY.
|
||||
-T report an error if DSTFILE is a directory.
|
||||
|
||||
Environment variables override the default commands:
|
||||
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
|
||||
RMPROG STRIPPROG
|
||||
"
|
||||
|
||||
while test $# -ne 0; do
|
||||
case $1 in
|
||||
-c) ;;
|
||||
|
||||
-C) copy_on_change=true;;
|
||||
|
||||
-d) dir_arg=true;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift;;
|
||||
|
||||
--help) echo "$usage"; exit $?;;
|
||||
|
||||
-m) mode=$2
|
||||
case $mode in
|
||||
*' '* | *' '* | *'
|
||||
'* | *'*'* | *'?'* | *'['*)
|
||||
echo "$0: invalid mode: $mode" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift;;
|
||||
|
||||
-s) stripcmd=$stripprog;;
|
||||
|
||||
-t) dst_arg=$2
|
||||
shift;;
|
||||
|
||||
-T) no_target_directory=true;;
|
||||
|
||||
--version) echo "$0 $scriptversion"; exit $?;;
|
||||
|
||||
--) shift
|
||||
break;;
|
||||
|
||||
-*) echo "$0: invalid option: $1" >&2
|
||||
exit 1;;
|
||||
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
|
||||
# When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dst_arg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dst_arg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dst_arg=$arg
|
||||
done
|
||||
fi
|
||||
|
||||
if test $# -eq 0; then
|
||||
if test -z "$dir_arg"; then
|
||||
echo "$0: no input file specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
# It's OK to call `install-sh -d' without argument.
|
||||
# This can happen when creating conditional directories.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
trap '(exit $?); exit' 1 2 13 15
|
||||
|
||||
# Set umask so as not to create temps with too-generous modes.
|
||||
# However, 'strip' requires both read and write access to temps.
|
||||
case $mode in
|
||||
# Optimize common cases.
|
||||
*644) cp_umask=133;;
|
||||
*755) cp_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw='% 200'
|
||||
fi
|
||||
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
|
||||
*)
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw=,u+rw
|
||||
fi
|
||||
cp_umask=$mode$u_plus_rw;;
|
||||
esac
|
||||
fi
|
||||
|
||||
for src
|
||||
do
|
||||
# Protect names starting with `-'.
|
||||
case $src in
|
||||
-*) src=./$src;;
|
||||
esac
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
dst=$src
|
||||
dstdir=$dst
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
if test ! -f "$src" && test ! -d "$src"; then
|
||||
echo "$0: $src does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$dst_arg"; then
|
||||
echo "$0: no destination specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dst=$dst_arg
|
||||
# Protect names starting with `-'.
|
||||
case $dst in
|
||||
-*) dst=./$dst;;
|
||||
esac
|
||||
|
||||
# If destination is a directory, append the input filename; won't work
|
||||
# if double slashes aren't ignored.
|
||||
if test -d "$dst"; then
|
||||
if test -n "$no_target_directory"; then
|
||||
echo "$0: $dst_arg: Is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
dstdir=$dst
|
||||
dst=$dstdir/`basename "$src"`
|
||||
dstdir_status=0
|
||||
else
|
||||
# Prefer dirname, but fall back on a substitute if dirname fails.
|
||||
dstdir=`
|
||||
(dirname "$dst") 2>/dev/null ||
|
||||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
|
||||
X"$dst" : 'X\(//\)[^/]' \| \
|
||||
X"$dst" : 'X\(//\)$' \| \
|
||||
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
|
||||
echo X"$dst" |
|
||||
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)[^/].*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\).*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
s/.*/./; q'
|
||||
`
|
||||
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
obsolete_mkdir_used=false
|
||||
|
||||
if test $dstdir_status != 0; then
|
||||
case $posix_mkdir in
|
||||
'')
|
||||
# Create intermediate dirs using mode 755 as modified by the umask.
|
||||
# This is like FreeBSD 'install' as of 1997-10-28.
|
||||
umask=`umask`
|
||||
case $stripcmd.$umask in
|
||||
# Optimize common cases.
|
||||
*[2367][2367]) mkdir_umask=$umask;;
|
||||
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
mkdir_umask=`expr $umask + 22 \
|
||||
- $umask % 100 % 40 + $umask % 20 \
|
||||
- $umask % 10 % 4 + $umask % 2
|
||||
`;;
|
||||
*) mkdir_umask=$umask,go-w;;
|
||||
esac
|
||||
|
||||
# With -d, create the new directory with the user-specified mode.
|
||||
# Otherwise, rely on $mkdir_umask.
|
||||
if test -n "$dir_arg"; then
|
||||
mkdir_mode=-m$mode
|
||||
else
|
||||
mkdir_mode=
|
||||
fi
|
||||
|
||||
posix_mkdir=false
|
||||
case $umask in
|
||||
*[123567][0-7][0-7])
|
||||
# POSIX mkdir -p sets u+wx bits regardless of umask, which
|
||||
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
|
||||
;;
|
||||
*)
|
||||
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
|
||||
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
|
||||
|
||||
if (umask $mkdir_umask &&
|
||||
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
|
||||
then
|
||||
if test -z "$dir_arg" || {
|
||||
# Check for POSIX incompatibilities with -m.
|
||||
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
||||
# other-writeable bit of parent directory when it shouldn't.
|
||||
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
||||
ls_ld_tmpdir=`ls -ld "$tmpdir"`
|
||||
case $ls_ld_tmpdir in
|
||||
d????-?r-*) different_mode=700;;
|
||||
d????-?--*) different_mode=755;;
|
||||
*) false;;
|
||||
esac &&
|
||||
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
|
||||
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
|
||||
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
|
||||
}
|
||||
}
|
||||
then posix_mkdir=:
|
||||
fi
|
||||
rmdir "$tmpdir/d" "$tmpdir"
|
||||
else
|
||||
# Remove any dirs left behind by ancient mkdir implementations.
|
||||
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
|
||||
fi
|
||||
trap '' 0;;
|
||||
esac;;
|
||||
esac
|
||||
|
||||
if
|
||||
$posix_mkdir && (
|
||||
umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
|
||||
)
|
||||
then :
|
||||
else
|
||||
|
||||
# The umask is ridiculous, or mkdir does not conform to POSIX,
|
||||
# or it failed possibly due to a race condition. Create the
|
||||
# directory the slow way, step by step, checking for races as we go.
|
||||
|
||||
case $dstdir in
|
||||
/*) prefix='/';;
|
||||
-*) prefix='./';;
|
||||
*) prefix='';;
|
||||
esac
|
||||
|
||||
eval "$initialize_posix_glob"
|
||||
|
||||
oIFS=$IFS
|
||||
IFS=/
|
||||
$posix_glob set -f
|
||||
set fnord $dstdir
|
||||
shift
|
||||
$posix_glob set +f
|
||||
IFS=$oIFS
|
||||
|
||||
prefixes=
|
||||
|
||||
for d
|
||||
do
|
||||
test -z "$d" && continue
|
||||
|
||||
prefix=$prefix$d
|
||||
if test -d "$prefix"; then
|
||||
prefixes=
|
||||
else
|
||||
if $posix_mkdir; then
|
||||
(umask=$mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
|
||||
# Don't fail if two instances are running concurrently.
|
||||
test -d "$prefix" || exit 1
|
||||
else
|
||||
case $prefix in
|
||||
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
|
||||
*) qprefix=$prefix;;
|
||||
esac
|
||||
prefixes="$prefixes '$qprefix'"
|
||||
fi
|
||||
fi
|
||||
prefix=$prefix/
|
||||
done
|
||||
|
||||
if test -n "$prefixes"; then
|
||||
# Don't fail if two instances are running concurrently.
|
||||
(umask $mkdir_umask &&
|
||||
eval "\$doit_exec \$mkdirprog $prefixes") ||
|
||||
test -d "$dstdir" || exit 1
|
||||
obsolete_mkdir_used=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
|
||||
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
|
||||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
|
||||
else
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
dsttmp=$dstdir/_inst.$$_
|
||||
rmtmp=$dstdir/_rm.$$_
|
||||
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
|
||||
# Copy the file name to the temp name.
|
||||
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits.
|
||||
#
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $cpprog $src $dsttmp" command.
|
||||
#
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
|
||||
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
|
||||
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
|
||||
|
||||
# If -C, don't bother to copy if it wouldn't change the file.
|
||||
if $copy_on_change &&
|
||||
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
|
||||
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
|
||||
|
||||
eval "$initialize_posix_glob" &&
|
||||
$posix_glob set -f &&
|
||||
set X $old && old=:$2:$4:$5:$6 &&
|
||||
set X $new && new=:$2:$4:$5:$6 &&
|
||||
$posix_glob set +f &&
|
||||
|
||||
test "$old" = "$new" &&
|
||||
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
|
||||
then
|
||||
rm -f "$dsttmp"
|
||||
else
|
||||
# Rename the file to the real destination.
|
||||
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
|
||||
|
||||
# The rename failed, perhaps because mv can't rename something else
|
||||
# to itself, or perhaps because mv is so ancient that it does not
|
||||
# support -f.
|
||||
{
|
||||
# Now remove or move aside any old file at destination location.
|
||||
# We try this two ways since rm can't unlink itself on some
|
||||
# systems and the destination file might be busy for other
|
||||
# reasons. In this case, the final cleanup might fail but the new
|
||||
# file should still install successfully.
|
||||
{
|
||||
test ! -f "$dst" ||
|
||||
$doit $rmcmd -f "$dst" 2>/dev/null ||
|
||||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
|
||||
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
|
||||
} ||
|
||||
{ echo "$0: cannot unlink or rename $dst" >&2
|
||||
(exit 1); exit 1
|
||||
}
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
$doit $mvcmd "$dsttmp" "$dst"
|
||||
}
|
||||
fi || exit 1
|
||||
|
||||
trap '' 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
0
libpng-config.in
Executable file → Normal file
1468
libpng-manual.txt
12
libpngpf.3
@@ -1,6 +1,6 @@
|
||||
.TH LIBPNGPF 3 "February 3, 2011"
|
||||
.TH LIBPNGPF 3 "February 3, 2012"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.5.1
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.0beta10
|
||||
(private functions)
|
||||
.SH SYNOPSIS
|
||||
\fB#include \fI"pngpriv.h"
|
||||
@@ -18,11 +18,9 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.5.1
|
||||
\fI\fB
|
||||
|
||||
.SH DESCRIPTION
|
||||
The functions previously listed here are used privately by libpng
|
||||
and are not recommended for use by applications. They are
|
||||
not "exported" to applications using shared libraries. They
|
||||
are listed alphabetically here as an aid to libpng maintainers.
|
||||
See pngpriv.h for more information on these functions.
|
||||
The functions previously listed here are used privately by libpng and are not
|
||||
available for use by applications. They are not "exported" to applications
|
||||
using shared libraries.
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR "png"(5), " libpng"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5)
|
||||
|
||||
376
missing
@@ -1,376 +0,0 @@
|
||||
#! /bin/sh
|
||||
# Common stub for a few missing GNU programs while installing.
|
||||
|
||||
scriptversion=2009-04-28.21; # UTC
|
||||
|
||||
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
|
||||
# 2008, 2009 Free Software Foundation, Inc.
|
||||
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
if test $# -eq 0; then
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run=:
|
||||
sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
|
||||
sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
|
||||
|
||||
# In the cases where this matters, `missing' is being run in the
|
||||
# srcdir already.
|
||||
if test -f configure.ac; then
|
||||
configure_ac=configure.ac
|
||||
else
|
||||
configure_ac=configure.in
|
||||
fi
|
||||
|
||||
msg="missing on your system"
|
||||
|
||||
case $1 in
|
||||
--run)
|
||||
# Try to run requested program, and just exit if it succeeds.
|
||||
run=
|
||||
shift
|
||||
"$@" && exit 0
|
||||
# Exit code 63 means version mismatch. This often happens
|
||||
# when the user try to use an ancient version of a tool on
|
||||
# a file that requires a minimum version. In this case we
|
||||
# we should proceed has if the program had been absent, or
|
||||
# if --run hadn't been passed.
|
||||
if test $? = 63; then
|
||||
run=:
|
||||
msg="probably too old"
|
||||
fi
|
||||
;;
|
||||
|
||||
-h|--h|--he|--hel|--help)
|
||||
echo "\
|
||||
$0 [OPTION]... PROGRAM [ARGUMENT]...
|
||||
|
||||
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
|
||||
error status if there is no known handling for PROGRAM.
|
||||
|
||||
Options:
|
||||
-h, --help display this help and exit
|
||||
-v, --version output version information and exit
|
||||
--run try to run the given command, and emulate it if it fails
|
||||
|
||||
Supported PROGRAM values:
|
||||
aclocal touch file \`aclocal.m4'
|
||||
autoconf touch file \`configure'
|
||||
autoheader touch file \`config.h.in'
|
||||
autom4te touch the output file, or create a stub one
|
||||
automake touch all \`Makefile.in' files
|
||||
bison create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||
flex create \`lex.yy.c', if possible, from existing .c
|
||||
help2man touch the output file
|
||||
lex create \`lex.yy.c', if possible, from existing .c
|
||||
makeinfo touch the output file
|
||||
tar try tar, gnutar, gtar, then tar without non-portable flags
|
||||
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||
|
||||
Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
|
||||
\`g' are ignored when checking the name.
|
||||
|
||||
Send bug reports to <bug-automake@gnu.org>."
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
|
||||
echo "missing $scriptversion (GNU Automake)"
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-*)
|
||||
echo 1>&2 "$0: Unknown \`$1' option"
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
# normalize program name to check for.
|
||||
program=`echo "$1" | sed '
|
||||
s/^gnu-//; t
|
||||
s/^gnu//; t
|
||||
s/^g//; t'`
|
||||
|
||||
# Now exit if we have it, but it failed. Also exit now if we
|
||||
# don't have it and --version was passed (most likely to detect
|
||||
# the program). This is about non-GNU programs, so use $1 not
|
||||
# $program.
|
||||
case $1 in
|
||||
lex*|yacc*)
|
||||
# Not GNU programs, they don't have --version.
|
||||
;;
|
||||
|
||||
tar*)
|
||||
if test -n "$run"; then
|
||||
echo 1>&2 "ERROR: \`tar' requires --run"
|
||||
exit 1
|
||||
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
|
||||
# We have it, but it failed.
|
||||
exit 1
|
||||
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
|
||||
# Could not run --version or --help. This is probably someone
|
||||
# running `$TOOL --version' or `$TOOL --help' to check whether
|
||||
# $TOOL exists and not knowing $TOOL uses missing.
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# If it does not exist, or fails to run (possibly an outdated version),
|
||||
# try to emulate it.
|
||||
case $program in
|
||||
aclocal*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
|
||||
to install the \`Automake' and \`Perl' packages. Grab them from
|
||||
any GNU archive site."
|
||||
touch aclocal.m4
|
||||
;;
|
||||
|
||||
autoconf*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`${configure_ac}'. You might want to install the
|
||||
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
|
||||
archive site."
|
||||
touch configure
|
||||
;;
|
||||
|
||||
autoheader*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`acconfig.h' or \`${configure_ac}'. You might want
|
||||
to install the \`Autoconf' and \`GNU m4' packages. Grab them
|
||||
from any GNU archive site."
|
||||
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
|
||||
test -z "$files" && files="config.h"
|
||||
touch_files=
|
||||
for f in $files; do
|
||||
case $f in
|
||||
*:*) touch_files="$touch_files "`echo "$f" |
|
||||
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
|
||||
*) touch_files="$touch_files $f.in";;
|
||||
esac
|
||||
done
|
||||
touch $touch_files
|
||||
;;
|
||||
|
||||
automake*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
|
||||
You might want to install the \`Automake' and \`Perl' packages.
|
||||
Grab them from any GNU archive site."
|
||||
find . -type f -name Makefile.am -print |
|
||||
sed 's/\.am$/.in/' |
|
||||
while read f; do touch "$f"; done
|
||||
;;
|
||||
|
||||
autom4te*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is needed, but is $msg.
|
||||
You might have modified some files without having the
|
||||
proper tools for further handling them.
|
||||
You can get \`$1' as part of \`Autoconf' from any GNU
|
||||
archive site."
|
||||
|
||||
file=`echo "$*" | sed -n "$sed_output"`
|
||||
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||
if test -f "$file"; then
|
||||
touch $file
|
||||
else
|
||||
test -z "$file" || exec >$file
|
||||
echo "#! /bin/sh"
|
||||
echo "# Created by GNU Automake missing as a replacement of"
|
||||
echo "# $ $@"
|
||||
echo "exit 0"
|
||||
chmod +x $file
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
bison*|yacc*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' $msg. You should only need it if
|
||||
you modified a \`.y' file. You may need the \`Bison' package
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Bison' from any GNU archive site."
|
||||
rm -f y.tab.c y.tab.h
|
||||
if test $# -ne 1; then
|
||||
eval LASTARG="\${$#}"
|
||||
case $LASTARG in
|
||||
*.y)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
|
||||
if test -f "$SRCFILE"; then
|
||||
cp "$SRCFILE" y.tab.c
|
||||
fi
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
|
||||
if test -f "$SRCFILE"; then
|
||||
cp "$SRCFILE" y.tab.h
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if test ! -f y.tab.h; then
|
||||
echo >y.tab.h
|
||||
fi
|
||||
if test ! -f y.tab.c; then
|
||||
echo 'main() { return 0; }' >y.tab.c
|
||||
fi
|
||||
;;
|
||||
|
||||
lex*|flex*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a \`.l' file. You may need the \`Flex' package
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Flex' from any GNU archive site."
|
||||
rm -f lex.yy.c
|
||||
if test $# -ne 1; then
|
||||
eval LASTARG="\${$#}"
|
||||
case $LASTARG in
|
||||
*.l)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
|
||||
if test -f "$SRCFILE"; then
|
||||
cp "$SRCFILE" lex.yy.c
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if test ! -f lex.yy.c; then
|
||||
echo 'main() { return 0; }' >lex.yy.c
|
||||
fi
|
||||
;;
|
||||
|
||||
help2man*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a dependency of a manual page. You may need the
|
||||
\`Help2man' package in order for those modifications to take
|
||||
effect. You can get \`Help2man' from any GNU archive site."
|
||||
|
||||
file=`echo "$*" | sed -n "$sed_output"`
|
||||
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||
if test -f "$file"; then
|
||||
touch $file
|
||||
else
|
||||
test -z "$file" || exec >$file
|
||||
echo ".ab help2man is required to generate this page"
|
||||
exit $?
|
||||
fi
|
||||
;;
|
||||
|
||||
makeinfo*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a \`.texi' or \`.texinfo' file, or any other file
|
||||
indirectly affecting the aspect of the manual. The spurious
|
||||
call might also be the consequence of using a buggy \`make' (AIX,
|
||||
DU, IRIX). You might want to install the \`Texinfo' package or
|
||||
the \`GNU make' package. Grab either from any GNU archive site."
|
||||
# The file to touch is that specified with -o ...
|
||||
file=`echo "$*" | sed -n "$sed_output"`
|
||||
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||
if test -z "$file"; then
|
||||
# ... or it is the one specified with @setfilename ...
|
||||
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
|
||||
file=`sed -n '
|
||||
/^@setfilename/{
|
||||
s/.* \([^ ]*\) *$/\1/
|
||||
p
|
||||
q
|
||||
}' $infile`
|
||||
# ... or it is derived from the source name (dir/f.texi becomes f.info)
|
||||
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
|
||||
fi
|
||||
# If the file does not exist, the user really needs makeinfo;
|
||||
# let's fail without touching anything.
|
||||
test -f $file || exit 1
|
||||
touch $file
|
||||
;;
|
||||
|
||||
tar*)
|
||||
shift
|
||||
|
||||
# We have already tried tar in the generic part.
|
||||
# Look for gnutar/gtar before invocation to avoid ugly error
|
||||
# messages.
|
||||
if (gnutar --version > /dev/null 2>&1); then
|
||||
gnutar "$@" && exit 0
|
||||
fi
|
||||
if (gtar --version > /dev/null 2>&1); then
|
||||
gtar "$@" && exit 0
|
||||
fi
|
||||
firstarg="$1"
|
||||
if shift; then
|
||||
case $firstarg in
|
||||
*o*)
|
||||
firstarg=`echo "$firstarg" | sed s/o//`
|
||||
tar "$firstarg" "$@" && exit 0
|
||||
;;
|
||||
esac
|
||||
case $firstarg in
|
||||
*h*)
|
||||
firstarg=`echo "$firstarg" | sed s/h//`
|
||||
tar "$firstarg" "$@" && exit 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo 1>&2 "\
|
||||
WARNING: I can't seem to be able to run \`tar' with the given arguments.
|
||||
You may want to install GNU tar or Free paxutils, or check the
|
||||
command line arguments."
|
||||
exit 1
|
||||
;;
|
||||
|
||||
*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is needed, and is $msg.
|
||||
You might have modified some files without having the
|
||||
proper tools for further handling them. Check the \`README' file,
|
||||
it often tells you about the needed prerequisites for installing
|
||||
this package. You may also peek at any GNU archive site, in case
|
||||
some other package would contain this missing \`$1' program."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
2
png.5
@@ -1,4 +1,4 @@
|
||||
.TH PNG 5 "February 3, 2011"
|
||||
.TH PNG 5 "February 3, 2012"
|
||||
.SH NAME
|
||||
png \- Portable Network Graphics (PNG) format
|
||||
.SH DESCRIPTION
|
||||
|
||||
484
pngconf.h
@@ -1,9 +1,9 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng version 1.5.1 - February 3, 2011
|
||||
* libpng version 1.6.0beta10 - February 3, 2012
|
||||
*
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -22,31 +22,49 @@
|
||||
#ifndef PNGCONF_H
|
||||
#define PNGCONF_H
|
||||
|
||||
/* PNG_NO_LIMITS_H may be used to turn off the use of the standard C
|
||||
* definition file for machine specific limits, this may impact the
|
||||
* correctness of the definitons below (see uses of INT_MAX).
|
||||
#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */
|
||||
|
||||
/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C
|
||||
* compiler for correct compilation. The following header files are required by
|
||||
* the standard. If your compiler doesn't provide these header files, or they
|
||||
* do not match the standard, you will need to provide/improve them.
|
||||
*/
|
||||
#ifndef PNG_NO_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
|
||||
/* For the memory copy APIs (i.e. the standard definitions of these),
|
||||
* because this file defines png_memcpy and so on the base APIs must
|
||||
* be defined here.
|
||||
/* Library header files. These header files are all defined by ISOC90; libpng
|
||||
* expects conformant implementations, however, an ISOC90 conformant system need
|
||||
* not provide these header files if the functionality cannot be implemented.
|
||||
* In this case it will be necessary to disable the relevant parts of libpng in
|
||||
* the build of pnglibconf.h.
|
||||
*
|
||||
* Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not
|
||||
* include this unnecessary header file.
|
||||
*/
|
||||
#ifdef BSD
|
||||
# include <strings.h>
|
||||
#else
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
/* For png_FILE_p - this provides the standard definition of a
|
||||
* FILE
|
||||
*/
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
/* Required for the definition of FILE: */
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
/* Required for the definition of jmp_buf and the declaration of longjmp: */
|
||||
# include <setjmp.h>
|
||||
#endif
|
||||
|
||||
#ifdef PNG_CONVERT_tIME_SUPPORTED
|
||||
/* Required for struct tm: */
|
||||
# include <time.h>
|
||||
#endif
|
||||
|
||||
#endif /* PNG_BUILDING_SYMBOL_TABLE */
|
||||
|
||||
/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using
|
||||
* PNG_NO_CONST; this is no longer supported except for data declarations which
|
||||
* apparently still cause problems in 2011 on some compilers.
|
||||
*/
|
||||
#define PNG_CONST const /* backward compatibility only */
|
||||
|
||||
/* This controls optimization of the reading of 16 and 32 bit values
|
||||
* from PNG files. It can be set on a per-app-file basis - it
|
||||
* just changes whether a macro is used to the function is called.
|
||||
@@ -70,28 +88,13 @@
|
||||
* may be changed on a per-file basis when compiling against libpng.
|
||||
*/
|
||||
|
||||
/* The PNGARG macro protects us against machines that don't have function
|
||||
* prototypes (ie K&R style headers). If your compiler does not handle
|
||||
* function prototypes, define this macro and use the included ansi2knr.
|
||||
* I've always been able to use _NO_PROTO as the indicator, but you may
|
||||
* need to drag the empty declaration out in front of here, or change the
|
||||
* ifdef to suit your own needs.
|
||||
/* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect
|
||||
* against legacy (pre ISOC90) compilers that did not understand function
|
||||
* prototypes. It is not required for modern C compilers.
|
||||
*/
|
||||
#ifndef PNGARG
|
||||
|
||||
# ifdef OF /* zlib prototype munger */
|
||||
# define PNGARG(arglist) OF(arglist)
|
||||
# else
|
||||
|
||||
# ifdef _NO_PROTO
|
||||
# define PNGARG(arglist) ()
|
||||
# else
|
||||
# define PNGARG(arglist) arglist
|
||||
# endif /* _NO_PROTO */
|
||||
|
||||
# endif /* OF */
|
||||
|
||||
#endif /* PNGARG */
|
||||
#endif
|
||||
|
||||
/* Function calling conventions.
|
||||
* =============================
|
||||
@@ -162,7 +165,9 @@
|
||||
* 'type', compiler specific.
|
||||
*
|
||||
* PNG_DLL_EXPORT Set to the magic to use during a libpng build to
|
||||
* make a symbol exported from the DLL.
|
||||
* make a symbol exported from the DLL. Not used in the
|
||||
* public header files; see pngpriv.h for how it is used
|
||||
* in the libpng build.
|
||||
*
|
||||
* PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come
|
||||
* from a DLL - used to define PNG_IMPEXP when
|
||||
@@ -215,7 +220,7 @@
|
||||
/* NOTE: PNGCBAPI always defaults to PNGCAPI. */
|
||||
|
||||
# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)
|
||||
ERROR: PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed
|
||||
# error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed"
|
||||
# endif
|
||||
|
||||
# if (defined(_MSC_VER) && _MSC_VER < 800) ||\
|
||||
@@ -256,49 +261,30 @@
|
||||
# define PNGAPI PNGCAPI
|
||||
#endif
|
||||
|
||||
/* The default for PNG_IMPEXP depends on whether the library is
|
||||
* being built or used.
|
||||
/* PNG_IMPEXP may be set on the compilation system command line or (if not set)
|
||||
* then in an internal header file when building the library, otherwise (when
|
||||
* using the library) it is set here.
|
||||
*/
|
||||
#ifndef PNG_IMPEXP
|
||||
# ifdef PNGLIB_BUILD
|
||||
/* Building the library */
|
||||
# if (defined(DLL_EXPORT)/*from libtool*/ ||\
|
||||
defined(_WINDLL) || defined(_DLL) || defined(__DLL__) ||\
|
||||
defined(_USRDLL) ||\
|
||||
defined(PNG_BUILD_DLL)) && defined(PNG_DLL_EXPORT)
|
||||
/* Building a DLL. */
|
||||
# define PNG_IMPEXP PNG_DLL_EXPORT
|
||||
# endif /* DLL */
|
||||
# else
|
||||
/* Using the library */
|
||||
# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)
|
||||
/* This forces use of a DLL, disallowing static linking */
|
||||
# define PNG_IMPEXP PNG_DLL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef PNG_IMPEXP
|
||||
# define PNG_IMPEXP
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* THe following complexity is concerned with getting the 'attributes' of the
|
||||
* declared function in the correct place. This potentially requires a separate
|
||||
* PNG_EXPORT function for every compiler.
|
||||
/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat
|
||||
* 'attributes' as a storage class - the attributes go at the start of the
|
||||
* function definition, and attributes are always appended regardless of the
|
||||
* compiler. This considerably simplifies these macros but may cause problems
|
||||
* if any compilers both need function attributes and fail to handle them as
|
||||
* a storage class (this is unlikely.)
|
||||
*/
|
||||
#ifndef PNG_FUNCTION
|
||||
# ifdef __GNUC__
|
||||
# define PNG_FUNCTION(type, name, args, attributes)\
|
||||
attributes type name args
|
||||
# else /* !GNUC */
|
||||
# ifdef _MSC_VER
|
||||
# define PNG_FUNCTION(type, name, args, attributes)\
|
||||
attributes type name args
|
||||
# else /* !MSC */
|
||||
# define PNG_FUNCTION(type, name, args, attributes)\
|
||||
type name args
|
||||
# endif
|
||||
# endif
|
||||
# define PNG_FUNCTION(type, name, args, attributes) attributes type name args
|
||||
#endif
|
||||
|
||||
#ifndef PNG_EXPORT_TYPE
|
||||
@@ -310,13 +296,19 @@
|
||||
* scripts directory.
|
||||
*/
|
||||
#ifndef PNG_EXPORTA
|
||||
|
||||
# define PNG_EXPORTA(ordinal, type, name, args, attributes)\
|
||||
extern PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args),\
|
||||
attributes)
|
||||
PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \
|
||||
extern attributes)
|
||||
#endif
|
||||
|
||||
/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
|
||||
* so make something non-empty to satisfy the requirement:
|
||||
*/
|
||||
#define PNG_EMPTY /*empty list*/
|
||||
|
||||
#define PNG_EXPORT(ordinal, type, name, args)\
|
||||
PNG_EXPORTA(ordinal, type, name, args, )
|
||||
PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)
|
||||
|
||||
/* Use PNG_REMOVED to comment out a removed interface. */
|
||||
#ifndef PNG_REMOVED
|
||||
@@ -324,8 +316,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef PNG_CALLBACK
|
||||
# define PNG_CALLBACK(type, name, args, attributes)\
|
||||
type (PNGCBAPI name) PNGARG(args) attributes
|
||||
# define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)
|
||||
#endif
|
||||
|
||||
/* Support for compiler specific function attributes. These are used
|
||||
@@ -343,35 +334,24 @@
|
||||
|
||||
#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED
|
||||
/* Support for compiler specific function attributes. These are used
|
||||
* so that where compiler support is available incorrect use of API
|
||||
* so that where compiler support is available, incorrect use of API
|
||||
* functions in png.h will generate compiler warnings. Added at libpng
|
||||
* version 1.2.41.
|
||||
* version 1.2.41. Disabling these removes the warnings but may also produce
|
||||
* less efficient code.
|
||||
*/
|
||||
# ifdef __GNUC__
|
||||
# if defined(__GNUC__)
|
||||
# ifndef PNG_USE_RESULT
|
||||
# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
|
||||
# endif
|
||||
# ifndef PNG_NORETURN
|
||||
# define PNG_NORETURN __attribute__((__noreturn__))
|
||||
# endif
|
||||
# ifndef PNG_PTR_NORETURN
|
||||
# define PNG_PTR_NORETURN __attribute__((__noreturn__))
|
||||
# endif
|
||||
# ifndef PNG_ALLOCATED
|
||||
# define PNG_ALLOCATED __attribute__((__malloc__))
|
||||
# endif
|
||||
|
||||
/* This specifically protects structure members that should only be
|
||||
* accessed from within the library, therefore should be empty during
|
||||
* a library build.
|
||||
*/
|
||||
# ifndef PNGLIB_BUILD
|
||||
# ifndef PNG_DEPRECATED
|
||||
# define PNG_DEPRECATED __attribute__((__deprecated__))
|
||||
# endif
|
||||
# ifndef PNG_DEPSTRUCT
|
||||
# define PNG_DEPSTRUCT __attribute__((__deprecated__))
|
||||
# endif
|
||||
# ifndef PNG_PRIVATE
|
||||
# if 0 /* Doesn't work so we use deprecated instead*/
|
||||
# define PNG_PRIVATE \
|
||||
@@ -380,39 +360,40 @@
|
||||
# define PNG_PRIVATE \
|
||||
__attribute__((__deprecated__))
|
||||
# endif
|
||||
# endif /* PNG_PRIVATE */
|
||||
# endif /* PNGLIB_BUILD */
|
||||
# endif /* __GNUC__ */
|
||||
# ifdef _MSC_VER /* may need to check value */
|
||||
# endif
|
||||
# ifndef PNG_RESTRICT
|
||||
# define PNG_RESTRICT __restrict
|
||||
# endif
|
||||
|
||||
# elif defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
# ifndef PNG_USE_RESULT
|
||||
# define PNG_USE_RESULT /* not supported */
|
||||
# endif
|
||||
# ifndef PNG_NORETURN
|
||||
# define PNG_NORETURN __declspec(noreturn)
|
||||
# endif
|
||||
# ifndef PNG_PTR_NORETURN
|
||||
# define PNG_PTR_NORETURN /*not supported*/
|
||||
# endif
|
||||
# ifndef PNG_ALLOCATED
|
||||
# if (_MSC_VER >= 1400)
|
||||
# define PNG_ALLOCATED __declspec(restrict)
|
||||
# endif
|
||||
|
||||
/* This specifically protects structure members that should only be
|
||||
* accessed from within the library, therefore should be empty during
|
||||
* a library build.
|
||||
*/
|
||||
# ifndef PNGLIB_BUILD
|
||||
# endif
|
||||
# ifndef PNG_DEPRECATED
|
||||
# define PNG_DEPRECATED __declspec(deprecated)
|
||||
# endif
|
||||
# ifndef PNG_DEPSTRUCT
|
||||
# define PNG_DEPSTRUCT __declspec(deprecated)
|
||||
# endif
|
||||
# ifndef PNG_PRIVATE
|
||||
# define PNG_PRIVATE __declspec(deprecated)
|
||||
# endif /* PNG_PRIVATE */
|
||||
# endif /* PNGLIB_BUILD */
|
||||
# endif /* __GNUC__ */
|
||||
# endif
|
||||
# ifndef PNG_RESTRICT
|
||||
# if (_MSC_VER >= 1400)
|
||||
# define PNG_RESTRICT __restrict
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# elif defined(__WATCOMC__)
|
||||
# ifndef PNG_RESTRICT
|
||||
# define PNG_RESTRICT __restrict
|
||||
# endif
|
||||
# endif /* _MSC_VER */
|
||||
#endif /* PNG_PEDANTIC_WARNINGS */
|
||||
|
||||
#ifndef PNG_DEPRECATED
|
||||
@@ -427,9 +408,6 @@
|
||||
#ifndef PNG_ALLOCATED
|
||||
# define PNG_ALLOCATED /* The result of the function is new memory */
|
||||
#endif
|
||||
#ifndef PNG_DEPSTRUCT
|
||||
# define PNG_DEPSTRUCT /* Access to this struct member is deprecated */
|
||||
#endif
|
||||
#ifndef PNG_PRIVATE
|
||||
# define PNG_PRIVATE /* This is a private libpng function */
|
||||
#endif
|
||||
@@ -450,183 +428,167 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The following uses const char * instead of char * for error
|
||||
* and warning message functions, so some compilers won't complain.
|
||||
* If you do not want to use const, define PNG_NO_CONST here.
|
||||
#ifndef PNG_BUILDING_SYMBOL_TABLE
|
||||
/* Some typedefs to get us started. These should be safe on most of the common
|
||||
* platforms.
|
||||
*
|
||||
* This should not change how the APIs are called, so it can be done
|
||||
* on a per-file basis in the application.
|
||||
* png_uint_32 and png_int_32 may, currently, be larger than required to hold a
|
||||
* 32-bit value however this is not normally advisable.
|
||||
*
|
||||
* png_uint_16 and png_int_16 should always be two bytes in size - this is
|
||||
* verified at library build time.
|
||||
*
|
||||
* png_byte must always be one byte in size.
|
||||
*
|
||||
* The checks below use constants from limits.h, as defined by the ISOC90
|
||||
* standard.
|
||||
*/
|
||||
#ifndef PNG_CONST
|
||||
# ifndef PNG_NO_CONST
|
||||
# define PNG_CONST const
|
||||
# else
|
||||
# define PNG_CONST
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Some typedefs to get us started. These should be safe on most of the
|
||||
* common platforms. The typedefs should be at least as large as the
|
||||
* numbers suggest (a png_uint_32 must be at least 32 bits long), but they
|
||||
* don't have to be exactly that size. Some compilers dislike passing
|
||||
* unsigned shorts as function parameters, so you may be better off using
|
||||
* unsigned int for png_uint_16.
|
||||
*/
|
||||
|
||||
#if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL)
|
||||
typedef unsigned int png_uint_32;
|
||||
typedef int png_int_32;
|
||||
#else
|
||||
typedef unsigned long png_uint_32;
|
||||
typedef long png_int_32;
|
||||
#endif
|
||||
typedef unsigned short png_uint_16;
|
||||
typedef short png_int_16;
|
||||
#if CHAR_BIT == 8 && UCHAR_MAX == 255
|
||||
typedef unsigned char png_byte;
|
||||
|
||||
#ifdef PNG_NO_SIZE_T
|
||||
typedef unsigned int png_size_t;
|
||||
#else
|
||||
typedef size_t png_size_t;
|
||||
# error "libpng requires 8 bit bytes"
|
||||
#endif
|
||||
|
||||
#if INT_MIN == -32768 && INT_MAX == 32767
|
||||
typedef int png_int_16;
|
||||
#elif SHRT_MIN == -32768 && SHRT_MAX == 32767
|
||||
typedef short png_int_16;
|
||||
#else
|
||||
# error "libpng requires a signed 16 bit type"
|
||||
#endif
|
||||
|
||||
#if UINT_MAX == 65535
|
||||
typedef unsigned int png_uint_16;
|
||||
#elif USHRT_MAX == 65535
|
||||
typedef unsigned short png_uint_16;
|
||||
#else
|
||||
# error "libpng requires an unsigned 16 bit type"
|
||||
#endif
|
||||
|
||||
#if INT_MIN < -2147483646 && INT_MAX > 2147483646
|
||||
typedef int png_int_32;
|
||||
#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646
|
||||
typedef long int png_int_32;
|
||||
#else
|
||||
# error "libpng requires a signed 32 bit (or more) type"
|
||||
#endif
|
||||
|
||||
#if UINT_MAX > 4294967294
|
||||
typedef unsigned int png_uint_32;
|
||||
#elif ULONG_MAX > 4294967294
|
||||
typedef unsigned long int png_uint_32;
|
||||
#else
|
||||
# error "libpng requires an unsigned 32 bit (or more) type"
|
||||
#endif
|
||||
|
||||
/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however,
|
||||
* requires an ISOC90 compiler and relies on consistent behavior of sizeof.
|
||||
*/
|
||||
typedef size_t png_size_t;
|
||||
typedef ptrdiff_t png_ptrdiff_t;
|
||||
|
||||
/* libpng needs to know the maximum value of 'size_t' and this controls the
|
||||
* definition of png_alloc_size_t, below. This maximum value of size_t limits
|
||||
* but does not control the maximum allocations the library makes - there is
|
||||
* direct application control of this through png_set_user_limits().
|
||||
*/
|
||||
#ifndef PNG_SMALL_SIZE_T
|
||||
/* Compiler specific tests for systems where size_t is known to be less than
|
||||
* 32 bits (some of these systems may no longer work because of the lack of
|
||||
* 'far' support; see above.)
|
||||
*/
|
||||
# if (defined(__TURBOC__) && !defined(__FLAT__)) ||\
|
||||
(defined(_MSC_VER) && defined(MAXSEG_64K))
|
||||
# define PNG_SMALL_SIZE_T
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no
|
||||
* smaller than png_uint_32. Casts from png_size_t or png_uint_32 to
|
||||
* png_alloc_size_t are not necessary; in fact, it is recommended not to use
|
||||
* them at all so that the compiler can complain when something turns out to be
|
||||
* problematic.
|
||||
*
|
||||
* Casts in the other direction (from png_alloc_size_t to png_size_t or
|
||||
* png_uint_32) should be explicitly applied; however, we do not expect to
|
||||
* encounter practical situations that require such conversions.
|
||||
*
|
||||
* PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than
|
||||
* 4294967295 - i.e. less than the maximum value of png_uint_32.
|
||||
*/
|
||||
#ifdef PNG_SMALL_SIZE_T
|
||||
typedef png_uint_32 png_alloc_size_t;
|
||||
#else
|
||||
typedef png_size_t png_alloc_size_t;
|
||||
#endif
|
||||
|
||||
/* This macro makes the sizeof operator look and behave like a function, except
|
||||
* that it can take a type without the enclosing () as an argument so long as
|
||||
* the type contains no "," characters.
|
||||
*/
|
||||
#define png_sizeof(x) (sizeof (x))
|
||||
|
||||
/* The following is needed for medium model support. It cannot be in the
|
||||
* pngpriv.h header. Needs modification for other compilers besides
|
||||
* MSC. Model independent support declares all arrays and pointers to be
|
||||
* large using the far keyword. The zlib version used must also support
|
||||
* model independent data. As of version zlib 1.0.4, the necessary changes
|
||||
* have been made in zlib. The USE_FAR_KEYWORD define triggers other
|
||||
* changes that are needed. (Tim Wegner)
|
||||
/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler
|
||||
* implementations of Intel CPU specific support of user-mode segmented address
|
||||
* spaces, where 16-bit pointers address more than 65536 bytes of memory using
|
||||
* separate 'segment' registers. The implementation requires two different
|
||||
* types of pointer (only one of which includes the segment value.)
|
||||
*
|
||||
* If required this support is available in version 1.2 of libpng and may be
|
||||
* available in versions through 1.5, although the correctness of the code has
|
||||
* not been verified recently.
|
||||
*/
|
||||
|
||||
/* Separate compiler dependencies (problem here is that zlib.h always
|
||||
* defines FAR. (SJT)
|
||||
*/
|
||||
#ifdef __BORLANDC__
|
||||
# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
|
||||
# define LDATA 1
|
||||
# else
|
||||
# define LDATA 0
|
||||
# endif
|
||||
/* GRR: why is Cygwin in here? Cygwin is not Borland C... */
|
||||
# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
|
||||
# define PNG_MAX_MALLOC_64K /* only used in build */
|
||||
# if (LDATA != 1)
|
||||
# ifndef FAR
|
||||
# define FAR __far
|
||||
# endif
|
||||
# define USE_FAR_KEYWORD
|
||||
# endif /* LDATA != 1 */
|
||||
/* Possibly useful for moving data out of default segment.
|
||||
* Uncomment it if you want. Could also define FARDATA as
|
||||
* const if your compiler supports it. (SJT)
|
||||
# define FARDATA FAR
|
||||
*/
|
||||
# endif /* __WIN32__, __FLAT__, __CYGWIN__ */
|
||||
#endif /* __BORLANDC__ */
|
||||
|
||||
|
||||
/* Suggest testing for specific compiler first before testing for
|
||||
* FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
|
||||
* making reliance oncertain keywords suspect. (SJT)
|
||||
*/
|
||||
|
||||
/* MSC Medium model */
|
||||
#ifdef FAR
|
||||
# ifdef M_I86MM
|
||||
# define USE_FAR_KEYWORD
|
||||
# define FARDATA FAR
|
||||
# include <dos.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* SJT: default case */
|
||||
#ifndef FAR
|
||||
# define FAR
|
||||
#endif
|
||||
|
||||
/* At this point FAR is always defined */
|
||||
#ifndef FARDATA
|
||||
# define FARDATA
|
||||
#endif
|
||||
|
||||
/* Typedef for floating-point numbers that are converted
|
||||
* to fixed-point with a multiple of 100,000, e.g., gamma
|
||||
/* Typedef for floating-point numbers that are converted to fixed-point with a
|
||||
* multiple of 100,000, e.g., gamma
|
||||
*/
|
||||
typedef png_int_32 png_fixed_point;
|
||||
|
||||
/* Add typedefs for pointers */
|
||||
typedef void FAR * png_voidp;
|
||||
typedef PNG_CONST void FAR * png_const_voidp;
|
||||
typedef png_byte FAR * png_bytep;
|
||||
typedef PNG_CONST png_byte FAR * png_const_bytep;
|
||||
typedef png_uint_32 FAR * png_uint_32p;
|
||||
typedef PNG_CONST png_uint_32 FAR * png_const_uint_32p;
|
||||
typedef png_int_32 FAR * png_int_32p;
|
||||
typedef PNG_CONST png_int_32 FAR * png_const_int_32p;
|
||||
typedef png_uint_16 FAR * png_uint_16p;
|
||||
typedef PNG_CONST png_uint_16 FAR * png_const_uint_16p;
|
||||
typedef png_int_16 FAR * png_int_16p;
|
||||
typedef PNG_CONST png_int_16 FAR * png_const_int_16p;
|
||||
typedef char FAR * png_charp;
|
||||
typedef PNG_CONST char FAR * png_const_charp;
|
||||
typedef png_fixed_point FAR * png_fixed_point_p;
|
||||
typedef PNG_CONST png_fixed_point FAR * png_const_fixed_point_p;
|
||||
typedef png_size_t FAR * png_size_tp;
|
||||
typedef PNG_CONST png_size_t FAR * png_const_size_tp;
|
||||
typedef void * png_voidp;
|
||||
typedef const void * png_const_voidp;
|
||||
typedef png_byte * png_bytep;
|
||||
typedef const png_byte * png_const_bytep;
|
||||
typedef png_uint_32 * png_uint_32p;
|
||||
typedef const png_uint_32 * png_const_uint_32p;
|
||||
typedef png_int_32 * png_int_32p;
|
||||
typedef const png_int_32 * png_const_int_32p;
|
||||
typedef png_uint_16 * png_uint_16p;
|
||||
typedef const png_uint_16 * png_const_uint_16p;
|
||||
typedef png_int_16 * png_int_16p;
|
||||
typedef const png_int_16 * png_const_int_16p;
|
||||
typedef char * png_charp;
|
||||
typedef const char * png_const_charp;
|
||||
typedef png_fixed_point * png_fixed_point_p;
|
||||
typedef const png_fixed_point * png_const_fixed_point_p;
|
||||
typedef png_size_t * png_size_tp;
|
||||
typedef const png_size_t * png_const_size_tp;
|
||||
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
typedef FILE * png_FILE_p;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
typedef double FAR * png_doublep;
|
||||
typedef PNG_CONST double FAR * png_const_doublep;
|
||||
typedef double * png_doublep;
|
||||
typedef const double * png_const_doublep;
|
||||
#endif
|
||||
|
||||
/* Pointers to pointers; i.e. arrays */
|
||||
typedef png_byte FAR * FAR * png_bytepp;
|
||||
typedef png_uint_32 FAR * FAR * png_uint_32pp;
|
||||
typedef png_int_32 FAR * FAR * png_int_32pp;
|
||||
typedef png_uint_16 FAR * FAR * png_uint_16pp;
|
||||
typedef png_int_16 FAR * FAR * png_int_16pp;
|
||||
typedef PNG_CONST char FAR * FAR * png_const_charpp;
|
||||
typedef char FAR * FAR * png_charpp;
|
||||
typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
|
||||
typedef png_byte * * png_bytepp;
|
||||
typedef png_uint_32 * * png_uint_32pp;
|
||||
typedef png_int_32 * * png_int_32pp;
|
||||
typedef png_uint_16 * * png_uint_16pp;
|
||||
typedef png_int_16 * * png_int_16pp;
|
||||
typedef const char * * png_const_charpp;
|
||||
typedef char * * png_charpp;
|
||||
typedef png_fixed_point * * png_fixed_point_pp;
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
typedef double FAR * FAR * png_doublepp;
|
||||
typedef double * * png_doublepp;
|
||||
#endif
|
||||
|
||||
/* Pointers to pointers to pointers; i.e., pointer to array */
|
||||
typedef char FAR * FAR * FAR * png_charppp;
|
||||
typedef char * * * png_charppp;
|
||||
|
||||
/* png_alloc_size_t is guaranteed to be no smaller than png_size_t,
|
||||
* and no smaller than png_uint_32. Casts from png_size_t or png_uint_32
|
||||
* to png_alloc_size_t are not necessary; in fact, it is recommended
|
||||
* not to use them at all so that the compiler can complain when something
|
||||
* turns out to be problematic.
|
||||
* Casts in the other direction (from png_alloc_size_t to png_size_t or
|
||||
* png_uint_32) should be explicitly applied; however, we do not expect
|
||||
* to encounter practical situations that require such conversions.
|
||||
*/
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
typedef unsigned long png_alloc_size_t;
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
typedef unsigned long png_alloc_size_t;
|
||||
# else
|
||||
/* This is an attempt to detect an old Windows system where (int) is
|
||||
* actually 16 bits, in that case png_malloc must have an argument with a
|
||||
* bigger size to accomodate the requirements of the library.
|
||||
*/
|
||||
# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_)) && \
|
||||
(!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
|
||||
typedef DWORD png_alloc_size_t;
|
||||
# else
|
||||
typedef png_size_t png_alloc_size_t;
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#endif /* PNG_BUILDING_SYMBOL_TABLE */
|
||||
|
||||
#endif /* PNGCONF_H */
|
||||
|
||||
512
pngerror.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.5.1 [February 3, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -20,12 +20,12 @@
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
|
||||
static PNG_FUNCTION(void, png_default_error,PNGARG((png_structp png_ptr,
|
||||
static PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr,
|
||||
png_const_charp error_message)),PNG_NORETURN);
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
static void /* PRIVATE */
|
||||
png_default_warning PNGARG((png_structp png_ptr,
|
||||
png_default_warning PNGARG((png_const_structrp png_ptr,
|
||||
png_const_charp warning_message));
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
|
||||
@@ -36,7 +36,8 @@ png_default_warning PNGARG((png_structp png_ptr,
|
||||
*/
|
||||
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
||||
png_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
{
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
char msg[16];
|
||||
@@ -79,7 +80,7 @@ png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
||||
}
|
||||
#endif
|
||||
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||
(*(png_ptr->error_fn))(png_ptr, error_message);
|
||||
(*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr), error_message);
|
||||
|
||||
/* If the custom handler doesn't exist, or if it returns,
|
||||
use the default handler, which will not return. */
|
||||
@@ -87,17 +88,123 @@ png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
||||
}
|
||||
#else
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_err,(png_structp png_ptr),PNG_NORETURN)
|
||||
png_err,(png_const_structrp png_ptr),PNG_NORETURN)
|
||||
{
|
||||
/* Prior to 1.5.2 the error_fn received a NULL pointer, expressed
|
||||
* erroneously as '\0', instead of the empty string "". This was
|
||||
* apparently an error, introduced in libpng-1.2.20, and png_default_error
|
||||
* will crash in this case.
|
||||
*/
|
||||
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||
(*(png_ptr->error_fn))(png_ptr, '\0');
|
||||
(*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr), "");
|
||||
|
||||
/* If the custom handler doesn't exist, or if it returns,
|
||||
use the default handler, which will not return. */
|
||||
png_default_error(png_ptr, '\0');
|
||||
png_default_error(png_ptr, "");
|
||||
}
|
||||
#endif /* PNG_ERROR_TEXT_SUPPORTED */
|
||||
|
||||
/* Utility to safely appends strings to a buffer. This never errors out so
|
||||
* error checking is not required in the caller.
|
||||
*/
|
||||
size_t
|
||||
png_safecat(png_charp buffer, size_t bufsize, size_t pos,
|
||||
png_const_charp string)
|
||||
{
|
||||
if (buffer != NULL && pos < bufsize)
|
||||
{
|
||||
if (string != NULL)
|
||||
while (*string != '\0' && pos < bufsize-1)
|
||||
buffer[pos++] = *string++;
|
||||
|
||||
buffer[pos] = '\0';
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||
/* Utility to dump an unsigned value into a buffer, given a start pointer and
|
||||
* and end pointer (which should point just *beyond* the end of the buffer!)
|
||||
* Returns the pointer to the start of the formatted string.
|
||||
*/
|
||||
png_charp
|
||||
png_format_number(png_const_charp start, png_charp end, int format,
|
||||
png_alloc_size_t number)
|
||||
{
|
||||
int count = 0; /* number of digits output */
|
||||
int mincount = 1; /* minimum number required */
|
||||
int output = 0; /* digit output (for the fixed point format) */
|
||||
|
||||
*--end = '\0';
|
||||
|
||||
/* This is written so that the loop always runs at least once, even with
|
||||
* number zero.
|
||||
*/
|
||||
while (end > start && (number != 0 || count < mincount))
|
||||
{
|
||||
|
||||
static const char digits[] = "0123456789ABCDEF";
|
||||
|
||||
switch (format)
|
||||
{
|
||||
case PNG_NUMBER_FORMAT_fixed:
|
||||
/* Needs five digits (the fraction) */
|
||||
mincount = 5;
|
||||
if (output || number % 10 != 0)
|
||||
{
|
||||
*--end = digits[number % 10];
|
||||
output = 1;
|
||||
}
|
||||
number /= 10;
|
||||
break;
|
||||
|
||||
case PNG_NUMBER_FORMAT_02u:
|
||||
/* Expects at least 2 digits. */
|
||||
mincount = 2;
|
||||
/* fall through */
|
||||
|
||||
case PNG_NUMBER_FORMAT_u:
|
||||
*--end = digits[number % 10];
|
||||
number /= 10;
|
||||
break;
|
||||
|
||||
case PNG_NUMBER_FORMAT_02x:
|
||||
/* This format expects at least two digits */
|
||||
mincount = 2;
|
||||
/* fall through */
|
||||
|
||||
case PNG_NUMBER_FORMAT_x:
|
||||
*--end = digits[number & 0xf];
|
||||
number >>= 4;
|
||||
break;
|
||||
|
||||
default: /* an error */
|
||||
number = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Keep track of the number of digits added */
|
||||
++count;
|
||||
|
||||
/* Float a fixed number here: */
|
||||
if (format == PNG_NUMBER_FORMAT_fixed) if (count == 5) if (end > start)
|
||||
{
|
||||
/* End of the fraction, but maybe nothing was output? In that case
|
||||
* drop the decimal point. If the number is a true zero handle that
|
||||
* here.
|
||||
*/
|
||||
if (output)
|
||||
*--end = '.';
|
||||
else if (number == 0) /* and !output */
|
||||
*--end = '0';
|
||||
}
|
||||
}
|
||||
|
||||
return end;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
/* This function is called whenever there is a non-fatal error. This function
|
||||
* should not be changed. If there is a need to handle warnings differently,
|
||||
@@ -105,7 +212,7 @@ png_err,(png_structp png_ptr),PNG_NORETURN)
|
||||
* png_set_error_fn() to replace the warning function at run-time.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||
{
|
||||
int offset = 0;
|
||||
if (png_ptr != NULL)
|
||||
@@ -124,15 +231,134 @@ png_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
}
|
||||
}
|
||||
if (png_ptr != NULL && png_ptr->warning_fn != NULL)
|
||||
(*(png_ptr->warning_fn))(png_ptr, warning_message + offset);
|
||||
(*(png_ptr->warning_fn))(png_constcast(png_structrp,png_ptr),
|
||||
warning_message + offset);
|
||||
else
|
||||
png_default_warning(png_ptr, warning_message + offset);
|
||||
}
|
||||
|
||||
/* These functions support 'formatted' warning messages with up to
|
||||
* PNG_WARNING_PARAMETER_COUNT parameters. In the format string the parameter
|
||||
* is introduced by @<number>, where 'number' starts at 1. This follows the
|
||||
* standard established by X/Open for internationalizable error messages.
|
||||
*/
|
||||
void
|
||||
png_warning_parameter(png_warning_parameters p, int number,
|
||||
png_const_charp string)
|
||||
{
|
||||
if (number > 0 && number <= PNG_WARNING_PARAMETER_COUNT)
|
||||
(void)png_safecat(p[number-1], (sizeof p[number-1]), 0, string);
|
||||
}
|
||||
|
||||
void
|
||||
png_warning_parameter_unsigned(png_warning_parameters p, int number, int format,
|
||||
png_alloc_size_t value)
|
||||
{
|
||||
char buffer[PNG_NUMBER_BUFFER_SIZE];
|
||||
png_warning_parameter(p, number, PNG_FORMAT_NUMBER(buffer, format, value));
|
||||
}
|
||||
|
||||
void
|
||||
png_warning_parameter_signed(png_warning_parameters p, int number, int format,
|
||||
png_int_32 value)
|
||||
{
|
||||
png_alloc_size_t u;
|
||||
png_charp str;
|
||||
char buffer[PNG_NUMBER_BUFFER_SIZE];
|
||||
|
||||
/* Avoid overflow by doing the negate in a png_alloc_size_t: */
|
||||
u = (png_alloc_size_t)value;
|
||||
if (value < 0)
|
||||
u = ~u + 1;
|
||||
|
||||
str = PNG_FORMAT_NUMBER(buffer, format, u);
|
||||
|
||||
if (value < 0 && str > buffer)
|
||||
*--str = '-';
|
||||
|
||||
png_warning_parameter(p, number, str);
|
||||
}
|
||||
|
||||
void
|
||||
png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p,
|
||||
png_const_charp message)
|
||||
{
|
||||
/* The internal buffer is just 192 bytes - enough for all our messages,
|
||||
* overflow doesn't happen because this code checks! If someone figures
|
||||
* out how to send us a message longer than 192 bytes, all that will
|
||||
* happen is that the message will be truncated appropriately.
|
||||
*/
|
||||
size_t i = 0; /* Index in the msg[] buffer: */
|
||||
char msg[192];
|
||||
|
||||
/* Each iteration through the following loop writes at most one character
|
||||
* to msg[i++] then returns here to validate that there is still space for
|
||||
* the trailing '\0'. It may (in the case of a parameter) read more than
|
||||
* one character from message[]; it must check for '\0' and continue to the
|
||||
* test if it finds the end of string.
|
||||
*/
|
||||
while (i<(sizeof msg)-1 && *message != '\0')
|
||||
{
|
||||
/* '@' at end of string is now just printed (previously it was skipped);
|
||||
* it is an error in the calling code to terminate the string with @.
|
||||
*/
|
||||
if (p != NULL && *message == '@' && message[1] != '\0')
|
||||
{
|
||||
int parameter_char = *++message; /* Consume the '@' */
|
||||
static const char valid_parameters[] = "123456789";
|
||||
int parameter = 0;
|
||||
|
||||
/* Search for the parameter digit, the index in the string is the
|
||||
* parameter to use.
|
||||
*/
|
||||
while (valid_parameters[parameter] != parameter_char &&
|
||||
valid_parameters[parameter] != '\0')
|
||||
++parameter;
|
||||
|
||||
/* If the parameter digit is out of range it will just get printed. */
|
||||
if (parameter < PNG_WARNING_PARAMETER_COUNT)
|
||||
{
|
||||
/* Append this parameter */
|
||||
png_const_charp parm = p[parameter];
|
||||
png_const_charp pend = p[parameter] + (sizeof p[parameter]);
|
||||
|
||||
/* No need to copy the trailing '\0' here, but there is no guarantee
|
||||
* that parm[] has been initialized, so there is no guarantee of a
|
||||
* trailing '\0':
|
||||
*/
|
||||
while (i<(sizeof msg)-1 && *parm != '\0' && parm < pend)
|
||||
msg[i++] = *parm++;
|
||||
|
||||
/* Consume the parameter digit too: */
|
||||
++message;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* else not a parameter and there is a character after the @ sign; just
|
||||
* copy that. This is known not to be '\0' because of the test above.
|
||||
*/
|
||||
}
|
||||
|
||||
/* At this point *message can't be '\0', even in the bad parameter case
|
||||
* above where there is a lone '@' at the end of the message string.
|
||||
*/
|
||||
msg[i++] = *message++;
|
||||
}
|
||||
|
||||
/* i is always less than (sizeof msg), so: */
|
||||
msg[i] = '\0';
|
||||
|
||||
/* And this is the formatted message. It may be larger than
|
||||
* PNG_MAX_ERROR_TEXT, but that is only used for 'chunk' errors and these
|
||||
* are not (currently) formatted.
|
||||
*/
|
||||
png_warning(png_ptr, msg);
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_benign_error(png_structp png_ptr, png_const_charp error_message)
|
||||
png_benign_error(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||
png_warning(png_ptr, error_message);
|
||||
@@ -156,14 +382,17 @@ static PNG_CONST char png_digit[16] = {
|
||||
#define PNG_MAX_ERROR_TEXT 64
|
||||
#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||
static void /* PRIVATE */
|
||||
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
||||
png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp
|
||||
error_message)
|
||||
{
|
||||
int iout = 0, iin = 0;
|
||||
png_uint_32 chunk_name = png_ptr->chunk_name;
|
||||
int iout = 0, ishift = 24;
|
||||
|
||||
while (iin < 4)
|
||||
while (ishift >= 0)
|
||||
{
|
||||
int c = png_ptr->chunk_name[iin++];
|
||||
int c = (int)(chunk_name >> ishift) & 0xff;
|
||||
|
||||
ishift -= 8;
|
||||
if (isnonalpha(c))
|
||||
{
|
||||
buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET;
|
||||
@@ -174,7 +403,7 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
||||
|
||||
else
|
||||
{
|
||||
buffer[iout++] = (png_byte)c;
|
||||
buffer[iout++] = (char)c;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,17 +412,23 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
||||
|
||||
else
|
||||
{
|
||||
int iin = 0;
|
||||
|
||||
buffer[iout++] = ':';
|
||||
buffer[iout++] = ' ';
|
||||
png_memcpy(buffer + iout, error_message, PNG_MAX_ERROR_TEXT);
|
||||
buffer[iout + PNG_MAX_ERROR_TEXT - 1] = '\0';
|
||||
|
||||
while (iin < PNG_MAX_ERROR_TEXT-1 && error_message[iin] != '\0')
|
||||
buffer[iout++] = error_message[iin++];
|
||||
|
||||
/* iin < PNG_MAX_ERROR_TEXT, so the following is safe: */
|
||||
buffer[iout] = '\0';
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_chunk_error,(png_structp png_ptr, png_const_charp error_message),
|
||||
png_chunk_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
{
|
||||
char msg[18+PNG_MAX_ERROR_TEXT];
|
||||
@@ -210,7 +445,7 @@ png_chunk_error,(png_structp png_ptr, png_const_charp error_message),
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
png_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||
{
|
||||
char msg[18+PNG_MAX_ERROR_TEXT];
|
||||
if (png_ptr == NULL)
|
||||
@@ -227,7 +462,7 @@ png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_chunk_benign_error(png_structp png_ptr, png_const_charp error_message)
|
||||
png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||
png_chunk_warning(png_ptr, error_message);
|
||||
@@ -241,7 +476,7 @@ png_chunk_benign_error(png_structp png_ptr, png_const_charp error_message)
|
||||
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
PNG_FUNCTION(void,
|
||||
png_fixed_error,(png_structp png_ptr, png_const_charp name),PNG_NORETURN)
|
||||
png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN)
|
||||
{
|
||||
# define fixed_message "fixed point overflow in "
|
||||
# define fixed_message_ln ((sizeof fixed_message)-1)
|
||||
@@ -265,14 +500,111 @@ png_fixed_error,(png_structp png_ptr, png_const_charp name),PNG_NORETURN)
|
||||
* otherwise it is necessary for png_default_error to be overridden.
|
||||
*/
|
||||
jmp_buf* PNGAPI
|
||||
png_set_longjmp_fn(png_structp png_ptr, png_longjmp_ptr longjmp_fn,
|
||||
png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn,
|
||||
size_t jmp_buf_size)
|
||||
{
|
||||
if (png_ptr == NULL || jmp_buf_size != png_sizeof(jmp_buf))
|
||||
/* From libpng 1.6.0 the app gets one chance to set a 'jmpbuf_size' value
|
||||
* and it must not change after that. Libpng doesn't care how big the
|
||||
* buffer is, just that it doesn't change.
|
||||
*
|
||||
* If the buffer size is no *larger* than the size of jmp_buf when libpng is
|
||||
* compiled a built in jmp_buf is returned; this preserves the pre-1.6.0
|
||||
* semantics that this call will not fail. If the size is larger, however,
|
||||
* the buffer is allocated and this may fail, causing the function to return
|
||||
* NULL.
|
||||
*/
|
||||
if (png_ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
if (png_ptr->jmp_buf_ptr == NULL)
|
||||
{
|
||||
png_ptr->jmp_buf_size = 0; /* not allocated */
|
||||
|
||||
if (jmp_buf_size <= sizeof png_ptr->jmp_buf_local)
|
||||
png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local;
|
||||
|
||||
else
|
||||
{
|
||||
png_ptr->jmp_buf_ptr = png_voidcast(jmp_buf *,
|
||||
png_malloc_warn(png_ptr, jmp_buf_size));
|
||||
|
||||
if (png_ptr->jmp_buf_ptr == NULL)
|
||||
return NULL; /* new NULL return on OOM */
|
||||
|
||||
png_ptr->jmp_buf_size = jmp_buf_size;
|
||||
}
|
||||
}
|
||||
|
||||
else /* Already allocated: check the size */
|
||||
{
|
||||
size_t size = png_ptr->jmp_buf_size;
|
||||
|
||||
if (size == 0)
|
||||
{
|
||||
size = sizeof png_ptr->jmp_buf_local;
|
||||
if (png_ptr->jmp_buf_ptr != &png_ptr->jmp_buf_local)
|
||||
{
|
||||
/* This is an internal error in libpng: somehow we have been left
|
||||
* with a stack allocated jmp_buf when the application regained
|
||||
* control. It's always possible to fix this up, but for the moment
|
||||
* this is a png_error because that makes it easy to detect.
|
||||
*/
|
||||
png_error(png_ptr, "Libpng jmp_buf still allocated");
|
||||
/* png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local; */
|
||||
}
|
||||
}
|
||||
|
||||
if (size != jmp_buf_size)
|
||||
{
|
||||
png_warning(png_ptr, "Application jmp_buf size changed");
|
||||
return NULL; /* caller will probably crash: no choice here */
|
||||
}
|
||||
}
|
||||
|
||||
/* Finally fill in the function, now we have a satisfactory buffer. It is
|
||||
* valid to change the function on every call.
|
||||
*/
|
||||
png_ptr->longjmp_fn = longjmp_fn;
|
||||
return &png_ptr->png_jmpbuf;
|
||||
return png_ptr->jmp_buf_ptr;
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_free_jmpbuf(png_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
jmp_buf *jb = png_ptr->jmp_buf_ptr;
|
||||
|
||||
/* A size of 0 is used to indicate a local, stack, allocation of the
|
||||
* pointer; used here and in png.c
|
||||
*/
|
||||
if (jb != NULL && png_ptr->jmp_buf_size > 0)
|
||||
{
|
||||
|
||||
/* This stuff is so that a failure to free the error control structure
|
||||
* does not leave libpng in a state with no valid error handling: the
|
||||
* free always succeeds, if there is an error it gets ignored.
|
||||
*/
|
||||
if (jb != &png_ptr->jmp_buf_local)
|
||||
{
|
||||
/* Make an internal, libpng, jmp_buf to return here */
|
||||
jmp_buf free_jmp_buf;
|
||||
|
||||
if (!setjmp(free_jmp_buf))
|
||||
{
|
||||
png_ptr->jmp_buf_ptr = &free_jmp_buf; /* come back here */
|
||||
png_ptr->jmp_buf_size = 0; /* stack allocation */
|
||||
png_ptr->longjmp_fn = longjmp;
|
||||
png_free(png_ptr, jb); /* Return to setjmp on error */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* *Always* cancel everything out: */
|
||||
png_ptr->jmp_buf_size = 0;
|
||||
png_ptr->jmp_buf_ptr = NULL;
|
||||
png_ptr->longjmp_fn = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -282,12 +614,13 @@ png_set_longjmp_fn(png_structp png_ptr, png_longjmp_ptr longjmp_fn,
|
||||
* error function pointer in png_set_error_fn().
|
||||
*/
|
||||
static PNG_FUNCTION(void /* PRIVATE */,
|
||||
png_default_error,(png_structp png_ptr, png_const_charp error_message),
|
||||
png_default_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
{
|
||||
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
if (*error_message == PNG_LITERAL_SHARP)
|
||||
/* Check on NULL only added in 1.5.4 */
|
||||
if (error_message != NULL && *error_message == PNG_LITERAL_SHARP)
|
||||
{
|
||||
/* Strip "#nnnn " from beginning of error message. */
|
||||
int offset;
|
||||
@@ -317,34 +650,24 @@ png_default_error,(png_structp png_ptr, png_const_charp error_message),
|
||||
else
|
||||
#endif
|
||||
{
|
||||
fprintf(stderr, "libpng error: %s", error_message);
|
||||
fprintf(stderr, "libpng error: %s", error_message ? error_message :
|
||||
"undefined");
|
||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||
}
|
||||
#endif
|
||||
#ifndef PNG_CONSOLE_IO_SUPPORTED
|
||||
#else
|
||||
PNG_UNUSED(error_message) /* Make compiler happy */
|
||||
#endif
|
||||
png_longjmp(png_ptr, 1);
|
||||
}
|
||||
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_longjmp,(png_structp png_ptr, int val),PNG_NORETURN)
|
||||
png_longjmp,(png_const_structrp png_ptr, int val),PNG_NORETURN)
|
||||
{
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
if (png_ptr && png_ptr->longjmp_fn)
|
||||
{
|
||||
# ifdef USE_FAR_KEYWORD
|
||||
{
|
||||
jmp_buf png_jmpbuf;
|
||||
png_memcpy(png_jmpbuf, png_ptr->png_jmpbuf, png_sizeof(jmp_buf));
|
||||
png_ptr->longjmp_fn(png_jmpbuf, val);
|
||||
}
|
||||
if (png_ptr && png_ptr->longjmp_fn && png_ptr->jmp_buf_ptr)
|
||||
png_ptr->longjmp_fn(*png_ptr->jmp_buf_ptr, val);
|
||||
#endif
|
||||
|
||||
# else
|
||||
png_ptr->longjmp_fn(png_ptr->png_jmpbuf, val);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
/* Here if not setjmp support or if png_ptr is null. */
|
||||
PNG_ABORT();
|
||||
}
|
||||
@@ -356,7 +679,7 @@ png_longjmp,(png_structp png_ptr, int val),PNG_NORETURN)
|
||||
* not used, but it is passed in case it may be useful.
|
||||
*/
|
||||
static void /* PRIVATE */
|
||||
png_default_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
png_default_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||
{
|
||||
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
||||
# ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
@@ -403,10 +726,10 @@ png_default_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
/* This function is called when the application wants to use another method
|
||||
* of handling errors and warnings. Note that the error function MUST NOT
|
||||
* return to the calling routine or serious problems will occur. The return
|
||||
* method used in the default routine calls longjmp(png_ptr->png_jmpbuf, 1)
|
||||
* method used in the default routine calls longjmp(png_ptr->jmp_buf_ptr, 1)
|
||||
*/
|
||||
void PNGAPI
|
||||
png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
||||
png_set_error_fn(png_structrp png_ptr, png_voidp error_ptr,
|
||||
png_error_ptr error_fn, png_error_ptr warning_fn)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
@@ -414,7 +737,11 @@ png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
||||
|
||||
png_ptr->error_ptr = error_ptr;
|
||||
png_ptr->error_fn = error_fn;
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
png_ptr->warning_fn = warning_fn;
|
||||
#else
|
||||
PNG_UNUSED(warning_fn)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -423,7 +750,7 @@ png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
||||
* pointer before png_write_destroy and png_read_destroy are called.
|
||||
*/
|
||||
png_voidp PNGAPI
|
||||
png_get_error_ptr(png_const_structp png_ptr)
|
||||
png_get_error_ptr(png_const_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return NULL;
|
||||
@@ -434,7 +761,7 @@ png_get_error_ptr(png_const_structp png_ptr)
|
||||
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
|
||||
png_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
@@ -444,4 +771,89 @@ png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined PNG_SIMPLIFIED_READ_SUPPORTED ||\
|
||||
defined PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||
/* Currently the above both depend on SETJMP_SUPPORTED, however it would be
|
||||
* possible to implement without setjmp support just so long as there is some
|
||||
* way to handle the error return here:
|
||||
*/
|
||||
PNG_FUNCTION(void /* PRIVATE */,
|
||||
png_safe_error,(png_structp png_nonconst_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
{
|
||||
const png_const_structrp png_ptr = png_nonconst_ptr;
|
||||
png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
|
||||
|
||||
/* An error is always logged here, overwriting anything (typically a warning)
|
||||
* that is already there:
|
||||
*/
|
||||
if (image != NULL)
|
||||
{
|
||||
png_safecat(image->message, sizeof image->message, 0, error_message);
|
||||
image->warning_or_error |= PNG_IMAGE_ERROR;
|
||||
|
||||
/* Retrieve the jmp_buf from within the png_control, making this work for
|
||||
* C++ compilation too is pretty tricky: C++ wants a pointer to the first
|
||||
* element of a jmp_buf, but C doesn't tell us the type of that.
|
||||
*/
|
||||
if (image->opaque != NULL && image->opaque->error_buf != NULL)
|
||||
longjmp(png_control_jmp_buf(image->opaque), 1);
|
||||
|
||||
/* Missing longjmp buffer, the following is to help debugging: */
|
||||
{
|
||||
size_t pos = png_safecat(image->message, sizeof image->message, 0,
|
||||
"bad longjmp: ");
|
||||
png_safecat(image->message, sizeof image->message, pos, error_message);
|
||||
}
|
||||
}
|
||||
|
||||
/* Here on an internal programming error. */
|
||||
abort();
|
||||
}
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
|
||||
{
|
||||
const png_const_structrp png_ptr = png_nonconst_ptr;
|
||||
png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
|
||||
|
||||
/* A warning is only logged if there is no prior warning or error. */
|
||||
if (image->warning_or_error == 0)
|
||||
{
|
||||
png_safecat(image->message, sizeof image->message, 0, warning_message);
|
||||
image->warning_or_error |= PNG_IMAGE_WARNING;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int /* PRIVATE */
|
||||
png_safe_execute(png_imagep imageIn, int (*function)(png_voidp), png_voidp arg)
|
||||
{
|
||||
volatile png_imagep image = imageIn;
|
||||
volatile int result;
|
||||
volatile png_voidp saved_error_buf;
|
||||
jmp_buf safe_jmpbuf;
|
||||
|
||||
/* Safely execute function(arg) with png_error returning to this function. */
|
||||
saved_error_buf = image->opaque->error_buf;
|
||||
result = setjmp(safe_jmpbuf) == 0;
|
||||
|
||||
if (result)
|
||||
{
|
||||
|
||||
image->opaque->error_buf = safe_jmpbuf;
|
||||
result = function(arg);
|
||||
}
|
||||
|
||||
image->opaque->error_buf = saved_error_buf;
|
||||
|
||||
/* And do the cleanup prior to any failure return. */
|
||||
if (!result)
|
||||
png_image_free(image);
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif /* SIMPLIFIED READ/WRITE */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
|
||||
270
pngget.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* Last changed in libpng 1.5.1 [February 3, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -17,7 +17,7 @@
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_valid(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_uint_32 flag)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -27,7 +27,7 @@ png_get_valid(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
}
|
||||
|
||||
png_size_t PNGAPI
|
||||
png_get_rowbytes(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_rowbytes(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return(info_ptr->rowbytes);
|
||||
@@ -37,7 +37,7 @@ png_get_rowbytes(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
|
||||
#ifdef PNG_INFO_IMAGE_SUPPORTED
|
||||
png_bytepp PNGAPI
|
||||
png_get_rows(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_rows(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return(info_ptr->row_pointers);
|
||||
@@ -49,7 +49,7 @@ png_get_rows(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
#ifdef PNG_EASY_ACCESS_SUPPORTED
|
||||
/* Easy access to info, added in libpng-0.99 */
|
||||
png_uint_32 PNGAPI
|
||||
png_get_image_width(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_image_width(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return info_ptr->width;
|
||||
@@ -58,7 +58,7 @@ png_get_image_width(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_image_height(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_image_height(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return info_ptr->height;
|
||||
@@ -67,7 +67,7 @@ png_get_image_height(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
}
|
||||
|
||||
png_byte PNGAPI
|
||||
png_get_bit_depth(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_bit_depth(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return info_ptr->bit_depth;
|
||||
@@ -76,7 +76,7 @@ png_get_bit_depth(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
}
|
||||
|
||||
png_byte PNGAPI
|
||||
png_get_color_type(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_color_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return info_ptr->color_type;
|
||||
@@ -85,7 +85,7 @@ png_get_color_type(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
}
|
||||
|
||||
png_byte PNGAPI
|
||||
png_get_filter_type(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_filter_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return info_ptr->filter_type;
|
||||
@@ -94,7 +94,7 @@ png_get_filter_type(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
}
|
||||
|
||||
png_byte PNGAPI
|
||||
png_get_interlace_type(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_interlace_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return info_ptr->interlace_type;
|
||||
@@ -103,7 +103,7 @@ png_get_interlace_type(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
}
|
||||
|
||||
png_byte PNGAPI
|
||||
png_get_compression_type(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return info_ptr->compression_type;
|
||||
@@ -112,7 +112,7 @@ png_get_compression_type(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_x_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_pHYs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
@@ -129,7 +129,7 @@ png_get_x_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_y_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_pHYs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
@@ -146,7 +146,7 @@ png_get_y_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_pHYs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
@@ -164,7 +164,7 @@ png_get_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
float PNGAPI
|
||||
png_get_pixel_aspect_ratio(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_READ_pHYs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
@@ -183,8 +183,8 @@ png_get_pixel_aspect_ratio(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_fixed_point PNGAPI
|
||||
png_get_pixel_aspect_ratio_fixed(png_const_structp png_ptr,
|
||||
png_const_infop info_ptr)
|
||||
png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_READ_pHYs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)
|
||||
@@ -210,7 +210,7 @@ png_get_pixel_aspect_ratio_fixed(png_const_structp png_ptr,
|
||||
#endif
|
||||
|
||||
png_int_32 PNGAPI
|
||||
png_get_x_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||
@@ -226,7 +226,7 @@ png_get_x_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
}
|
||||
|
||||
png_int_32 PNGAPI
|
||||
png_get_y_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||
@@ -242,7 +242,7 @@ png_get_y_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
}
|
||||
|
||||
png_int_32 PNGAPI
|
||||
png_get_x_offset_pixels(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||
@@ -258,7 +258,7 @@ png_get_x_offset_pixels(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
}
|
||||
|
||||
png_int_32 PNGAPI
|
||||
png_get_y_offset_pixels(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||
@@ -307,26 +307,26 @@ ppi_from_ppm(png_uint_32 ppm)
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr));
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_x_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_x_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr));
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_y_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_y_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr));
|
||||
}
|
||||
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
static png_fixed_point
|
||||
png_fixed_inches_from_microns(png_structp png_ptr, png_int_32 microns)
|
||||
png_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns)
|
||||
{
|
||||
/* Convert from metres * 1,000,000 to inches * 100,000, meters to
|
||||
* inches is simply *(100/2.54), so we want *(10/2.54) == 500/127.
|
||||
@@ -337,8 +337,8 @@ png_fixed_inches_from_microns(png_structp png_ptr, png_int_32 microns)
|
||||
}
|
||||
|
||||
png_fixed_point PNGAPI
|
||||
png_get_x_offset_inches_fixed(png_structp png_ptr,
|
||||
png_const_infop info_ptr)
|
||||
png_get_x_offset_inches_fixed(png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr)
|
||||
{
|
||||
return png_fixed_inches_from_microns(png_ptr,
|
||||
png_get_x_offset_microns(png_ptr, info_ptr));
|
||||
@@ -347,8 +347,8 @@ png_get_x_offset_inches_fixed(png_structp png_ptr,
|
||||
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_fixed_point PNGAPI
|
||||
png_get_y_offset_inches_fixed(png_structp png_ptr,
|
||||
png_const_infop info_ptr)
|
||||
png_get_y_offset_inches_fixed(png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr)
|
||||
{
|
||||
return png_fixed_inches_from_microns(png_ptr,
|
||||
png_get_y_offset_microns(png_ptr, info_ptr));
|
||||
@@ -357,7 +357,7 @@ png_get_y_offset_inches_fixed(png_structp png_ptr,
|
||||
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
float PNGAPI
|
||||
png_get_x_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_x_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
/* To avoid the overflow do the conversion directly in floating
|
||||
* point.
|
||||
@@ -368,7 +368,7 @@ png_get_x_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
float PNGAPI
|
||||
png_get_y_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_y_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
/* To avoid the overflow do the conversion directly in floating
|
||||
* point.
|
||||
@@ -379,7 +379,7 @@ png_get_y_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
|
||||
#ifdef PNG_pHYs_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pHYs_dpi(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
|
||||
{
|
||||
png_uint_32 retval = 0;
|
||||
@@ -423,7 +423,7 @@ png_get_pHYs_dpi(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
#endif /* PNG_EASY_ACCESS_SUPPORTED */
|
||||
|
||||
png_byte PNGAPI
|
||||
png_get_channels(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return(info_ptr->channels);
|
||||
@@ -432,7 +432,7 @@ png_get_channels(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
}
|
||||
|
||||
png_const_bytep PNGAPI
|
||||
png_get_signature(png_const_structp png_ptr, png_infop info_ptr)
|
||||
png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return(info_ptr->signature);
|
||||
@@ -442,7 +442,7 @@ png_get_signature(png_const_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
#ifdef PNG_bKGD_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_bKGD(png_const_structp png_ptr, png_infop info_ptr,
|
||||
png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_color_16p *background)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
|
||||
@@ -459,9 +459,68 @@ png_get_bKGD(png_const_structp png_ptr, png_infop info_ptr,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_cHRM_SUPPORTED
|
||||
/* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the
|
||||
* same time to correct the rgb grayscale coefficient defaults obtained from the
|
||||
* cHRM chunk in 1.5.4
|
||||
*/
|
||||
png_uint_32 PNGFAPI
|
||||
png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
|
||||
png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
|
||||
png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
|
||||
png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
|
||||
png_fixed_point *int_blue_Z)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
|
||||
{
|
||||
png_xy xy;
|
||||
png_XYZ XYZ;
|
||||
|
||||
png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
|
||||
|
||||
xy.whitex = info_ptr->x_white;
|
||||
xy.whitey = info_ptr->y_white;
|
||||
xy.redx = info_ptr->x_red;
|
||||
xy.redy = info_ptr->y_red;
|
||||
xy.greenx = info_ptr->x_green;
|
||||
xy.greeny = info_ptr->y_green;
|
||||
xy.bluex = info_ptr->x_blue;
|
||||
xy.bluey = info_ptr->y_blue;
|
||||
|
||||
/* The *_checked function handles error reporting, so just return 0 if
|
||||
* there is a failure here.
|
||||
*/
|
||||
if (png_XYZ_from_xy_checked(png_ptr, &XYZ, xy))
|
||||
{
|
||||
if (int_red_X != NULL)
|
||||
*int_red_X = XYZ.redX;
|
||||
if (int_red_Y != NULL)
|
||||
*int_red_Y = XYZ.redY;
|
||||
if (int_red_Z != NULL)
|
||||
*int_red_Z = XYZ.redZ;
|
||||
if (int_green_X != NULL)
|
||||
*int_green_X = XYZ.greenX;
|
||||
if (int_green_Y != NULL)
|
||||
*int_green_Y = XYZ.greenY;
|
||||
if (int_green_Z != NULL)
|
||||
*int_green_Z = XYZ.greenZ;
|
||||
if (int_blue_X != NULL)
|
||||
*int_blue_X = XYZ.blueX;
|
||||
if (int_blue_Y != NULL)
|
||||
*int_blue_Y = XYZ.blueY;
|
||||
if (int_blue_Z != NULL)
|
||||
*int_blue_Z = XYZ.blueZ;
|
||||
|
||||
return (PNG_INFO_cHRM);
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_cHRM(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
double *white_x, double *white_y, double *red_x, double *red_y,
|
||||
double *green_x, double *green_y, double *blue_x, double *blue_y)
|
||||
{
|
||||
@@ -490,11 +549,47 @@ png_get_cHRM(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
double *red_X, double *red_Y, double *red_Z, double *green_X,
|
||||
double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
|
||||
double *blue_Z)
|
||||
{
|
||||
png_XYZ XYZ;
|
||||
|
||||
if (png_get_cHRM_XYZ_fixed(png_ptr, info_ptr,
|
||||
&XYZ.redX, &XYZ.redY, &XYZ.redZ, &XYZ.greenX, &XYZ.greenY, &XYZ.greenZ,
|
||||
&XYZ.blueX, &XYZ.blueY, &XYZ.blueZ) & PNG_INFO_cHRM)
|
||||
{
|
||||
if (red_X != NULL)
|
||||
*red_X = png_float(png_ptr, XYZ.redX, "cHRM red X");
|
||||
if (red_Y != NULL)
|
||||
*red_Y = png_float(png_ptr, XYZ.redY, "cHRM red Y");
|
||||
if (red_Z != NULL)
|
||||
*red_Z = png_float(png_ptr, XYZ.redZ, "cHRM red Z");
|
||||
if (green_X != NULL)
|
||||
*green_X = png_float(png_ptr, XYZ.greenX, "cHRM green X");
|
||||
if (green_Y != NULL)
|
||||
*green_Y = png_float(png_ptr, XYZ.greenY, "cHRM green Y");
|
||||
if (green_Z != NULL)
|
||||
*green_Z = png_float(png_ptr, XYZ.greenZ, "cHRM green Z");
|
||||
if (blue_X != NULL)
|
||||
*blue_X = png_float(png_ptr, XYZ.blueX, "cHRM blue X");
|
||||
if (blue_Y != NULL)
|
||||
*blue_Y = png_float(png_ptr, XYZ.blueY, "cHRM blue Y");
|
||||
if (blue_Z != NULL)
|
||||
*blue_Z = png_float(png_ptr, XYZ.blueZ, "cHRM blue Z");
|
||||
return (PNG_INFO_cHRM);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_cHRM_fixed(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
|
||||
png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
|
||||
png_fixed_point *blue_x, png_fixed_point *blue_y)
|
||||
@@ -529,7 +624,7 @@ png_get_cHRM_fixed(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
|
||||
#ifdef PNG_gAMA_SUPPORTED
|
||||
png_uint_32 PNGFAPI
|
||||
png_get_gAMA_fixed(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_fixed_point *file_gamma)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "gAMA");
|
||||
@@ -545,7 +640,7 @@ png_get_gAMA_fixed(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
}
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_gAMA(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
double *file_gamma)
|
||||
{
|
||||
png_fixed_point igamma;
|
||||
@@ -562,7 +657,7 @@ png_get_gAMA(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
|
||||
#ifdef PNG_sRGB_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sRGB(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
int *file_srgb_intent)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "sRGB");
|
||||
@@ -580,22 +675,23 @@ png_get_sRGB(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
|
||||
#ifdef PNG_iCCP_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_iCCP(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
png_get_iCCP(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_charpp name, int *compression_type,
|
||||
png_bytepp profile, png_uint_32 *proflen)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "iCCP");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
|
||||
&& name != NULL && profile != NULL && proflen != NULL)
|
||||
&& name != NULL && compression_type != NULL && profile != NULL &&
|
||||
proflen != NULL)
|
||||
{
|
||||
*name = info_ptr->iccp_name;
|
||||
*profile = info_ptr->iccp_profile;
|
||||
/* Compression_type is a dummy so the API won't have to change
|
||||
* if we introduce multiple compression types later.
|
||||
*/
|
||||
*proflen = (int)info_ptr->iccp_proflen;
|
||||
*compression_type = (int)info_ptr->iccp_compression;
|
||||
*proflen = info_ptr->iccp_proflen;
|
||||
*compression_type = info_ptr->iccp_compression;
|
||||
return (PNG_INFO_iCCP);
|
||||
}
|
||||
|
||||
@@ -605,7 +701,7 @@ png_get_iCCP(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
|
||||
#ifdef PNG_sPLT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sPLT(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
png_get_sPLT(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_sPLT_tpp spalettes)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
|
||||
@@ -620,7 +716,7 @@ png_get_sPLT(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
|
||||
#ifdef PNG_hIST_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_hIST(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
png_get_hIST(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_uint_16p *hist)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "hIST");
|
||||
@@ -637,11 +733,10 @@ png_get_hIST(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
#endif
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||
png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_uint_32 *width, png_uint_32 *height, int *bit_depth,
|
||||
int *color_type, int *interlace_type, int *compression_type,
|
||||
int *filter_type)
|
||||
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "IHDR");
|
||||
|
||||
@@ -677,7 +772,7 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_oFFs(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "oFFs");
|
||||
@@ -697,7 +792,7 @@ png_get_oFFs(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
|
||||
#ifdef PNG_pCAL_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pCAL(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
png_get_pCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
|
||||
png_charp *units, png_charpp *params)
|
||||
{
|
||||
@@ -723,16 +818,20 @@ png_get_pCAL(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
|
||||
#ifdef PNG_sCAL_SUPPORTED
|
||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
# if (defined PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
|
||||
(defined PNG_FLOATING_POINT_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sCAL_fixed(png_structp png_ptr, png_const_infop info_ptr,
|
||||
png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
int *unit, png_fixed_point *width, png_fixed_point *height)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_sCAL))
|
||||
{
|
||||
*unit = info_ptr->scal_unit;
|
||||
/*TODO: make this work without FP support */
|
||||
/*TODO: make this work without FP support; the API is currently eliminated
|
||||
* if neither floating point APIs nor internal floating point arithmetic
|
||||
* are enabled.
|
||||
*/
|
||||
*width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width");
|
||||
*height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),
|
||||
"sCAL height");
|
||||
@@ -745,7 +844,7 @@ png_get_sCAL_fixed(png_structp png_ptr, png_const_infop info_ptr,
|
||||
# endif /* FIXED_POINT */
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sCAL(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
int *unit, double *width, double *height)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
@@ -761,7 +860,7 @@ png_get_sCAL(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
}
|
||||
# endif /* FLOATING POINT */
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sCAL_s(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
int *unit, png_charpp width, png_charpp height)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
@@ -779,7 +878,7 @@ png_get_sCAL_s(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
|
||||
#ifdef PNG_pHYs_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pHYs(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
|
||||
{
|
||||
png_uint_32 retval = 0;
|
||||
@@ -813,7 +912,7 @@ png_get_pHYs(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
#endif /* pHYs */
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_PLTE(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
png_get_PLTE(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_colorp *palette, int *num_palette)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "PLTE");
|
||||
@@ -832,7 +931,7 @@ png_get_PLTE(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
|
||||
#ifdef PNG_sBIT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sBIT(png_const_structp png_ptr, png_infop info_ptr,
|
||||
png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_color_8p *sig_bit)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "sBIT");
|
||||
@@ -850,14 +949,13 @@ png_get_sBIT(png_const_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_text(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
png_get_text(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_textp *text_ptr, int *num_text)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function",
|
||||
(png_ptr->chunk_name[0] == '\0' ? "text" :
|
||||
(png_const_charp)png_ptr->chunk_name));
|
||||
png_debug1(1, "in 0x%lx retrieval function",
|
||||
(unsigned long)png_ptr->chunk_name);
|
||||
|
||||
if (text_ptr != NULL)
|
||||
*text_ptr = info_ptr->text;
|
||||
@@ -877,7 +975,8 @@ png_get_text(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
|
||||
#ifdef PNG_tIME_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_tIME(png_const_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
|
||||
png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_timep *mod_time)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "tIME");
|
||||
|
||||
@@ -894,7 +993,7 @@ png_get_tIME(png_const_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
|
||||
|
||||
#ifdef PNG_tRNS_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_tRNS(png_const_structp png_ptr, png_infop info_ptr,
|
||||
png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
|
||||
{
|
||||
png_uint_32 retval = 0;
|
||||
@@ -939,7 +1038,7 @@ png_get_tRNS(png_const_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
int PNGAPI
|
||||
png_get_unknown_chunks(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
png_get_unknown_chunks(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_unknown_chunkpp unknowns)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
|
||||
@@ -954,7 +1053,7 @@ png_get_unknown_chunks(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
png_byte PNGAPI
|
||||
png_get_rgb_to_gray_status (png_const_structp png_ptr)
|
||||
png_get_rgb_to_gray_status (png_const_structrp png_ptr)
|
||||
{
|
||||
return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);
|
||||
}
|
||||
@@ -962,44 +1061,43 @@ png_get_rgb_to_gray_status (png_const_structp png_ptr)
|
||||
|
||||
#ifdef PNG_USER_CHUNKS_SUPPORTED
|
||||
png_voidp PNGAPI
|
||||
png_get_user_chunk_ptr(png_const_structp png_ptr)
|
||||
png_get_user_chunk_ptr(png_const_structrp png_ptr)
|
||||
{
|
||||
return (png_ptr ? png_ptr->user_chunk_ptr : NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
png_size_t PNGAPI
|
||||
png_get_compression_buffer_size(png_const_structp png_ptr)
|
||||
png_get_compression_buffer_size(png_const_structrp png_ptr)
|
||||
{
|
||||
return (png_ptr ? png_ptr->zbuf_size : 0L);
|
||||
return (png_ptr ? png_ptr->zbuf_size : 0);
|
||||
}
|
||||
|
||||
|
||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
/* These functions were added to libpng 1.2.6 and were enabled
|
||||
* by default in libpng-1.4.0 */
|
||||
png_uint_32 PNGAPI
|
||||
png_get_user_width_max (png_const_structp png_ptr)
|
||||
png_get_user_width_max (png_const_structrp png_ptr)
|
||||
{
|
||||
return (png_ptr ? png_ptr->user_width_max : 0);
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_user_height_max (png_const_structp png_ptr)
|
||||
png_get_user_height_max (png_const_structrp png_ptr)
|
||||
{
|
||||
return (png_ptr ? png_ptr->user_height_max : 0);
|
||||
}
|
||||
|
||||
/* This function was added to libpng 1.4.0 */
|
||||
png_uint_32 PNGAPI
|
||||
png_get_chunk_cache_max (png_const_structp png_ptr)
|
||||
png_get_chunk_cache_max (png_const_structrp png_ptr)
|
||||
{
|
||||
return (png_ptr ? png_ptr->user_chunk_cache_max : 0);
|
||||
}
|
||||
|
||||
/* This function was added to libpng 1.4.1 */
|
||||
png_alloc_size_t PNGAPI
|
||||
png_get_chunk_malloc_max (png_const_structp png_ptr)
|
||||
png_get_chunk_malloc_max (png_const_structrp png_ptr)
|
||||
{
|
||||
return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
|
||||
}
|
||||
@@ -1008,25 +1106,25 @@ png_get_chunk_malloc_max (png_const_structp png_ptr)
|
||||
/* These functions were added to libpng 1.4.0 */
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_io_state (png_structp png_ptr)
|
||||
png_get_io_state (png_const_structrp png_ptr)
|
||||
{
|
||||
return png_ptr->io_state;
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_io_chunk_type (png_const_structp png_ptr)
|
||||
{
|
||||
return ((png_ptr->chunk_name[0] << 24) +
|
||||
(png_ptr->chunk_name[1] << 16) +
|
||||
(png_ptr->chunk_name[2] << 8) +
|
||||
(png_ptr->chunk_name[3]));
|
||||
}
|
||||
|
||||
png_const_bytep PNGAPI
|
||||
png_get_io_chunk_name (png_structp png_ptr)
|
||||
png_get_io_chunk_type (png_const_structrp png_ptr)
|
||||
{
|
||||
return png_ptr->chunk_name;
|
||||
}
|
||||
|
||||
#if PNG_LIBPNG_VER < 10600
|
||||
png_const_bytep PNGAPI
|
||||
png_get_io_chunk_name (png_structrp png_ptr)
|
||||
{
|
||||
PNG_CSTRING_FROM_CHUNK(png_ptr->io_chunk_string, png_ptr->chunk_name);
|
||||
return png_ptr->io_chunk_string;
|
||||
}
|
||||
#endif
|
||||
#endif /* ?PNG_IO_STATE_SUPPORTED */
|
||||
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
|
||||
@@ -138,7 +138,6 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
* single color specified that should be treated as fully transparent.
|
||||
* Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
|
||||
*/
|
||||
png_bytep trans; /* alpha values for paletted image */
|
||||
png_bytep trans_alpha; /* alpha values for paletted image */
|
||||
png_color_16 trans_color; /* transparent color for non-palette image */
|
||||
#endif
|
||||
|
||||
647
pngmem.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.5.1 [February 3, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -20,447 +20,22 @@
|
||||
#include "pngpriv.h"
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
|
||||
/* Borland DOS special memory handler */
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
/* If you change this, be sure to change the one in png.h also */
|
||||
|
||||
/* Allocate memory for a png_struct. The malloc and memset can be replaced
|
||||
by a single call to calloc() if this is thought to improve performance. */
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_create_struct,(int type),PNG_ALLOCATED)
|
||||
{
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
return (png_create_struct_2(type, NULL, NULL));
|
||||
}
|
||||
|
||||
/* Alternate version of png_create_struct, for use with user-defined malloc. */
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_create_struct_2,(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr),
|
||||
PNG_ALLOCATED)
|
||||
{
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
png_size_t size;
|
||||
png_voidp struct_ptr;
|
||||
|
||||
if (type == PNG_STRUCT_INFO)
|
||||
size = png_sizeof(png_info);
|
||||
|
||||
else if (type == PNG_STRUCT_PNG)
|
||||
size = png_sizeof(png_struct);
|
||||
|
||||
else
|
||||
return (png_get_copyright(NULL));
|
||||
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (malloc_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
png_ptr->mem_ptr=mem_ptr;
|
||||
struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size);
|
||||
}
|
||||
|
||||
else
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
struct_ptr = (png_voidp)farmalloc(size);
|
||||
if (struct_ptr != NULL)
|
||||
png_memset(struct_ptr, 0, size);
|
||||
|
||||
return (struct_ptr);
|
||||
}
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
/* Free a png_struct */
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct(png_voidp struct_ptr)
|
||||
png_destroy_png_struct(png_structrp png_ptr)
|
||||
{
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_destroy_struct_2(struct_ptr, NULL, NULL);
|
||||
}
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
||||
png_voidp mem_ptr)
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
# endif
|
||||
if (struct_ptr != NULL)
|
||||
{
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (free_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
png_ptr->mem_ptr=mem_ptr;
|
||||
(*(free_fn))(png_ptr, struct_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
farfree (struct_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate memory. For reasonable files, size should never exceed
|
||||
* 64K. However, zlib may allocate more then 64K if you don't tell
|
||||
* it not to. See zconf.h and png.h for more information. zlib does
|
||||
* need to allocate exactly 64K, so whatever you call here must
|
||||
* have the ability to do that.
|
||||
*
|
||||
* Borland seems to have a problem in DOS mode for exactly 64K.
|
||||
* It gives you a segment with an offset of 8 (perhaps to store its
|
||||
* memory stuff). zlib doesn't like this at all, so we have to
|
||||
* detect and deal with it. This code should not be needed in
|
||||
* Windows or OS/2 modes, and only in 16 bit mode. This code has
|
||||
* been updated by Alexander Lehmann for version 0.89 to waste less
|
||||
* memory.
|
||||
*
|
||||
* Note that we can't use png_size_t for the "size" declaration,
|
||||
* since on some systems a png_size_t is a 16-bit quantity, and as a
|
||||
* result, we would be truncating potentially larger memory requests
|
||||
* (which should cause a fatal error) and introducing major problems.
|
||||
/* png_free might call png_error and may certainly call
|
||||
* png_get_mem_ptr, so fake a temporary png_struct to support this.
|
||||
*/
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_calloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
png_struct dummy_struct = *png_ptr;
|
||||
memset(png_ptr, 0, sizeof *png_ptr);
|
||||
png_free(&dummy_struct, png_ptr);
|
||||
|
||||
ret = (png_malloc(png_ptr, size));
|
||||
|
||||
if (ret != NULL)
|
||||
png_memset(ret,0,(png_size_t)size);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr->malloc_fn != NULL)
|
||||
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
|
||||
|
||||
else
|
||||
ret = (png_malloc_default(png_ptr, size));
|
||||
|
||||
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of memory");
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
|
||||
# ifdef PNG_MAX_MALLOC_64K
|
||||
if (size > (png_uint_32)65536L)
|
||||
{
|
||||
png_warning(png_ptr, "Cannot Allocate > 64K");
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
else
|
||||
# endif
|
||||
|
||||
if (size != (size_t)size)
|
||||
ret = NULL;
|
||||
|
||||
else if (size == (png_uint_32)65536L)
|
||||
{
|
||||
if (png_ptr->offset_table == NULL)
|
||||
{
|
||||
/* Try to see if we need to do any of this fancy stuff */
|
||||
ret = farmalloc(size);
|
||||
if (ret == NULL || ((png_size_t)ret & 0xffff))
|
||||
{
|
||||
int num_blocks;
|
||||
png_uint_32 total_size;
|
||||
png_bytep table;
|
||||
int i;
|
||||
png_byte huge * hptr;
|
||||
|
||||
if (ret != NULL)
|
||||
{
|
||||
farfree(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
if (png_ptr->zlib_window_bits > 14)
|
||||
num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14));
|
||||
|
||||
else
|
||||
num_blocks = 1;
|
||||
|
||||
if (png_ptr->zlib_mem_level >= 7)
|
||||
num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7));
|
||||
|
||||
else
|
||||
num_blocks++;
|
||||
|
||||
total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks+16;
|
||||
|
||||
table = farmalloc(total_size);
|
||||
|
||||
if (table == NULL)
|
||||
{
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out Of Memory"); /* Note "O", "M" */
|
||||
|
||||
else
|
||||
png_warning(png_ptr, "Out Of Memory");
|
||||
# endif
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if ((png_size_t)table & 0xfff0)
|
||||
{
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr,
|
||||
"Farmalloc didn't return normalized pointer");
|
||||
|
||||
else
|
||||
png_warning(png_ptr,
|
||||
"Farmalloc didn't return normalized pointer");
|
||||
# endif
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
png_ptr->offset_table = table;
|
||||
png_ptr->offset_table_ptr = farmalloc(num_blocks *
|
||||
png_sizeof(png_bytep));
|
||||
|
||||
if (png_ptr->offset_table_ptr == NULL)
|
||||
{
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out Of memory"); /* Note "O", "m" */
|
||||
|
||||
else
|
||||
png_warning(png_ptr, "Out Of memory");
|
||||
# endif
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
hptr = (png_byte huge *)table;
|
||||
if ((png_size_t)hptr & 0xf)
|
||||
{
|
||||
hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
|
||||
hptr = hptr + 16L; /* "hptr += 16L" fails on Turbo C++ 3.0 */
|
||||
}
|
||||
|
||||
for (i = 0; i < num_blocks; i++)
|
||||
{
|
||||
png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
|
||||
hptr = hptr + (png_uint_32)65536L; /* "+=" fails on TC++3.0 */
|
||||
}
|
||||
|
||||
png_ptr->offset_table_number = num_blocks;
|
||||
png_ptr->offset_table_count = 0;
|
||||
png_ptr->offset_table_count_free = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (png_ptr->offset_table_count >= png_ptr->offset_table_number)
|
||||
{
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of Memory"); /* Note "o" and "M" */
|
||||
|
||||
else
|
||||
png_warning(png_ptr, "Out of Memory");
|
||||
# endif
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++];
|
||||
}
|
||||
|
||||
else
|
||||
ret = farmalloc(size);
|
||||
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if (ret == NULL)
|
||||
{
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of memory"); /* Note "o" and "m" */
|
||||
|
||||
else
|
||||
png_warning(png_ptr, "Out of memory"); /* Note "o" and "m" */
|
||||
}
|
||||
# endif
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/* Free a pointer allocated by png_malloc(). In the default
|
||||
* configuration, png_ptr is not used, but is passed in case it
|
||||
* is needed. If ptr is NULL, return without taking any action.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_free(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr->free_fn != NULL)
|
||||
{
|
||||
(*(png_ptr->free_fn))(png_ptr, ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
else
|
||||
png_free_default(png_ptr, ptr);
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
|
||||
if (png_ptr->offset_table != NULL)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < png_ptr->offset_table_count; i++)
|
||||
{
|
||||
if (ptr == png_ptr->offset_table_ptr[i])
|
||||
{
|
||||
ptr = NULL;
|
||||
png_ptr->offset_table_count_free++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (png_ptr->offset_table_count_free == png_ptr->offset_table_count)
|
||||
{
|
||||
farfree(png_ptr->offset_table);
|
||||
farfree(png_ptr->offset_table_ptr);
|
||||
png_ptr->offset_table = NULL;
|
||||
png_ptr->offset_table_ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (ptr != NULL)
|
||||
farfree(ptr);
|
||||
}
|
||||
|
||||
#else /* Not the Borland DOS special memory handler */
|
||||
|
||||
/* Allocate memory for a png_struct or a png_info. The malloc and
|
||||
memset can be replaced by a single call to calloc() if this is thought
|
||||
to improve performance noticably. */
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_create_struct,(int type),PNG_ALLOCATED)
|
||||
{
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
return (png_create_struct_2(type, NULL, NULL));
|
||||
}
|
||||
|
||||
/* Allocate memory for a png_struct or a png_info. The malloc and
|
||||
memset can be replaced by a single call to calloc() if this is thought
|
||||
to improve performance noticably. */
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_create_struct_2,(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr),
|
||||
PNG_ALLOCATED)
|
||||
{
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
png_size_t size;
|
||||
png_voidp struct_ptr;
|
||||
|
||||
if (type == PNG_STRUCT_INFO)
|
||||
size = png_sizeof(png_info);
|
||||
|
||||
else if (type == PNG_STRUCT_PNG)
|
||||
size = png_sizeof(png_struct);
|
||||
|
||||
else
|
||||
return (NULL);
|
||||
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (malloc_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
png_ptr->mem_ptr=mem_ptr;
|
||||
struct_ptr = (*(malloc_fn))(png_ptr, size);
|
||||
|
||||
if (struct_ptr != NULL)
|
||||
png_memset(struct_ptr, 0, size);
|
||||
|
||||
return (struct_ptr);
|
||||
}
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
struct_ptr = (png_voidp)farmalloc(size);
|
||||
# else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
struct_ptr = (png_voidp)halloc(size, 1);
|
||||
# else
|
||||
struct_ptr = (png_voidp)malloc(size);
|
||||
# endif
|
||||
# endif
|
||||
|
||||
if (struct_ptr != NULL)
|
||||
png_memset(struct_ptr, 0, size);
|
||||
|
||||
return (struct_ptr);
|
||||
}
|
||||
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct(png_voidp struct_ptr)
|
||||
{
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_destroy_struct_2(struct_ptr, NULL, NULL);
|
||||
}
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
||||
png_voidp mem_ptr)
|
||||
{
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
if (struct_ptr != NULL)
|
||||
{
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (free_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
png_ptr->mem_ptr=mem_ptr;
|
||||
(*(free_fn))(png_ptr, struct_ptr);
|
||||
return;
|
||||
}
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
farfree(struct_ptr);
|
||||
|
||||
# else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
hfree(struct_ptr);
|
||||
|
||||
# else
|
||||
free(struct_ptr);
|
||||
|
||||
# endif
|
||||
# ifdef PNG_SETJMP_SUPPORTED
|
||||
/* We may have a jmp_buf left to deallocate. */
|
||||
png_free_jmpbuf(&dummy_struct);
|
||||
# endif
|
||||
}
|
||||
}
|
||||
@@ -471,167 +46,149 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
||||
* need to allocate exactly 64K, so whatever you call here must
|
||||
* have the ability to do that.
|
||||
*/
|
||||
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_calloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
png_calloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
ret = (png_malloc(png_ptr, size));
|
||||
ret = png_malloc(png_ptr, size);
|
||||
|
||||
if (ret != NULL)
|
||||
png_memset(ret,0,(png_size_t)size);
|
||||
png_memset(ret, 0, size);
|
||||
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
/* png_malloc_base, an internal function added at libpng 1.6.0, does the work of
|
||||
* allocating memory, taking into account limits and PNG_USER_MEM_SUPPORTED.
|
||||
* Checking and error handling must happen outside this routine; it returns NULL
|
||||
* if the allocation cannot be done (for any reason.)
|
||||
*/
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
/* Moved to png_malloc_base from png_malloc_default in 1.6.0; the DOS
|
||||
* allocators have also been removed in 1.6.0, so any 16-bit system now has
|
||||
* to implement a user memory handler. This checks to be sure it isn't
|
||||
* called with big numbers.
|
||||
*/
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
|
||||
if (png_ptr->malloc_fn != NULL)
|
||||
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
|
||||
|
||||
else
|
||||
ret = (png_malloc_default(png_ptr, size));
|
||||
|
||||
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
|
||||
PNG_UNUSED(png_ptr)
|
||||
#endif
|
||||
if (size > 0 && size <= ~(size_t)0
|
||||
# ifdef PNG_MAX_MALLOC_64K
|
||||
if (size > (png_uint_32)65536L)
|
||||
&& size <= 65536U
|
||||
# endif
|
||||
)
|
||||
{
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Cannot Allocate > 64K");
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr != NULL && png_ptr->malloc_fn != NULL)
|
||||
return png_ptr->malloc_fn(png_constcast(png_structrp,png_ptr), size);
|
||||
|
||||
else
|
||||
#endif
|
||||
return malloc((size_t)size); /* checked for truncation above */
|
||||
}
|
||||
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Check for overflow */
|
||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
/* Various functions that have different error handling are derived from this.
|
||||
* png_malloc always exists, but if PNG_USER_MEM_SUPPORTED is defined a separate
|
||||
* function png_malloc_default is also provided.
|
||||
*/
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
if (size != (unsigned long)size)
|
||||
ret = NULL;
|
||||
if (png_ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
else
|
||||
ret = farmalloc(size);
|
||||
ret = png_malloc_base(png_ptr, size);
|
||||
|
||||
# else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
if (size != (unsigned long)size)
|
||||
ret = NULL;
|
||||
if (ret == NULL)
|
||||
png_error(png_ptr, "Out of memory"); /* 'm' means png_malloc */
|
||||
|
||||
else
|
||||
ret = halloc(size, 1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
# else
|
||||
if (size != (size_t)size)
|
||||
ret = NULL;
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
PNG_ALLOCATED PNG_DEPRECATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
else
|
||||
ret = malloc((size_t)size);
|
||||
# endif
|
||||
# endif
|
||||
if (png_ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
# endif
|
||||
/* Passing 'NULL' here bypasses the application provided memory handler. */
|
||||
ret = png_malloc_base(NULL/*use malloc*/, size);
|
||||
|
||||
return (ret);
|
||||
if (ret == NULL)
|
||||
png_error(png_ptr, "Out of Memory"); /* 'M' means png_malloc_default */
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
/* This function was added at libpng version 1.2.3. The png_malloc_warn()
|
||||
* function will issue a png_warning and return NULL instead of issuing a
|
||||
* png_error, if it fails to allocate the requested memory.
|
||||
*/
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc_warn,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
PNG_ALLOCATED)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
png_voidp ret = png_malloc_base(png_ptr, size);
|
||||
|
||||
if (ret != NULL)
|
||||
return ret;
|
||||
|
||||
png_warning(png_ptr, "Out of memory");
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Free a pointer allocated by png_malloc(). If ptr is NULL, return
|
||||
* without taking any action.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_free(png_structp png_ptr, png_voidp ptr)
|
||||
png_free(png_const_structrp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr->free_fn != NULL)
|
||||
{
|
||||
(*(png_ptr->free_fn))(png_ptr, ptr);
|
||||
return;
|
||||
}
|
||||
png_ptr->free_fn(png_constcast(png_structrp,png_ptr), ptr);
|
||||
|
||||
else
|
||||
png_free_default(png_ptr, ptr);
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_free_default,(png_const_structrp png_ptr, png_voidp ptr),PNG_DEPRECATED)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
farfree(ptr);
|
||||
|
||||
# else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
hfree(ptr);
|
||||
|
||||
# else
|
||||
free(ptr);
|
||||
|
||||
# endif
|
||||
# endif
|
||||
}
|
||||
#endif /* Not Borland DOS special memory handler */
|
||||
|
||||
/* This function was added at libpng version 1.2.3. The png_malloc_warn()
|
||||
* function will set up png_malloc() to issue a png_warning and return NULL
|
||||
* instead of issuing a png_error, if it fails to allocate the requested
|
||||
* memory.
|
||||
*/
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc_warn,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ptr;
|
||||
png_uint_32 save_flags;
|
||||
if (png_ptr == NULL)
|
||||
return (NULL);
|
||||
|
||||
save_flags = png_ptr->flags;
|
||||
png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
|
||||
ptr = (png_voidp)png_malloc((png_structp)png_ptr, size);
|
||||
png_ptr->flags=save_flags;
|
||||
return(ptr);
|
||||
}
|
||||
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
/* This function is called when the application wants to use another method
|
||||
* of allocating and freeing memory.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||
png_set_mem_fn(png_structrp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||
malloc_fn, png_free_ptr free_fn)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
@@ -647,12 +204,12 @@ png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||
* pointer before png_write_destroy and png_read_destroy are called.
|
||||
*/
|
||||
png_voidp PNGAPI
|
||||
png_get_mem_ptr(png_const_structp png_ptr)
|
||||
png_get_mem_ptr(png_const_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return (NULL);
|
||||
return NULL;
|
||||
|
||||
return ((png_voidp)png_ptr->mem_ptr);
|
||||
return png_ptr->mem_ptr;
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
|
||||
304
pngpread.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* Last changed in libpng 1.5.1 [February 3, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -27,7 +27,7 @@
|
||||
#define PNG_ERROR_MODE 8
|
||||
|
||||
void PNGAPI
|
||||
png_process_data(png_structp png_ptr, png_infop info_ptr,
|
||||
png_process_data(png_structrp png_ptr, png_inforp info_ptr,
|
||||
png_bytep buffer, png_size_t buffer_size)
|
||||
{
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
@@ -42,7 +42,7 @@ png_process_data(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
|
||||
png_size_t PNGAPI
|
||||
png_process_data_pause(png_structp png_ptr, int save)
|
||||
png_process_data_pause(png_structrp png_ptr, int save)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
@@ -69,7 +69,7 @@ png_process_data_pause(png_structp png_ptr, int save)
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_process_data_skip(png_structp png_ptr)
|
||||
png_process_data_skip(png_structrp png_ptr)
|
||||
{
|
||||
png_uint_32 remaining = 0;
|
||||
|
||||
@@ -103,7 +103,7 @@ png_process_data_skip(png_structp png_ptr)
|
||||
* doing before we ran out of data...
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_process_some_data(png_structp png_ptr, png_infop info_ptr)
|
||||
png_process_some_data(png_structrp png_ptr, png_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
@@ -173,7 +173,7 @@ png_process_some_data(png_structp png_ptr, png_infop info_ptr)
|
||||
* routine.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
|
||||
png_push_read_sig(png_structrp png_ptr, png_inforp info_ptr)
|
||||
{
|
||||
png_size_t num_checked = png_ptr->sig_bytes,
|
||||
num_to_check = 8 - num_checked;
|
||||
@@ -206,63 +206,9 @@ png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
{
|
||||
PNG_IHDR;
|
||||
PNG_IDAT;
|
||||
PNG_IEND;
|
||||
PNG_PLTE;
|
||||
#ifdef PNG_READ_bKGD_SUPPORTED
|
||||
PNG_bKGD;
|
||||
#endif
|
||||
#ifdef PNG_READ_cHRM_SUPPORTED
|
||||
PNG_cHRM;
|
||||
#endif
|
||||
#ifdef PNG_READ_gAMA_SUPPORTED
|
||||
PNG_gAMA;
|
||||
#endif
|
||||
#ifdef PNG_READ_hIST_SUPPORTED
|
||||
PNG_hIST;
|
||||
#endif
|
||||
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||
PNG_iCCP;
|
||||
#endif
|
||||
#ifdef PNG_READ_iTXt_SUPPORTED
|
||||
PNG_iTXt;
|
||||
#endif
|
||||
#ifdef PNG_READ_oFFs_SUPPORTED
|
||||
PNG_oFFs;
|
||||
#endif
|
||||
#ifdef PNG_READ_pCAL_SUPPORTED
|
||||
PNG_pCAL;
|
||||
#endif
|
||||
#ifdef PNG_READ_pHYs_SUPPORTED
|
||||
PNG_pHYs;
|
||||
#endif
|
||||
#ifdef PNG_READ_sBIT_SUPPORTED
|
||||
PNG_sBIT;
|
||||
#endif
|
||||
#ifdef PNG_READ_sCAL_SUPPORTED
|
||||
PNG_sCAL;
|
||||
#endif
|
||||
#ifdef PNG_READ_sRGB_SUPPORTED
|
||||
PNG_sRGB;
|
||||
#endif
|
||||
#ifdef PNG_READ_sPLT_SUPPORTED
|
||||
PNG_sPLT;
|
||||
#endif
|
||||
#ifdef PNG_READ_tEXt_SUPPORTED
|
||||
PNG_tEXt;
|
||||
#endif
|
||||
#ifdef PNG_READ_tIME_SUPPORTED
|
||||
PNG_tIME;
|
||||
#endif
|
||||
#ifdef PNG_READ_tRNS_SUPPORTED
|
||||
PNG_tRNS;
|
||||
#endif
|
||||
#ifdef PNG_READ_zTXt_SUPPORTED
|
||||
PNG_zTXt;
|
||||
#endif
|
||||
png_uint_32 chunk_name;
|
||||
|
||||
/* First we make sure we have enough data for the 4 byte chunk name
|
||||
* and the 4 byte chunk length before proceeding with decoding the
|
||||
@@ -273,6 +219,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
|
||||
{
|
||||
png_byte chunk_length[4];
|
||||
png_byte chunk_tag[4];
|
||||
|
||||
if (png_ptr->buffer_size < 8)
|
||||
{
|
||||
@@ -283,16 +230,27 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
png_push_fill_buffer(png_ptr, chunk_length, 4);
|
||||
png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
|
||||
png_reset_crc(png_ptr);
|
||||
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
|
||||
png_crc_read(png_ptr, chunk_tag, 4);
|
||||
png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
|
||||
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
|
||||
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
|
||||
}
|
||||
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
chunk_name = png_ptr->chunk_name;
|
||||
|
||||
if (chunk_name == png_IDAT)
|
||||
{
|
||||
/* This is here above the if/else case statement below because if the
|
||||
* unknown handling marks 'IDAT' as unknown then the IDAT handling case is
|
||||
* completely skipped.
|
||||
*
|
||||
* TODO: there must be a better way of doing this.
|
||||
*/
|
||||
if (png_ptr->mode & PNG_AFTER_IDAT)
|
||||
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
|
||||
}
|
||||
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
|
||||
if (chunk_name == png_IHDR)
|
||||
{
|
||||
if (png_ptr->push_length != 13)
|
||||
png_error(png_ptr, "Invalid IHDR length");
|
||||
@@ -306,7 +264,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
|
||||
else if (chunk_name == png_IEND)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@@ -321,7 +279,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
}
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name))
|
||||
else if (png_chunk_unknown_handling(png_ptr, chunk_name))
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@@ -329,15 +287,15 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
if (chunk_name == png_IDAT)
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
|
||||
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);
|
||||
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
||||
if (chunk_name == png_PLTE)
|
||||
png_ptr->mode |= PNG_HAVE_PLTE;
|
||||
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
else if (chunk_name == png_IDAT)
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
png_error(png_ptr, "Missing IHDR before IDAT");
|
||||
@@ -349,7 +307,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
}
|
||||
|
||||
#endif
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
||||
else if (chunk_name == png_PLTE)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@@ -359,7 +317,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
else if (chunk_name == png_IDAT)
|
||||
{
|
||||
/* If we reach an IDAT chunk, this means we have read all of the
|
||||
* header chunks, and we can start reading the image (or if this
|
||||
@@ -395,7 +353,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_gAMA_SUPPORTED
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4))
|
||||
else if (png_ptr->chunk_name == png_gAMA)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@@ -408,7 +366,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_sBIT_SUPPORTED
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4))
|
||||
else if (png_ptr->chunk_name == png_sBIT)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@@ -421,7 +379,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_cHRM_SUPPORTED
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4))
|
||||
else if (png_ptr->chunk_name == png_cHRM)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@@ -434,7 +392,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_sRGB_SUPPORTED
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4))
|
||||
else if (chunk_name == png_sRGB)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@@ -447,7 +405,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4))
|
||||
else if (png_ptr->chunk_name == png_iCCP)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@@ -460,7 +418,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_sPLT_SUPPORTED
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4))
|
||||
else if (chunk_name == png_sPLT)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@@ -473,7 +431,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_tRNS_SUPPORTED
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4))
|
||||
else if (chunk_name == png_tRNS)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@@ -486,7 +444,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_bKGD_SUPPORTED
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4))
|
||||
else if (chunk_name == png_bKGD)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@@ -499,7 +457,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_hIST_SUPPORTED
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4))
|
||||
else if (chunk_name == png_hIST)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@@ -512,7 +470,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_pHYs_SUPPORTED
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4))
|
||||
else if (chunk_name == png_pHYs)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@@ -525,7 +483,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_oFFs_SUPPORTED
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4))
|
||||
else if (chunk_name == png_oFFs)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@@ -538,7 +496,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_pCAL_SUPPORTED
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4))
|
||||
else if (chunk_name == png_pCAL)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@@ -551,7 +509,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_sCAL_SUPPORTED
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4))
|
||||
else if (chunk_name == png_sCAL)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@@ -564,7 +522,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_tIME_SUPPORTED
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4))
|
||||
else if (chunk_name == png_tIME)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@@ -577,7 +535,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_tEXt_SUPPORTED
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
|
||||
else if (chunk_name == png_tEXt)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@@ -590,7 +548,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_zTXt_SUPPORTED
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
|
||||
else if (chunk_name == png_zTXt)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@@ -603,7 +561,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_iTXt_SUPPORTED
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
|
||||
else if (chunk_name == png_iTXt)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@@ -629,14 +587,14 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_push_crc_skip(png_structp png_ptr, png_uint_32 skip)
|
||||
png_push_crc_skip(png_structrp png_ptr, png_uint_32 skip)
|
||||
{
|
||||
png_ptr->process_mode = PNG_SKIP_MODE;
|
||||
png_ptr->skip_length = skip;
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_push_crc_finish(png_structp png_ptr)
|
||||
png_push_crc_finish(png_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr->skip_length && png_ptr->save_buffer_size)
|
||||
{
|
||||
@@ -740,7 +698,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_push_save_buffer(png_structp png_ptr)
|
||||
png_push_save_buffer(png_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr->save_buffer_size)
|
||||
{
|
||||
@@ -797,7 +755,7 @@ png_push_save_buffer(png_structp png_ptr)
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_push_restore_buffer(png_structp png_ptr, png_bytep buffer,
|
||||
png_push_restore_buffer(png_structrp png_ptr, png_bytep buffer,
|
||||
png_size_t buffer_length)
|
||||
{
|
||||
png_ptr->current_buffer = buffer;
|
||||
@@ -807,13 +765,14 @@ png_push_restore_buffer(png_structp png_ptr, png_bytep buffer,
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_push_read_IDAT(png_structp png_ptr)
|
||||
png_push_read_IDAT(png_structrp png_ptr)
|
||||
{
|
||||
PNG_IDAT;
|
||||
if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
|
||||
{
|
||||
png_byte chunk_length[4];
|
||||
png_byte chunk_tag[4];
|
||||
|
||||
/* TODO: this code can be commoned up with the same code in push_read */
|
||||
if (png_ptr->buffer_size < 8)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
@@ -823,10 +782,11 @@ png_push_read_IDAT(png_structp png_ptr)
|
||||
png_push_fill_buffer(png_ptr, chunk_length, 4);
|
||||
png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
|
||||
png_reset_crc(png_ptr);
|
||||
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
|
||||
png_crc_read(png_ptr, chunk_tag, 4);
|
||||
png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
|
||||
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
|
||||
|
||||
if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
if (png_ptr->chunk_name != png_IDAT)
|
||||
{
|
||||
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
|
||||
|
||||
@@ -838,6 +798,7 @@ png_push_read_IDAT(png_structp png_ptr)
|
||||
|
||||
png_ptr->idat_size = png_ptr->push_length;
|
||||
}
|
||||
|
||||
if (png_ptr->idat_size && png_ptr->save_buffer_size)
|
||||
{
|
||||
png_size_t save_size = png_ptr->save_buffer_size;
|
||||
@@ -905,7 +866,7 @@ png_push_read_IDAT(png_structp png_ptr)
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
|
||||
png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
|
||||
png_size_t buffer_length)
|
||||
{
|
||||
/* The caller checks for a non-zero buffer length. */
|
||||
@@ -1009,36 +970,58 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_push_process_row(png_structp png_ptr)
|
||||
png_push_process_row(png_structrp png_ptr)
|
||||
{
|
||||
png_ptr->row_info.color_type = png_ptr->color_type;
|
||||
png_ptr->row_info.width = png_ptr->iwidth;
|
||||
png_ptr->row_info.channels = png_ptr->channels;
|
||||
png_ptr->row_info.bit_depth = png_ptr->bit_depth;
|
||||
png_ptr->row_info.pixel_depth = png_ptr->pixel_depth;
|
||||
/* 1.5.6: row_info moved out of png_struct to a local here. */
|
||||
png_row_info row_info;
|
||||
|
||||
png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
|
||||
png_ptr->row_info.width);
|
||||
row_info.width = png_ptr->iwidth; /* NOTE: width of current interlaced row */
|
||||
row_info.color_type = png_ptr->color_type;
|
||||
row_info.bit_depth = png_ptr->bit_depth;
|
||||
row_info.channels = png_ptr->channels;
|
||||
row_info.pixel_depth = png_ptr->pixel_depth;
|
||||
row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);
|
||||
|
||||
png_read_filter_row(png_ptr, &(png_ptr->row_info),
|
||||
png_ptr->row_buf + 1, png_ptr->prev_row + 1,
|
||||
(int)(png_ptr->row_buf[0]));
|
||||
if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE)
|
||||
{
|
||||
if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST)
|
||||
png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1,
|
||||
png_ptr->prev_row + 1, png_ptr->row_buf[0]);
|
||||
else
|
||||
png_error(png_ptr, "bad adaptive filter value");
|
||||
}
|
||||
|
||||
png_memcpy(png_ptr->prev_row, png_ptr->row_buf, png_ptr->rowbytes + 1);
|
||||
/* libpng 1.5.6: the following line was copying png_ptr->rowbytes before
|
||||
* 1.5.6, while the buffer really is this big in current versions of libpng
|
||||
* it may not be in the future, so this was changed just to copy the
|
||||
* interlaced row count:
|
||||
*/
|
||||
png_memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
|
||||
|
||||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||
if (png_ptr->transformations)
|
||||
png_do_read_transformations(png_ptr, &row_info);
|
||||
#endif
|
||||
|
||||
/* The transformed pixel depth should match the depth now in row_info. */
|
||||
if (png_ptr->transformed_pixel_depth == 0)
|
||||
{
|
||||
png_ptr->transformed_pixel_depth = row_info.pixel_depth;
|
||||
if (row_info.pixel_depth > png_ptr->maximum_pixel_depth)
|
||||
png_error(png_ptr, "progressive row overflow");
|
||||
}
|
||||
|
||||
else if (png_ptr->transformed_pixel_depth != row_info.pixel_depth)
|
||||
png_error(png_ptr, "internal progressive row size calculation error");
|
||||
|
||||
if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA))
|
||||
png_do_read_transformations(png_ptr);
|
||||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
/* Blow up interlaced rows to full size */
|
||||
if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
|
||||
{
|
||||
if (png_ptr->pass < 6)
|
||||
/* old interface (pre-1.0.9):
|
||||
png_do_read_interlace(&(png_ptr->row_info),
|
||||
png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations);
|
||||
*/
|
||||
png_do_read_interlace(png_ptr);
|
||||
png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass,
|
||||
png_ptr->transformations);
|
||||
|
||||
switch (png_ptr->pass)
|
||||
{
|
||||
@@ -1216,25 +1199,25 @@ png_push_process_row(png_structp png_ptr)
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_read_push_finish_row(png_structp png_ptr)
|
||||
png_read_push_finish_row(png_structrp png_ptr)
|
||||
{
|
||||
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||
|
||||
/* Start of interlace block */
|
||||
PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
|
||||
static PNG_CONST png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
|
||||
|
||||
/* Offset to next interlace block */
|
||||
PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
static PNG_CONST png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
|
||||
/* Start of interlace block in the y direction */
|
||||
PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
|
||||
static PNG_CONST png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
|
||||
|
||||
/* Offset to next interlace block in the y direction */
|
||||
PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
||||
static PNG_CONST png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
||||
|
||||
/* Height of interlace block. This is not currently used - if you need
|
||||
* it, uncomment it here and in png.h
|
||||
PNG_CONST int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
static PNG_CONST png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
*/
|
||||
|
||||
png_ptr->row_number++;
|
||||
@@ -1281,7 +1264,7 @@ png_read_push_finish_row(png_structp png_ptr)
|
||||
|
||||
#ifdef PNG_READ_tEXt_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
||||
png_push_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32
|
||||
length)
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
|
||||
@@ -1312,7 +1295,7 @@ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
|
||||
png_push_read_tEXt(png_structrp png_ptr, png_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr->buffer_size && png_ptr->current_text_left)
|
||||
{
|
||||
@@ -1378,7 +1361,7 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
#ifdef PNG_READ_zTXt_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
||||
png_push_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32
|
||||
length)
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
|
||||
@@ -1411,7 +1394,7 @@ png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
||||
png_push_read_zTXt(png_structrp png_ptr, png_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr->buffer_size && png_ptr->current_text_left)
|
||||
{
|
||||
@@ -1582,7 +1565,7 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
#ifdef PNG_READ_iTXt_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
||||
png_push_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32
|
||||
length)
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
|
||||
@@ -1613,7 +1596,7 @@ png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
|
||||
png_push_read_iTXt(png_structrp png_ptr, png_inforp info_ptr)
|
||||
{
|
||||
|
||||
if (png_ptr->buffer_size && png_ptr->current_text_left)
|
||||
@@ -1708,15 +1691,16 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
|
||||
* name or a critical chunk), the chunk is (currently) silently ignored.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
||||
png_push_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, png_uint_32
|
||||
length)
|
||||
{
|
||||
png_uint_32 skip = 0;
|
||||
png_uint_32 chunk_name = png_ptr->chunk_name;
|
||||
|
||||
if (!(png_ptr->chunk_name[0] & 0x20))
|
||||
if (PNG_CHUNK_CRITICAL(chunk_name))
|
||||
{
|
||||
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
|
||||
if (png_chunk_unknown_handling(png_ptr, chunk_name) !=
|
||||
PNG_HANDLE_CHUNK_ALWAYS
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
&& png_ptr->read_user_chunk_fn == NULL
|
||||
@@ -1729,22 +1713,26 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* TODO: the code below is apparently just using the
|
||||
* png_struct::unknown_chunk member as a temporarily variable, it should be
|
||||
* possible to eliminate both it and the temporary buffer.
|
||||
*/
|
||||
if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
|
||||
{
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
if (length > (png_uint_32)65535L)
|
||||
if (length > 65535)
|
||||
{
|
||||
png_warning(png_ptr, "unknown chunk too large to fit in memory");
|
||||
skip = length - (png_uint_32)65535L;
|
||||
length = (png_uint_32)65535L;
|
||||
skip = length - 65535;
|
||||
length = 65535;
|
||||
}
|
||||
#endif
|
||||
png_memcpy((png_charp)png_ptr->unknown_chunk.name,
|
||||
(png_charp)png_ptr->chunk_name,
|
||||
png_sizeof(png_ptr->unknown_chunk.name));
|
||||
png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name) - 1]
|
||||
= '\0';
|
||||
/* This is just a record for the user; libpng doesn't use the character
|
||||
* form of the name.
|
||||
*/
|
||||
PNG_CSTRING_FROM_CHUNK(png_ptr->unknown_chunk.name, png_ptr->chunk_name);
|
||||
|
||||
/* The following cast should be safe because of the check above. */
|
||||
png_ptr->unknown_chunk.size = (png_size_t)length;
|
||||
|
||||
if (length == 0)
|
||||
@@ -1753,8 +1741,9 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
||||
else
|
||||
{
|
||||
png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr,
|
||||
(png_size_t)length);
|
||||
png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length);
|
||||
png_ptr->unknown_chunk.size);
|
||||
png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data,
|
||||
png_ptr->unknown_chunk.size);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
@@ -1770,8 +1759,8 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
||||
|
||||
if (ret == 0)
|
||||
{
|
||||
if (!(png_ptr->chunk_name[0] & 0x20))
|
||||
if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
|
||||
if (PNG_CHUNK_CRITICAL(png_ptr->chunk_name))
|
||||
if (png_chunk_unknown_handling(png_ptr, chunk_name) !=
|
||||
PNG_HANDLE_CHUNK_ALWAYS)
|
||||
png_chunk_error(png_ptr, "unknown critical chunk");
|
||||
png_set_unknown_chunks(png_ptr, info_ptr,
|
||||
@@ -1793,43 +1782,46 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_push_have_info(png_structp png_ptr, png_infop info_ptr)
|
||||
png_push_have_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr->info_fn != NULL)
|
||||
(*(png_ptr->info_fn))(png_ptr, info_ptr);
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_push_have_end(png_structp png_ptr, png_infop info_ptr)
|
||||
png_push_have_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr->end_fn != NULL)
|
||||
(*(png_ptr->end_fn))(png_ptr, info_ptr);
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_push_have_row(png_structp png_ptr, png_bytep row)
|
||||
png_push_have_row(png_structrp png_ptr, png_bytep row)
|
||||
{
|
||||
if (png_ptr->row_fn != NULL)
|
||||
(*(png_ptr->row_fn))(png_ptr, row, png_ptr->row_number,
|
||||
(int)png_ptr->pass);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
void PNGAPI
|
||||
png_progressive_combine_row (png_structp png_ptr, png_bytep old_row,
|
||||
png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row,
|
||||
png_const_bytep new_row)
|
||||
{
|
||||
PNG_CONST int FARDATA png_pass_dsp_mask[7] =
|
||||
{0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */
|
||||
png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]);
|
||||
/* new_row is a flag here - if it is NULL then the app callback was called
|
||||
* from an empty row (see the calls to png_struct::row_fn below), otherwise
|
||||
* it must be png_ptr->row_buf+1
|
||||
*/
|
||||
if (new_row != NULL)
|
||||
png_combine_row(png_ptr, old_row, 1/*display*/);
|
||||
}
|
||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
|
||||
void PNGAPI
|
||||
png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr,
|
||||
png_set_progressive_read_fn(png_structrp png_ptr, png_voidp progressive_ptr,
|
||||
png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
|
||||
png_progressive_end_ptr end_fn)
|
||||
{
|
||||
@@ -1844,7 +1836,7 @@ png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr,
|
||||
}
|
||||
|
||||
png_voidp PNGAPI
|
||||
png_get_progressive_ptr(png_const_structp png_ptr)
|
||||
png_get_progressive_ptr(png_const_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return (NULL);
|
||||
|
||||
68
pngrio.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -29,7 +29,7 @@
|
||||
* to read more then 64K on a 16 bit machine.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
png_read_data(png_structrp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_debug1(4, "reading %d bytes", (int)length);
|
||||
|
||||
@@ -46,7 +46,6 @@ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
* read_data function and use it at run time with png_set_read_fn(), rather
|
||||
* than changing the library.
|
||||
*/
|
||||
# ifndef USE_FAR_KEYWORD
|
||||
void PNGCBAPI
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
@@ -58,68 +57,11 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
|
||||
* instead of an int, which is what fread() actually returns.
|
||||
*/
|
||||
check = fread(data, 1, length, (png_FILE_p)png_ptr->io_ptr);
|
||||
check = fread(data, 1, length, png_voidcast(png_FILE_p, png_ptr->io_ptr));
|
||||
|
||||
if (check != length)
|
||||
png_error(png_ptr, "Read Error");
|
||||
}
|
||||
# else
|
||||
/* This is the model-independent version. Since the standard I/O library
|
||||
can't handle far buffers in the medium and small models, we have to copy
|
||||
the data.
|
||||
*/
|
||||
|
||||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
static void PNGCBAPI
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_size_t check;
|
||||
png_byte *n_data;
|
||||
png_FILE_p io_ptr;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
n_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
||||
|
||||
if ((png_bytep)n_data == data)
|
||||
{
|
||||
check = fread(n_data, 1, length, io_ptr);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_byte buf[NEAR_BUF_SIZE];
|
||||
png_size_t read, remaining, err;
|
||||
check = 0;
|
||||
remaining = length;
|
||||
|
||||
do
|
||||
{
|
||||
read = MIN(NEAR_BUF_SIZE, remaining);
|
||||
err = fread(buf, 1, read, io_ptr);
|
||||
png_memcpy(data, buf, read); /* copy far buffer to near buffer */
|
||||
|
||||
if (err != read)
|
||||
break;
|
||||
|
||||
else
|
||||
check += err;
|
||||
|
||||
data += read;
|
||||
remaining -= read;
|
||||
}
|
||||
while (remaining != 0);
|
||||
}
|
||||
|
||||
if ((png_uint_32)check != (png_uint_32)length)
|
||||
png_error(png_ptr, "read Error");
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* This function allows the application to supply a new input function
|
||||
@@ -142,7 +84,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
* be used.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr read_data_fn)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
|
||||
2446
pngrtran.c
1469
pngrutil.c
334
pngset.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* Last changed in libpng 1.5.1 [February 3, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -22,22 +22,22 @@
|
||||
|
||||
#ifdef PNG_bKGD_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_bKGD(png_structp png_ptr, png_infop info_ptr,
|
||||
png_set_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_const_color_16p background)
|
||||
{
|
||||
png_debug1(1, "in %s storage function", "bKGD");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL || background == NULL)
|
||||
return;
|
||||
|
||||
png_memcpy(&(info_ptr->background), background, png_sizeof(png_color_16));
|
||||
info_ptr->background = *background;
|
||||
info_ptr->valid |= PNG_INFO_bKGD;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_cHRM_SUPPORTED
|
||||
void PNGFAPI
|
||||
png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
|
||||
png_set_cHRM_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x,
|
||||
png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y,
|
||||
png_fixed_point blue_x, png_fixed_point blue_y)
|
||||
@@ -64,9 +64,42 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
}
|
||||
|
||||
void PNGFAPI
|
||||
png_set_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_fixed_point int_red_X, png_fixed_point int_red_Y,
|
||||
png_fixed_point int_red_Z, png_fixed_point int_green_X,
|
||||
png_fixed_point int_green_Y, png_fixed_point int_green_Z,
|
||||
png_fixed_point int_blue_X, png_fixed_point int_blue_Y,
|
||||
png_fixed_point int_blue_Z)
|
||||
{
|
||||
png_XYZ XYZ;
|
||||
png_xy xy;
|
||||
|
||||
png_debug1(1, "in %s storage function", "cHRM XYZ fixed");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
XYZ.redX = int_red_X;
|
||||
XYZ.redY = int_red_Y;
|
||||
XYZ.redZ = int_red_Z;
|
||||
XYZ.greenX = int_green_X;
|
||||
XYZ.greenY = int_green_Y;
|
||||
XYZ.greenZ = int_green_Z;
|
||||
XYZ.blueX = int_blue_X;
|
||||
XYZ.blueY = int_blue_Y;
|
||||
XYZ.blueZ = int_blue_Z;
|
||||
|
||||
if (png_xy_from_XYZ(&xy, XYZ))
|
||||
png_error(png_ptr, "XYZ values out of representable range");
|
||||
|
||||
png_set_cHRM_fixed(png_ptr, info_ptr, xy.whitex, xy.whitey, xy.redx, xy.redy,
|
||||
xy.greenx, xy.greeny, xy.bluex, xy.bluey);
|
||||
}
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
png_set_cHRM(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
double white_x, double white_y, double red_x, double red_y,
|
||||
double green_x, double green_y, double blue_x, double blue_y)
|
||||
{
|
||||
@@ -80,29 +113,47 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
png_fixed(png_ptr, blue_x, "cHRM Blue X"),
|
||||
png_fixed(png_ptr, blue_y, "cHRM Blue Y"));
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X,
|
||||
double red_Y, double red_Z, double green_X, double green_Y, double green_Z,
|
||||
double blue_X, double blue_Y, double blue_Z)
|
||||
{
|
||||
png_set_cHRM_XYZ_fixed(png_ptr, info_ptr,
|
||||
png_fixed(png_ptr, red_X, "cHRM Red X"),
|
||||
png_fixed(png_ptr, red_Y, "cHRM Red Y"),
|
||||
png_fixed(png_ptr, red_Z, "cHRM Red Z"),
|
||||
png_fixed(png_ptr, green_X, "cHRM Red X"),
|
||||
png_fixed(png_ptr, green_Y, "cHRM Red Y"),
|
||||
png_fixed(png_ptr, green_Z, "cHRM Red Z"),
|
||||
png_fixed(png_ptr, blue_X, "cHRM Red X"),
|
||||
png_fixed(png_ptr, blue_Y, "cHRM Red Y"),
|
||||
png_fixed(png_ptr, blue_Z, "cHRM Red Z"));
|
||||
}
|
||||
# endif /* PNG_FLOATING_POINT_SUPPORTED */
|
||||
|
||||
#endif /* PNG_cHRM_SUPPORTED */
|
||||
|
||||
#ifdef PNG_gAMA_SUPPORTED
|
||||
void PNGFAPI
|
||||
png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
|
||||
file_gamma)
|
||||
png_set_gAMA_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_fixed_point file_gamma)
|
||||
{
|
||||
png_debug1(1, "in %s storage function", "gAMA");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* Previously these values were limited, however they must be
|
||||
* wrong, therefore storing them (and setting PNG_INFO_gAMA)
|
||||
* must be wrong too.
|
||||
/* Changed in libpng-1.5.4 to limit the values to ensure overflow can't
|
||||
* occur. Since the fixed point representation is assymetrical it is
|
||||
* possible for 1/gamma to overflow the limit of 21474 and this means the
|
||||
* gamma value must be at least 5/100000 and hence at most 20000.0. For
|
||||
* safety the limits here are a little narrower. The values are 0.00016 to
|
||||
* 6250.0, which are truly ridiculous gammma values (and will produce
|
||||
* displays that are all black or all white.)
|
||||
*/
|
||||
if (file_gamma > (png_fixed_point)PNG_UINT_31_MAX)
|
||||
png_warning(png_ptr, "Gamma too large, ignored");
|
||||
|
||||
else if (file_gamma <= 0)
|
||||
png_warning(png_ptr, "Negative or zero gamma ignored");
|
||||
if (file_gamma < 16 || file_gamma > 625000000)
|
||||
png_warning(png_ptr, "Out of range gamma value ignored");
|
||||
|
||||
else
|
||||
{
|
||||
@@ -113,7 +164,7 @@ png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
|
||||
png_set_gAMA(png_const_structrp png_ptr, png_inforp info_ptr, double file_gamma)
|
||||
{
|
||||
png_set_gAMA_fixed(png_ptr, info_ptr, png_fixed(png_ptr, file_gamma,
|
||||
"png_set_gAMA"));
|
||||
@@ -123,7 +174,8 @@ png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
|
||||
|
||||
#ifdef PNG_hIST_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_const_uint_16p hist)
|
||||
png_set_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_const_uint_16p hist)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -146,26 +198,26 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_const_uint_16p hist)
|
||||
/* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in
|
||||
* version 1.2.1
|
||||
*/
|
||||
png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr,
|
||||
PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16));
|
||||
info_ptr->hist = png_voidcast(png_uint_16p, png_malloc_warn(png_ptr,
|
||||
PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16)));
|
||||
|
||||
if (png_ptr->hist == NULL)
|
||||
if (info_ptr->hist == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for hIST chunk data");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < info_ptr->num_palette; i++)
|
||||
png_ptr->hist[i] = hist[i];
|
||||
|
||||
info_ptr->hist = png_ptr->hist;
|
||||
info_ptr->valid |= PNG_INFO_hIST;
|
||||
info_ptr->free_me |= PNG_FREE_HIST;
|
||||
|
||||
for (i = 0; i < info_ptr->num_palette; i++)
|
||||
info_ptr->hist[i] = hist[i];
|
||||
|
||||
info_ptr->valid |= PNG_INFO_hIST;
|
||||
}
|
||||
#endif
|
||||
|
||||
void PNGAPI
|
||||
png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||
png_set_IHDR(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_uint_32 width, png_uint_32 height, int bit_depth,
|
||||
int color_type, int interlace_type, int compression_type,
|
||||
int filter_type)
|
||||
@@ -215,7 +267,7 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_oFFs(png_structp png_ptr, png_infop info_ptr,
|
||||
png_set_oFFs(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_int_32 offset_x, png_int_32 offset_y, int unit_type)
|
||||
{
|
||||
png_debug1(1, "in %s storage function", "oFFs");
|
||||
@@ -232,7 +284,7 @@ png_set_oFFs(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_pCAL_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type,
|
||||
int nparams, png_const_charp units, png_charpp params)
|
||||
{
|
||||
@@ -241,7 +293,8 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
png_debug1(1, "in %s storage function", "pCAL");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL || purpose == NULL || units == NULL
|
||||
|| (nparams > 0 && params == NULL))
|
||||
return;
|
||||
|
||||
length = png_strlen(purpose) + 1;
|
||||
@@ -254,12 +307,17 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
if (type < 0 || type > 3)
|
||||
png_error(png_ptr, "Invalid pCAL equation type");
|
||||
|
||||
if (nparams < 0 || nparams > 255)
|
||||
png_error(png_ptr, "Invalid pCAL parameter count");
|
||||
|
||||
/* Validate params[nparams] */
|
||||
for (i=0; i<nparams; ++i)
|
||||
if (!png_check_fp_string(params[i], png_strlen(params[i])))
|
||||
if (params[i] == NULL ||
|
||||
!png_check_fp_string(params[i], png_strlen(params[i])))
|
||||
png_error(png_ptr, "Invalid format for pCAL parameter");
|
||||
|
||||
info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length);
|
||||
info_ptr->pcal_purpose = png_voidcast(png_charp,
|
||||
png_malloc_warn(png_ptr, length));
|
||||
|
||||
if (info_ptr->pcal_purpose == NULL)
|
||||
{
|
||||
@@ -279,7 +337,8 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
png_debug1(3, "allocating units for info (%lu bytes)",
|
||||
(unsigned long)length);
|
||||
|
||||
info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length);
|
||||
info_ptr->pcal_units = png_voidcast(png_charp,
|
||||
png_malloc_warn(png_ptr, length));
|
||||
|
||||
if (info_ptr->pcal_units == NULL)
|
||||
{
|
||||
@@ -289,8 +348,8 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
png_memcpy(info_ptr->pcal_units, units, length);
|
||||
|
||||
info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr,
|
||||
(png_size_t)((nparams + 1) * png_sizeof(png_charp)));
|
||||
info_ptr->pcal_params = png_voidcast(png_charpp, png_malloc_warn(png_ptr,
|
||||
(png_size_t)((nparams + 1) * png_sizeof(png_charp))));
|
||||
|
||||
if (info_ptr->pcal_params == NULL)
|
||||
{
|
||||
@@ -324,7 +383,7 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_sCAL_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
|
||||
png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
int unit, png_const_charp swidth, png_const_charp sheight)
|
||||
{
|
||||
png_size_t lengthw = 0, lengthh = 0;
|
||||
@@ -340,11 +399,11 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
|
||||
if (unit != 1 && unit != 2)
|
||||
png_error(png_ptr, "Invalid sCAL unit");
|
||||
|
||||
if (swidth == NULL || (lengthw = png_strlen(swidth)) <= 0 ||
|
||||
if (swidth == NULL || (lengthw = png_strlen(swidth)) == 0 ||
|
||||
swidth[0] == 45 /* '-' */ || !png_check_fp_string(swidth, lengthw))
|
||||
png_error(png_ptr, "Invalid sCAL width");
|
||||
|
||||
if (sheight == NULL || (lengthh = png_strlen(sheight)) <= 0 ||
|
||||
if (sheight == NULL || (lengthh = png_strlen(sheight)) == 0 ||
|
||||
sheight[0] == 45 /* '-' */ || !png_check_fp_string(sheight, lengthh))
|
||||
png_error(png_ptr, "Invalid sCAL height");
|
||||
|
||||
@@ -354,7 +413,8 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthw);
|
||||
|
||||
info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, lengthw);
|
||||
info_ptr->scal_s_width = png_voidcast(png_charp,
|
||||
png_malloc_warn(png_ptr, lengthw));
|
||||
|
||||
if (info_ptr->scal_s_width == NULL)
|
||||
{
|
||||
@@ -368,7 +428,8 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthh);
|
||||
|
||||
info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, lengthh);
|
||||
info_ptr->scal_s_height = png_voidcast(png_charp,
|
||||
png_malloc_warn(png_ptr, lengthh));
|
||||
|
||||
if (info_ptr->scal_s_height == NULL)
|
||||
{
|
||||
@@ -387,8 +448,8 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_sCAL(png_structp png_ptr, png_infop info_ptr, int unit, double width,
|
||||
double height)
|
||||
png_set_sCAL(png_const_structrp png_ptr, png_inforp info_ptr, int unit,
|
||||
double width, double height)
|
||||
{
|
||||
png_debug1(1, "in %s storage function", "sCAL");
|
||||
|
||||
@@ -417,7 +478,7 @@ png_set_sCAL(png_structp png_ptr, png_infop info_ptr, int unit, double width,
|
||||
|
||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_sCAL_fixed(png_structp png_ptr, png_infop info_ptr, int unit,
|
||||
png_set_sCAL_fixed(png_const_structrp png_ptr, png_inforp info_ptr, int unit,
|
||||
png_fixed_point width, png_fixed_point height)
|
||||
{
|
||||
png_debug1(1, "in %s storage function", "sCAL");
|
||||
@@ -446,7 +507,7 @@ png_set_sCAL_fixed(png_structp png_ptr, png_infop info_ptr, int unit,
|
||||
|
||||
#ifdef PNG_pHYs_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_pHYs(png_structp png_ptr, png_infop info_ptr,
|
||||
png_set_pHYs(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_uint_32 res_x, png_uint_32 res_y, int unit_type)
|
||||
{
|
||||
png_debug1(1, "in %s storage function", "pHYs");
|
||||
@@ -462,13 +523,13 @@ png_set_pHYs(png_structp png_ptr, png_infop info_ptr,
|
||||
#endif
|
||||
|
||||
void PNGAPI
|
||||
png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
|
||||
png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
||||
png_const_colorp palette, int num_palette)
|
||||
{
|
||||
|
||||
png_debug1(1, "in %s storage function", "PLTE");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL || palette == NULL)
|
||||
return;
|
||||
|
||||
if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH)
|
||||
@@ -486,6 +547,9 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
|
||||
/* It may not actually be necessary to set png_ptr->palette here;
|
||||
* we do it for backward compatibility with the way the png_handle_tRNS
|
||||
* function used to do the allocation.
|
||||
*
|
||||
* 1.6.0: the above statement appears to be incorrect; something has to set
|
||||
* the palette inside png_struct on read.
|
||||
*/
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);
|
||||
|
||||
@@ -493,8 +557,8 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
|
||||
* of num_palette entries, in case of an invalid PNG file that has
|
||||
* too-large sample values.
|
||||
*/
|
||||
png_ptr->palette = (png_colorp)png_calloc(png_ptr,
|
||||
PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color));
|
||||
png_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr,
|
||||
PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)));
|
||||
|
||||
png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof(png_color));
|
||||
info_ptr->palette = png_ptr->palette;
|
||||
@@ -507,22 +571,22 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_sBIT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
|
||||
png_set_sBIT(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_const_color_8p sig_bit)
|
||||
{
|
||||
png_debug1(1, "in %s storage function", "sBIT");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL || sig_bit == NULL)
|
||||
return;
|
||||
|
||||
png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof(png_color_8));
|
||||
info_ptr->sig_bit = *sig_bit;
|
||||
info_ptr->valid |= PNG_INFO_sBIT;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sRGB_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int srgb_intent)
|
||||
png_set_sRGB(png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent)
|
||||
{
|
||||
png_debug1(1, "in %s storage function", "sRGB");
|
||||
|
||||
@@ -534,7 +598,7 @@ png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int srgb_intent)
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
png_set_sRGB_gAMA_and_cHRM(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
int srgb_intent)
|
||||
{
|
||||
png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM");
|
||||
@@ -545,16 +609,16 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
png_set_sRGB(png_ptr, info_ptr, srgb_intent);
|
||||
|
||||
# ifdef PNG_gAMA_SUPPORTED
|
||||
png_set_gAMA_fixed(png_ptr, info_ptr, 45455L);
|
||||
png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_sRGB_INVERSE);
|
||||
# endif
|
||||
|
||||
# ifdef PNG_cHRM_SUPPORTED
|
||||
png_set_cHRM_fixed(png_ptr, info_ptr,
|
||||
/* color x y */
|
||||
/* white */ 31270L, 32900L,
|
||||
/* red */ 64000L, 33000L,
|
||||
/* green */ 30000L, 60000L,
|
||||
/* blue */ 15000L, 6000L
|
||||
/* white */ 31270, 32900,
|
||||
/* red */ 64000, 33000,
|
||||
/* green */ 30000, 60000,
|
||||
/* blue */ 15000, 6000
|
||||
);
|
||||
# endif /* cHRM */
|
||||
}
|
||||
@@ -563,13 +627,13 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_iCCP_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
|
||||
png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_const_charp name, int compression_type,
|
||||
png_const_bytep profile, png_uint_32 proflen)
|
||||
{
|
||||
png_charp new_iccp_name;
|
||||
png_bytep new_iccp_profile;
|
||||
png_uint_32 length;
|
||||
png_size_t length;
|
||||
|
||||
png_debug1(1, "in %s storage function", "iCCP");
|
||||
|
||||
@@ -577,7 +641,7 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
|
||||
return;
|
||||
|
||||
length = png_strlen(name)+1;
|
||||
new_iccp_name = (png_charp)png_malloc_warn(png_ptr, length);
|
||||
new_iccp_name = png_voidcast(png_charp, png_malloc_warn(png_ptr, length));
|
||||
|
||||
if (new_iccp_name == NULL)
|
||||
{
|
||||
@@ -586,7 +650,8 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
|
||||
png_memcpy(new_iccp_name, name, length);
|
||||
new_iccp_profile = (png_bytep)png_malloc_warn(png_ptr, proflen);
|
||||
new_iccp_profile = png_voidcast(png_bytep,
|
||||
png_malloc_warn(png_ptr, proflen));
|
||||
|
||||
if (new_iccp_profile == NULL)
|
||||
{
|
||||
@@ -596,7 +661,7 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
|
||||
return;
|
||||
}
|
||||
|
||||
png_memcpy(new_iccp_profile, profile, (png_size_t)proflen);
|
||||
png_memcpy(new_iccp_profile, profile, proflen);
|
||||
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0);
|
||||
|
||||
@@ -614,8 +679,8 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_text(png_structp png_ptr, png_infop info_ptr, png_const_textp text_ptr,
|
||||
int num_text)
|
||||
png_set_text(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_const_textp text_ptr, int num_text)
|
||||
{
|
||||
int ret;
|
||||
ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text);
|
||||
@@ -625,14 +690,13 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_const_textp text_ptr,
|
||||
}
|
||||
|
||||
int /* PRIVATE */
|
||||
png_set_text_2(png_structp png_ptr, png_infop info_ptr,
|
||||
png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_const_textp text_ptr, int num_text)
|
||||
{
|
||||
int i;
|
||||
|
||||
png_debug1(1, "in %s storage function", ((png_ptr == NULL ||
|
||||
png_ptr->chunk_name[0] == '\0') ?
|
||||
"text" : (png_const_charp)png_ptr->chunk_name));
|
||||
png_debug1(1, "in %lx storage function", png_ptr == NULL ? "unexpected" :
|
||||
(unsigned long)png_ptr->chunk_name);
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL || num_text == 0)
|
||||
return(0);
|
||||
@@ -806,22 +870,32 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_tIME_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_const_timep mod_time)
|
||||
png_set_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_const_timep mod_time)
|
||||
{
|
||||
png_debug1(1, "in %s storage function", "tIME");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL ||
|
||||
if (png_ptr == NULL || info_ptr == NULL || mod_time == NULL ||
|
||||
(png_ptr->mode & PNG_WROTE_tIME))
|
||||
return;
|
||||
|
||||
png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof(png_time));
|
||||
if (mod_time->month == 0 || mod_time->month > 12 ||
|
||||
mod_time->day == 0 || mod_time->day > 31 ||
|
||||
mod_time->hour > 23 || mod_time->minute > 59 ||
|
||||
mod_time->second > 60)
|
||||
{
|
||||
png_warning(png_ptr, "Ignoring invalid time value");
|
||||
return;
|
||||
}
|
||||
|
||||
info_ptr->mod_time = *mod_time;
|
||||
info_ptr->valid |= PNG_INFO_tIME;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_tRNS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||
png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
|
||||
png_const_bytep trans_alpha, int num_trans, png_const_color_16p trans_color)
|
||||
{
|
||||
png_debug1(1, "in %s storage function", "tRNS");
|
||||
@@ -834,13 +908,17 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||
/* It may not actually be necessary to set png_ptr->trans_alpha here;
|
||||
* we do it for backward compatibility with the way the png_handle_tRNS
|
||||
* function used to do the allocation.
|
||||
*
|
||||
* 1.6.0: The above statement is incorrect; png_handle_tRNS effectively
|
||||
* relies on png_set_tRNS storing the information in png_struct
|
||||
* (otherwise it won't be there for the code in pngrtran.c).
|
||||
*/
|
||||
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
|
||||
|
||||
/* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */
|
||||
png_ptr->trans_alpha = info_ptr->trans_alpha =
|
||||
(png_bytep)png_malloc(png_ptr, (png_size_t)PNG_MAX_PALETTE_LENGTH);
|
||||
png_ptr->trans_alpha = info_ptr->trans_alpha = png_voidcast(png_bytep,
|
||||
png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));
|
||||
|
||||
if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH)
|
||||
png_memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans);
|
||||
@@ -851,16 +929,15 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||
int sample_max = (1 << info_ptr->bit_depth);
|
||||
|
||||
if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
|
||||
(int)trans_color->gray > sample_max) ||
|
||||
trans_color->gray > sample_max) ||
|
||||
(info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
|
||||
((int)trans_color->red > sample_max ||
|
||||
(int)trans_color->green > sample_max ||
|
||||
(int)trans_color->blue > sample_max)))
|
||||
(trans_color->red > sample_max ||
|
||||
trans_color->green > sample_max ||
|
||||
trans_color->blue > sample_max)))
|
||||
png_warning(png_ptr,
|
||||
"tRNS chunk has out-of-range samples for bit_depth");
|
||||
|
||||
png_memcpy(&(info_ptr->trans_color), trans_color,
|
||||
png_sizeof(png_color_16));
|
||||
info_ptr->trans_color = *trans_color;
|
||||
|
||||
if (num_trans == 0)
|
||||
num_trans = 1;
|
||||
@@ -878,8 +955,8 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_sPLT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_sPLT(png_structp png_ptr,
|
||||
png_infop info_ptr, png_const_sPLT_tp entries, int nentries)
|
||||
png_set_sPLT(png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, png_const_sPLT_tp entries, int nentries)
|
||||
/*
|
||||
* entries - array of png_sPLT_t structures
|
||||
* to be added to the list of palettes
|
||||
@@ -892,12 +969,12 @@ png_set_sPLT(png_structp png_ptr,
|
||||
png_sPLT_tp np;
|
||||
int i;
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL || nentries <= 0 ||
|
||||
entries == NULL)
|
||||
return;
|
||||
|
||||
np = (png_sPLT_tp)png_malloc_warn(png_ptr,
|
||||
(info_ptr->splt_palettes_num + nentries) *
|
||||
(png_size_t)png_sizeof(png_sPLT_t));
|
||||
np = png_voidcast(png_sPLT_tp, png_malloc_warn(png_ptr,
|
||||
(info_ptr->splt_palettes_num + nentries) * png_sizeof(png_sPLT_t)));
|
||||
|
||||
if (np == NULL)
|
||||
{
|
||||
@@ -911,14 +988,26 @@ png_set_sPLT(png_structp png_ptr,
|
||||
png_free(png_ptr, info_ptr->splt_palettes);
|
||||
info_ptr->splt_palettes=NULL;
|
||||
|
||||
/* TODO: fix this, it apparently leaves NULL entries in the event of OOM
|
||||
* below.
|
||||
*/
|
||||
for (i = 0; i < nentries; i++)
|
||||
{
|
||||
png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;
|
||||
png_const_sPLT_tp from = entries + i;
|
||||
png_uint_32 length;
|
||||
png_size_t length;
|
||||
|
||||
/* In event of error below the name and entries fields must be set to
|
||||
* NULL, otherwise libpng will crash later on while trying to free the
|
||||
* uninitialized pointers.
|
||||
*/
|
||||
png_memset(to, 0, sizeof *to);
|
||||
|
||||
if (from->name == NULL || from->entries == NULL)
|
||||
continue;
|
||||
|
||||
length = png_strlen(from->name) + 1;
|
||||
to->name = (png_charp)png_malloc_warn(png_ptr, (png_size_t)length);
|
||||
to->name = png_voidcast(png_charp, png_malloc_warn(png_ptr, length));
|
||||
|
||||
if (to->name == NULL)
|
||||
{
|
||||
@@ -928,13 +1017,12 @@ png_set_sPLT(png_structp png_ptr,
|
||||
}
|
||||
|
||||
png_memcpy(to->name, from->name, length);
|
||||
to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr,
|
||||
(png_size_t)(from->nentries * png_sizeof(png_sPLT_entry)));
|
||||
to->entries = png_voidcast(png_sPLT_entryp, png_malloc_warn(png_ptr,
|
||||
from->nentries * png_sizeof(png_sPLT_entry)));
|
||||
|
||||
if (to->entries == NULL)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Out of memory while processing sPLT chunk");
|
||||
png_warning(png_ptr, "Out of memory while processing sPLT chunk");
|
||||
png_free(png_ptr, to->name);
|
||||
to->name = NULL;
|
||||
continue;
|
||||
@@ -956,8 +1044,8 @@ png_set_sPLT(png_structp png_ptr,
|
||||
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_unknown_chunks(png_structp png_ptr,
|
||||
png_infop info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)
|
||||
png_set_unknown_chunks(png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)
|
||||
{
|
||||
png_unknown_chunkp np;
|
||||
int i;
|
||||
@@ -965,9 +1053,9 @@ png_set_unknown_chunks(png_structp png_ptr,
|
||||
if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0)
|
||||
return;
|
||||
|
||||
np = (png_unknown_chunkp)png_malloc_warn(png_ptr,
|
||||
np = png_voidcast(png_unknown_chunkp, png_malloc_warn(png_ptr,
|
||||
(png_size_t)(info_ptr->unknown_chunks_num + num_unknowns) *
|
||||
png_sizeof(png_unknown_chunk));
|
||||
png_sizeof(png_unknown_chunk)));
|
||||
|
||||
if (np == NULL)
|
||||
{
|
||||
@@ -1021,7 +1109,7 @@ png_set_unknown_chunks(png_structp png_ptr,
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr,
|
||||
png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
int chunk, int location)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk <
|
||||
@@ -1033,31 +1121,30 @@ png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features)
|
||||
png_permit_mng_features (png_structrp png_ptr, png_uint_32 mng_features)
|
||||
{
|
||||
png_debug(1, "in png_permit_mng_features");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return (png_uint_32)0;
|
||||
return 0;
|
||||
|
||||
png_ptr->mng_features_permitted =
|
||||
(png_byte)(mng_features & PNG_ALL_MNG_FEATURES);
|
||||
png_ptr->mng_features_permitted = mng_features & PNG_ALL_MNG_FEATURES;
|
||||
|
||||
return (png_uint_32)png_ptr->mng_features_permitted;
|
||||
return png_ptr->mng_features_permitted;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_const_bytep
|
||||
chunk_list, int num_chunks)
|
||||
png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
||||
png_const_bytep chunk_list, int num_chunksIn)
|
||||
{
|
||||
png_bytep new_list, p;
|
||||
int i, old_num_chunks;
|
||||
unsigned int i, num_chunks, old_num_chunks;
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (num_chunks == 0)
|
||||
if (num_chunksIn <= 0)
|
||||
{
|
||||
if (keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE)
|
||||
png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS;
|
||||
@@ -1077,20 +1164,22 @@ png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_const_bytep
|
||||
if (chunk_list == NULL)
|
||||
return;
|
||||
|
||||
/* The argument is >0 */
|
||||
num_chunks = (unsigned int)num_chunksIn;
|
||||
|
||||
old_num_chunks = png_ptr->num_chunk_list;
|
||||
new_list=(png_bytep)png_malloc(png_ptr,
|
||||
(png_size_t)(5*(num_chunks + old_num_chunks)));
|
||||
new_list = png_voidcast(png_bytep, png_malloc(png_ptr,
|
||||
5 * (num_chunks + old_num_chunks)));
|
||||
|
||||
if (png_ptr->chunk_list != NULL)
|
||||
{
|
||||
png_memcpy(new_list, png_ptr->chunk_list,
|
||||
(png_size_t)(5*old_num_chunks));
|
||||
png_memcpy(new_list, png_ptr->chunk_list, 5*old_num_chunks);
|
||||
png_free(png_ptr, png_ptr->chunk_list);
|
||||
png_ptr->chunk_list=NULL;
|
||||
}
|
||||
|
||||
png_memcpy(new_list + 5*old_num_chunks, chunk_list,
|
||||
(png_size_t)(5*num_chunks));
|
||||
5*(unsigned int)num_chunks);
|
||||
|
||||
for (p = new_list + 5*old_num_chunks + 4, i = 0; i<num_chunks; i++, p += 5)
|
||||
*p=(png_byte)keep;
|
||||
@@ -1103,7 +1192,7 @@ png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_const_bytep
|
||||
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr,
|
||||
png_set_read_user_chunk_fn(png_structrp png_ptr, png_voidp user_chunk_ptr,
|
||||
png_user_chunk_ptr read_user_chunk_fn)
|
||||
{
|
||||
png_debug(1, "in png_set_read_user_chunk_fn");
|
||||
@@ -1118,7 +1207,8 @@ png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr,
|
||||
|
||||
#ifdef PNG_INFO_IMAGE_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers)
|
||||
png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_bytepp row_pointers)
|
||||
{
|
||||
png_debug1(1, "in %s storage function", "rows");
|
||||
|
||||
@@ -1136,7 +1226,7 @@ png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers)
|
||||
#endif
|
||||
|
||||
void PNGAPI
|
||||
png_set_compression_buffer_size(png_structp png_ptr, png_size_t size)
|
||||
png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
@@ -1164,18 +1254,17 @@ png_set_compression_buffer_size(png_structp png_ptr, png_size_t size)
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask)
|
||||
png_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask)
|
||||
{
|
||||
if (png_ptr && info_ptr)
|
||||
info_ptr->valid &= ~mask;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
/* This function was added to libpng 1.2.6 */
|
||||
void PNGAPI
|
||||
png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max,
|
||||
png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max,
|
||||
png_uint_32 user_height_max)
|
||||
{
|
||||
/* Images with dimensions larger than these limits will be
|
||||
@@ -1191,8 +1280,7 @@ png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max,
|
||||
|
||||
/* This function was added to libpng 1.4.0 */
|
||||
void PNGAPI
|
||||
png_set_chunk_cache_max (png_structp png_ptr,
|
||||
png_uint_32 user_chunk_cache_max)
|
||||
png_set_chunk_cache_max (png_structrp png_ptr, png_uint_32 user_chunk_cache_max)
|
||||
{
|
||||
if (png_ptr)
|
||||
png_ptr->user_chunk_cache_max = user_chunk_cache_max;
|
||||
@@ -1200,7 +1288,7 @@ png_set_chunk_cache_max (png_structp png_ptr,
|
||||
|
||||
/* This function was added to libpng 1.4.1 */
|
||||
void PNGAPI
|
||||
png_set_chunk_malloc_max (png_structp png_ptr,
|
||||
png_set_chunk_malloc_max (png_structrp png_ptr,
|
||||
png_alloc_size_t user_chunk_malloc_max)
|
||||
{
|
||||
if (png_ptr)
|
||||
@@ -1211,7 +1299,7 @@ png_set_chunk_malloc_max (png_structp png_ptr,
|
||||
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_benign_errors(png_structp png_ptr, int allowed)
|
||||
png_set_benign_errors(png_structrp png_ptr, int allowed)
|
||||
{
|
||||
png_debug(1, "in png_set_benign_errors");
|
||||
|
||||
|
||||
106
pngstruct.h
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngstruct.h - header file for PNG reference library
|
||||
*
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -29,11 +29,15 @@
|
||||
struct png_struct_def
|
||||
{
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
jmp_buf png_jmpbuf; /* used in png_error */
|
||||
jmp_buf jmp_buf_local; /* New name in 1.6.0 for jmp_buf in png_struct */
|
||||
png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */
|
||||
jmp_buf *jmp_buf_ptr; /* passed to longjmp_fn */
|
||||
size_t jmp_buf_size; /* size of the above, if allocated */
|
||||
#endif
|
||||
png_error_ptr error_fn; /* function for printing errors and aborting */
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
png_error_ptr warning_fn; /* function for printing warnings */
|
||||
#endif
|
||||
png_voidp error_ptr; /* user supplied struct for error functions */
|
||||
png_rw_ptr write_data_fn; /* function for writing output data */
|
||||
png_rw_ptr read_data_fn; /* function for reading input data */
|
||||
@@ -64,11 +68,36 @@ struct png_struct_def
|
||||
z_stream zstream; /* pointer to decompression structure (below) */
|
||||
png_bytep zbuf; /* buffer for zlib */
|
||||
uInt zbuf_size; /* size of zbuf (typically 65536) */
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
|
||||
/* Added in 1.5.4: state to keep track of whether the zstream has been
|
||||
* initialized and if so whether it is for IDAT or some other chunk.
|
||||
*/
|
||||
#define PNG_ZLIB_UNINITIALIZED 0
|
||||
#define PNG_ZLIB_FOR_IDAT 1
|
||||
#define PNG_ZLIB_FOR_TEXT 2 /* anything other than IDAT */
|
||||
#define PNG_ZLIB_USE_MASK 3 /* bottom two bits */
|
||||
#define PNG_ZLIB_IN_USE 4 /* a flag value */
|
||||
|
||||
png_uint_32 zlib_state; /* State of zlib initialization */
|
||||
/* End of material added at libpng 1.5.4 */
|
||||
|
||||
int zlib_level; /* holds zlib compression level */
|
||||
int zlib_method; /* holds zlib compression method */
|
||||
int zlib_window_bits; /* holds zlib compression window bits */
|
||||
int zlib_mem_level; /* holds zlib compression memory level */
|
||||
int zlib_strategy; /* holds zlib compression strategy */
|
||||
#endif
|
||||
/* Added at libpng 1.5.4 */
|
||||
#if defined(PNG_WRITE_COMPRESSED_TEXT_SUPPORTED) || \
|
||||
defined(PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED)
|
||||
int zlib_text_level; /* holds zlib compression level */
|
||||
int zlib_text_method; /* holds zlib compression method */
|
||||
int zlib_text_window_bits; /* holds zlib compression window bits */
|
||||
int zlib_text_mem_level; /* holds zlib compression memory level */
|
||||
int zlib_text_strategy; /* holds zlib compression strategy */
|
||||
#endif
|
||||
/* End of material added at libpng 1.5.4 */
|
||||
|
||||
png_uint_32 width; /* width of image in pixels */
|
||||
png_uint_32 height; /* height of image in pixels */
|
||||
@@ -77,20 +106,24 @@ struct png_struct_def
|
||||
png_size_t rowbytes; /* size of row in bytes */
|
||||
png_uint_32 iwidth; /* width of current interlaced row in pixels */
|
||||
png_uint_32 row_number; /* current row in interlace pass */
|
||||
png_bytep prev_row; /* buffer to save previous (unfiltered) row */
|
||||
png_bytep row_buf; /* buffer to save current (unfiltered) row */
|
||||
png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */
|
||||
png_bytep prev_row; /* buffer to save previous (unfiltered) row.
|
||||
* This is a pointer into big_prev_row
|
||||
*/
|
||||
png_bytep row_buf; /* buffer to save current (unfiltered) row.
|
||||
* This is a pointer into big_row_buf
|
||||
*/
|
||||
png_bytep sub_row; /* buffer to save "sub" row when filtering */
|
||||
png_bytep up_row; /* buffer to save "up" row when filtering */
|
||||
png_bytep avg_row; /* buffer to save "avg" row when filtering */
|
||||
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
|
||||
png_row_info row_info; /* used for transformation routines */
|
||||
png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */
|
||||
|
||||
png_uint_32 idat_size; /* current IDAT size for read */
|
||||
png_uint_32 crc; /* current chunk CRC value */
|
||||
png_colorp palette; /* palette from the input file */
|
||||
png_uint_16 num_palette; /* number of color entries in palette */
|
||||
png_uint_16 num_trans; /* number of transparency values */
|
||||
png_byte chunk_name[5]; /* null-terminated name of current chunk */
|
||||
png_byte compression; /* file compression type (always 0) */
|
||||
png_byte filter; /* file filter type (always 0) */
|
||||
png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
|
||||
@@ -98,17 +131,26 @@ struct png_struct_def
|
||||
png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */
|
||||
png_byte color_type; /* color type of file */
|
||||
png_byte bit_depth; /* bit depth of file */
|
||||
png_byte usr_bit_depth; /* bit depth of users row */
|
||||
png_byte usr_bit_depth; /* bit depth of users row: write only */
|
||||
png_byte pixel_depth; /* number of bits per pixel */
|
||||
png_byte channels; /* number of channels in file */
|
||||
png_byte usr_channels; /* channels at start of write */
|
||||
png_byte usr_channels; /* channels at start of write: write only */
|
||||
png_byte sig_bytes; /* magic bytes read/written from start of file */
|
||||
png_byte maximum_pixel_depth;
|
||||
/* pixel depth used for the row buffers */
|
||||
png_byte transformed_pixel_depth;
|
||||
/* pixel depth after read/write transforms */
|
||||
#if PNG_LIBPNG_VER < 10600
|
||||
png_byte io_chunk_string[5];
|
||||
/* string name of chunk */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
png_uint_16 filler; /* filler bytes for pixel expansion */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_bKGD_SUPPORTED
|
||||
#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
png_byte background_gamma_type;
|
||||
png_fixed_point background_gamma;
|
||||
png_color_16 background; /* background color in screen gamma space */
|
||||
@@ -123,19 +165,21 @@ struct png_struct_def
|
||||
png_uint_32 flush_rows; /* number of rows written since last flush */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */
|
||||
png_fixed_point gamma; /* file gamma value */
|
||||
png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_bytep gamma_table; /* gamma table for 8-bit depth files */
|
||||
png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
|
||||
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
png_bytep gamma_from_1; /* converts from 1.0 to screen */
|
||||
png_bytep gamma_to_1; /* converts from file to 1.0 */
|
||||
png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
|
||||
png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
|
||||
png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
|
||||
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)
|
||||
@@ -194,10 +238,6 @@ struct png_struct_def
|
||||
png_bytep quantize_index; /* index translation for palette files */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_QUANTIZE_SUPPORTED) || defined(PNG_hIST_SUPPORTED)
|
||||
png_uint_16p hist; /* histogram */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
png_byte heuristic_method; /* heuristic for row filter selection */
|
||||
png_byte num_prev_filters; /* number of weights for previous rows */
|
||||
@@ -208,8 +248,10 @@ struct png_struct_def
|
||||
png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
|
||||
#endif
|
||||
|
||||
#if PNG_LIBPNG_VER < 10700
|
||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||
png_charp time_buffer; /* String to hold RFC 1123 time text */
|
||||
char time_buffer[29]; /* String to hold RFC 1123 time text */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.0.6 */
|
||||
@@ -222,17 +264,24 @@ struct png_struct_def
|
||||
#endif
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
int num_chunk_list;
|
||||
unsigned int num_chunk_list;
|
||||
png_bytep chunk_list;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_sRGB_SUPPORTED
|
||||
/* Added in 1.5.5 to record an sRGB chunk in the png. */
|
||||
png_byte is_sRGB;
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.0.3 */
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
png_byte rgb_to_gray_status;
|
||||
/* Added in libpng 1.5.5 to record setting of coefficients: */
|
||||
png_byte rgb_to_gray_coefficients_set;
|
||||
/* These were changed from png_byte in libpng-1.0.6 */
|
||||
png_uint_16 rgb_to_gray_red_coeff;
|
||||
png_uint_16 rgb_to_gray_green_coeff;
|
||||
png_uint_16 rgb_to_gray_blue_coeff;
|
||||
/* deleted in 1.5.5: rgb_to_gray_blue_coeff; */
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.0.4 (renamed in 1.0.9) */
|
||||
@@ -289,13 +338,16 @@ struct png_struct_def
|
||||
|
||||
/* New member added in libpng-1.0.25 and 1.2.17 */
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Storage for unknown chunk that the library doesn't recognize. */
|
||||
/* Temporary storage for unknown chunk that the library doesn't recognize,
|
||||
* used while reading the chunk.
|
||||
*/
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
png_unknown_chunk unknown_chunk;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.2.26 */
|
||||
/* New member added in libpng-1.2.26 */
|
||||
png_size_t old_big_row_buf_size;
|
||||
png_size_t old_prev_row_size;
|
||||
|
||||
/* New member added in libpng-1.2.30 */
|
||||
png_charp chunkdata; /* buffer for reading chunk data */
|
||||
@@ -304,5 +356,11 @@ struct png_struct_def
|
||||
/* New member added in libpng-1.4.0 */
|
||||
png_uint_32 io_state;
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.5.6 */
|
||||
png_bytep big_prev_row;
|
||||
|
||||
void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
|
||||
png_bytep row, png_const_bytep prev_row);
|
||||
};
|
||||
#endif /* PNGSTRUCT_H */
|
||||
|
||||
239
pngtest.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
*
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -31,6 +31,8 @@
|
||||
* of files at once by typing "pngtest -m file1.png file2.png ..."
|
||||
*/
|
||||
|
||||
#define _POSIX_SOURCE 1
|
||||
|
||||
#include "zlib.h"
|
||||
#include "png.h"
|
||||
/* Copied from pngpriv.h but only used in error messages below. */
|
||||
@@ -65,17 +67,6 @@ typedef FILE * png_FILE_p;
|
||||
# define SINGLE_ROWBUF_ALLOC /* Makes buffer overruns easier to nail */
|
||||
#endif
|
||||
|
||||
/* The code uses memcmp and memcpy on large objects (typically row pointers) so
|
||||
* it is necessary to do soemthing special on certain architectures, note that
|
||||
* the actual support for this was effectively removed in 1.4, so only the
|
||||
* memory remains in this program:
|
||||
*/
|
||||
#define CVT_PTR(ptr) (ptr)
|
||||
#define CVT_PTR_NOCHECK(ptr) (ptr)
|
||||
#define png_memcmp memcmp
|
||||
#define png_memcpy memcpy
|
||||
#define png_memset memset
|
||||
|
||||
/* Turn on CPU timing
|
||||
#define PNGTEST_TIMING
|
||||
*/
|
||||
@@ -96,8 +87,7 @@ static char tIME_string[PNG_tIME_STRING_LENGTH] = "tIME chunk is not present";
|
||||
#endif
|
||||
|
||||
static int verbose = 0;
|
||||
|
||||
int test_one_file PNGARG((PNG_CONST char *inname, PNG_CONST char *outname));
|
||||
static int strict = 0;
|
||||
|
||||
#ifdef __TURBOC__
|
||||
#include <mem.h>
|
||||
@@ -117,9 +107,7 @@ static int status_pass = 1;
|
||||
static int status_dots_requested = 0;
|
||||
static int status_dots = 1;
|
||||
|
||||
void PNGCBAPI
|
||||
read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass);
|
||||
void PNGCBAPI
|
||||
static void PNGCBAPI
|
||||
read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
|
||||
{
|
||||
if (png_ptr == NULL || row_number > PNG_UINT_31_MAX)
|
||||
@@ -143,9 +131,7 @@ read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
|
||||
fprintf(stdout, "r");
|
||||
}
|
||||
|
||||
void PNGCBAPI
|
||||
write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass);
|
||||
void PNGCBAPI
|
||||
static void PNGCBAPI
|
||||
write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
|
||||
{
|
||||
if (png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7)
|
||||
@@ -161,9 +147,7 @@ write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
|
||||
* 5 in case illegal filter values are present.)
|
||||
*/
|
||||
static png_uint_32 filters_used[256];
|
||||
void PNGCBAPI
|
||||
count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data);
|
||||
void PNGCBAPI
|
||||
static void PNGCBAPI
|
||||
count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||
{
|
||||
if (png_ptr != NULL && row_info != NULL)
|
||||
@@ -178,9 +162,7 @@ count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||
|
||||
static png_uint_32 zero_samples;
|
||||
|
||||
void PNGCBAPI
|
||||
count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data);
|
||||
void PNGCBAPI
|
||||
static void PNGCBAPI
|
||||
count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||
{
|
||||
png_bytep dp = data;
|
||||
@@ -341,7 +323,6 @@ pngtest_check_io_state(png_structp png_ptr, png_size_t data_length,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
static void PNGCBAPI
|
||||
pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
@@ -366,59 +347,6 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
pngtest_check_io_state(png_ptr, length, PNG_IO_READING);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
/* This is the model-independent version. Since the standard I/O library
|
||||
can't handle far buffers in the medium and small models, we have to copy
|
||||
the data.
|
||||
*/
|
||||
|
||||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
static void PNGCBAPI
|
||||
pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_size_t check;
|
||||
png_byte *n_data;
|
||||
png_FILE_p io_ptr;
|
||||
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
n_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_get_io_ptr(png_ptr));
|
||||
if ((png_bytep)n_data == data)
|
||||
{
|
||||
check = fread(n_data, 1, length, io_ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
png_byte buf[NEAR_BUF_SIZE];
|
||||
png_size_t read, remaining, err;
|
||||
check = 0;
|
||||
remaining = length;
|
||||
|
||||
do
|
||||
{
|
||||
read = MIN(NEAR_BUF_SIZE, remaining);
|
||||
err = fread(buf, 1, 1, io_ptr);
|
||||
png_memcpy(data, buf, read); /* Copy far buffer to near buffer */
|
||||
if (err != read)
|
||||
break;
|
||||
else
|
||||
check += err;
|
||||
data += read;
|
||||
remaining -= read;
|
||||
}
|
||||
while (remaining != 0);
|
||||
}
|
||||
|
||||
if (check != length)
|
||||
png_error(png_ptr, "Read Error");
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
pngtest_check_io_state(png_ptr, length, PNG_IO_READING);
|
||||
#endif
|
||||
}
|
||||
#endif /* USE_FAR_KEYWORD */
|
||||
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
static void PNGCBAPI
|
||||
@@ -434,7 +362,6 @@ pngtest_flush(png_structp png_ptr)
|
||||
* write_data function and use it at run time with png_set_write_fn(), rather
|
||||
* than changing the library.
|
||||
*/
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
static void PNGCBAPI
|
||||
pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
@@ -451,63 +378,6 @@ pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
pngtest_check_io_state(png_ptr, length, PNG_IO_WRITING);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
/* This is the model-independent version. Since the standard I/O library
|
||||
can't handle far buffers in the medium and small models, we have to copy
|
||||
the data.
|
||||
*/
|
||||
|
||||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
static void PNGCBAPI
|
||||
pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_size_t check;
|
||||
png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */
|
||||
png_FILE_p io_ptr;
|
||||
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
near_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_get_io_ptr(png_ptr));
|
||||
|
||||
if ((png_bytep)near_data == data)
|
||||
{
|
||||
check = fwrite(near_data, 1, length, io_ptr);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_byte buf[NEAR_BUF_SIZE];
|
||||
png_size_t written, remaining, err;
|
||||
check = 0;
|
||||
remaining = length;
|
||||
|
||||
do
|
||||
{
|
||||
written = MIN(NEAR_BUF_SIZE, remaining);
|
||||
png_memcpy(buf, data, written); /* Copy far buffer to near buffer */
|
||||
err = fwrite(buf, 1, written, io_ptr);
|
||||
if (err != written)
|
||||
break;
|
||||
else
|
||||
check += err;
|
||||
data += written;
|
||||
remaining -= written;
|
||||
}
|
||||
while (remaining != 0);
|
||||
}
|
||||
|
||||
if (check != length)
|
||||
{
|
||||
png_error(png_ptr, "Write Error");
|
||||
}
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
pngtest_check_io_state(png_ptr, length, PNG_IO_WRITING);
|
||||
#endif
|
||||
}
|
||||
#endif /* USE_FAR_KEYWORD */
|
||||
|
||||
/* This function is called when there is a warning, but the library thinks
|
||||
* it can continue anyway. Replacement functions don't have to do anything
|
||||
@@ -560,9 +430,9 @@ typedef struct memory_information
|
||||
{
|
||||
png_alloc_size_t size;
|
||||
png_voidp pointer;
|
||||
struct memory_information FAR *next;
|
||||
struct memory_information *next;
|
||||
} memory_information;
|
||||
typedef memory_information FAR *memory_infop;
|
||||
typedef memory_information *memory_infop;
|
||||
|
||||
static memory_infop pinformation = NULL;
|
||||
static int current_allocation = 0;
|
||||
@@ -618,7 +488,7 @@ PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size)
|
||||
pinfo->next = pinformation;
|
||||
pinformation = pinfo;
|
||||
/* Make sure the caller isn't assuming zeroed memory. */
|
||||
png_memset(pinfo->pointer, 0xdd, pinfo->size);
|
||||
memset(pinfo->pointer, 0xdd, pinfo->size);
|
||||
|
||||
if (verbose)
|
||||
printf("png_malloc %lu bytes at %p\n", (unsigned long)size,
|
||||
@@ -645,7 +515,7 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
|
||||
|
||||
/* Unlink the element from the list. */
|
||||
{
|
||||
memory_infop FAR *ppinfo = &pinformation;
|
||||
memory_infop *ppinfo = &pinformation;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@@ -659,7 +529,7 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
|
||||
fprintf(STDERR, "Duplicate free of memory\n");
|
||||
/* We must free the list element too, but first kill
|
||||
the memory that is to be freed. */
|
||||
png_memset(ptr, 0x55, pinfo->size);
|
||||
memset(ptr, 0x55, pinfo->size);
|
||||
png_free_default(png_ptr, pinfo);
|
||||
pinfo = NULL;
|
||||
break;
|
||||
@@ -756,7 +626,7 @@ static int PNGCBAPI read_user_chunk_callback(png_struct *png_ptr,
|
||||
/* END of code to demonstrate user chunk support */
|
||||
|
||||
/* Test one file */
|
||||
int
|
||||
static int
|
||||
test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
static png_FILE_p fpin;
|
||||
@@ -777,11 +647,6 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_uint_32 width, height;
|
||||
int num_pass, pass;
|
||||
int bit_depth, color_type;
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
jmp_buf png_jmpbuf;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
char inbuf[256], outbuf[256];
|
||||
|
||||
@@ -847,11 +712,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
pngtest_debug("Setting jmpbuf for read struct");
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
if (setjmp(png_jmpbuf))
|
||||
#else
|
||||
if (setjmp(png_jmpbuf(read_ptr)))
|
||||
#endif
|
||||
{
|
||||
fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname);
|
||||
png_free(read_ptr, row_buf);
|
||||
@@ -865,18 +726,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
FCLOSE(fpout);
|
||||
return (1);
|
||||
}
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
png_memcpy(png_jmpbuf(read_ptr), png_jmpbuf, png_sizeof(jmp_buf));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
pngtest_debug("Setting jmpbuf for write struct");
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
|
||||
if (setjmp(png_jmpbuf))
|
||||
#else
|
||||
if (setjmp(png_jmpbuf(write_ptr)))
|
||||
#endif
|
||||
{
|
||||
fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname);
|
||||
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
||||
@@ -888,10 +742,6 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
FCLOSE(fpout);
|
||||
return (1);
|
||||
}
|
||||
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
png_memcpy(png_jmpbuf(write_ptr), png_jmpbuf, png_sizeof(jmp_buf));
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -913,6 +763,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
/* Normally one would use Z_DEFAULT_STRATEGY for text compression.
|
||||
* This is here just to make pngtest replicate the results from libpng
|
||||
* versions prior to 1.5.4, and to test this new API.
|
||||
*/
|
||||
png_set_text_compression_strategy(write_ptr, Z_FILTERED);
|
||||
#endif
|
||||
|
||||
if (status_dots_requested == 1)
|
||||
{
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
@@ -1152,6 +1010,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0)
|
||||
{
|
||||
pngtest_debug1("Handling %d iTXt/tEXt/zTXt chunks", num_text);
|
||||
|
||||
if (verbose)
|
||||
printf("\n Text compression=%d\n", text_ptr->compression);
|
||||
|
||||
png_set_text(write_ptr, write_info_ptr, text_ptr, num_text);
|
||||
}
|
||||
}
|
||||
@@ -1164,15 +1026,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
png_set_tIME(write_ptr, write_info_ptr, mod_time);
|
||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||
/* We have to use png_memcpy instead of "=" because the string
|
||||
* pointed to by png_convert_to_rfc1123() gets free'ed before
|
||||
* we use it.
|
||||
*/
|
||||
png_memcpy(tIME_string,
|
||||
png_convert_to_rfc1123(read_ptr, mod_time),
|
||||
png_sizeof(tIME_string));
|
||||
|
||||
if (png_convert_to_rfc1123_buffer(tIME_string, mod_time))
|
||||
tIME_string[png_sizeof(tIME_string) - 1] = '\0';
|
||||
|
||||
else
|
||||
strcpy(tIME_string, "*** invalid time ***");
|
||||
|
||||
tIME_chunk_present++;
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
}
|
||||
@@ -1360,14 +1219,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
png_set_tIME(write_ptr, write_end_info_ptr, mod_time);
|
||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||
/* We have to use png_memcpy instead of "=" because the string
|
||||
pointed to by png_convert_to_rfc1123() gets free'ed before
|
||||
we use it */
|
||||
png_memcpy(tIME_string,
|
||||
png_convert_to_rfc1123(read_ptr, mod_time),
|
||||
png_sizeof(tIME_string));
|
||||
|
||||
if (png_convert_to_rfc1123_buffer(tIME_string, mod_time))
|
||||
tIME_string[png_sizeof(tIME_string) - 1] = '\0';
|
||||
|
||||
else
|
||||
strcpy(tIME_string, "*** invalid time ***");
|
||||
|
||||
tIME_chunk_present++;
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
}
|
||||
@@ -1469,13 +1326,18 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
|
||||
FCLOSE(fpin);
|
||||
FCLOSE(fpout);
|
||||
|
||||
if (strict != 0)
|
||||
return (1);
|
||||
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (!num_in)
|
||||
break;
|
||||
|
||||
if (png_memcmp(inbuf, outbuf, num_in))
|
||||
if (memcmp(inbuf, outbuf, num_in))
|
||||
{
|
||||
fprintf(STDERR, "\nFiles %s and %s are different\n", inname, outname);
|
||||
|
||||
@@ -1494,6 +1356,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
|
||||
FCLOSE(fpin);
|
||||
FCLOSE(fpout);
|
||||
|
||||
if (strict != 0)
|
||||
return (1);
|
||||
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
@@ -1576,6 +1443,14 @@ main(int argc, char *argv[])
|
||||
inname = argv[2];
|
||||
}
|
||||
|
||||
else if (strcmp(argv[1], "--strict") == 0)
|
||||
{
|
||||
status_dots_requested = 0;
|
||||
verbose = 1;
|
||||
inname = argv[2];
|
||||
strict++;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
inname = argv[1];
|
||||
@@ -1784,4 +1659,4 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef png_libpng_version_1_5_1 Your_png_h_is_not_version_1_5_1;
|
||||
typedef png_libpng_version_1_6_0beta10 Your_png_h_is_not_version_1_6_0beta10;
|
||||
|
||||
BIN
pngtest.png
|
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB |
263
pngtrans.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* Last changed in libpng 1.5.1 [February 3, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -18,7 +18,7 @@
|
||||
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
||||
/* Turn on BGR-to-RGB mapping */
|
||||
void PNGAPI
|
||||
png_set_bgr(png_structp png_ptr)
|
||||
png_set_bgr(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_bgr");
|
||||
|
||||
@@ -32,7 +32,7 @@ png_set_bgr(png_structp png_ptr)
|
||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||
/* Turn on 16 bit byte swapping */
|
||||
void PNGAPI
|
||||
png_set_swap(png_structp png_ptr)
|
||||
png_set_swap(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_swap");
|
||||
|
||||
@@ -47,7 +47,7 @@ png_set_swap(png_structp png_ptr)
|
||||
#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
/* Turn on pixel packing */
|
||||
void PNGAPI
|
||||
png_set_packing(png_structp png_ptr)
|
||||
png_set_packing(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_packing");
|
||||
|
||||
@@ -65,7 +65,7 @@ png_set_packing(png_structp png_ptr)
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
||||
/* Turn on packed pixel swapping */
|
||||
void PNGAPI
|
||||
png_set_packswap(png_structp png_ptr)
|
||||
png_set_packswap(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_packswap");
|
||||
|
||||
@@ -79,7 +79,7 @@ png_set_packswap(png_structp png_ptr)
|
||||
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_shift(png_structp png_ptr, png_const_color_8p true_bits)
|
||||
png_set_shift(png_structrp png_ptr, png_const_color_8p true_bits)
|
||||
{
|
||||
png_debug(1, "in png_set_shift");
|
||||
|
||||
@@ -94,7 +94,7 @@ png_set_shift(png_structp png_ptr, png_const_color_8p true_bits)
|
||||
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
|
||||
defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
int PNGAPI
|
||||
png_set_interlace_handling(png_structp png_ptr)
|
||||
png_set_interlace_handling(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_interlace handling");
|
||||
|
||||
@@ -115,7 +115,7 @@ png_set_interlace_handling(png_structp png_ptr)
|
||||
* that don't like bytes as parameters.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
{
|
||||
png_debug(1, "in png_set_filler");
|
||||
|
||||
@@ -152,7 +152,7 @@ png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
|
||||
/* Added to libpng-1.2.7 */
|
||||
void PNGAPI
|
||||
png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
png_set_add_alpha(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
{
|
||||
png_debug(1, "in png_set_add_alpha");
|
||||
|
||||
@@ -168,7 +168,7 @@ png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
|
||||
defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_swap_alpha(png_structp png_ptr)
|
||||
png_set_swap_alpha(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_swap_alpha");
|
||||
|
||||
@@ -182,7 +182,7 @@ png_set_swap_alpha(png_structp png_ptr)
|
||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
|
||||
defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_invert_alpha(png_structp png_ptr)
|
||||
png_set_invert_alpha(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_invert_alpha");
|
||||
|
||||
@@ -195,7 +195,7 @@ png_set_invert_alpha(png_structp png_ptr)
|
||||
|
||||
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_invert_mono(png_structp png_ptr)
|
||||
png_set_invert_mono(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_invert_mono");
|
||||
|
||||
@@ -424,170 +424,119 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
|
||||
|
||||
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
||||
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||
/* Remove filler or alpha byte(s) */
|
||||
/* Remove a channel - this used to be 'png_do_strip_filler' but it used a
|
||||
* somewhat weird combination of flags to determine what to do. All the calls
|
||||
* to png_do_strip_filler are changed in 1.5.2 to call this instead with the
|
||||
* correct arguments.
|
||||
*
|
||||
* The routine isn't general - the channel must be the channel at the start or
|
||||
* end (not in the middle) of each pixel.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
||||
png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||
{
|
||||
png_debug(1, "in png_do_strip_filler");
|
||||
png_bytep sp = row; /* source pointer */
|
||||
png_bytep dp = row; /* destination pointer */
|
||||
png_bytep ep = row + row_info->rowbytes; /* One beyond end of row */
|
||||
|
||||
{
|
||||
png_bytep sp = row;
|
||||
png_bytep dp = row;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
png_uint_32 i;
|
||||
/* At the start sp will point to the first byte to copy and dp to where
|
||||
* it is copied to. ep always points just beyond the end of the row, so
|
||||
* the loop simply copies (channels-1) channels until sp reaches ep.
|
||||
*
|
||||
* at_start: 0 -- convert AG, XG, ARGB, XRGB, AAGG, XXGG, etc.
|
||||
* nonzero -- convert GA, GX, RGBA, RGBX, GGAA, RRGGBBXX, etc.
|
||||
*/
|
||||
|
||||
if ((row_info->color_type == PNG_COLOR_TYPE_RGB ||
|
||||
(row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&
|
||||
(flags & PNG_FLAG_STRIP_ALPHA))) &&
|
||||
row_info->channels == 4)
|
||||
/* GA, GX, XG cases */
|
||||
if (row_info->channels == 2)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
/* This converts from RGBX or RGBA to RGB */
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
dp += 3; sp += 4;
|
||||
for (i = 1; i < row_width; i++)
|
||||
{
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
sp++;
|
||||
}
|
||||
if (at_start) /* Skip initial filler */
|
||||
++sp;
|
||||
else /* Skip initial channel and, for sp, the filler */
|
||||
sp += 2, ++dp;
|
||||
|
||||
/* For a 1 pixel wide image there is nothing to do */
|
||||
while (sp < ep)
|
||||
*dp++ = *sp, sp += 2;
|
||||
|
||||
row_info->pixel_depth = 8;
|
||||
}
|
||||
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
if (at_start) /* Skip initial filler */
|
||||
sp += 2;
|
||||
else /* Skip initial channel and, for sp, the filler */
|
||||
sp += 4, dp += 2;
|
||||
|
||||
while (sp < ep)
|
||||
*dp++ = *sp++, *dp++ = *sp, sp += 3;
|
||||
|
||||
row_info->pixel_depth = 16;
|
||||
}
|
||||
|
||||
/* This converts from XRGB or ARGB to RGB */
|
||||
else
|
||||
{
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
}
|
||||
return; /* bad bit depth */
|
||||
|
||||
row_info->channels = 1;
|
||||
|
||||
/* Finally fix the color type if it records an alpha channel */
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
row_info->color_type = PNG_COLOR_TYPE_GRAY;
|
||||
}
|
||||
|
||||
/* RGBA, RGBX, XRGB cases */
|
||||
else if (row_info->channels == 4)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
if (at_start) /* Skip initial filler */
|
||||
++sp;
|
||||
else /* Skip initial channels and, for sp, the filler */
|
||||
sp += 4, dp += 3;
|
||||
|
||||
/* Note that the loop adds 3 to dp and 4 to sp each time. */
|
||||
while (sp < ep)
|
||||
*dp++ = *sp++, *dp++ = *sp++, *dp++ = *sp, sp += 2;
|
||||
|
||||
row_info->pixel_depth = 24;
|
||||
row_info->rowbytes = row_width * 3;
|
||||
}
|
||||
|
||||
else /* if (row_info->bit_depth == 16) */
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
/* This converts from RRGGBBXX or RRGGBBAA to RRGGBB */
|
||||
sp += 8; dp += 6;
|
||||
for (i = 1; i < row_width; i++)
|
||||
{
|
||||
/* This could be (although png_memcpy is probably slower):
|
||||
png_memcpy(dp, sp, 6);
|
||||
sp += 8;
|
||||
dp += 6;
|
||||
*/
|
||||
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
if (at_start) /* Skip initial filler */
|
||||
sp += 2;
|
||||
}
|
||||
}
|
||||
else /* Skip initial channels and, for sp, the filler */
|
||||
sp += 8, dp += 6;
|
||||
|
||||
else
|
||||
while (sp < ep)
|
||||
{
|
||||
/* This converts from XXRRGGBB or AARRGGBB to RRGGBB */
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
/* This could be (although png_memcpy is probably slower):
|
||||
png_memcpy(dp, sp, 6);
|
||||
sp += 8;
|
||||
dp += 6;
|
||||
*/
|
||||
|
||||
sp += 2;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
}
|
||||
/* Copy 6 bytes, skip 2 */
|
||||
*dp++ = *sp++, *dp++ = *sp++;
|
||||
*dp++ = *sp++, *dp++ = *sp++;
|
||||
*dp++ = *sp++, *dp++ = *sp, sp += 3;
|
||||
}
|
||||
|
||||
row_info->pixel_depth = 48;
|
||||
row_info->rowbytes = row_width * 6;
|
||||
}
|
||||
|
||||
else
|
||||
return; /* bad bit depth */
|
||||
|
||||
row_info->channels = 3;
|
||||
}
|
||||
|
||||
else if ((row_info->color_type == PNG_COLOR_TYPE_GRAY ||
|
||||
(row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
|
||||
(flags & PNG_FLAG_STRIP_ALPHA))) &&
|
||||
row_info->channels == 2)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
/* This converts from GX or GA to G */
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*dp++ = *sp++;
|
||||
sp++;
|
||||
}
|
||||
/* Finally fix the color type if it records an alpha channel */
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
row_info->color_type = PNG_COLOR_TYPE_RGB;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* This converts from XG or AG to G */
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
sp++;
|
||||
*dp++ = *sp++;
|
||||
}
|
||||
}
|
||||
return; /* The filler channel has gone already */
|
||||
|
||||
row_info->pixel_depth = 8;
|
||||
row_info->rowbytes = row_width;
|
||||
}
|
||||
|
||||
else /* if (row_info->bit_depth == 16) */
|
||||
{
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
/* This converts from GGXX or GGAA to GG */
|
||||
sp += 4; dp += 2;
|
||||
for (i = 1; i < row_width; i++)
|
||||
{
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
sp += 2;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* This converts from XXGG or AAGG to GG */
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
sp += 2;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
}
|
||||
}
|
||||
|
||||
row_info->pixel_depth = 16;
|
||||
row_info->rowbytes = row_width * 2;
|
||||
}
|
||||
row_info->channels = 1;
|
||||
}
|
||||
|
||||
if (flags & PNG_FLAG_STRIP_ALPHA)
|
||||
row_info->color_type = (png_byte)(row_info->color_type &
|
||||
~PNG_COLOR_MASK_ALPHA);
|
||||
}
|
||||
/* Fix the rowbytes value. */
|
||||
row_info->rowbytes = dp-row;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -674,7 +623,7 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_user_transform_info(png_structp png_ptr, png_voidp
|
||||
png_set_user_transform_info(png_structrp png_ptr, png_voidp
|
||||
user_transform_ptr, int user_transform_depth, int user_transform_channels)
|
||||
{
|
||||
png_debug(1, "in png_set_user_transform_info");
|
||||
@@ -694,30 +643,36 @@ png_set_user_transform_info(png_structp png_ptr, png_voidp
|
||||
*/
|
||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
png_voidp PNGAPI
|
||||
png_get_user_transform_ptr(png_const_structp png_ptr)
|
||||
png_get_user_transform_ptr(png_const_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return (NULL);
|
||||
|
||||
return ((png_voidp)png_ptr->user_transform_ptr);
|
||||
return png_ptr->user_transform_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_current_row_number(png_const_structp png_ptr)
|
||||
png_get_current_row_number(png_const_structrp png_ptr)
|
||||
{
|
||||
/* See the comments in png.h - this is the sub-image row when reading and
|
||||
* interlaced image.
|
||||
*/
|
||||
if (png_ptr != NULL)
|
||||
return png_ptr->row_number;
|
||||
|
||||
return PNG_UINT_32_MAX; /* help the app not to fail silently */
|
||||
}
|
||||
|
||||
png_byte PNGAPI
|
||||
png_get_current_pass_number(png_const_structp png_ptr)
|
||||
png_get_current_pass_number(png_const_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
return png_ptr->pass;
|
||||
return 8; /* invalid */
|
||||
}
|
||||
#endif /* PNG_USER_TRANSFORM_INFO_SUPPORTED */
|
||||
#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||
|
||||
PNG_WRITE_USER_TRANSFORM_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
|
||||
106
pngwio.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngwio.c - functions for data output
|
||||
*
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -30,11 +30,12 @@
|
||||
*/
|
||||
|
||||
void /* PRIVATE */
|
||||
png_write_data(png_structp png_ptr, png_const_bytep data, png_size_t length)
|
||||
png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length)
|
||||
{
|
||||
/* NOTE: write_data_fn must not change the buffer! */
|
||||
if (png_ptr->write_data_fn != NULL )
|
||||
(*(png_ptr->write_data_fn))(png_ptr, (png_bytep)data, length);
|
||||
(*(png_ptr->write_data_fn))(png_ptr, png_constcast(png_bytep,data),
|
||||
length);
|
||||
|
||||
else
|
||||
png_error(png_ptr, "Call to NULL write function");
|
||||
@@ -46,7 +47,6 @@ png_write_data(png_structp png_ptr, png_const_bytep data, png_size_t length)
|
||||
* write_data function and use it at run time with png_set_write_fn(), rather
|
||||
* than changing the library.
|
||||
*/
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
void PNGCBAPI
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
@@ -60,64 +60,6 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
if (check != length)
|
||||
png_error(png_ptr, "Write Error");
|
||||
}
|
||||
#else
|
||||
/* This is the model-independent version. Since the standard I/O library
|
||||
* can't handle far buffers in the medium and small models, we have to copy
|
||||
* the data.
|
||||
*/
|
||||
|
||||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
void PNGCBAPI
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_uint_32 check;
|
||||
png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */
|
||||
png_FILE_p io_ptr;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
near_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
||||
|
||||
if ((png_bytep)near_data == data)
|
||||
{
|
||||
check = fwrite(near_data, 1, length, io_ptr);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_byte buf[NEAR_BUF_SIZE];
|
||||
png_size_t written, remaining, err;
|
||||
check = 0;
|
||||
remaining = length;
|
||||
|
||||
do
|
||||
{
|
||||
written = MIN(NEAR_BUF_SIZE, remaining);
|
||||
png_memcpy(buf, data, written); /* Copy far buffer to near buffer */
|
||||
err = fwrite(buf, 1, written, io_ptr);
|
||||
|
||||
if (err != written)
|
||||
break;
|
||||
|
||||
else
|
||||
check += err;
|
||||
|
||||
data += written;
|
||||
remaining -= written;
|
||||
}
|
||||
while (remaining != 0);
|
||||
}
|
||||
|
||||
if (check != length)
|
||||
png_error(png_ptr, "Write Error");
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* This function is called to output any data pending writing (normally
|
||||
@@ -126,7 +68,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
*/
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
png_flush(png_structp png_ptr)
|
||||
png_flush(png_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr->output_flush_fn != NULL)
|
||||
(*(png_ptr->output_flush_fn))(png_ptr);
|
||||
@@ -141,7 +83,7 @@ png_default_flush(png_structp png_ptr)
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
|
||||
io_ptr = png_voidcast(png_FILE_p, (png_ptr->io_ptr));
|
||||
fflush(io_ptr);
|
||||
}
|
||||
# endif
|
||||
@@ -177,7 +119,7 @@ png_default_flush(png_structp png_ptr)
|
||||
* *FILE structure.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
@@ -219,36 +161,4 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
" same structure");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
# ifdef _MSC_VER
|
||||
void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
|
||||
{
|
||||
void *near_ptr;
|
||||
void FAR *far_ptr;
|
||||
FP_OFF(near_ptr) = FP_OFF(ptr);
|
||||
far_ptr = (void FAR *)near_ptr;
|
||||
|
||||
if (check != 0)
|
||||
if (FP_SEG(ptr) != FP_SEG(far_ptr))
|
||||
png_error(png_ptr, "segment lost in conversion");
|
||||
|
||||
return(near_ptr);
|
||||
}
|
||||
# else
|
||||
void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
|
||||
{
|
||||
void *near_ptr;
|
||||
void FAR *far_ptr;
|
||||
near_ptr = (void FAR *)ptr;
|
||||
far_ptr = (void FAR *)near_ptr;
|
||||
|
||||
if (check != 0)
|
||||
if (far_ptr != ptr)
|
||||
png_error(png_ptr, "segment lost in conversion");
|
||||
|
||||
return(near_ptr);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
|
||||
1232
pngwrite.c
66
pngwtran.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -15,11 +15,12 @@
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
|
||||
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
/* Transform the data according to the user's wishes. The order of
|
||||
* transformations is significant.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_do_write_transformations(png_structp png_ptr)
|
||||
png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
{
|
||||
png_debug(1, "in png_do_write_transformations");
|
||||
|
||||
@@ -32,7 +33,7 @@ png_do_write_transformations(png_structp png_ptr)
|
||||
(*(png_ptr->write_user_transform_fn)) /* User write transform
|
||||
function */
|
||||
(png_ptr, /* png_ptr */
|
||||
&(png_ptr->row_info), /* row_info: */
|
||||
row_info, /* row_info: */
|
||||
/* png_uint_32 width; width of row */
|
||||
/* png_size_t rowbytes; number of bytes in row */
|
||||
/* png_byte color_type; color type of pixels */
|
||||
@@ -44,50 +45,50 @@ png_do_write_transformations(png_structp png_ptr)
|
||||
|
||||
#ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_FILLER)
|
||||
png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
png_ptr->flags);
|
||||
png_do_strip_channel(row_info, png_ptr->row_buf + 1,
|
||||
!(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_PACKSWAP)
|
||||
png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
png_do_packswap(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_PACK_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_PACK)
|
||||
png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
png_do_pack(row_info, png_ptr->row_buf + 1,
|
||||
(png_uint_32)png_ptr->bit_depth);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SWAP_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SWAP_BYTES)
|
||||
png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
png_do_swap(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SHIFT_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SHIFT)
|
||||
png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
png_do_shift(row_info, png_ptr->row_buf + 1,
|
||||
&(png_ptr->shift));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SWAP_ALPHA)
|
||||
png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_INVERT_ALPHA)
|
||||
png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_BGR_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_BGR)
|
||||
png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
png_do_bgr(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_INVERT_MONO)
|
||||
png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
png_do_invert(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -286,7 +287,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
png_bytep bp = row;
|
||||
png_size_t i;
|
||||
png_byte mask;
|
||||
unsigned int mask;
|
||||
png_size_t row_bytes = row_info->rowbytes;
|
||||
|
||||
if (bit_depth->gray == 1 && row_info->bit_depth == 2)
|
||||
@@ -300,20 +301,22 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
|
||||
for (i = 0; i < row_bytes; i++, bp++)
|
||||
{
|
||||
png_uint_16 v;
|
||||
int j;
|
||||
unsigned int v, out;
|
||||
|
||||
v = *bp;
|
||||
*bp = 0;
|
||||
out = 0;
|
||||
|
||||
for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0])
|
||||
{
|
||||
if (j > 0)
|
||||
*bp |= (png_byte)((v << j) & 0xff);
|
||||
out |= v << j;
|
||||
|
||||
else
|
||||
*bp |= (png_byte)((v >> (-j)) & mask);
|
||||
out |= (v >> (-j)) & mask;
|
||||
}
|
||||
|
||||
*bp = (png_byte)(out & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,21 +329,23 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
for (i = 0; i < istop; i++, bp++)
|
||||
{
|
||||
|
||||
png_uint_16 v;
|
||||
const unsigned int c = i%channels;
|
||||
int j;
|
||||
int c = (int)(i%channels);
|
||||
unsigned int v, out;
|
||||
|
||||
v = *bp;
|
||||
*bp = 0;
|
||||
out = 0;
|
||||
|
||||
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
||||
{
|
||||
if (j > 0)
|
||||
*bp |= (png_byte)((v << j) & 0xff);
|
||||
out |= v << j;
|
||||
|
||||
else
|
||||
*bp |= (png_byte)((v >> (-j)) & 0xff);
|
||||
out |= v >> (-j);
|
||||
}
|
||||
|
||||
*bp = (png_byte)(out & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,22 +357,22 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
|
||||
for (bp = row, i = 0; i < istop; i++)
|
||||
{
|
||||
int c = (int)(i%channels);
|
||||
png_uint_16 value, v;
|
||||
const unsigned int c = i%channels;
|
||||
int j;
|
||||
unsigned int value, v;
|
||||
|
||||
v = (png_uint_16)(((png_uint_16)(*bp) << 8) + *(bp + 1));
|
||||
v = png_get_uint_16(bp);
|
||||
value = 0;
|
||||
|
||||
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
||||
{
|
||||
if (j > 0)
|
||||
value |= (png_uint_16)((v << j) & (png_uint_16)0xffff);
|
||||
value |= v << j;
|
||||
|
||||
else
|
||||
value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff);
|
||||
value |= v >> (-j);
|
||||
}
|
||||
*bp++ = (png_byte)(value >> 8);
|
||||
*bp++ = (png_byte)((value >> 8) & 0xff);
|
||||
*bp++ = (png_byte)(value & 0xff);
|
||||
}
|
||||
}
|
||||
@@ -563,6 +568,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
|
||||
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
/* Undoes intrapixel differencing */
|
||||
|
||||
628
pngwutil.c
383
projects/owatcom/libpng.tgt
Normal file
@@ -0,0 +1,383 @@
|
||||
40
|
||||
targetIdent
|
||||
0
|
||||
MProject
|
||||
1
|
||||
MComponent
|
||||
0
|
||||
2
|
||||
WString
|
||||
3
|
||||
LIB
|
||||
3
|
||||
WString
|
||||
5
|
||||
n_2sn
|
||||
1
|
||||
0
|
||||
0
|
||||
4
|
||||
MCommand
|
||||
0
|
||||
5
|
||||
MCommand
|
||||
0
|
||||
6
|
||||
MItem
|
||||
10
|
||||
libpng.lib
|
||||
7
|
||||
WString
|
||||
3
|
||||
LIB
|
||||
8
|
||||
WVList
|
||||
0
|
||||
9
|
||||
WVList
|
||||
1
|
||||
10
|
||||
ActionStates
|
||||
11
|
||||
WString
|
||||
5
|
||||
&Make
|
||||
12
|
||||
WVList
|
||||
0
|
||||
-1
|
||||
1
|
||||
1
|
||||
0
|
||||
13
|
||||
WPickList
|
||||
16
|
||||
14
|
||||
MItem
|
||||
3
|
||||
*.c
|
||||
15
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
16
|
||||
WVList
|
||||
2
|
||||
17
|
||||
MVState
|
||||
18
|
||||
WString
|
||||
3
|
||||
WCC
|
||||
19
|
||||
WString
|
||||
25
|
||||
n????Include directories:
|
||||
1
|
||||
20
|
||||
WString
|
||||
39
|
||||
"$(%zlib);$(%watcom)/h;$(%watcom)/h/nt"
|
||||
0
|
||||
21
|
||||
MVState
|
||||
22
|
||||
WString
|
||||
3
|
||||
WCC
|
||||
23
|
||||
WString
|
||||
25
|
||||
n????Include directories:
|
||||
0
|
||||
24
|
||||
WString
|
||||
39
|
||||
"$(%zlib);$(%watcom)/h;$(%watcom)/h/nt"
|
||||
0
|
||||
25
|
||||
WVList
|
||||
1
|
||||
26
|
||||
ActionStates
|
||||
27
|
||||
WString
|
||||
5
|
||||
&Make
|
||||
28
|
||||
WVList
|
||||
0
|
||||
-1
|
||||
1
|
||||
1
|
||||
0
|
||||
29
|
||||
MItem
|
||||
11
|
||||
..\..\png.c
|
||||
30
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
31
|
||||
WVList
|
||||
0
|
||||
32
|
||||
WVList
|
||||
0
|
||||
14
|
||||
1
|
||||
1
|
||||
0
|
||||
33
|
||||
MItem
|
||||
16
|
||||
..\..\pngerror.c
|
||||
34
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
35
|
||||
WVList
|
||||
0
|
||||
36
|
||||
WVList
|
||||
0
|
||||
14
|
||||
1
|
||||
1
|
||||
0
|
||||
37
|
||||
MItem
|
||||
14
|
||||
..\..\pngget.c
|
||||
38
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
39
|
||||
WVList
|
||||
0
|
||||
40
|
||||
WVList
|
||||
0
|
||||
14
|
||||
1
|
||||
1
|
||||
0
|
||||
41
|
||||
MItem
|
||||
14
|
||||
..\..\pngmem.c
|
||||
42
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
43
|
||||
WVList
|
||||
0
|
||||
44
|
||||
WVList
|
||||
0
|
||||
14
|
||||
1
|
||||
1
|
||||
0
|
||||
45
|
||||
MItem
|
||||
16
|
||||
..\..\pngpread.c
|
||||
46
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
47
|
||||
WVList
|
||||
0
|
||||
48
|
||||
WVList
|
||||
0
|
||||
14
|
||||
1
|
||||
1
|
||||
0
|
||||
49
|
||||
MItem
|
||||
15
|
||||
..\..\pngread.c
|
||||
50
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
51
|
||||
WVList
|
||||
0
|
||||
52
|
||||
WVList
|
||||
0
|
||||
14
|
||||
1
|
||||
1
|
||||
0
|
||||
53
|
||||
MItem
|
||||
14
|
||||
..\..\pngrio.c
|
||||
54
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
55
|
||||
WVList
|
||||
0
|
||||
56
|
||||
WVList
|
||||
0
|
||||
14
|
||||
1
|
||||
1
|
||||
0
|
||||
57
|
||||
MItem
|
||||
16
|
||||
..\..\pngrtran.c
|
||||
58
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
59
|
||||
WVList
|
||||
0
|
||||
60
|
||||
WVList
|
||||
0
|
||||
14
|
||||
1
|
||||
1
|
||||
0
|
||||
61
|
||||
MItem
|
||||
16
|
||||
..\..\pngrutil.c
|
||||
62
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
63
|
||||
WVList
|
||||
0
|
||||
64
|
||||
WVList
|
||||
0
|
||||
14
|
||||
1
|
||||
1
|
||||
0
|
||||
65
|
||||
MItem
|
||||
14
|
||||
..\..\pngset.c
|
||||
66
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
67
|
||||
WVList
|
||||
0
|
||||
68
|
||||
WVList
|
||||
0
|
||||
14
|
||||
1
|
||||
1
|
||||
0
|
||||
69
|
||||
MItem
|
||||
16
|
||||
..\..\pngtrans.c
|
||||
70
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
71
|
||||
WVList
|
||||
0
|
||||
72
|
||||
WVList
|
||||
0
|
||||
14
|
||||
1
|
||||
1
|
||||
0
|
||||
73
|
||||
MItem
|
||||
14
|
||||
..\..\pngwio.c
|
||||
74
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
75
|
||||
WVList
|
||||
0
|
||||
76
|
||||
WVList
|
||||
0
|
||||
14
|
||||
1
|
||||
1
|
||||
0
|
||||
77
|
||||
MItem
|
||||
16
|
||||
..\..\pngwrite.c
|
||||
78
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
79
|
||||
WVList
|
||||
0
|
||||
80
|
||||
WVList
|
||||
0
|
||||
14
|
||||
1
|
||||
1
|
||||
0
|
||||
81
|
||||
MItem
|
||||
16
|
||||
..\..\pngwtran.c
|
||||
82
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
83
|
||||
WVList
|
||||
0
|
||||
84
|
||||
WVList
|
||||
0
|
||||
14
|
||||
1
|
||||
1
|
||||
0
|
||||
85
|
||||
MItem
|
||||
16
|
||||
..\..\pngwutil.c
|
||||
86
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
87
|
||||
WVList
|
||||
0
|
||||
88
|
||||
WVList
|
||||
0
|
||||
14
|
||||
1
|
||||
1
|
||||
0
|
||||
112
projects/owatcom/libpng.wpj
Normal file
@@ -0,0 +1,112 @@
|
||||
40
|
||||
projectIdent
|
||||
0
|
||||
VpeMain
|
||||
1
|
||||
WRect
|
||||
256
|
||||
0
|
||||
8960
|
||||
9294
|
||||
2
|
||||
MProject
|
||||
3
|
||||
MCommand
|
||||
322
|
||||
# Locations of zlib and (if required) awk (change as required:)
|
||||
set zlib=..\..\..\zlib
|
||||
set awk=
|
||||
#
|
||||
@if not exist pngconfig.dfa $(MAKE) $(__MAKEOPTS__) -f pngconfig.mak defaults
|
||||
@if exist config.inf type config.inf
|
||||
@echo Checking for the libpng configuration file pnglibconf.h
|
||||
$(MAKE) $(__MAKEOPTS__) -f pngconfig.mak
|
||||
4
|
||||
MCommand
|
||||
19
|
||||
@type pngconfig.inf
|
||||
4
|
||||
5
|
||||
WFileName
|
||||
10
|
||||
libpng.tgt
|
||||
6
|
||||
WFileName
|
||||
11
|
||||
pngtest.tgt
|
||||
7
|
||||
WFileName
|
||||
12
|
||||
pngvalid.tgt
|
||||
8
|
||||
WFileName
|
||||
12
|
||||
pngstest.tgt
|
||||
9
|
||||
WVList
|
||||
4
|
||||
10
|
||||
VComponent
|
||||
11
|
||||
WRect
|
||||
0
|
||||
0
|
||||
5638
|
||||
4174
|
||||
0
|
||||
0
|
||||
12
|
||||
WFileName
|
||||
10
|
||||
libpng.tgt
|
||||
0
|
||||
0
|
||||
13
|
||||
VComponent
|
||||
14
|
||||
WRect
|
||||
1280
|
||||
1550
|
||||
5638
|
||||
4174
|
||||
0
|
||||
0
|
||||
15
|
||||
WFileName
|
||||
11
|
||||
pngtest.tgt
|
||||
0
|
||||
1
|
||||
16
|
||||
VComponent
|
||||
17
|
||||
WRect
|
||||
524
|
||||
497
|
||||
5638
|
||||
4174
|
||||
0
|
||||
0
|
||||
18
|
||||
WFileName
|
||||
12
|
||||
pngvalid.tgt
|
||||
0
|
||||
1
|
||||
19
|
||||
VComponent
|
||||
20
|
||||
WRect
|
||||
2054
|
||||
2701
|
||||
5674
|
||||
4232
|
||||
0
|
||||
0
|
||||
21
|
||||
WFileName
|
||||
12
|
||||
pngstest.tgt
|
||||
0
|
||||
1
|
||||
19
|
||||
160
projects/owatcom/pngconfig.mak
Normal file
@@ -0,0 +1,160 @@
|
||||
# This is an OpenWatcom make file which builds pnglibconf.h - the libpng
|
||||
# configuration header. You can ignore this file if you don't need to
|
||||
# configure libpng; a default configuration will be built.
|
||||
#
|
||||
# For more information build libpng.wpj under the IDE and then read the
|
||||
# generated files:
|
||||
#
|
||||
# config.inf: Basic configuration information for a standard build.
|
||||
# pngconfig.dfa: Advanced configuration for non-standard libpng builds.
|
||||
#
|
||||
DELETE=rm -f
|
||||
ECHO=echo
|
||||
COPY=copy
|
||||
#
|
||||
# If your configuration needs to test compiler flags when building
|
||||
# pnglibconf.h you may need to override the following on the wmake command
|
||||
# line:
|
||||
CFLAGS=
|
||||
CC=wcl386
|
||||
CPP=$(CC) -pw0
|
||||
#
|
||||
# Read awk from the environment if set, else it can be set on the command
|
||||
# line (the default approach is to set the %awk% environment variable in the
|
||||
# IDE libpng.wpj 'before' rule - this setting is local.)
|
||||
!ifdef %awk
|
||||
AWK=$(%awk)
|
||||
!endif
|
||||
#
|
||||
# pnglibconf.h must exist in the source directory, this is the final rule
|
||||
# which copies the local built version (and this is the default target for
|
||||
# this makefile.)
|
||||
..\..\pnglibconf.h: pnglibconf.h
|
||||
$(COPY) pnglibconf.h $@
|
||||
|
||||
!ifdef AWK
|
||||
# CPPFLAGS should contain the options to control the result,
|
||||
# but DEFS and CFLAGS are also supported here, override
|
||||
# as appropriate
|
||||
DFNFLAGS = $(DEFS) $(CPPFLAGS) $(CFLAGS)
|
||||
|
||||
pnglibconf.h: pnglibconf.dfn
|
||||
$(DELETE) $@ dfn.c dfn1.out dfn2.out
|
||||
$(ECHO) $#include "pnglibconf.dfn" >dfn.c
|
||||
$(CPP) $(DFNFLAGS) dfn.c >dfn1.out
|
||||
$(AWK) -f << dfn1.out >dfn2.out
|
||||
/^.*PNG_DEFN_MAGIC-.*-PNG_DEFN_END.*$$/{
|
||||
sub(/^.*PNG_DEFN_MAGIC-/, "")
|
||||
sub(/ *-PNG_DEFN_END.*$$/, "")
|
||||
gsub(/ *@@@ */, "")
|
||||
print
|
||||
}
|
||||
<<
|
||||
$(COPY) dfn2.out $@
|
||||
@type << >pngconfig.inf
|
||||
This is a locally configurable build of libpng.lib; for configuration
|
||||
instructions consult and edit projects/openwatcom/pngconfig.dfa
|
||||
<<
|
||||
$(DELETE) dfn.c dfn1.out dfn2.out
|
||||
|
||||
pnglibconf.dfn: ..\..\scripts\pnglibconf.dfa ..\..\scripts\options.awk pngconfig.dfa ..\..\pngconf.h
|
||||
$(DELETE) $@ dfn1.out dfn2.out
|
||||
$(AWK) -f ..\..\scripts\options.awk out=dfn1.out version=search ..\..\pngconf.h ..\..\scripts\pnglibconf.dfa pngconfig.dfa $(DFA_XTRA) 1>&2
|
||||
$(AWK) -f ..\..\scripts\options.awk out=dfn2.out dfn1.out 1>&2
|
||||
$(COPY) dfn2.out $@
|
||||
$(DELETE) dfn1.out dfn2.out
|
||||
|
||||
!else
|
||||
# The following lines are used to copy scripts\pnglibconf.h.prebuilt and make
|
||||
# the required change to the calling convention.
|
||||
#
|
||||
# By default libpng is built to use the __cdecl calling convention on
|
||||
# Windows. This gives compatibility with MSVC and GCC. Unfortunately it
|
||||
# does not work with OpenWatcom because OpenWatcom implements longjmp using
|
||||
# the __watcall convention (compared with both MSVC and GCC which use __cdecl
|
||||
# for library functions.)
|
||||
#
|
||||
# Thus the default must be changed to build on OpenWatcom and, once changed,
|
||||
# the result will not be compatible with applications built using other
|
||||
# compilers (in fact attempts to build will fail at compile time.)
|
||||
#
|
||||
pnglibconf.h: ..\..\scripts\pnglibconf.h.prebuilt .existsonly
|
||||
@$(ECHO) .
|
||||
@$(ECHO) .
|
||||
@$(ECHO) $$(AWK) NOT AVAILABLE: COPYING scripts\pnglibconf.h.prebuilt
|
||||
@$(ECHO) .
|
||||
@$(ECHO) .
|
||||
vi -q -k ":1,$$s/PNG_API_RULE 0$$/PNG_API_RULE 2/\n:w! $@\n:q!\n" ..\..\scripts\pnglibconf.h.prebuilt
|
||||
@$(ECHO) .
|
||||
@$(ECHO) .
|
||||
@$(ECHO) YOU HAVE A DEFAULT CONFIGURATION BECAUSE YOU DO NOT HAVE AWK!
|
||||
@$(ECHO) .
|
||||
@$(ECHO) .
|
||||
@type << >pngconfig.inf
|
||||
This is the default configuration of libpng.lib, if you wish to
|
||||
change the configuration please consult the instructions in
|
||||
projects/owatcom/pngconfig.dfa.
|
||||
<<
|
||||
|
||||
!endif
|
||||
|
||||
# Make the default files
|
||||
defaults: .symbolic
|
||||
@$(COPY) << config.inf
|
||||
$# The libpng project is incompletely configured. To complete configuration
|
||||
$# please complete the following steps:
|
||||
$#
|
||||
$# 1) Edit the 'before' rule of libpng.wpj (from the IDE) to define the
|
||||
$# locations of the zlib include file zlib.h and the built zlib library,
|
||||
$# zlib.lib.
|
||||
$#
|
||||
$# 2) If you want to change libpng to a non-standard configuration also
|
||||
$# change the definition of 'awk' in the before rule to the name of your
|
||||
$# awk command. For more instructions on configuration read
|
||||
$# pngconfig.dfa.
|
||||
$#
|
||||
$# 3) Delete this file (config.inf).
|
||||
<<
|
||||
@$(COPY) << pngconfig.dfa
|
||||
$# pngconfig.dfa: this file contains configuration options for libpng.
|
||||
$# If emtpy the standard configuration will be built. For this file to be
|
||||
$# used a working version of the program 'awk' is required and the program
|
||||
$# must be identified in the 'before' rule of the project.
|
||||
$#
|
||||
$# If you don't already have 'awk', or the version of awk you have seems not
|
||||
$# to work, download Brian Kernighan's awk (Brian Kernighan is the author of
|
||||
$# awk.) You can find source code and a built executable (called awk95.exe)
|
||||
$# here:
|
||||
$#
|
||||
$# http://www.cs.princeton.edu/~bwk/btl.mirror/
|
||||
$#
|
||||
$# The executable works just fine.
|
||||
$#
|
||||
$# If build issues errors after a change to pngconfig.dfa you have entered
|
||||
$# inconsistent feature requests, or even malformed requests, in
|
||||
$# pngconfig.dfa. The error messages from awk should be comprehensible, but
|
||||
$# if not simply go back to the start (nothing but comments in this file) and
|
||||
$# enter configuration lines one by one until one produces an error. (Or, of
|
||||
$# course, do the standard binary chop.)
|
||||
$#
|
||||
$# You need to rebuild everything after a change to pnglibconf.dfa - i.e. you
|
||||
$# must do Actions/Mark All Targets for Remake. This is because the compiler
|
||||
$# generated dependency information (as of OpenWatcom 1.9) does not record the
|
||||
$# dependency on pnglibconf.h correctly.
|
||||
$#
|
||||
$# If awk isn't set then this file is bypassed. If you just want the standard
|
||||
$# configuration it is automatically produced from the distributed version
|
||||
$# (scripts\pnglibconf.h.prebuilt) by editting PNG_API_RULE to 2 (to force use
|
||||
$# of the OpenWatcom library calling convention.)
|
||||
$#
|
||||
<<
|
||||
|
||||
clean:: .symbolic
|
||||
$(DELETE) ..\..\pnglibconf.h pnglibconf.* dfn.c *.out pngconfig.inf
|
||||
$(DELETE) *.obj *.mbr *.sym *.err *.pch libpng.mk
|
||||
$(DELETE) libpng.lib libpng.lbr libpng.lb1 libpng.cbr libpng.mk1
|
||||
$(DELETE) pngtest.exe pngtest.map pngtest.lk1 pngtest.mk1
|
||||
$(DELETE) pngvalid.exe pngvalid.map pngvalid.lk1 pngvalid.mk1
|
||||
|
||||
distclean:: clean .symbolic
|
||||
$(DELETE) zlib.inf awk.inf config.inf pngconfig.dfa
|
||||
219
projects/owatcom/pngstest.tgt
Normal file
@@ -0,0 +1,219 @@
|
||||
40
|
||||
targetIdent
|
||||
0
|
||||
MProject
|
||||
1
|
||||
MComponent
|
||||
0
|
||||
2
|
||||
WString
|
||||
4
|
||||
NEXE
|
||||
3
|
||||
WString
|
||||
5
|
||||
nc2en
|
||||
1
|
||||
0
|
||||
0
|
||||
4
|
||||
MCommand
|
||||
0
|
||||
5
|
||||
MCommand
|
||||
1035
|
||||
pngstest --log ../../contrib/pngsuite/basn0g01.png ../../contrib/pngsuite/basn0g02.png ../../contrib/pngsuite/basn0g04.png ../../contrib/pngsuite/basn0g08.png ../../contrib/pngsuite/basn0g16.png ../../contrib/pngsuite/basn2c08.png ../../contrib/pngsuite/basn2c16.png ../../contrib/pngsuite/basn3p01.png ../../contrib/pngsuite/basn3p02.png ../../contrib/pngsuite/basn3p04.png ../../contrib/pngsuite/basn3p08.png ../../contrib/pngsuite/basn4a08.png ../../contrib/pngsuite/basn4a16.png ../../contrib/pngsuite/basn6a08.png ../../contrib/pngsuite/basn6a16.png ../../contrib/pngsuite/ftbbn0g04.png ../../contrib/pngsuite/ftbbn0g01.png ../../contrib/pngsuite/ftbbn0g02.png ../../contrib/pngsuite/ftbbn2c16.png ../../contrib/pngsuite/ftbbn3p08.png ../../contrib/pngsuite/ftbgn2c16.png ../../contrib/pngsuite/ftbgn3p08.png ../../contrib/pngsuite/ftbrn2c08.png ../../contrib/pngsuite/ftbwn0g16.png ../../contrib/pngsuite/ftbwn3p08.png ../../contrib/pngsuite/ftbyn3p08.png ../../contrib/pngsuite/ftp0n0g08.png ../../contrib/pngsuite/ftp0n2c08.png ../../contrib/pngsuite/ftp0n3p08.png ../../contrib/pngsuite/ftp1n3p08.png
|
||||
6
|
||||
MItem
|
||||
12
|
||||
pngstest.exe
|
||||
7
|
||||
WString
|
||||
4
|
||||
NEXE
|
||||
8
|
||||
WVList
|
||||
6
|
||||
9
|
||||
MVState
|
||||
10
|
||||
WString
|
||||
7
|
||||
WINLINK
|
||||
11
|
||||
WString
|
||||
11
|
||||
?????Stack:
|
||||
1
|
||||
12
|
||||
WString
|
||||
4
|
||||
768k
|
||||
0
|
||||
13
|
||||
MVState
|
||||
14
|
||||
WString
|
||||
7
|
||||
WINLINK
|
||||
15
|
||||
WString
|
||||
28
|
||||
?????Library directories(;):
|
||||
1
|
||||
16
|
||||
WString
|
||||
8
|
||||
$(%zlib)
|
||||
0
|
||||
17
|
||||
MVState
|
||||
18
|
||||
WString
|
||||
7
|
||||
WINLINK
|
||||
19
|
||||
WString
|
||||
18
|
||||
?????Libraries(,):
|
||||
1
|
||||
20
|
||||
WString
|
||||
19
|
||||
libpng.lib zlib.lib
|
||||
0
|
||||
21
|
||||
MVState
|
||||
22
|
||||
WString
|
||||
7
|
||||
WINLINK
|
||||
23
|
||||
WString
|
||||
11
|
||||
?????Stack:
|
||||
0
|
||||
24
|
||||
WString
|
||||
4
|
||||
768k
|
||||
0
|
||||
25
|
||||
MVState
|
||||
26
|
||||
WString
|
||||
7
|
||||
WINLINK
|
||||
27
|
||||
WString
|
||||
28
|
||||
?????Library directories(;):
|
||||
0
|
||||
28
|
||||
WString
|
||||
8
|
||||
$(%zlib)
|
||||
0
|
||||
29
|
||||
MVState
|
||||
30
|
||||
WString
|
||||
7
|
||||
WINLINK
|
||||
31
|
||||
WString
|
||||
18
|
||||
?????Libraries(,):
|
||||
0
|
||||
32
|
||||
WString
|
||||
19
|
||||
libpng.lib zlib.lib
|
||||
0
|
||||
33
|
||||
WVList
|
||||
1
|
||||
34
|
||||
ActionStates
|
||||
35
|
||||
WString
|
||||
4
|
||||
&Run
|
||||
36
|
||||
WVList
|
||||
0
|
||||
-1
|
||||
1
|
||||
1
|
||||
0
|
||||
37
|
||||
WPickList
|
||||
2
|
||||
38
|
||||
MItem
|
||||
3
|
||||
*.c
|
||||
39
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
40
|
||||
WVList
|
||||
2
|
||||
41
|
||||
MVState
|
||||
42
|
||||
WString
|
||||
3
|
||||
WCC
|
||||
43
|
||||
WString
|
||||
25
|
||||
n????Include directories:
|
||||
1
|
||||
44
|
||||
WString
|
||||
39
|
||||
"$(%zlib);$(%watcom)/h;$(%watcom)/h/nt"
|
||||
0
|
||||
45
|
||||
MVState
|
||||
46
|
||||
WString
|
||||
3
|
||||
WCC
|
||||
47
|
||||
WString
|
||||
25
|
||||
n????Include directories:
|
||||
0
|
||||
48
|
||||
WString
|
||||
39
|
||||
"$(%zlib);$(%watcom)/h;$(%watcom)/h/nt"
|
||||
0
|
||||
49
|
||||
WVList
|
||||
0
|
||||
-1
|
||||
1
|
||||
1
|
||||
0
|
||||
50
|
||||
MItem
|
||||
33
|
||||
..\..\contrib\libtests\pngstest.c
|
||||
51
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
52
|
||||
WVList
|
||||
0
|
||||
53
|
||||
WVList
|
||||
0
|
||||
38
|
||||
1
|
||||
1
|
||||
0
|
||||
179
projects/owatcom/pngtest.tgt
Normal file
@@ -0,0 +1,179 @@
|
||||
40
|
||||
targetIdent
|
||||
0
|
||||
MProject
|
||||
1
|
||||
MComponent
|
||||
0
|
||||
2
|
||||
WString
|
||||
4
|
||||
NEXE
|
||||
3
|
||||
WString
|
||||
5
|
||||
nc2en
|
||||
1
|
||||
0
|
||||
0
|
||||
4
|
||||
MCommand
|
||||
0
|
||||
5
|
||||
MCommand
|
||||
34
|
||||
cd ..\..
|
||||
projects\owatcom\pngtest
|
||||
6
|
||||
MItem
|
||||
11
|
||||
pngtest.exe
|
||||
7
|
||||
WString
|
||||
4
|
||||
NEXE
|
||||
8
|
||||
WVList
|
||||
4
|
||||
9
|
||||
MVState
|
||||
10
|
||||
WString
|
||||
7
|
||||
WINLINK
|
||||
11
|
||||
WString
|
||||
28
|
||||
?????Library directories(;):
|
||||
1
|
||||
12
|
||||
WString
|
||||
8
|
||||
$(%zlib)
|
||||
0
|
||||
13
|
||||
MVState
|
||||
14
|
||||
WString
|
||||
7
|
||||
WINLINK
|
||||
15
|
||||
WString
|
||||
18
|
||||
?????Libraries(,):
|
||||
1
|
||||
16
|
||||
WString
|
||||
19
|
||||
libpng.lib zlib.lib
|
||||
0
|
||||
17
|
||||
MVState
|
||||
18
|
||||
WString
|
||||
7
|
||||
WINLINK
|
||||
19
|
||||
WString
|
||||
28
|
||||
?????Library directories(;):
|
||||
0
|
||||
20
|
||||
WString
|
||||
8
|
||||
$(%zlib)
|
||||
0
|
||||
21
|
||||
MVState
|
||||
22
|
||||
WString
|
||||
7
|
||||
WINLINK
|
||||
23
|
||||
WString
|
||||
18
|
||||
?????Libraries(,):
|
||||
0
|
||||
24
|
||||
WString
|
||||
19
|
||||
libpng.lib zlib.lib
|
||||
0
|
||||
25
|
||||
WVList
|
||||
0
|
||||
-1
|
||||
1
|
||||
1
|
||||
0
|
||||
26
|
||||
WPickList
|
||||
2
|
||||
27
|
||||
MItem
|
||||
3
|
||||
*.c
|
||||
28
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
29
|
||||
WVList
|
||||
2
|
||||
30
|
||||
MVState
|
||||
31
|
||||
WString
|
||||
3
|
||||
WCC
|
||||
32
|
||||
WString
|
||||
25
|
||||
n????Include directories:
|
||||
1
|
||||
33
|
||||
WString
|
||||
39
|
||||
"$(%zlib);$(%watcom)/h;$(%watcom)/h/nt"
|
||||
0
|
||||
34
|
||||
MVState
|
||||
35
|
||||
WString
|
||||
3
|
||||
WCC
|
||||
36
|
||||
WString
|
||||
25
|
||||
n????Include directories:
|
||||
0
|
||||
37
|
||||
WString
|
||||
39
|
||||
"$(%zlib);$(%watcom)/h;$(%watcom)/h/nt"
|
||||
0
|
||||
38
|
||||
WVList
|
||||
0
|
||||
-1
|
||||
1
|
||||
1
|
||||
0
|
||||
39
|
||||
MItem
|
||||
15
|
||||
..\..\pngtest.c
|
||||
40
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
41
|
||||
WVList
|
||||
0
|
||||
42
|
||||
WVList
|
||||
0
|
||||
27
|
||||
1
|
||||
1
|
||||
0
|
||||
210
projects/owatcom/pngvalid.tgt
Normal file
@@ -0,0 +1,210 @@
|
||||
40
|
||||
targetIdent
|
||||
0
|
||||
MProject
|
||||
1
|
||||
MComponent
|
||||
0
|
||||
2
|
||||
WString
|
||||
4
|
||||
NEXE
|
||||
3
|
||||
WString
|
||||
5
|
||||
nc2en
|
||||
1
|
||||
0
|
||||
0
|
||||
4
|
||||
MCommand
|
||||
0
|
||||
5
|
||||
MCommand
|
||||
8
|
||||
pngvalid
|
||||
6
|
||||
MItem
|
||||
12
|
||||
pngvalid.exe
|
||||
7
|
||||
WString
|
||||
4
|
||||
NEXE
|
||||
8
|
||||
WVList
|
||||
6
|
||||
9
|
||||
MVState
|
||||
10
|
||||
WString
|
||||
7
|
||||
WINLINK
|
||||
11
|
||||
WString
|
||||
11
|
||||
?????Stack:
|
||||
1
|
||||
12
|
||||
WString
|
||||
4
|
||||
768k
|
||||
0
|
||||
13
|
||||
MVState
|
||||
14
|
||||
WString
|
||||
7
|
||||
WINLINK
|
||||
15
|
||||
WString
|
||||
28
|
||||
?????Library directories(;):
|
||||
1
|
||||
16
|
||||
WString
|
||||
8
|
||||
$(%zlib)
|
||||
0
|
||||
17
|
||||
MVState
|
||||
18
|
||||
WString
|
||||
7
|
||||
WINLINK
|
||||
19
|
||||
WString
|
||||
18
|
||||
?????Libraries(,):
|
||||
1
|
||||
20
|
||||
WString
|
||||
19
|
||||
libpng.lib zlib.lib
|
||||
0
|
||||
21
|
||||
MVState
|
||||
22
|
||||
WString
|
||||
7
|
||||
WINLINK
|
||||
23
|
||||
WString
|
||||
11
|
||||
?????Stack:
|
||||
0
|
||||
24
|
||||
WString
|
||||
4
|
||||
768k
|
||||
0
|
||||
25
|
||||
MVState
|
||||
26
|
||||
WString
|
||||
7
|
||||
WINLINK
|
||||
27
|
||||
WString
|
||||
28
|
||||
?????Library directories(;):
|
||||
0
|
||||
28
|
||||
WString
|
||||
8
|
||||
$(%zlib)
|
||||
0
|
||||
29
|
||||
MVState
|
||||
30
|
||||
WString
|
||||
7
|
||||
WINLINK
|
||||
31
|
||||
WString
|
||||
18
|
||||
?????Libraries(,):
|
||||
0
|
||||
32
|
||||
WString
|
||||
19
|
||||
libpng.lib zlib.lib
|
||||
0
|
||||
33
|
||||
WVList
|
||||
0
|
||||
-1
|
||||
1
|
||||
1
|
||||
0
|
||||
34
|
||||
WPickList
|
||||
2
|
||||
35
|
||||
MItem
|
||||
3
|
||||
*.c
|
||||
36
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
37
|
||||
WVList
|
||||
2
|
||||
38
|
||||
MVState
|
||||
39
|
||||
WString
|
||||
3
|
||||
WCC
|
||||
40
|
||||
WString
|
||||
25
|
||||
n????Include directories:
|
||||
1
|
||||
41
|
||||
WString
|
||||
39
|
||||
"$(%zlib);$(%watcom)/h;$(%watcom)/h/nt"
|
||||
0
|
||||
42
|
||||
MVState
|
||||
43
|
||||
WString
|
||||
3
|
||||
WCC
|
||||
44
|
||||
WString
|
||||
25
|
||||
n????Include directories:
|
||||
0
|
||||
45
|
||||
WString
|
||||
39
|
||||
"$(%zlib);$(%watcom)/h;$(%watcom)/h/nt"
|
||||
0
|
||||
46
|
||||
WVList
|
||||
0
|
||||
-1
|
||||
1
|
||||
1
|
||||
0
|
||||
47
|
||||
MItem
|
||||
33
|
||||
..\..\contrib\libtests\pngvalid.c
|
||||
48
|
||||
WString
|
||||
4
|
||||
COBJ
|
||||
49
|
||||
WVList
|
||||
0
|
||||
50
|
||||
WVList
|
||||
0
|
||||
35
|
||||
1
|
||||
1
|
||||
0
|
||||
@@ -37,9 +37,9 @@ To use:
|
||||
|
||||
This project builds the libpng binaries as follows:
|
||||
|
||||
* Win32_DLL_Release\libpng15.dll DLL build
|
||||
* Win32_DLL_Debug\libpng15d.dll DLL build (debug version)
|
||||
* Win32_DLL_VB\libpng15vb.dll DLL build for Visual Basic, using stdcall
|
||||
* Win32_DLL_Release\libpng16.dll DLL build
|
||||
* Win32_DLL_Debug\libpng16d.dll DLL build (debug version)
|
||||
* Win32_DLL_VB\libpng16vb.dll DLL build for Visual Basic, using stdcall
|
||||
* Win32_LIB_Release\libpng.lib static build
|
||||
* Win32_LIB_Debug\libpngd.lib static build (debug version)
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/libpng15.dll"
|
||||
OutputFile="$(OutDir)/libpng16.dll"
|
||||
LinkIncremental="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
@@ -78,7 +78,7 @@
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/libpng15d.dll"
|
||||
OutputFile="$(OutDir)/libpng16d.dll"
|
||||
GenerateDebugInformation="TRUE"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
@@ -126,7 +126,7 @@
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/libpng15vb.dll"
|
||||
OutputFile="$(OutDir)/libpng16vb.dll"
|
||||
LinkIncremental="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
|
||||
@@ -130,7 +130,7 @@ $(TargetPath) ..\..\pngtest.png $(IntDir)\pngout.png"
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/pngtest.exe"
|
||||
LinkIncremental="1"
|
||||
IgnoreDefaultLibraryNames="$(IntDir)\libpng15b.lib"
|
||||
IgnoreDefaultLibraryNames="$(IntDir)\libpng16b.lib"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
|
||||
@@ -63,23 +63,23 @@
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<CustomBuildBeforeTargets>
|
||||
</CustomBuildBeforeTargets>
|
||||
<TargetName>$(ProjectName)15</TargetName>
|
||||
<TargetName>$(ProjectName)16</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Library|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<CustomBuildBeforeTargets />
|
||||
<TargetName>$(ProjectName)15</TargetName>
|
||||
<TargetName>$(ProjectName)16</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<CustomBuildBeforeTargets>
|
||||
</CustomBuildBeforeTargets>
|
||||
<TargetName>$(ProjectName)15</TargetName>
|
||||
<TargetName>$(ProjectName)16</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Library|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<CustomBuildBeforeTargets />
|
||||
<TargetName>$(ProjectName)15</TargetName>
|
||||
<TargetName>$(ProjectName)16</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -106,7 +106,7 @@
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>zlib.lib</AdditionalDependencies>
|
||||
<Version>15</Version>
|
||||
<Version>16</Version>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
@@ -118,7 +118,7 @@
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
@@ -163,7 +163,7 @@
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>zlib.lib</AdditionalDependencies>
|
||||
<Version>15</Version>
|
||||
<Version>16</Version>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
@@ -175,7 +175,7 @@
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
|
||||
<PrecompiledHeaderFile>pngpriv.h</PrecompiledHeaderFile>
|
||||
|
||||
218
projects/vstudio/pngstest/pngstest.vcxproj
Normal file
@@ -0,0 +1,218 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug Library|Win32">
|
||||
<Configuration>Debug Library</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release Library|Win32">
|
||||
<Configuration>Release Library</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9B36B6FE-7FC0-434F-A71F-BBEF8099F1D8}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>pngstest</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<Import Project="$(SolutionDir)\zlib.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Library|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Library|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Library|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Library|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<CustomBuildAfterTargets />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Library|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<CustomBuildAfterTargets />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<CustomBuildAfterTargets />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Library|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<CustomBuildAfterTargets />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;PNG_USE_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996;4127</DisableSpecificWarnings>
|
||||
<CompileAsManaged>false</CompileAsManaged>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
<Message>Executing libpng simplified API test program</Message>
|
||||
<Command>"$(OutDir)pngstest.exe" --log --touch "$(IntDir)pngstest.out" ../../../contrib/pngsuite/basn0g01.png ../../../contrib/pngsuite/basn0g02.png ../../../contrib/pngsuite/basn0g04.png ../../../contrib/pngsuite/basn0g08.png ../../../contrib/pngsuite/basn0g16.png ../../../contrib/pngsuite/basn2c08.png ../../../contrib/pngsuite/basn2c16.png ../../../contrib/pngsuite/basn3p01.png ../../../contrib/pngsuite/basn3p02.png ../../../contrib/pngsuite/basn3p04.png ../../../contrib/pngsuite/basn3p08.png ../../../contrib/pngsuite/basn4a08.png ../../../contrib/pngsuite/basn4a16.png ../../../contrib/pngsuite/basn6a08.png ../../../contrib/pngsuite/basn6a16.png ../../../contrib/pngsuite/ftbbn0g01.png ../../../contrib/pngsuite/ftbbn0g02.png ../../../contrib/pngsuite/ftbbn0g04.png ../../../contrib/pngsuite/ftbbn2c16.png ../../../contrib/pngsuite/ftbbn3p08.png ../../../contrib/pngsuite/ftbgn2c16.png ../../../contrib/pngsuite/ftbgn3p08.png ../../../contrib/pngsuite/ftbrn2c08.png ../../../contrib/pngsuite/ftbwn0g16.png ../../../contrib/pngsuite/ftbwn3p08.png ../../../contrib/pngsuite/ftbyn3p08.png ../../../contrib/pngsuite/ftp0n0g08.png ../../../contrib/pngsuite/ftp0n2c08.png ../../../contrib/pngsuite/ftp0n3p08.png ../../../contrib/pngsuite/ftp1n3p08.png</Command>
|
||||
<Outputs>$(IntDir)pngstest.out</Outputs>
|
||||
<Inputs>$(OutDir)pngstest.exe</Inputs>
|
||||
</CustomBuildStep>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Library|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996;4127</DisableSpecificWarnings>
|
||||
<CompileAsManaged>false</CompileAsManaged>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
<Message>Executing libpng simplified API test program</Message>
|
||||
<Command>"$(OutDir)pngstest.exe" --log --touch "$(IntDir)pngstest.out" ../../../contrib/pngsuite/basn0g01.png ../../../contrib/pngsuite/basn0g02.png ../../../contrib/pngsuite/basn0g04.png ../../../contrib/pngsuite/basn0g08.png ../../../contrib/pngsuite/basn0g16.png ../../../contrib/pngsuite/basn2c08.png ../../../contrib/pngsuite/basn2c16.png ../../../contrib/pngsuite/basn3p01.png ../../../contrib/pngsuite/basn3p02.png ../../../contrib/pngsuite/basn3p04.png ../../../contrib/pngsuite/basn3p08.png ../../../contrib/pngsuite/basn4a08.png ../../../contrib/pngsuite/basn4a16.png ../../../contrib/pngsuite/basn6a08.png ../../../contrib/pngsuite/basn6a16.png ../../../contrib/pngsuite/ftbbn0g01.png ../../../contrib/pngsuite/ftbbn0g02.png ../../../contrib/pngsuite/ftbbn0g04.png ../../../contrib/pngsuite/ftbbn2c16.png ../../../contrib/pngsuite/ftbbn3p08.png ../../../contrib/pngsuite/ftbgn2c16.png ../../../contrib/pngsuite/ftbgn3p08.png ../../../contrib/pngsuite/ftbrn2c08.png ../../../contrib/pngsuite/ftbwn0g16.png ../../../contrib/pngsuite/ftbwn3p08.png ../../../contrib/pngsuite/ftbyn3p08.png ../../../contrib/pngsuite/ftp0n0g08.png ../../../contrib/pngsuite/ftp0n2c08.png ../../../contrib/pngsuite/ftp0n3p08.png ../../../contrib/pngsuite/ftp1n3p08.png</Command>
|
||||
<Outputs>$(IntDir)pngstest.out</Outputs>
|
||||
<Inputs>$(OutDir)pngstest.exe</Inputs>
|
||||
</CustomBuildStep>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;PNG_USE_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996;4127</DisableSpecificWarnings>
|
||||
<CompileAsManaged>false</CompileAsManaged>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
<Message>Executing libpng simplified API test program</Message>
|
||||
<Command>"$(OutDir)pngstest.exe" --log --touch "$(IntDir)pngstest.out" ../../../contrib/pngsuite/basn0g01.png ../../../contrib/pngsuite/basn0g02.png ../../../contrib/pngsuite/basn0g04.png ../../../contrib/pngsuite/basn0g08.png ../../../contrib/pngsuite/basn0g16.png ../../../contrib/pngsuite/basn2c08.png ../../../contrib/pngsuite/basn2c16.png ../../../contrib/pngsuite/basn3p01.png ../../../contrib/pngsuite/basn3p02.png ../../../contrib/pngsuite/basn3p04.png ../../../contrib/pngsuite/basn3p08.png ../../../contrib/pngsuite/basn4a08.png ../../../contrib/pngsuite/basn4a16.png ../../../contrib/pngsuite/basn6a08.png ../../../contrib/pngsuite/basn6a16.png ../../../contrib/pngsuite/ftbbn0g01.png ../../../contrib/pngsuite/ftbbn0g02.png ../../../contrib/pngsuite/ftbbn0g04.png ../../../contrib/pngsuite/ftbbn2c16.png ../../../contrib/pngsuite/ftbbn3p08.png ../../../contrib/pngsuite/ftbgn2c16.png ../../../contrib/pngsuite/ftbgn3p08.png ../../../contrib/pngsuite/ftbrn2c08.png ../../../contrib/pngsuite/ftbwn0g16.png ../../../contrib/pngsuite/ftbwn3p08.png ../../../contrib/pngsuite/ftbyn3p08.png ../../../contrib/pngsuite/ftp0n0g08.png ../../../contrib/pngsuite/ftp0n2c08.png ../../../contrib/pngsuite/ftp0n3p08.png ../../../contrib/pngsuite/ftp1n3p08.png</Command>
|
||||
<Outputs>$(IntDir)pngstest.out</Outputs>
|
||||
<Inputs>$(OutDir)pngstest.exe</Inputs>
|
||||
</CustomBuildStep>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Library|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Full</Optimization>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996;4127</DisableSpecificWarnings>
|
||||
<CompileAsManaged>false</CompileAsManaged>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
<Message>Executing libpng simplified API test program</Message>
|
||||
<Command>"$(OutDir)pngstest.exe" --log --touch "$(IntDir)pngstest.out" ../../../contrib/pngsuite/basn0g01.png ../../../contrib/pngsuite/basn0g02.png ../../../contrib/pngsuite/basn0g04.png ../../../contrib/pngsuite/basn0g08.png ../../../contrib/pngsuite/basn0g16.png ../../../contrib/pngsuite/basn2c08.png ../../../contrib/pngsuite/basn2c16.png ../../../contrib/pngsuite/basn3p01.png ../../../contrib/pngsuite/basn3p02.png ../../../contrib/pngsuite/basn3p04.png ../../../contrib/pngsuite/basn3p08.png ../../../contrib/pngsuite/basn4a08.png ../../../contrib/pngsuite/basn4a16.png ../../../contrib/pngsuite/basn6a08.png ../../../contrib/pngsuite/basn6a16.png ../../../contrib/pngsuite/ftbbn0g01.png ../../../contrib/pngsuite/ftbbn0g02.png ../../../contrib/pngsuite/ftbbn0g04.png ../../../contrib/pngsuite/ftbbn2c16.png ../../../contrib/pngsuite/ftbbn3p08.png ../../../contrib/pngsuite/ftbgn2c16.png ../../../contrib/pngsuite/ftbgn3p08.png ../../../contrib/pngsuite/ftbrn2c08.png ../../../contrib/pngsuite/ftbwn0g16.png ../../../contrib/pngsuite/ftbwn3p08.png ../../../contrib/pngsuite/ftbyn3p08.png ../../../contrib/pngsuite/ftp0n0g08.png ../../../contrib/pngsuite/ftp0n2c08.png ../../../contrib/pngsuite/ftp0n3p08.png ../../../contrib/pngsuite/ftp1n3p08.png</Command>
|
||||
<Outputs>$(IntDir)pngstest.out</Outputs>
|
||||
<Inputs>$(OutDir)pngstest.exe</Inputs>
|
||||
</CustomBuildStep>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\contrib\libtests\pngstest.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||