Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
685c73260e | ||
|
|
7753fff93e | ||
|
|
4dbeb487fa | ||
|
|
6216805c10 | ||
|
|
9dff73bebc | ||
|
|
5650dd434b | ||
|
|
db5972e098 | ||
|
|
9c97172706 | ||
|
|
a60b9d75e9 | ||
|
|
94f6f7315b | ||
|
|
b535e2bf6f | ||
|
|
95911a1c2c | ||
|
|
3d206dd424 | ||
|
|
e81febb70f | ||
|
|
eba593294d | ||
|
|
88152bebaf | ||
|
|
81b26f034d | ||
|
|
5087fe8507 | ||
|
|
a664b35b96 | ||
|
|
f8dd26d304 | ||
|
|
d40aa2dba4 | ||
|
|
0d6e6bc228 | ||
|
|
a55124f960 | ||
|
|
ea53869fb6 | ||
|
|
a7cb83ff00 | ||
|
|
02230f5642 | ||
|
|
cadfff2e1d | ||
|
|
eccbe7112e | ||
|
|
6589e863d8 | ||
|
|
6272852b8d | ||
|
|
d1487d7be3 | ||
|
|
f1a91e42b3 | ||
|
|
8929277ee7 | ||
|
|
c820d16c30 | ||
|
|
6d616b716d | ||
|
|
1c7b4f59c4 | ||
|
|
821e91d79e | ||
|
|
f00e8166da | ||
|
|
36cbce4d58 | ||
|
|
f59f4a0d43 | ||
|
|
fa7a5b36a5 | ||
|
|
9d6c745d68 | ||
|
|
3cdffebd6d | ||
|
|
8e269601ce | ||
|
|
c2789e2dc1 | ||
|
|
6360737552 | ||
|
|
986f906ed0 | ||
|
|
b00d0060ba | ||
|
|
27fc7da3f0 | ||
|
|
9a19607464 | ||
|
|
8f8916c1d3 | ||
|
|
de67665367 | ||
|
|
e5bacb710f | ||
|
|
9f528cd1d0 | ||
|
|
942e1d5787 | ||
|
|
dbdda56243 | ||
|
|
6357fdfe72 | ||
|
|
8a7a48d7a6 | ||
|
|
05cc3842bc | ||
|
|
5eb068a4cd | ||
|
|
2653d1f860 | ||
|
|
2c020586ef | ||
|
|
e847ff922d | ||
|
|
3688f59a88 | ||
|
|
62d76b6942 | ||
|
|
07ad8fc313 | ||
|
|
7a3fb2deb1 | ||
|
|
fe77ab2933 | ||
|
|
15a6e537df | ||
|
|
dd29a569fb | ||
|
|
b8ac0e1a08 | ||
|
|
e9aeaa60bf | ||
|
|
ea882c3c24 | ||
|
|
03666cb5fd | ||
|
|
1baa2ae009 | ||
|
|
4ff9b5bd57 | ||
|
|
e59805a542 | ||
|
|
6507678444 | ||
|
|
be023be419 | ||
|
|
27cb3445f8 | ||
|
|
4e63559f2b | ||
|
|
706e895071 | ||
|
|
23194d8dc1 | ||
|
|
08e11fcab4 | ||
|
|
f600f4783f | ||
|
|
3c73bd4e3f | ||
|
|
ffdae44185 | ||
|
|
5a5f71ebed | ||
|
|
2fc4422e3c | ||
|
|
585b795bd3 | ||
|
|
b8d67338a4 | ||
|
|
0171fffd8b | ||
|
|
0b13e4c54e | ||
|
|
5576398153 | ||
|
|
5dd28a6d5d | ||
|
|
dcfd41ac4e | ||
|
|
60c7dd4b17 | ||
|
|
a455f07aa0 | ||
|
|
28c38d648b | ||
|
|
00a7af3b4c | ||
|
|
969ec37b5d | ||
|
|
e3b387e000 | ||
|
|
c785239cdc | ||
|
|
aed77c7271 | ||
|
|
9676263f0a | ||
|
|
a6db4dba26 | ||
|
|
d4149c6ea0 | ||
|
|
a47d88dfe5 | ||
|
|
ac0dc61642 | ||
|
|
e41d6f7f6d | ||
|
|
c8473efc35 | ||
|
|
deb4fc9dc8 | ||
|
|
360f37108f | ||
|
|
5d8db4b5af | ||
|
|
72bd93dd2b | ||
|
|
693d7bc0f5 | ||
|
|
cffd2852c4 | ||
|
|
845243dbf0 | ||
|
|
178c3ec53e | ||
|
|
7dc39d1820 | ||
|
|
80b47cbc63 | ||
|
|
462f1f475f | ||
|
|
f3d5c259a5 | ||
|
|
0d92971bcb | ||
|
|
699c7d4cbd | ||
|
|
fb0adc29d6 | ||
|
|
8528b2efcc | ||
|
|
c798b6d73e | ||
|
|
e0523817f3 | ||
|
|
dee840de72 | ||
|
|
5da038136c | ||
|
|
7f785d921a | ||
|
|
5abbbaa014 | ||
|
|
b72ff5be4e | ||
|
|
4d80f0a0c7 | ||
|
|
bbd0873cff | ||
|
|
de4eb41ff3 | ||
|
|
29d7641553 | ||
|
|
1b74e216e7 | ||
|
|
a20298c478 | ||
|
|
1398819a20 | ||
|
|
c0b80d25ec | ||
|
|
8833b848d3 | ||
|
|
9a23b3c4c5 | ||
|
|
c4b8c35a84 | ||
|
|
04118f8a42 | ||
|
|
3f84a2b453 | ||
|
|
51d00bc6d5 | ||
|
|
dfb4383686 | ||
|
|
e1fee35139 | ||
|
|
d4253ba1d3 | ||
|
|
6c40341116 | ||
|
|
8825c4b021 | ||
|
|
dfd5e8fda0 | ||
|
|
41bb7c3a85 | ||
|
|
dee5bda6c0 | ||
|
|
251395dd28 | ||
|
|
58b32c8ea6 | ||
|
|
d753cc15a2 | ||
|
|
928fc695df | ||
|
|
6c778e6b1f | ||
|
|
d7bdca8c4b | ||
|
|
99554bc7b7 | ||
|
|
2454463357 | ||
|
|
4b0bbcfacf | ||
|
|
6fd7d51025 | ||
|
|
e924dd999f | ||
|
|
b4ca093e73 | ||
|
|
b94c2313ce | ||
|
|
a6cd5e5960 | ||
|
|
1c3ecce849 | ||
|
|
9ab54a8580 | ||
|
|
2af10009a5 | ||
|
|
2d1e74dbd1 | ||
|
|
20503843ab | ||
|
|
ce1477da0b | ||
|
|
cf0bdb6729 | ||
|
|
b4acdea3e7 | ||
|
|
1ae923da26 | ||
|
|
a56c5a0975 | ||
|
|
b2387f3324 | ||
|
|
87d39ea1b9 | ||
|
|
c503d6a65b | ||
|
|
358b1938e1 | ||
|
|
c5c9e6f077 | ||
|
|
5e9d713ed4 | ||
|
|
5ebecad3d4 | ||
|
|
91d24c2585 | ||
|
|
a4a26fc753 | ||
|
|
e217f9d5a0 | ||
|
|
4d019acf96 | ||
|
|
a571789645 | ||
|
|
6b9cb37577 | ||
|
|
5a8e565482 | ||
|
|
395a3c881b | ||
|
|
e79965bbe7 | ||
|
|
307afbc66d | ||
|
|
c95c773508 | ||
|
|
cc5f3312a7 | ||
|
|
c69be56bce | ||
|
|
c662851405 | ||
|
|
e1ab15b90b | ||
|
|
ffb7c45730 | ||
|
|
f46f73ba1a | ||
|
|
4c809ccf16 | ||
|
|
e414a9d579 | ||
|
|
af3dfc78a4 | ||
|
|
3c8480e3b7 | ||
|
|
bb1ff4f80e | ||
|
|
8ce83e402f | ||
|
|
2005dbb4f8 | ||
|
|
021a737bfa | ||
|
|
025467ab01 | ||
|
|
562bfcad1d | ||
|
|
1d28fe6380 | ||
|
|
cee5e991e5 | ||
|
|
25bad3798f | ||
|
|
376916d25f | ||
|
|
e0f66bf0c2 | ||
|
|
f964953812 | ||
|
|
10fe25bddf | ||
|
|
19af4e4ab5 | ||
|
|
97e9225fa5 | ||
|
|
651b14ffa9 | ||
|
|
0c74f424b1 | ||
|
|
5fd944398f | ||
|
|
3705f82b64 | ||
|
|
818fb8ce88 | ||
|
|
9d9c83d279 | ||
|
|
f53258e4bb | ||
|
|
3dff9205c1 | ||
|
|
9d62554d07 | ||
|
|
3375c9aef3 | ||
|
|
4e2a38d58a | ||
|
|
2a78a5bcfb | ||
|
|
67e5cfe29a | ||
|
|
85a286648d | ||
|
|
6791bff9f7 | ||
|
|
393bed45bd | ||
|
|
c7d27f3758 | ||
|
|
b87fadea8e | ||
|
|
16ab4a205c | ||
|
|
335947359c | ||
|
|
68d62c65a0 | ||
|
|
cf118ec82e | ||
|
|
dfacff5a84 | ||
|
|
65feafdf64 | ||
|
|
dbb825a831 | ||
|
|
ea185ba31a | ||
|
|
de7bfd7d43 | ||
|
|
e7b57edcbf | ||
|
|
0b02532471 | ||
|
|
ce3d768b4d | ||
|
|
55a8ed454b | ||
|
|
4728ce9b8e | ||
|
|
5320c9d89c | ||
|
|
8d0bf12233 | ||
|
|
51558511bd | ||
|
|
a4db8cd398 | ||
|
|
95994b65ea | ||
|
|
3c7e2aff4f | ||
|
|
d14d67ef38 | ||
|
|
5769bfea8c | ||
|
|
e1b4eef40f | ||
|
|
f8498e2a9a | ||
|
|
86d31b233b | ||
|
|
2cccf6d75b | ||
|
|
cfc9269c0a | ||
|
|
efa56cdc07 | ||
|
|
4be388f1a6 | ||
|
|
6c4d39c6ed | ||
|
|
8c6676d883 | ||
|
|
ef4a936e3e | ||
|
|
995763a316 | ||
|
|
5e7c59d6a9 | ||
|
|
1fb779037d | ||
|
|
4d0329a453 | ||
|
|
49856998c3 | ||
|
|
668d2c1a52 | ||
|
|
1e7d217a32 | ||
|
|
f56fbd4528 | ||
|
|
ed6f7be3ef | ||
|
|
8b20804fc0 | ||
|
|
05b38946b1 | ||
|
|
341588333e | ||
|
|
bb33843b63 | ||
|
|
f438759105 | ||
|
|
b57c8b03ea | ||
|
|
32cbd32218 | ||
|
|
5fd37d37e6 | ||
|
|
a4acea370f | ||
|
|
5177b6a638 | ||
|
|
7b3c170189 | ||
|
|
36c522699b | ||
|
|
7d2df16340 | ||
|
|
f71fc35535 | ||
|
|
f0c1b25f4a | ||
|
|
432a3b64ad | ||
|
|
fc733c6a26 | ||
|
|
07f922106b | ||
|
|
12140bfdb2 | ||
|
|
69eef88fc0 | ||
|
|
4126f6d794 | ||
|
|
83384f847f | ||
|
|
27b26dfcee | ||
|
|
eab89a627f | ||
|
|
ca85b5f760 | ||
|
|
91e7bd01d0 | ||
|
|
280a568ae8 | ||
|
|
3225f137a9 | ||
|
|
4b54117c6d | ||
|
|
ce304fe647 | ||
|
|
1dff4271ad | ||
|
|
ac72178f1a | ||
|
|
73692ebdf8 | ||
|
|
eabde1635a | ||
|
|
6ac40fefa1 | ||
|
|
6e2dac5f90 | ||
|
|
add28aa361 | ||
|
|
4fc16f649f | ||
|
|
cb88a5b6bf | ||
|
|
54eeadb88b | ||
|
|
74e8d3cf71 | ||
|
|
6aeda415e0 | ||
|
|
df547d0ee5 | ||
|
|
130ef8d657 | ||
|
|
ccbdbd5258 | ||
|
|
493d328e92 | ||
|
|
e429387c54 | ||
|
|
1bcbc6bcf0 | ||
|
|
f127333d8c | ||
|
|
d1028f7a8d | ||
|
|
7f7258f25b | ||
|
|
350ff161c8 | ||
|
|
9812658366 | ||
|
|
df665f6077 | ||
|
|
c2755a3d20 | ||
|
|
4f34a374b2 | ||
|
|
e97e716e21 | ||
|
|
5fc887f552 | ||
|
|
74bcfc74da | ||
|
|
7b1f03c386 | ||
|
|
b36bb2f9be | ||
|
|
72187a0fb7 | ||
|
|
70f8d926cc | ||
|
|
78b1977875 | ||
|
|
56aa5d01e6 | ||
|
|
7583f9f3ed | ||
|
|
8e424c701e | ||
|
|
cff0aeba96 | ||
|
|
6ac0ab5064 | ||
|
|
e2ac7e48ac | ||
|
|
738e04099b | ||
|
|
b8d15d9dbe | ||
|
|
97785f8527 | ||
|
|
71c90a51bc | ||
|
|
c978a6c3ea | ||
|
|
50eab58d6e | ||
|
|
46ea8e2a5c | ||
|
|
a693d1f365 | ||
|
|
be9785ac6d | ||
|
|
c58e47a183 | ||
|
|
7eb0f8ca76 | ||
|
|
be0bac4c88 | ||
|
|
b2cdf4292a | ||
|
|
211704a9e6 | ||
|
|
527208be70 | ||
|
|
33cda33473 | ||
|
|
86e058e4ed | ||
|
|
118c5d1082 | ||
|
|
c6c80cefa6 | ||
|
|
e3e23b1dd0 | ||
|
|
95942e5048 | ||
|
|
9f0c7bff9b | ||
|
|
a0a18437d6 | ||
|
|
e8874d75f5 | ||
|
|
0dabdfe857 | ||
|
|
6fd4237b0b | ||
|
|
cea6047054 | ||
|
|
ba425745d6 | ||
|
|
f79d2d5d1e | ||
|
|
7e28cd362b | ||
|
|
7ead6c42c7 | ||
|
|
e53b14876f | ||
|
|
d0c721cad7 | ||
|
|
b5c7d4c4e0 | ||
|
|
9be22b639e | ||
|
|
b90b20d36d | ||
|
|
d2f2dbc392 | ||
|
|
9bd48f0dbd | ||
|
|
8c0859a804 | ||
|
|
17adf4308c | ||
|
|
b8b12c44c1 | ||
|
|
214fe59954 | ||
|
|
ada85f3663 | ||
|
|
ddd7f04482 | ||
|
|
f0a7bb7bdc | ||
|
|
1d5b1181c9 | ||
|
|
881a070194 | ||
|
|
6bb0f1171a | ||
|
|
bda075a7f3 | ||
|
|
223078d722 | ||
|
|
61656f9218 | ||
|
|
d1f658afa5 | ||
|
|
b0e1c25dd1 | ||
|
|
c861f25cbc | ||
|
|
ec8ef90c1f | ||
|
|
aa2cd98b3e | ||
|
|
feb8db628d | ||
|
|
538b8f2935 | ||
|
|
c8e1289def | ||
|
|
3f37593175 | ||
|
|
afaabc3e50 | ||
|
|
69818e2f2d | ||
|
|
6366e8f776 | ||
|
|
33aee1275d | ||
|
|
82a7fbb1fa | ||
|
|
688012dca2 | ||
|
|
ff049e353e | ||
|
|
8ef8f7ce21 | ||
|
|
12ba27949b | ||
|
|
f171d7a2cd | ||
|
|
d63de61b1e | ||
|
|
9c22495e5e | ||
|
|
a63e18ca43 | ||
|
|
e304e5a5cb | ||
|
|
0f8ae9442a | ||
|
|
bc4d708262 | ||
|
|
46832efcb0 | ||
|
|
9477634d2a | ||
|
|
d1b6b9c1b3 | ||
|
|
97d65859bc | ||
|
|
8a4f6b587b | ||
|
|
6be14e882f | ||
|
|
c0f0316931 | ||
|
|
3c774f1903 | ||
|
|
188e054164 | ||
|
|
3f8db71882 | ||
|
|
7be6324424 | ||
|
|
9ce5083225 | ||
|
|
c074eb73d3 | ||
|
|
47591619e1 | ||
|
|
1123f312b4 | ||
|
|
e146a61d9d | ||
|
|
4eea4d5d93 | ||
|
|
9f84326b13 | ||
|
|
bdaf7c7f4f | ||
|
|
e131fde62b | ||
|
|
3bde37ac83 | ||
|
|
dc3369a794 | ||
|
|
a34d7ddee2 | ||
|
|
d46354584f | ||
|
|
70645941f9 | ||
|
|
4bcdec3734 | ||
|
|
f1f86eedee | ||
|
|
0c16f2d84b | ||
|
|
c2a28a12c6 | ||
|
|
193c94b30c | ||
|
|
3cfa4b9b12 | ||
|
|
38eb7b00cb | ||
|
|
a9de164cfa | ||
|
|
8d5fbea923 | ||
|
|
06910438d1 | ||
|
|
a03faa56c5 | ||
|
|
393a5ebe49 | ||
|
|
ff9a315b42 | ||
|
|
aec4ed6c3c | ||
|
|
be62af1f18 | ||
|
|
c4516f9dc7 | ||
|
|
9103999432 | ||
|
|
86993bbeb8 | ||
|
|
6e83cb0ea9 | ||
|
|
749edaed71 | ||
|
|
35f53f7a0b | ||
|
|
87e0190d2d | ||
|
|
565b8923af | ||
|
|
2c0f2ed803 | ||
|
|
2c1d4b6b01 | ||
|
|
a1be870b1f | ||
|
|
fa6f622f40 | ||
|
|
21ad9b4412 | ||
|
|
0530835da4 | ||
|
|
8f38557ef6 | ||
|
|
2c015f27ba | ||
|
|
1650d657ba | ||
|
|
490a7df08f | ||
|
|
3da0dddadb | ||
|
|
07042f1941 | ||
|
|
f37aa3718f | ||
|
|
23b315d10f | ||
|
|
2e7640c966 | ||
|
|
234971dfd8 | ||
|
|
ac45771ea4 | ||
|
|
9e233f6077 | ||
|
|
59b6cd308a | ||
|
|
c83c038d35 | ||
|
|
cbb492c279 | ||
|
|
d7e78c1b37 | ||
|
|
a51efc12b2 | ||
|
|
aee0113f5e | ||
|
|
dee020782c | ||
|
|
b0ae5d7071 | ||
|
|
42173d6ace | ||
|
|
5e6a5fd6fa | ||
|
|
2d32ae7305 | ||
|
|
1bdbd03fbb | ||
|
|
db1d212786 | ||
|
|
72de8fd00b | ||
|
|
e72bfcfa0d | ||
|
|
a2c551ee06 | ||
|
|
0be1bf06c7 | ||
|
|
d700853112 | ||
|
|
94854a8dbc | ||
|
|
4331d27569 | ||
|
|
70a164524e | ||
|
|
ced264e91c | ||
|
|
5109b2bf50 | ||
|
|
ba51f97994 | ||
|
|
137e90d14d | ||
|
|
0fd1a81d35 | ||
|
|
38a582016c | ||
|
|
166accba60 | ||
|
|
0c4a6a72ad | ||
|
|
24d3b2425a | ||
|
|
9b69732fec | ||
|
|
6bcaf4a163 | ||
|
|
8e264807f1 | ||
|
|
b6480e872a | ||
|
|
e920f4fee3 | ||
|
|
ffe0666b8f | ||
|
|
11afc7b734 | ||
|
|
3727ce6fe1 | ||
|
|
0ad56c292a | ||
|
|
553bb4b207 | ||
|
|
b88c3f9af2 | ||
|
|
d95b5b7628 | ||
|
|
ec18caeb67 | ||
|
|
73d34370e1 | ||
|
|
21d7dac23f | ||
|
|
352c1a7d03 | ||
|
|
91e95ee9ae | ||
|
|
e7e567536b | ||
|
|
56d05b4c38 | ||
|
|
f29061e600 | ||
|
|
eee54b38ec | ||
|
|
a0f7b1ed8a | ||
|
|
1e5e7f346b | ||
|
|
31d9e9f73d | ||
|
|
056dd97f45 | ||
|
|
a907281532 | ||
|
|
876aa5168f | ||
|
|
9b630b86ba | ||
|
|
1e013463ae | ||
|
|
43c28e3f6a | ||
|
|
a05860a087 | ||
|
|
4e17d7fbe2 | ||
|
|
f25d951a1c | ||
|
|
72e90d07fb | ||
|
|
c20132c278 | ||
|
|
227500897d | ||
|
|
aa863b5e82 | ||
|
|
ec862ac774 | ||
|
|
bdd7eba876 | ||
|
|
ddef030d3d | ||
|
|
36a18e2401 | ||
|
|
a7ac2a4235 | ||
|
|
fcbc4798ab | ||
|
|
6f7c1ce57f | ||
|
|
58ad3b5635 | ||
|
|
777080cd1f | ||
|
|
226345c23e | ||
|
|
096a228dba | ||
|
|
923d0f34c4 | ||
|
|
2abc5c6a28 | ||
|
|
caabf73d19 | ||
|
|
32c6d09814 | ||
|
|
cccc118091 | ||
|
|
ef68c48815 | ||
|
|
49e8f80394 | ||
|
|
f65c079c28 | ||
|
|
cfbb883bf6 | ||
|
|
afd7086090 | ||
|
|
e813112545 | ||
|
|
236b7191f0 | ||
|
|
a5c596561a | ||
|
|
343118c63c | ||
|
|
8bfc011991 | ||
|
|
fa99e8c88d | ||
|
|
47e61f69b3 | ||
|
|
eed69b50e7 | ||
|
|
f21ecf4a77 | ||
|
|
692870df22 | ||
|
|
d1d87635f1 | ||
|
|
d093eb5d96 | ||
|
|
c7caec9a4d | ||
|
|
3a1647ea9c | ||
|
|
7d0ed2ed5e | ||
|
|
814a2441e7 | ||
|
|
99c2808521 | ||
|
|
8c23b6fa5c | ||
|
|
6ac3c7a0b0 | ||
|
|
993c4885c6 | ||
|
|
4c3ddd99b6 | ||
|
|
300ca7731c | ||
|
|
f00484b951 | ||
|
|
4746f16253 | ||
|
|
48d6ece838 | ||
|
|
bad48e90b4 | ||
|
|
a10572b70d | ||
|
|
8fc154b6c5 | ||
|
|
728e1495e4 | ||
|
|
c5c9864714 | ||
|
|
3b727a6b17 | ||
|
|
ac6ddaf678 | ||
|
|
e70dee48f5 | ||
|
|
8fe3735942 | ||
|
|
5b1f85b55c | ||
|
|
5934fd2d88 | ||
|
|
84218df092 | ||
|
|
9c03a345fe | ||
|
|
27a45b790e | ||
|
|
ed8b658bf9 | ||
|
|
af1cf0789a | ||
|
|
e6b07b2ef4 | ||
|
|
b5d7d508ff | ||
|
|
644558a24f | ||
|
|
372371501b | ||
|
|
fd82c68d18 | ||
|
|
c3f095e6cd | ||
|
|
c1dfe33a8c | ||
|
|
71d5d20f11 | ||
|
|
7da8c385e0 | ||
|
|
35abe37853 | ||
|
|
42fc3324e1 | ||
|
|
115e1aea6b | ||
|
|
5e60251ea8 | ||
|
|
d4dd5c66d4 | ||
|
|
6e3d33b5c0 | ||
|
|
275735d035 | ||
|
|
1dbcacd786 | ||
|
|
f828040e88 | ||
|
|
eb4087c526 | ||
|
|
107070b9ab | ||
|
|
6ab8136187 | ||
|
|
38f67894cd | ||
|
|
dc73ae317e | ||
|
|
276c34252e | ||
|
|
a6cc522a4c | ||
|
|
d3057d8568 | ||
|
|
23cbc60863 | ||
|
|
870fc59cac | ||
|
|
3791130d21 | ||
|
|
3923d24ac2 | ||
|
|
8887c9e936 | ||
|
|
e6d7e0b76d | ||
|
|
6c0cbc28e7 | ||
|
|
2e78780ea5 | ||
|
|
e696b8f92a | ||
|
|
be617a9b90 | ||
|
|
9bba86183f | ||
|
|
ad886e10c5 | ||
|
|
9ba52d00ac | ||
|
|
73f45cfb3c | ||
|
|
47b55634ec | ||
|
|
7faec51e2b | ||
|
|
69f95389ac | ||
|
|
8e9ce05290 | ||
|
|
0afda60116 | ||
|
|
7915e7c6c7 | ||
|
|
0bd28e7c1c | ||
|
|
1c6dbb52f2 | ||
|
|
c5e6b2fff0 | ||
|
|
f3a5e0107f | ||
|
|
dd1bcc7abb | ||
|
|
47d0894f13 | ||
|
|
033f8b51b8 | ||
|
|
c9b9e0d856 | ||
|
|
6aec9314ee | ||
|
|
cd38e31d6e | ||
|
|
e990bbfad2 | ||
|
|
62f90c42fc | ||
|
|
7968c365b5 | ||
|
|
003b7a5cb9 | ||
|
|
d66540a28f | ||
|
|
da29b078c3 | ||
|
|
a812a39cb5 | ||
|
|
91e878fa1e | ||
|
|
fa1d6d787f | ||
|
|
ab6b92b271 | ||
|
|
67d94e4a19 | ||
|
|
661e747ab9 | ||
|
|
4252a61d3f | ||
|
|
ffeff66cf2 | ||
|
|
582455a501 | ||
|
|
835319ab8f | ||
|
|
48d4340963 | ||
|
|
16354c94ee | ||
|
|
28fc6ff780 | ||
|
|
f80227b9e7 | ||
|
|
50904e4381 | ||
|
|
963b928845 | ||
|
|
8088d606a8 | ||
|
|
7fae4544fc | ||
|
|
a15a68df39 | ||
|
|
6fcf5fd957 | ||
|
|
276579611c | ||
|
|
32f075901f | ||
|
|
21ae5bbb02 | ||
|
|
9ba9c66cca | ||
|
|
b2d6198417 | ||
|
|
560f1b0115 | ||
|
|
7643b4c434 | ||
|
|
fa8b983a26 | ||
|
|
ce539dc06b | ||
|
|
dfe8aa027c | ||
|
|
cbd71793f5 | ||
|
|
1ab0e2696a | ||
|
|
f45ed446e9 | ||
|
|
fa3806c158 | ||
|
|
ef984ef786 | ||
|
|
88727514f0 | ||
|
|
03620e4c31 | ||
|
|
182bd6716c | ||
|
|
c3f0b90df5 | ||
|
|
b63e40603b | ||
|
|
36c8177fe8 | ||
|
|
2582c406b0 | ||
|
|
0e58c40f80 | ||
|
|
19db1d316b | ||
|
|
cbe3e496a9 | ||
|
|
7d5ad29ed0 | ||
|
|
db2622a63b |
+47
-40
@@ -1,3 +1,14 @@
|
||||
# Operating system (build VM template)
|
||||
image:
|
||||
- "Visual Studio 2022"
|
||||
- "Visual Studio 2019"
|
||||
|
||||
platform: x64
|
||||
|
||||
configuration:
|
||||
- Release
|
||||
- Debug
|
||||
|
||||
environment:
|
||||
AV_PROJECTS: 'c:\projects'
|
||||
AV_TIFF_DOWNLOAD: 'c:\projects\download'
|
||||
@@ -6,78 +17,75 @@ environment:
|
||||
AV_TIFF_INSTALL: 'c:\projects\install'
|
||||
|
||||
matrix:
|
||||
- compiler: vc-cmake
|
||||
- compiler: cygwin-cmake
|
||||
configuration: Release
|
||||
generator: Unix Makefiles
|
||||
shared: ON
|
||||
- compiler: cygwin-cmake
|
||||
configuration: Debug
|
||||
generator: Unix Makefiles
|
||||
shared: OFF
|
||||
- compiler: mingw-cmake
|
||||
configuration: Release
|
||||
generator: MinGW Makefiles
|
||||
shared: ON
|
||||
- compiler: mingw-cmake
|
||||
configuration: Debug
|
||||
generator: MinGW Makefiles
|
||||
shared: OFF
|
||||
- compiler: vc14-cmake
|
||||
configuration: Release
|
||||
arch: x64
|
||||
generator: Visual Studio 16 2019
|
||||
shared: ON
|
||||
- compiler: vc14-cmake
|
||||
configuration: Debug
|
||||
arch: Win32
|
||||
generator: Visual Studio 16 2019
|
||||
shared: OFF
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
- image: "Visual Studio 2019"
|
||||
compiler: cygwin-cmake
|
||||
configuration: Release
|
||||
- image: "Visual Studio 2019"
|
||||
compiler: cygwin-cmake
|
||||
configuration: Debug
|
||||
- image: "Visual Studio 2019"
|
||||
compiler: mingw-cmake
|
||||
configuration: Release
|
||||
- image: "Visual Studio 2019"
|
||||
compiler: mingw-cmake
|
||||
configuration: Debug
|
||||
|
||||
cache:
|
||||
#- 'c:\projects\download -> appveyor.yml'
|
||||
|
||||
# Operating system (build VM template)
|
||||
os: 'Visual Studio 2019'
|
||||
|
||||
# clone directory
|
||||
# Clone directory
|
||||
clone_folder: 'c:\projects\libtiff'
|
||||
clone_depth: 5
|
||||
|
||||
platform: x64
|
||||
|
||||
init:
|
||||
- git config --global core.autocrlf input
|
||||
|
||||
before_build:
|
||||
- 'if %compiler%==vc-cmake if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2022" set "generator=Visual Studio 17 2022"'
|
||||
- 'if %compiler%==vc-cmake if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" set "generator=Visual Studio 16 2019"'
|
||||
- 'if %compiler%==cygwin-cmake set "generator=Unix Makefiles"'
|
||||
- 'if %compiler%==mingw-cmake set "generator=Ninja"'
|
||||
- 'if %Configuration%==Release set "shared=ON"'
|
||||
- 'if %Configuration%==Debug set "shared=OFF"'
|
||||
- 'if %compiler%==vc-cmake if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2022" set "arch=x64"'
|
||||
- 'if %compiler%==vc-cmake if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" set "arch=Win32"'
|
||||
- 'FOR /F "tokens=* USEBACKQ" %%F IN (`C:\cygwin64\bin\cygpath -u %AV_TIFF_SOURCE%`) DO SET AV_TIFF_CYG_SOURCE=%%F'
|
||||
- 'FOR /F "tokens=* USEBACKQ" %%F IN (`C:\cygwin64\bin\cygpath -u %AV_TIFF_INSTALL%`) DO SET AV_TIFF_CYG_INSTALL=%%F'
|
||||
- 'if %compiler%==cygwin-cmake C:\cygwin64\setup-x86_64 -q -R C:\cygwin64 -s http://cygwin.mirror.constant.com -l %AV_TIFF_DOWNLOAD%\cygwin -P cmake,libjpeg-devel,zlib-devel'
|
||||
- 'if %compiler%==cygwin-cmake C:\cygwin64\setup-x86_64 -q -R C:\cygwin64 -s http://cygwin.mirror.constant.com -l %AV_TIFF_DOWNLOAD%\cygwin -g -P cmake,libjpeg-devel,zlib-devel'
|
||||
- 'if %compiler%==cygwin-cmake set "PATH=C:\cygwin64\bin;%PATH%"'
|
||||
- set
|
||||
- 'if %compiler%==cygwin-cmake cygpath --version || echo cygpath not found'
|
||||
- 'if %compiler%==cygwin-cmake cmake --version || echo CMake not found'
|
||||
- set "AV_CMAKE_ARGS=-DBUILD_SHARED_LIBS:BOOL=%shared%"
|
||||
- 'if %compiler%==cygwin-cmake set "AV_CMAKE_ARGS=%AV_CMAKE_ARGS% -Dfatal-warnings=ON"'
|
||||
- 'if %compiler%==mingw32-cmake set "AV_CMAKE_ARGS=%AV_CMAKE_ARGS% -Dfatal-warnings=ON"'
|
||||
- 'if %compiler%==mingw-cmake set "AV_CMAKE_ARGS=%AV_CMAKE_ARGS% -Dfatal-warnings=ON"'
|
||||
- set "AV_TIFF_CMAKE_SOURCE=%AV_TIFF_SOURCE%"
|
||||
- set "AV_TIFF_CMAKE_INSTALL=%AV_TIFF_INSTALL%"
|
||||
- 'if %compiler%==cygwin-cmake set "AV_TIFF_CMAKE_SOURCE=%AV_TIFF_CYG_SOURCE%'
|
||||
- 'if %compiler%==cygwin-cmake set "AV_TIFF_CMAKE_INSTALL=%AV_TIFF_CYG_INSTALL%'
|
||||
- 'if %compiler%==mingw-cmake set "PATH=C:\MinGW\bin;%PATH%"'
|
||||
- 'if %compiler%==mingw-cmake C:\msys64\usr\bin\bash -lc "pacman -Syuu --noconfirm"'
|
||||
- 'if %compiler%==mingw-cmake C:\msys64\usr\bin\bash -lc "pacman -Syuu --noconfirm"'
|
||||
- 'if %compiler%==mingw-cmake C:\msys64\usr\bin\bash -lc "pacman -S --needed --noconfirm mingw-w64-ucrt-x86_64-{toolchain,cmake,ninja,zlib,libjpeg-turbo}"'
|
||||
- 'if %compiler%==mingw-cmake set "PATH=C:\msys64\ucrt64\bin;C:\msys64\usr\bin;%PATH%"'
|
||||
- mkdir %AV_TIFF_BUILD%
|
||||
- cd %AV_TIFF_BUILD%
|
||||
- set
|
||||
- echo Running cmake -G "%generator%" -DCMAKE_INSTALL_PREFIX=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_TIFF_CMAKE_SOURCE%
|
||||
- 'if %compiler%==cygwin-cmake bash -c "cmake -G \"%generator%\" -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%"'
|
||||
# Disable doc building because of 'Could not import extension sphinxcontrib.applehelp (exception: No module named 'sphinxcontrib.applehelp')'
|
||||
- 'if %compiler%==cygwin-cmake bash -c "cmake -G \"%generator%\" -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE% -Dtiff-docs=off"'
|
||||
- 'if %compiler%==mingw-cmake cmake -G "%generator%" -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%'
|
||||
- 'if %compiler%==vc14-cmake cmake -G "%generator%" -A %arch% -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%'
|
||||
- 'if %compiler%==vc-cmake cmake -G "%generator%" -A %arch% -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%'
|
||||
|
||||
build_script:
|
||||
- cd %AV_TIFF_BUILD%
|
||||
- 'if %compiler%==cygwin-cmake bash -c "cmake --build . --config %configuration% --target install"'
|
||||
- 'if %compiler%==mingw-cmake cmake --build . --config %configuration% --target install'
|
||||
- 'if %compiler%==vc14-cmake cmake --build . --config %configuration% --target install'
|
||||
- 'if %compiler%==vc9-cmake cmake --build . --config %configuration% --target install'
|
||||
- 'if %compiler%==vc-cmake cmake --build . --config %configuration% --target install'
|
||||
|
||||
# scripts to run after build
|
||||
after_build:
|
||||
@@ -90,8 +98,7 @@ before_test:
|
||||
- cd %AV_TIFF_BUILD%
|
||||
- 'if %compiler%==cygwin-cmake bash -c "ctest -V -C %configuration%"'
|
||||
- 'if %compiler%==mingw-cmake ctest -V -C %configuration%'
|
||||
- 'if %compiler%==vc14-cmake ctest -V -C %configuration%'
|
||||
- 'if %compiler%==vc9-cmake ctest -V -C %configuration%'
|
||||
- 'if %compiler%==vc-cmake ctest -V -C %configuration%'
|
||||
|
||||
# AppVeyor don't yet have a configurable retention policy, so this will
|
||||
# eventually use up all the storage allowance.
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
BasedOnStyle: llvm
|
||||
IndentWidth: 4
|
||||
ColumnLimit: 80
|
||||
BreakBeforeBraces: Allman
|
||||
IndentCaseLabels: true
|
||||
@@ -0,0 +1,4 @@
|
||||
42173d6ace476b5228d866640b5355f74e5a108d
|
||||
b0ae5d7071890160da67d2e833d84a400e0406d0
|
||||
dee020782c17c1388ca5774f9904d318b51b288b
|
||||
aee0113f5ec1fd39b97458539bd79a1447425ac4
|
||||
@@ -76,3 +76,7 @@ test/*.log
|
||||
test/*.trs
|
||||
test/o-*
|
||||
*~
|
||||
.idea
|
||||
.vs
|
||||
cmake-build*
|
||||
build*
|
||||
|
||||
+28
-11
@@ -1,38 +1,54 @@
|
||||
image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu20.04:latest
|
||||
image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu24.04:latest
|
||||
|
||||
stages:
|
||||
- build
|
||||
- static-analysis
|
||||
- pages
|
||||
|
||||
autoconf:
|
||||
|
||||
autoconf-current:
|
||||
stage: build
|
||||
script:
|
||||
- sh build/gitlab-ci autoconf
|
||||
after_script:
|
||||
- 'cat autoconf-build/test/test-suite.log'
|
||||
artifacts:
|
||||
name: distribution
|
||||
paths:
|
||||
- distribution
|
||||
|
||||
cmake-makefiles:
|
||||
autoconf-old:
|
||||
stage: build
|
||||
image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu22.04:latest
|
||||
script:
|
||||
- sh build/gitlab-ci autoconf-minimal
|
||||
after_script:
|
||||
- 'cat autoconf-build/test/test-suite.log'
|
||||
|
||||
cmake-makefiles-current:
|
||||
stage: build
|
||||
script:
|
||||
- sh build/gitlab-ci cmake "Unix Makefiles" Release
|
||||
|
||||
cmake-ninja:
|
||||
cmake-makefiles-current-static:
|
||||
stage: build
|
||||
script:
|
||||
- sh build/gitlab-ci cmake "Unix Makefiles" Release static
|
||||
|
||||
cmake-ninja-current:
|
||||
stage: build
|
||||
script:
|
||||
- sh build/gitlab-ci cmake "Ninja" Debug
|
||||
|
||||
cmake-ninja-arm64:
|
||||
tags: [arm64,freebsd]
|
||||
cmake-makefiles-old:
|
||||
stage: build
|
||||
image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu22.04:latest
|
||||
script:
|
||||
- sh build/gitlab-ci cmake "Ninja" Release
|
||||
rules:
|
||||
- if: '$CI_PROJECT_PATH == "libtiff/libtiff"'
|
||||
- sh build/gitlab-ci cmake "Unix Makefiles" Release
|
||||
|
||||
coverity:
|
||||
stage: static-analysis
|
||||
image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu20.04-coverity:latest
|
||||
image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu24.04-coverity:latest
|
||||
script:
|
||||
- sh build/gitlab-ci coverity "Ninja" Debug
|
||||
only:
|
||||
@@ -42,7 +58,8 @@ coverity:
|
||||
pages:
|
||||
stage: pages
|
||||
script:
|
||||
- cp -r html public
|
||||
- sh build/gitlab-ci cmake "Ninja" Debug
|
||||
- cp -r cmake-install/share/doc/tiff/manual/html public
|
||||
artifacts:
|
||||
name: $CI_PROJECT_NAME-$CI_JOB_NAME
|
||||
paths:
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||
rev: 'v15.0.4'
|
||||
hooks:
|
||||
- id: clang-format
|
||||
# tif_fax3sm.c is a generated file
|
||||
# tiffvers.h as well, and its formatting is sensitive for
|
||||
# FindTIFF.cmake to detect the version number
|
||||
# Furthermore, the .in files are formatting sensitive for
|
||||
# cmake functions.
|
||||
exclude: >
|
||||
(?x)^(
|
||||
libtiff/tif_fax3sm.c|
|
||||
libtiff/tiffvers.h|
|
||||
libtiff/tiffvers.h.in|
|
||||
libtiff/tif_config.h|
|
||||
libtiff/tif_config.h.in|
|
||||
libtiff/tif_config.h.cmake.in|
|
||||
libtiff/tiffconf.h|
|
||||
libtiff/tiffconf.h.in|
|
||||
libtiff/tiffconf.h.cmake.in
|
||||
)
|
||||
+52
-21
@@ -35,17 +35,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||
# Read version information from configure.ac.
|
||||
include(AutotoolsVersion)
|
||||
message(STATUS "Building tiff version ${LIBTIFF_VERSION_FULL}")
|
||||
message(STATUS "libtiff library version ${SO_VERSION}")
|
||||
string(TIMESTAMP BUILD_DATE "%Y%m%d")
|
||||
message(STATUS "libtiff build date: ${BUILD_DATE}")
|
||||
|
||||
|
||||
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries")
|
||||
|
||||
|
||||
# Disable deprecated features to ensure clean build
|
||||
add_definitions(-DTIFF_DISABLE_DEPRECATED)
|
||||
|
||||
|
||||
# Project definition
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
@@ -53,6 +42,26 @@ project(tiff
|
||||
VERSION "${LIBTIFF_VERSION}"
|
||||
LANGUAGES C CXX)
|
||||
|
||||
if(NOT CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
|
||||
# libtiff is being included as a subproject of some other project.
|
||||
set(TIFF_INSTALL_DEFAULT OFF)
|
||||
else()
|
||||
set(TIFF_INSTALL_DEFAULT ON)
|
||||
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
|
||||
endif()
|
||||
|
||||
option(tiff-tools "build TIFF tools" ON)
|
||||
option(tiff-tests "build TIFF tests" ON)
|
||||
option(tiff-contrib "build TIFF contrib" ON)
|
||||
option(tiff-docs "build TIFF documentation" ON)
|
||||
option(tiff-deprecated "build TIFF deprecated features" OFF)
|
||||
option(tiff-install "install TIFF targets" ${TIFF_INSTALL_DEFAULT})
|
||||
|
||||
# Disable deprecated features to ensure clean build
|
||||
if (tiff-deprecated)
|
||||
add_definitions(-DTIFF_DISABLE_DEPRECATED)
|
||||
endif()
|
||||
|
||||
# Autotools compatibility
|
||||
include(AutotoolsCompat)
|
||||
|
||||
@@ -131,16 +140,22 @@ find_package(CMath REQUIRED)
|
||||
# Release support
|
||||
include(Release)
|
||||
|
||||
|
||||
# Process subdirectories
|
||||
add_subdirectory(port)
|
||||
add_subdirectory(libtiff)
|
||||
add_subdirectory(tools)
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(contrib)
|
||||
if(tiff-tools)
|
||||
add_subdirectory(tools)
|
||||
endif()
|
||||
if(tiff-tests)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
if(tiff-contrib)
|
||||
add_subdirectory(contrib)
|
||||
endif()
|
||||
add_subdirectory(build)
|
||||
add_subdirectory(man)
|
||||
add_subdirectory(html)
|
||||
if(tiff-docs)
|
||||
add_subdirectory(doc)
|
||||
endif()
|
||||
|
||||
# pkg-config support
|
||||
include(PkgConfig)
|
||||
@@ -148,11 +163,23 @@ include(PkgConfig)
|
||||
message(STATUS "")
|
||||
message(STATUS "Libtiff is now configured for ${CMAKE_SYSTEM}")
|
||||
message(STATUS "")
|
||||
if (NOT LIBTIFF_RELEASE_VERSION STREQUAL LIBTIFF_VERSION_FULL)
|
||||
message(STATUS " Libtiff release version ${LIBTIFF_RELEASE_VERSION} is not equal to build version!")
|
||||
endif()
|
||||
message(STATUS " Libtiff build version: ${LIBTIFF_VERSION_FULL}")
|
||||
message(STATUS " Libtiff library version: ${SO_VERSION}")
|
||||
message(STATUS " Libtiff release date: ${LIBTIFF_RELEASE_DATE}")
|
||||
message(STATUS "")
|
||||
message(STATUS " Installation directory: ${prefix}")
|
||||
message(STATUS " Documentation directory: ${LIBTIFF_DOCDIR}")
|
||||
message(STATUS " C compiler: ${CMAKE_C_COMPILER}")
|
||||
message(STATUS " C++ compiler: ${CMAKE_CXX_COMPILER}")
|
||||
message(STATUS " Build shared libraries: ${BUILD_SHARED_LIBS}")
|
||||
message(STATUS " Build tools: ${tiff-tools}")
|
||||
message(STATUS " Build tests: ${tiff-tests}")
|
||||
message(STATUS " Build contrib: ${tiff-contrib}")
|
||||
message(STATUS " Build docs: ${tiff-docs}")
|
||||
message(STATUS " Build deprecated features: ${tiff-deprecated}")
|
||||
message(STATUS " Enable linker symbol versioning: ${HAVE_LD_VERSION_SCRIPT}")
|
||||
message(STATUS " Support Microsoft Document Imaging: ${mdi}")
|
||||
message(STATUS " Use win32 IO: ${USE_WIN32_FILEIO}")
|
||||
@@ -183,19 +210,23 @@ if(JPEG_SUPPORT)
|
||||
else()
|
||||
message(STATUS " Old JPEG support: Requested:${old-jpeg} Availability:${JPEG_SUPPORT} Support:${OJPEG_SUPPORT} (Depends on JPEG Support)")
|
||||
endif()
|
||||
message(STATUS " JPEG 8/12 bit dual mode: Requested:${jpeg12} Availability:${JPEG12_FOUND} Support:${JPEG_DUAL_MODE_8_12}")
|
||||
if(JPEG_SUPPORT AND HAVE_JPEGTURBO_DUAL_MODE_8_12)
|
||||
message(STATUS " JPEG 8/12 bit dual mode: Support: yes (libjpeg turbo >= 3.0 dual mode)")
|
||||
else()
|
||||
message(STATUS " JPEG 8/12 bit dual mode: Requested:${jpeg12} Availability:${JPEG12_FOUND} Support:${JPEG_DUAL_MODE_8_12}")
|
||||
endif()
|
||||
message(STATUS " ISO JBIG support: Requested:${jbig} Availability:${JBIG_FOUND} Support:${JBIG_SUPPORT}")
|
||||
if(ZLIB_SUPPORT)
|
||||
message(STATUS " LERC support: Requested:${lerc} Availability:${LERC_FOUND} Support:${LERC_SUPPORT}")
|
||||
else()
|
||||
message(STATUS " LERC support: Requested:${lerc} Availability:${LERC_FOUND} Support:${LERC_SUPPORT} (Depends on ZLIB Support)")
|
||||
endif()
|
||||
message(STATUS " LZMA2 support: Requested:${lzma} Availability:${LIBLZMA_FOUND} Support:${LZMA_SUPPORT}")
|
||||
message(STATUS " LZMA2 support: Requested:${lzma} Availability:${liblzma_FOUND} Support:${LZMA_SUPPORT}")
|
||||
message(STATUS " ZSTD support: Requested:${zstd} Availability:${ZSTD_USABLE} Support:${ZSTD_SUPPORT}")
|
||||
message(STATUS " WEBP support: Requested:${webp} Availability:${WEBP_FOUND} Support:${WEBP_SUPPORT}")
|
||||
message(STATUS " WEBP support: Requested:${webp} Availability:${WebP_FOUND} Support:${WEBP_SUPPORT}")
|
||||
message(STATUS "")
|
||||
message(STATUS " C++ support: ${cxx} (requested) ${CXX_SUPPORT} (availability)")
|
||||
message(STATUS "")
|
||||
# message(STATUS " X Athena Widgets support: ${HAVE_XAW}")
|
||||
message(STATUS " OpenGL support: ${HAVE_OPENGL}")
|
||||
message(STATUS " OpenGL support: Requested:${tiff-opengl} Availability:${HAVE_OPENGL} Support:${OPENGL_SUPPORT}")
|
||||
message(STATUS "")
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
Contributing
|
||||
------------
|
||||
|
||||
libtiff uses a ``.clang-format`` file to enforce code formatting rules.
|
||||
|
||||
Automatic code reformatting can be done with pre-commit.
|
||||
|
||||
Install (once) pre-commit with ``python -m pip install pre-commit``.
|
||||
|
||||
Install it (once) in the libtiff git repository with ``pre-commit install``.
|
||||
|
||||
Then the rules defined in the ``.pre-commit-config.yaml`` file will be
|
||||
enforced at ``git commit`` time, with automatic reformatting.
|
||||
|
||||
Due to whole-tree code reformatting done during libtiff 4.5 development,
|
||||
``git blame`` information might be misleading. To avoid that, you need
|
||||
to modify your git configuration as following to ignore the revision of
|
||||
the whole-tree reformatting:
|
||||
``git config blame.ignoreRevsFile .git-blame-ignore-revs``.
|
||||
+17
-13
@@ -41,14 +41,14 @@ Notes on releasing.
|
||||
mv ChangeLog.new ChangeLog
|
||||
rm ChangeLog.added
|
||||
|
||||
3. Create html/vX.X.html and add it to git with 'git add html/vX.X.html'.
|
||||
Take ChangeLog entries and html-ify in there.
|
||||
Easist thing to do is take html/vX.(X-1).html and use it as a template.
|
||||
3. Create doc/releases/vX.X.rst and add it to git with 'git add doc/releases/vX.X.rst'.
|
||||
Update doc/releases/index.rst to point to the new file
|
||||
Take ChangeLog entries and rst-ify in there.
|
||||
Easist thing to do is take doc/releases/vX.(X-1).rst and use it as a template.
|
||||
|
||||
4. Add vX.X.html file to the list of 'docfiles' files in the html/Makefile.am.
|
||||
4. Add vX.X.rst file to the list of 'rst_sources' files in the doc/Makefile.am.
|
||||
|
||||
5. Update html/index.html to refer to this new page as the current release,
|
||||
and update date at the bottom of the page
|
||||
5. Update "Latest Stable Release" in doc/index.rst.
|
||||
|
||||
6. Increment the release version in configure.ac. Put 'alpha' or
|
||||
'beta' after the version, if applicable. For example:
|
||||
@@ -100,11 +100,13 @@ Notes on releasing.
|
||||
|
||||
make release
|
||||
|
||||
This will update "RELEASE-DATE", "VERSION", and libtiff/tiffvers.h
|
||||
in the source tree.
|
||||
This will update "RELEASE-DATE", "VERSION" in the source tree,
|
||||
and libtiff/tiffvers.h in the build tree.
|
||||
|
||||
12. In the source tree, verify that the version info in RELEASE-DATE,
|
||||
VERSION and libtiff/tiffvers.h is right.
|
||||
VERSION is right.
|
||||
In the build tree, verify that the version info in
|
||||
libtiff/tiffvers.h is right.
|
||||
|
||||
13. In the build tree do
|
||||
|
||||
@@ -134,18 +136,20 @@ Notes on releasing.
|
||||
16. Sign the release files in the build tree using your private key
|
||||
|
||||
export GPG_TTY=$(tty)
|
||||
for file in tiff-*.tar.gz tiff-*.zip ; do \
|
||||
for file in tiff-*.tar.gz tiff-*.tar.xz tiff-*.zip ; do \
|
||||
gpg2 --output ${file}.sig --detach-sig $file ; \
|
||||
done
|
||||
|
||||
for file in tiff-*.tar.gz tiff-*.zip ; do \
|
||||
for file in tiff-*.tar.gz tiff-*.tar.xz tiff-*.zip ; do \
|
||||
gpg2 --verify ${file}.sig $file ; \
|
||||
done
|
||||
|
||||
17. Copy release packages from the build tree to the
|
||||
ftp.remotesensing.org ftp site.
|
||||
|
||||
scp tiff-*.tar.gz tiff-*.tar.gz.sig tiff-*.zip tiff-*.zip.sig \
|
||||
scp tiff-*.tar.gz tiff-*.tar.gz.sig tiff-*.tar.xz tiff-*.tar.xz.sig tiff-*.zip tiff-*.zip.sig \
|
||||
bfriesen@upload.osgeo.org:/osgeo/download/libtiff
|
||||
|
||||
18. Announce to list: tiff@lists.osgeo.org
|
||||
18. Create a gitlab release at https://gitlab.com/libtiff/libtiff/-/releases
|
||||
|
||||
19. Announce to list: tiff@lists.osgeo.org
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
Copyright (c) 1988-1997 Sam Leffler
|
||||
Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
# LibTIFF license
|
||||
|
||||
Copyright © 1988-1997 Sam Leffler\
|
||||
Copyright © 1991-1997 Silicon Graphics, Inc.
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this software and
|
||||
its documentation for any purpose is hereby granted without fee, provided
|
||||
+12
-6
@@ -25,12 +25,12 @@
|
||||
|
||||
docdir = $(LIBTIFF_DOCDIR)
|
||||
|
||||
AUTOMAKE_OPTIONS = 1.12 dist-zip foreign
|
||||
AUTOMAKE_OPTIONS = 1.11 dist-zip foreign
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
docfiles = \
|
||||
COPYRIGHT \
|
||||
ChangeLog \
|
||||
LICENSE.md \
|
||||
README.md \
|
||||
RELEASE-DATE \
|
||||
TODO \
|
||||
@@ -44,13 +44,15 @@ EXTRA_DIST = \
|
||||
autogen.sh \
|
||||
libtiff-4.pc.in
|
||||
|
||||
if TIFF_DOCS
|
||||
dist_doc_DATA = $(docfiles)
|
||||
endif
|
||||
|
||||
distcheck-hook:
|
||||
if [ -x "$(CMAKE)" ]; then \
|
||||
mkdir $(distdir)/_build/cmake \
|
||||
&& cd $(distdir)/_build/cmake \
|
||||
&& cmake ../.. \
|
||||
&& cmake -Dsphinx=OFF ../.. \
|
||||
&& $(MAKE) \
|
||||
&& ctest -V \
|
||||
&& $(MAKE) DESTDIR=../../_inst/cmake install ; \
|
||||
@@ -58,12 +60,16 @@ distcheck-hook:
|
||||
rm -rf $(distdir)/_build/cmake
|
||||
rm -rf $(distdir)/_inst/cmake
|
||||
|
||||
SUBDIRS = port libtiff tools build contrib test man html
|
||||
SUBDIRS = port libtiff tools build contrib test doc
|
||||
|
||||
|
||||
NEW_LIBTIFF_RELEASE_DATE=$(shell date +"%Y%m%d")
|
||||
|
||||
release:
|
||||
(rm -f $(top_srcdir)/RELEASE-DATE && echo $(LIBTIFF_RELEASE_DATE) > $(top_srcdir)/RELEASE-DATE)
|
||||
@(echo --- Setting release date to $(NEW_LIBTIFF_RELEASE_DATE) and release version to $(LIBTIFF_VERSION) ---)
|
||||
(rm -f $(top_srcdir)/RELEASE-DATE && echo $(NEW_LIBTIFF_RELEASE_DATE) > $(top_srcdir)/RELEASE-DATE)
|
||||
(rm -f $(top_srcdir)/VERSION && echo $(LIBTIFF_VERSION) > $(top_srcdir)/VERSION)
|
||||
(rm -f $(top_srcdir)/libtiff/tiffvers.h && sed 's,LIBTIFF_VERSION,$(LIBTIFF_VERSION),;s,LIBTIFF_RELEASE_DATE,$(LIBTIFF_RELEASE_DATE),' $(top_srcdir)/libtiff/tiffvers.h.in > $(top_srcdir)/libtiff/tiffvers.h)
|
||||
(rm -f $(top_builddir)/libtiff/tiffvers.h && sed 's,LIBTIFF_VERSION,$(LIBTIFF_VERSION),;s,LIBTIFF_RELEASE_DATE,$(NEW_LIBTIFF_RELEASE_DATE),;s,LIBTIFF_MAJOR_VERSION,$(LIBTIFF_MAJOR_VERSION),;s,LIBTIFF_MINOR_VERSION,$(LIBTIFF_MINOR_VERSION),;s,LIBTIFF_MICRO_VERSION,$(LIBTIFF_MICRO_VERSION),' $(top_srcdir)/libtiff/tiffvers.h.in > $(top_builddir)/libtiff/tiffvers.h && sed -i 's,@,,g' $(top_builddir)/libtiff/tiffvers.h)
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libtiff-4.pc
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
TIFF Software Distribution
|
||||
--------------------------
|
||||
This file is just a placeholder; all the documentation is now in
|
||||
HTML in the html directory. To view the documentation point your
|
||||
favorite WWW viewer at html/index.html;
|
||||
This file is just a placeholder; the entire documentation is now located
|
||||
as reStructuredText in the doc directory. To view the documentation
|
||||
as HTML, visit https://libtiff.gitlab.io/libtiff/ or
|
||||
http://www.simplesystems.org/libtiff/ or within the release package
|
||||
in the doc/html-prebuilt directory. The manual pages are
|
||||
located at doc/man-prebuilt.
|
||||
|
||||
e.g.
|
||||
The release package can be downloaded at
|
||||
|
||||
firefox html/index.html
|
||||
|
||||
If you don't have an HTML viewer then you can read the HTML source
|
||||
or fetch a PostScript version of this documentation from the directory
|
||||
|
||||
http://download.osgeo.org/libtiff/
|
||||
http://download.osgeo.org/libtiff/
|
||||
|
||||
If you can't hack either of these options then basically what you
|
||||
want to do is:
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
20220520
|
||||
20240911
|
||||
|
||||
+829
-761
File diff suppressed because it is too large
Load Diff
+336
-294
@@ -2,30 +2,30 @@
|
||||
* Copyright (c) 1990-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* convert a GIF file into a TIFF file.
|
||||
* based on Paul Haeberli's fromgif program which in turn is
|
||||
* based on a GIF file reader by Marcel J.E. Mol March 23 1989
|
||||
* based on a GIF file reader by Marcel J.E. Mol March 23 1989
|
||||
*
|
||||
* if input is 320 by 200 pixel aspect is probably 1.2
|
||||
* if input is 640 350 pixel aspect is probably 1.37
|
||||
@@ -33,67 +33,65 @@
|
||||
*/
|
||||
#include "tif_config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef NEED_LIBPORT
|
||||
# include "libport.h"
|
||||
#include "libport.h"
|
||||
#endif
|
||||
|
||||
#include "tiffio.h"
|
||||
|
||||
#define GIFGAMMA (1.5) /* smaller makes output img brighter */
|
||||
#define IMAX 0xffff /* max intensity value */
|
||||
#define EXTRAFUDGE 128 /* some people write BAD .gif files */
|
||||
#define GIFGAMMA (1.5) /* smaller makes output img brighter */
|
||||
#define IMAX 0xffff /* max intensity value */
|
||||
#define EXTRAFUDGE 128 /* some people write BAD .gif files */
|
||||
|
||||
#define streq(a,b) (strcmp(a,b) == 0)
|
||||
#define strneq(a,b,n) (strncmp(a,b,n) == 0)
|
||||
#define streq(a, b) (strcmp(a, b) == 0)
|
||||
#define strneq(a, b, n) (strncmp(a, b, n) == 0)
|
||||
|
||||
unsigned short gamtab[256];
|
||||
|
||||
void
|
||||
makegamtab(float gam)
|
||||
void makegamtab(float gam)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<256; i++)
|
||||
gamtab[i] = (unsigned short) (IMAX*pow(i/255.0,gam)+0.5);
|
||||
for (i = 0; i < 256; i++)
|
||||
gamtab[i] = (unsigned short)(IMAX * pow(i / 255.0, gam) + 0.5);
|
||||
}
|
||||
|
||||
char* stuff[] = {
|
||||
"usage: gif2tiff [options] input.gif output.tif",
|
||||
"where options are:",
|
||||
" -r # make each strip have no more than # rows",
|
||||
"",
|
||||
" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
|
||||
" -c zip[:opts] compress output with deflate encoding",
|
||||
" -c packbits compress output with packbits encoding",
|
||||
" -c none use no compression algorithm on output",
|
||||
"",
|
||||
"LZW and deflate options:",
|
||||
" # set predictor value",
|
||||
"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing",
|
||||
NULL
|
||||
};
|
||||
char *stuff[] = {
|
||||
"usage: gif2tiff [options] input.gif output.tif",
|
||||
"where options are:",
|
||||
" -r # make each strip have no more than # rows",
|
||||
"",
|
||||
" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
|
||||
" -c zip[:opts] compress output with deflate encoding",
|
||||
" -c packbits compress output with packbits encoding",
|
||||
" -c none use no compression algorithm on output",
|
||||
"",
|
||||
"LZW and deflate options:",
|
||||
" # set predictor value",
|
||||
"For example, -c lzw:2 to get LZW-encoded data with horizontal "
|
||||
"differencing",
|
||||
NULL};
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
static void usage(void)
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
int i;
|
||||
char buf[BUFSIZ];
|
||||
int i;
|
||||
|
||||
setbuf(stderr, buf);
|
||||
fprintf(stderr, "%s\n\n", TIFFGetVersion());
|
||||
for (i = 0; stuff[i] != NULL; i++)
|
||||
fprintf(stderr, "%s\n", stuff[i]);
|
||||
exit(-1);
|
||||
setbuf(stderr, buf);
|
||||
fprintf(stderr, "%s\n\n", TIFFGetVersion());
|
||||
for (i = 0; stuff[i] != NULL; i++)
|
||||
fprintf(stderr, "%s\n", stuff[i]);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
#define COLSIZE 256
|
||||
@@ -102,38 +100,37 @@ unsigned char *stackp;
|
||||
unsigned int prefix[4096];
|
||||
unsigned char suffix[4096];
|
||||
unsigned char stack[4096];
|
||||
int datasize,codesize,codemask; /* Decoder working variables */
|
||||
int clear,eoi; /* Special code values */
|
||||
int datasize, codesize, codemask; /* Decoder working variables */
|
||||
int clear, eoi; /* Special code values */
|
||||
int avail, oldcode;
|
||||
|
||||
FILE *infile;
|
||||
int global; /* Is there a global color map? */
|
||||
int globalbits; /* Number of bits of global colors */
|
||||
unsigned char globalmap[COLSIZE][3];/* RGB values for global color map */
|
||||
unsigned char *raster; /* Decoded image data */
|
||||
int global; /* Is there a global color map? */
|
||||
int globalbits; /* Number of bits of global colors */
|
||||
unsigned char globalmap[COLSIZE][3]; /* RGB values for global color map */
|
||||
unsigned char *raster; /* Decoded image data */
|
||||
unsigned long width, height;
|
||||
unsigned short red[COLSIZE];
|
||||
unsigned short green[COLSIZE];
|
||||
unsigned short blue[COLSIZE];
|
||||
char *filename, *imagename;
|
||||
|
||||
static uint16_t compression = COMPRESSION_PACKBITS;
|
||||
static uint16_t predictor = 0;
|
||||
static uint32_t rowsperstrip = (uint32_t) -1;
|
||||
static int processCompressOptions(char*);
|
||||
static uint16_t compression = COMPRESSION_PACKBITS;
|
||||
static uint16_t predictor = 0;
|
||||
static uint32_t rowsperstrip = (uint32_t)-1;
|
||||
static int processCompressOptions(char *);
|
||||
|
||||
int convert(void);
|
||||
int checksignature(void);
|
||||
int readscreen(void);
|
||||
int readgifimage(char*);
|
||||
int readextension(void);
|
||||
int readraster(void);
|
||||
int process(int, unsigned char**);
|
||||
void initcolors(unsigned char [COLSIZE][3], int);
|
||||
void rasterize(int, char*);
|
||||
int convert(void);
|
||||
int checksignature(void);
|
||||
int readscreen(void);
|
||||
int readgifimage(char *);
|
||||
int readextension(void);
|
||||
int readraster(void);
|
||||
int process(int, unsigned char **);
|
||||
void initcolors(unsigned char[COLSIZE][3], int);
|
||||
void rasterize(int, char *);
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#if !HAVE_DECL_OPTARG
|
||||
extern int optind;
|
||||
@@ -143,105 +140,119 @@ main(int argc, char* argv[])
|
||||
int c, status;
|
||||
|
||||
while ((c = getopt(argc, argv, "c:r:")) != -1)
|
||||
switch (c) {
|
||||
case 'c': /* compression scheme */
|
||||
if (!processCompressOptions(optarg))
|
||||
usage();
|
||||
break;
|
||||
case 'r': /* rows/strip */
|
||||
rowsperstrip = atoi(optarg);
|
||||
break;
|
||||
case '?':
|
||||
usage();
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
switch (c)
|
||||
{
|
||||
case 'c': /* compression scheme */
|
||||
if (!processCompressOptions(optarg))
|
||||
usage();
|
||||
break;
|
||||
case 'r': /* rows/strip */
|
||||
rowsperstrip = atoi(optarg);
|
||||
break;
|
||||
case '?':
|
||||
usage();
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
if (argc - optind != 2)
|
||||
usage();
|
||||
usage();
|
||||
|
||||
makegamtab(GIFGAMMA);
|
||||
filename = argv[optind];
|
||||
imagename = argv[optind+1];
|
||||
if ((infile = fopen(imagename, "rb")) != NULL) {
|
||||
int c;
|
||||
fclose(infile);
|
||||
printf("overwrite %s? ", imagename); fflush(stdout);
|
||||
c = getc(stdin);
|
||||
if (c != 'y' && c != 'Y')
|
||||
return (1);
|
||||
imagename = argv[optind + 1];
|
||||
if ((infile = fopen(imagename, "rb")) != NULL)
|
||||
{
|
||||
int c;
|
||||
fclose(infile);
|
||||
printf("overwrite %s? ", imagename);
|
||||
fflush(stdout);
|
||||
c = getc(stdin);
|
||||
if (c != 'y' && c != 'Y')
|
||||
return (1);
|
||||
}
|
||||
if ((infile = fopen(filename, "rb")) == NULL) {
|
||||
perror(filename);
|
||||
return (1);
|
||||
if ((infile = fopen(filename, "rb")) == NULL)
|
||||
{
|
||||
perror(filename);
|
||||
return (1);
|
||||
}
|
||||
status = convert();
|
||||
fclose(infile);
|
||||
return (status);
|
||||
}
|
||||
|
||||
static int
|
||||
processCompressOptions(char* opt)
|
||||
static int processCompressOptions(char *opt)
|
||||
{
|
||||
if (streq(opt, "none"))
|
||||
compression = COMPRESSION_NONE;
|
||||
else if (streq(opt, "packbits"))
|
||||
compression = COMPRESSION_PACKBITS;
|
||||
else if (strneq(opt, "lzw", 3)) {
|
||||
char* cp = strchr(opt, ':');
|
||||
if (cp)
|
||||
predictor = atoi(cp+1);
|
||||
compression = COMPRESSION_LZW;
|
||||
} else if (strneq(opt, "zip", 3)) {
|
||||
char* cp = strchr(opt, ':');
|
||||
if (cp)
|
||||
predictor = atoi(cp+1);
|
||||
compression = COMPRESSION_ADOBE_DEFLATE;
|
||||
} else
|
||||
return (0);
|
||||
return (1);
|
||||
if (streq(opt, "none"))
|
||||
compression = COMPRESSION_NONE;
|
||||
else if (streq(opt, "packbits"))
|
||||
compression = COMPRESSION_PACKBITS;
|
||||
else if (strneq(opt, "lzw", 3))
|
||||
{
|
||||
char *cp = strchr(opt, ':');
|
||||
if (cp)
|
||||
predictor = atoi(cp + 1);
|
||||
compression = COMPRESSION_LZW;
|
||||
}
|
||||
else if (strneq(opt, "zip", 3))
|
||||
{
|
||||
char *cp = strchr(opt, ':');
|
||||
if (cp)
|
||||
predictor = atoi(cp + 1);
|
||||
compression = COMPRESSION_ADOBE_DEFLATE;
|
||||
}
|
||||
else
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
int
|
||||
convert(void)
|
||||
int convert(void)
|
||||
{
|
||||
int ch;
|
||||
char* mode = "w";
|
||||
char *mode = "w";
|
||||
|
||||
if (!checksignature())
|
||||
return (-1);
|
||||
if (!readscreen())
|
||||
return (-1);
|
||||
while ((ch = getc(infile)) != ';' && ch != EOF) {
|
||||
switch (ch) {
|
||||
case '\0': break; /* this kludge for non-standard files */
|
||||
case ',': if (!readgifimage(mode))
|
||||
return (-1);
|
||||
mode = "a"; /* subsequent images append */
|
||||
break;
|
||||
case '!': if (!readextension())
|
||||
return (-1);
|
||||
break;
|
||||
default: fprintf(stderr, "illegal GIF block type\n");
|
||||
return (-1);
|
||||
while ((ch = getc(infile)) != ';' && ch != EOF)
|
||||
{
|
||||
switch (ch)
|
||||
{
|
||||
case '\0':
|
||||
break; /* this kludge for non-standard files */
|
||||
case ',':
|
||||
if (!readgifimage(mode))
|
||||
return (-1);
|
||||
mode = "a"; /* subsequent images append */
|
||||
break;
|
||||
case '!':
|
||||
if (!readextension())
|
||||
return (-1);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "illegal GIF block type\n");
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
checksignature(void)
|
||||
int checksignature(void)
|
||||
{
|
||||
char buf[6];
|
||||
|
||||
if (fread(buf,1,6,infile) != 6) {
|
||||
fprintf(stderr, "short read from file %s (%s)\n",
|
||||
filename, strerror(errno));
|
||||
if (fread(buf, 1, 6, infile) != 6)
|
||||
{
|
||||
fprintf(stderr, "short read from file %s (%s)\n", filename,
|
||||
strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
if (strncmp(buf,"GIF",3)) {
|
||||
if (strncmp(buf, "GIF", 3))
|
||||
{
|
||||
fprintf(stderr, "file is not a GIF file\n");
|
||||
return 0;
|
||||
}
|
||||
if (strncmp(&buf[3],"87a",3)) {
|
||||
if (strncmp(&buf[3], "87a", 3))
|
||||
{
|
||||
fprintf(stderr, "unknown GIF version number\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -249,35 +260,36 @@ checksignature(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* readscreen -
|
||||
* Get information which is global to all the images stored
|
||||
* readscreen -
|
||||
* Get information which is global to all the images stored
|
||||
* in the file
|
||||
*/
|
||||
int
|
||||
readscreen(void)
|
||||
int readscreen(void)
|
||||
{
|
||||
unsigned char buf[7];
|
||||
|
||||
if (fread(buf,1,7,infile) != 7) {
|
||||
fprintf(stderr, "short read from file %s (%s)\n",
|
||||
filename, strerror(errno));
|
||||
if (fread(buf, 1, 7, infile) != 7)
|
||||
{
|
||||
fprintf(stderr, "short read from file %s (%s)\n", filename,
|
||||
strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
global = buf[4] & 0x80;
|
||||
if (global) {
|
||||
if (global)
|
||||
{
|
||||
globalbits = (buf[4] & 0x07) + 1;
|
||||
if (fread(globalmap,3,((size_t)1)<<globalbits,infile) !=
|
||||
((size_t)1)<<globalbits) {
|
||||
fprintf(stderr, "short read from file %s (%s)\n",
|
||||
filename, strerror(errno));
|
||||
if (fread(globalmap, 3, ((size_t)1) << globalbits, infile) !=
|
||||
((size_t)1) << globalbits)
|
||||
{
|
||||
fprintf(stderr, "short read from file %s (%s)\n", filename,
|
||||
strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
readgifimage(char* mode)
|
||||
int readgifimage(char *mode)
|
||||
{
|
||||
unsigned char buf[9];
|
||||
int local, interleaved;
|
||||
@@ -286,50 +298,61 @@ readgifimage(char* mode)
|
||||
int status;
|
||||
size_t raster_size;
|
||||
|
||||
if (fread(buf, 1, 9, infile) != 9) {
|
||||
fprintf(stderr, "short read from file %s (%s)\n",
|
||||
filename, strerror(errno));
|
||||
return (0);
|
||||
if (fread(buf, 1, 9, infile) != 9)
|
||||
{
|
||||
fprintf(stderr, "short read from file %s (%s)\n", filename,
|
||||
strerror(errno));
|
||||
return (0);
|
||||
}
|
||||
width = (buf[4] + (buf[5] << 8)) & 0xffff; /* 16 bit */
|
||||
height = (buf[6] + (buf[7] << 8)) & 0xffff; /* 16 bit */
|
||||
width = (buf[4] + (buf[5] << 8)) & 0xffff; /* 16 bit */
|
||||
height = (buf[6] + (buf[7] << 8)) & 0xffff; /* 16 bit */
|
||||
local = buf[8] & 0x80;
|
||||
interleaved = buf[8] & 0x40;
|
||||
if (width == 0UL || height == 0UL || (width > 2000000000UL / height)) {
|
||||
if (width == 0UL || height == 0UL || (width > 2000000000UL / height))
|
||||
{
|
||||
fprintf(stderr, "Invalid value of width or height\n");
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
if (local == 0 && global == 0) {
|
||||
if (local == 0 && global == 0)
|
||||
{
|
||||
fprintf(stderr, "no colormap present for image\n");
|
||||
return (0);
|
||||
}
|
||||
raster_size=width*height;
|
||||
if ((raster_size/width) == height) {
|
||||
raster_size += EXTRAFUDGE; /* Add elbow room */
|
||||
} else {
|
||||
raster_size=0;
|
||||
raster_size = width * height;
|
||||
if ((raster_size / width) == height)
|
||||
{
|
||||
raster_size += EXTRAFUDGE; /* Add elbow room */
|
||||
}
|
||||
if ((raster = (unsigned char*) _TIFFmalloc(raster_size)) == NULL) {
|
||||
else
|
||||
{
|
||||
raster_size = 0;
|
||||
}
|
||||
if ((raster = (unsigned char *)_TIFFmalloc(raster_size)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "not enough memory for image\n");
|
||||
return (0);
|
||||
}
|
||||
if (local) {
|
||||
if (local)
|
||||
{
|
||||
localbits = (buf[8] & 0x7) + 1;
|
||||
|
||||
fprintf(stderr, " local colors: %d\n", 1<<localbits);
|
||||
fprintf(stderr, " local colors: %d\n", 1 << localbits);
|
||||
|
||||
if (fread(localmap, 3, ((size_t)1)<<localbits, infile) !=
|
||||
((size_t)1)<<localbits) {
|
||||
fprintf(stderr, "short read from file %s (%s)\n",
|
||||
filename, strerror(errno));
|
||||
if (fread(localmap, 3, ((size_t)1) << localbits, infile) !=
|
||||
((size_t)1) << localbits)
|
||||
{
|
||||
fprintf(stderr, "short read from file %s (%s)\n", filename,
|
||||
strerror(errno));
|
||||
return (0);
|
||||
}
|
||||
initcolors(localmap, 1<<localbits);
|
||||
} else if (global) {
|
||||
initcolors(globalmap, 1<<globalbits);
|
||||
initcolors(localmap, 1 << localbits);
|
||||
}
|
||||
else if (global)
|
||||
{
|
||||
initcolors(globalmap, 1 << globalbits);
|
||||
}
|
||||
if ((status = readraster()))
|
||||
rasterize(interleaved, mode);
|
||||
rasterize(interleaved, mode);
|
||||
_TIFFfree(raster);
|
||||
return status;
|
||||
}
|
||||
@@ -339,18 +362,18 @@ readgifimage(char* mode)
|
||||
* Read a GIF extension block (and do nothing with it).
|
||||
*
|
||||
*/
|
||||
int
|
||||
readextension(void)
|
||||
int readextension(void)
|
||||
{
|
||||
int count;
|
||||
char buf[255];
|
||||
int status = 1;
|
||||
|
||||
(void) getc(infile);
|
||||
(void)getc(infile);
|
||||
while ((count = getc(infile)) && count <= 255)
|
||||
if (fread(buf, 1, count, infile) != (size_t) count) {
|
||||
fprintf(stderr, "short read from file %s (%s)\n",
|
||||
filename, strerror(errno));
|
||||
if (fread(buf, 1, count, infile) != (size_t)count)
|
||||
{
|
||||
fprintf(stderr, "short read from file %s (%s)\n", filename,
|
||||
strerror(errno));
|
||||
status = 0;
|
||||
break;
|
||||
}
|
||||
@@ -362,114 +385,129 @@ readextension(void)
|
||||
* Decode a raster image
|
||||
*
|
||||
*/
|
||||
int
|
||||
readraster(void)
|
||||
int readraster(void)
|
||||
{
|
||||
unsigned char *fill = raster;
|
||||
unsigned char buf[255];
|
||||
register int bits=0;
|
||||
register unsigned long datum=0;
|
||||
register int bits = 0;
|
||||
register unsigned long datum = 0;
|
||||
register unsigned char *ch;
|
||||
register int count, code;
|
||||
int status = 1;
|
||||
|
||||
datasize = getc(infile);
|
||||
if (datasize > 12)
|
||||
return 0;
|
||||
return 0;
|
||||
clear = 1 << datasize;
|
||||
eoi = clear + 1;
|
||||
avail = clear + 2;
|
||||
oldcode = -1;
|
||||
codesize = datasize + 1;
|
||||
codemask = (1 << codesize) - 1;
|
||||
for (code = 0; code < clear; code++) {
|
||||
prefix[code] = 0;
|
||||
suffix[code] = code;
|
||||
for (code = 0; code < clear; code++)
|
||||
{
|
||||
prefix[code] = 0;
|
||||
suffix[code] = code;
|
||||
}
|
||||
stackp = stack;
|
||||
for (count = getc(infile); count > 0 && count <= 255; count = getc(infile)) {
|
||||
if (fread(buf,1,count,infile) != (size_t)count) {
|
||||
fprintf(stderr, "short read from file %s (%s)\n",
|
||||
filename, strerror(errno));
|
||||
for (count = getc(infile); count > 0 && count <= 255; count = getc(infile))
|
||||
{
|
||||
if (fread(buf, 1, count, infile) != (size_t)count)
|
||||
{
|
||||
fprintf(stderr, "short read from file %s (%s)\n", filename,
|
||||
strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
for (ch=buf; count-- > 0; ch++) {
|
||||
datum += (unsigned long) *ch << bits;
|
||||
bits += 8;
|
||||
while (bits >= codesize) {
|
||||
code = datum & codemask;
|
||||
datum >>= codesize;
|
||||
bits -= codesize;
|
||||
if (code == eoi) { /* This kludge put in */
|
||||
goto exitloop; /* because some GIF files*/
|
||||
} /* aren't standard */
|
||||
if (!process(code, &fill)) {
|
||||
status = 0;
|
||||
goto exitloop;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fill >= raster + width*height) {
|
||||
fprintf(stderr, "raster full before eoi code\n");
|
||||
break;
|
||||
}
|
||||
for (ch = buf; count-- > 0; ch++)
|
||||
{
|
||||
datum += (unsigned long)*ch << bits;
|
||||
bits += 8;
|
||||
while (bits >= codesize)
|
||||
{
|
||||
code = datum & codemask;
|
||||
datum >>= codesize;
|
||||
bits -= codesize;
|
||||
if (code == eoi)
|
||||
{ /* This kludge put in */
|
||||
goto exitloop; /* because some GIF files*/
|
||||
} /* aren't standard */
|
||||
if (!process(code, &fill))
|
||||
{
|
||||
status = 0;
|
||||
goto exitloop;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fill >= raster + width * height)
|
||||
{
|
||||
fprintf(stderr, "raster full before eoi code\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
exitloop:
|
||||
if (fill != raster + width*height) {
|
||||
fprintf(stderr, "warning: wrong rastersize: %ld bytes\n",
|
||||
(long) (fill-raster));
|
||||
fprintf(stderr, " instead of %ld bytes\n",
|
||||
(long) width*height);
|
||||
if (fill != raster + width * height)
|
||||
{
|
||||
fprintf(stderr, "warning: wrong rastersize: %ld bytes\n",
|
||||
(long)(fill - raster));
|
||||
fprintf(stderr, " instead of %ld bytes\n",
|
||||
(long)width * height);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* process -
|
||||
* Process a compression code. "clear" resets the code table.
|
||||
* Otherwise make a new code table entry, and output the bytes
|
||||
* process -
|
||||
* Process a compression code. "clear" resets the code table.
|
||||
* Otherwise make a new code table entry, and output the bytes
|
||||
* associated with the code.
|
||||
*/
|
||||
int
|
||||
process(register int code, unsigned char** fill)
|
||||
int process(register int code, unsigned char **fill)
|
||||
{
|
||||
int incode;
|
||||
static unsigned char firstchar;
|
||||
|
||||
if (code == clear) {
|
||||
codesize = datasize + 1;
|
||||
codemask = (1 << codesize) - 1;
|
||||
avail = clear + 2;
|
||||
oldcode = -1;
|
||||
return 1;
|
||||
if (code == clear)
|
||||
{
|
||||
codesize = datasize + 1;
|
||||
codemask = (1 << codesize) - 1;
|
||||
avail = clear + 2;
|
||||
oldcode = -1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (oldcode == -1) {
|
||||
if (code >= clear) {
|
||||
fprintf(stderr, "bad input: code=%d is larger than clear=%d\n",code, clear);
|
||||
if (oldcode == -1)
|
||||
{
|
||||
if (code >= clear)
|
||||
{
|
||||
fprintf(stderr, "bad input: code=%d is larger than clear=%d\n",
|
||||
code, clear);
|
||||
return 0;
|
||||
}
|
||||
if (*fill >= raster + width*height) {
|
||||
if (*fill >= raster + width * height)
|
||||
{
|
||||
fprintf(stderr, "raster full before eoi code\n");
|
||||
return 0;
|
||||
}
|
||||
*(*fill)++ = suffix[code];
|
||||
firstchar = oldcode = code;
|
||||
return 1;
|
||||
*(*fill)++ = suffix[code];
|
||||
firstchar = oldcode = code;
|
||||
return 1;
|
||||
}
|
||||
if (code > avail) {
|
||||
fprintf(stderr, "code %d too large for %d\n", code, avail);
|
||||
return 0;
|
||||
if (code > avail)
|
||||
{
|
||||
fprintf(stderr, "code %d too large for %d\n", code, avail);
|
||||
return 0;
|
||||
}
|
||||
|
||||
incode = code;
|
||||
if (code == avail) { /* the first code is always < avail */
|
||||
*stackp++ = firstchar;
|
||||
code = oldcode;
|
||||
if (code == avail)
|
||||
{ /* the first code is always < avail */
|
||||
*stackp++ = firstchar;
|
||||
code = oldcode;
|
||||
}
|
||||
while (code > clear) {
|
||||
*stackp++ = suffix[code];
|
||||
code = prefix[code];
|
||||
while (code > clear)
|
||||
{
|
||||
*stackp++ = suffix[code];
|
||||
code = prefix[code];
|
||||
}
|
||||
|
||||
*stackp++ = firstchar = suffix[code];
|
||||
@@ -477,17 +515,20 @@ process(register int code, unsigned char** fill)
|
||||
suffix[avail] = firstchar;
|
||||
avail++;
|
||||
|
||||
if (((avail & codemask) == 0) && (avail < 4096)) {
|
||||
codesize++;
|
||||
codemask += avail;
|
||||
if (((avail & codemask) == 0) && (avail < 4096))
|
||||
{
|
||||
codesize++;
|
||||
codemask += avail;
|
||||
}
|
||||
oldcode = incode;
|
||||
do {
|
||||
if (*fill >= raster + width*height) {
|
||||
do
|
||||
{
|
||||
if (*fill >= raster + width * height)
|
||||
{
|
||||
fprintf(stderr, "raster full before eoi code\n");
|
||||
return 0;
|
||||
}
|
||||
*(*fill)++ = *--stackp;
|
||||
*(*fill)++ = *--stackp;
|
||||
} while (stackp > stack);
|
||||
return 1;
|
||||
}
|
||||
@@ -495,23 +536,22 @@ process(register int code, unsigned char** fill)
|
||||
/*
|
||||
* initcolors -
|
||||
* Convert a color map (local or global) to arrays with R, G and B
|
||||
* values.
|
||||
* values.
|
||||
*
|
||||
*/
|
||||
void
|
||||
initcolors(unsigned char colormap[COLSIZE][3], int ncolors)
|
||||
void initcolors(unsigned char colormap[COLSIZE][3], int ncolors)
|
||||
{
|
||||
register int i;
|
||||
|
||||
for (i = 0; i < ncolors; i++) {
|
||||
red[i] = gamtab[colormap[i][0]];
|
||||
for (i = 0; i < ncolors; i++)
|
||||
{
|
||||
red[i] = gamtab[colormap[i][0]];
|
||||
green[i] = gamtab[colormap[i][1]];
|
||||
blue[i] = gamtab[colormap[i][2]];
|
||||
blue[i] = gamtab[colormap[i][2]];
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rasterize(int interleaved, char* mode)
|
||||
void rasterize(int interleaved, char *mode)
|
||||
{
|
||||
register unsigned long row;
|
||||
unsigned char *newras;
|
||||
@@ -520,71 +560,73 @@ rasterize(int interleaved, char* mode)
|
||||
tstrip_t strip;
|
||||
tsize_t stripsize;
|
||||
|
||||
if ((newras = (unsigned char*) _TIFFmalloc(width*height+EXTRAFUDGE)) == NULL) {
|
||||
if ((newras = (unsigned char *)_TIFFmalloc(width * height + EXTRAFUDGE)) ==
|
||||
NULL)
|
||||
{
|
||||
fprintf(stderr, "not enough memory for image\n");
|
||||
return;
|
||||
}
|
||||
#define DRAWSEGMENT(offset, step) { \
|
||||
for (row = offset; row < height; row += step) { \
|
||||
_TIFFmemcpy(newras + row*width, ras, width);\
|
||||
ras += width; \
|
||||
} \
|
||||
#define DRAWSEGMENT(offset, step) \
|
||||
{ \
|
||||
for (row = offset; row < height; row += step) \
|
||||
{ \
|
||||
_TIFFmemcpy(newras + row * width, ras, width); \
|
||||
ras += width; \
|
||||
} \
|
||||
}
|
||||
ras = raster;
|
||||
if (interleaved) {
|
||||
if (interleaved)
|
||||
{
|
||||
DRAWSEGMENT(0, 8);
|
||||
DRAWSEGMENT(4, 8);
|
||||
DRAWSEGMENT(2, 4);
|
||||
DRAWSEGMENT(1, 2);
|
||||
} else
|
||||
}
|
||||
else
|
||||
DRAWSEGMENT(0, 1);
|
||||
#undef DRAWSEGMENT
|
||||
|
||||
tif = TIFFOpen(imagename, mode);
|
||||
if (!tif) {
|
||||
TIFFError(imagename,"Can not open output image");
|
||||
exit(-1);
|
||||
if (!tif)
|
||||
{
|
||||
TIFFError(imagename, "Can not open output image");
|
||||
exit(-1);
|
||||
}
|
||||
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, (uint32_t) width);
|
||||
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, (uint32_t) height);
|
||||
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, (uint32_t)width);
|
||||
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, (uint32_t)height);
|
||||
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE);
|
||||
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
|
||||
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
|
||||
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP,
|
||||
rowsperstrip = TIFFDefaultStripSize(tif, rowsperstrip));
|
||||
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP,
|
||||
rowsperstrip = TIFFDefaultStripSize(tif, rowsperstrip));
|
||||
TIFFSetField(tif, TIFFTAG_COMPRESSION, compression);
|
||||
switch (compression) {
|
||||
case COMPRESSION_LZW:
|
||||
case COMPRESSION_ADOBE_DEFLATE:
|
||||
case COMPRESSION_DEFLATE:
|
||||
if (predictor != 0)
|
||||
TIFFSetField(tif, TIFFTAG_PREDICTOR, predictor);
|
||||
break;
|
||||
switch (compression)
|
||||
{
|
||||
case COMPRESSION_LZW:
|
||||
case COMPRESSION_ADOBE_DEFLATE:
|
||||
case COMPRESSION_DEFLATE:
|
||||
if (predictor != 0)
|
||||
TIFFSetField(tif, TIFFTAG_PREDICTOR, predictor);
|
||||
break;
|
||||
}
|
||||
TIFFSetField(tif, TIFFTAG_COLORMAP, red, green, blue);
|
||||
TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
|
||||
strip = 0;
|
||||
stripsize = TIFFStripSize(tif);
|
||||
for (row=0; row<height; row += rowsperstrip) {
|
||||
if (rowsperstrip > height-row) {
|
||||
rowsperstrip = height-row;
|
||||
stripsize = TIFFVStripSize(tif, rowsperstrip);
|
||||
}
|
||||
if (TIFFWriteEncodedStrip(tif, strip, newras+row*width, stripsize) < 0)
|
||||
break;
|
||||
strip++;
|
||||
for (row = 0; row < height; row += rowsperstrip)
|
||||
{
|
||||
if (rowsperstrip > height - row)
|
||||
{
|
||||
rowsperstrip = height - row;
|
||||
stripsize = TIFFVStripSize(tif, rowsperstrip);
|
||||
}
|
||||
if (TIFFWriteEncodedStrip(tif, strip, newras + row * width, stripsize) <
|
||||
0)
|
||||
break;
|
||||
strip++;
|
||||
}
|
||||
TIFFClose(tif);
|
||||
|
||||
_TIFFfree(newras);
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sts=8 sw=8 noet: */
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 4
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
+309
-287
@@ -2,344 +2,366 @@
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "tif_config.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef NEED_LIBPORT
|
||||
# include "libport.h"
|
||||
#include "libport.h"
|
||||
#endif
|
||||
|
||||
#include "rasterfile.h"
|
||||
#include "tiffio.h"
|
||||
|
||||
#ifndef howmany
|
||||
#define howmany(x, y) (((x)+((y)-1))/(y))
|
||||
#define howmany(x, y) (((x) + ((y)-1)) / (y))
|
||||
#endif
|
||||
#define streq(a,b) (strcmp(a,b) == 0)
|
||||
#define strneq(a,b,n) (strncmp(a,b,n) == 0)
|
||||
#define streq(a, b) (strcmp(a, b) == 0)
|
||||
#define strneq(a, b, n) (strncmp(a, b, n) == 0)
|
||||
|
||||
static uint16_t compression = (uint16_t) -1;
|
||||
static int jpegcolormode = JPEGCOLORMODE_RGB;
|
||||
static int quality = 75; /* JPEG quality */
|
||||
static uint16_t predictor = 0;
|
||||
static uint16_t compression = (uint16_t)-1;
|
||||
static int jpegcolormode = JPEGCOLORMODE_RGB;
|
||||
static int quality = 75; /* JPEG quality */
|
||||
static uint16_t predictor = 0;
|
||||
|
||||
static void usage(void);
|
||||
static int processCompressOptions(char*);
|
||||
static int processCompressOptions(char *);
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
unsigned char* buf;
|
||||
long row;
|
||||
tsize_t linebytes, scanline;
|
||||
TIFF *out;
|
||||
FILE *in;
|
||||
struct rasterfile h;
|
||||
uint16_t photometric;
|
||||
uint16_t config = PLANARCONFIG_CONTIG;
|
||||
uint32_t rowsperstrip = (uint32_t) -1;
|
||||
int c;
|
||||
unsigned char *buf;
|
||||
long row;
|
||||
tsize_t linebytes, scanline;
|
||||
TIFF *out;
|
||||
FILE *in;
|
||||
struct rasterfile h;
|
||||
uint16_t photometric;
|
||||
uint16_t config = PLANARCONFIG_CONTIG;
|
||||
uint32_t rowsperstrip = (uint32_t)-1;
|
||||
int c;
|
||||
#if !HAVE_DECL_OPTARG
|
||||
extern int optind;
|
||||
extern char* optarg;
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
#endif
|
||||
|
||||
while ((c = getopt(argc, argv, "c:r:h")) != -1)
|
||||
switch (c) {
|
||||
case 'c': /* compression scheme */
|
||||
if (!processCompressOptions(optarg))
|
||||
usage();
|
||||
break;
|
||||
case 'r': /* rows/strip */
|
||||
rowsperstrip = atoi(optarg);
|
||||
break;
|
||||
case 'h':
|
||||
usage();
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
if (argc - optind != 2)
|
||||
usage();
|
||||
in = fopen(argv[optind], "rb");
|
||||
if (in == NULL) {
|
||||
fprintf(stderr, "%s: Can not open.\n", argv[optind]);
|
||||
return (-1);
|
||||
}
|
||||
if (fread(&h, sizeof (h), 1, in) != 1) {
|
||||
fprintf(stderr, "%s: Can not read header.\n", argv[optind]);
|
||||
fclose(in);
|
||||
return (-2);
|
||||
}
|
||||
if (strcmp(h.ras_magic, RAS_MAGIC) == 0) {
|
||||
while ((c = getopt(argc, argv, "c:r:h")) != -1)
|
||||
switch (c)
|
||||
{
|
||||
case 'c': /* compression scheme */
|
||||
if (!processCompressOptions(optarg))
|
||||
usage();
|
||||
break;
|
||||
case 'r': /* rows/strip */
|
||||
rowsperstrip = atoi(optarg);
|
||||
break;
|
||||
case 'h':
|
||||
usage();
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
if (argc - optind != 2)
|
||||
usage();
|
||||
in = fopen(argv[optind], "rb");
|
||||
if (in == NULL)
|
||||
{
|
||||
fprintf(stderr, "%s: Can not open.\n", argv[optind]);
|
||||
return (-1);
|
||||
}
|
||||
if (fread(&h, sizeof(h), 1, in) != 1)
|
||||
{
|
||||
fprintf(stderr, "%s: Can not read header.\n", argv[optind]);
|
||||
fclose(in);
|
||||
return (-2);
|
||||
}
|
||||
if (strcmp(h.ras_magic, RAS_MAGIC) == 0)
|
||||
{
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
TIFFSwabLong((uint32_t *)&h.ras_width);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_height);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_depth);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_length);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_type);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_maptype);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_maplength);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_width);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_height);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_depth);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_length);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_type);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_maptype);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_maplength);
|
||||
#endif
|
||||
} else if (strcmp(h.ras_magic, RAS_MAGIC_INV) == 0) {
|
||||
}
|
||||
else if (strcmp(h.ras_magic, RAS_MAGIC_INV) == 0)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
TIFFSwabLong((uint32_t *)&h.ras_width);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_height);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_depth);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_length);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_type);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_maptype);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_maplength);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_width);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_height);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_depth);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_length);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_type);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_maptype);
|
||||
TIFFSwabLong((uint32_t *)&h.ras_maplength);
|
||||
#endif
|
||||
} else {
|
||||
fprintf(stderr, "%s: Not a rasterfile.\n", argv[optind]);
|
||||
fclose(in);
|
||||
return (-3);
|
||||
}
|
||||
if ((h.ras_width <= 0) || (h.ras_width >= INT_MAX) ||
|
||||
(h.ras_height <= 0) || (h.ras_height >= INT_MAX) ||
|
||||
(h.ras_depth <= 0) || (h.ras_depth >= INT_MAX) ||
|
||||
(h.ras_length <= 0) || (h.ras_length >= INT_MAX) ||
|
||||
(h.ras_type <= 0) ||
|
||||
(h.ras_maptype <= 0) ||
|
||||
(h.ras_maplength <= 0) || (h.ras_maplength >= INT_MAX)) {
|
||||
fprintf(stderr, "%s: Improper image header.\n", argv[optind]);
|
||||
fclose(in);
|
||||
return (-2);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s: Not a rasterfile.\n", argv[optind]);
|
||||
fclose(in);
|
||||
return (-3);
|
||||
}
|
||||
if ((h.ras_width <= 0) || (h.ras_width >= INT_MAX) || (h.ras_height <= 0) ||
|
||||
(h.ras_height >= INT_MAX) || (h.ras_depth <= 0) ||
|
||||
(h.ras_depth >= INT_MAX) || (h.ras_length <= 0) ||
|
||||
(h.ras_length >= INT_MAX) || (h.ras_type <= 0) ||
|
||||
(h.ras_maptype <= 0) || (h.ras_maplength <= 0) ||
|
||||
(h.ras_maplength >= INT_MAX))
|
||||
{
|
||||
fprintf(stderr, "%s: Improper image header.\n", argv[optind]);
|
||||
fclose(in);
|
||||
return (-2);
|
||||
}
|
||||
if ((h.ras_depth != 1) && (h.ras_depth != 8) && (h.ras_depth != 24))
|
||||
{
|
||||
fprintf(stderr, "%s: Improper image depth (%d).\n", argv[optind],
|
||||
h.ras_depth);
|
||||
fclose(in);
|
||||
return (-2);
|
||||
}
|
||||
out = TIFFOpen(argv[optind + 1], "w");
|
||||
if (out == NULL)
|
||||
{
|
||||
fclose(in);
|
||||
return (-4);
|
||||
}
|
||||
TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32_t)h.ras_width);
|
||||
TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32_t)h.ras_height);
|
||||
TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
|
||||
TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, h.ras_depth > 8 ? 3 : 1);
|
||||
TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, h.ras_depth > 1 ? 8 : 1);
|
||||
TIFFSetField(out, TIFFTAG_PLANARCONFIG, config);
|
||||
if (h.ras_maptype != RMT_NONE)
|
||||
{
|
||||
uint16_t *red;
|
||||
register uint16_t *map;
|
||||
register int i, j;
|
||||
int mapsize;
|
||||
|
||||
buf = (unsigned char *)_TIFFmalloc(h.ras_maplength);
|
||||
if (buf == NULL)
|
||||
{
|
||||
fprintf(stderr, "No space to read in colormap.\n");
|
||||
fclose(in);
|
||||
(void)TIFFClose(out);
|
||||
return (-5);
|
||||
}
|
||||
if ((h.ras_depth != 1) &&
|
||||
(h.ras_depth != 8) &&
|
||||
(h.ras_depth != 24)) {
|
||||
fprintf(stderr, "%s: Improper image depth (%d).\n",
|
||||
argv[optind], h.ras_depth);
|
||||
fclose(in);
|
||||
return (-2);
|
||||
if (fread(buf, h.ras_maplength, 1, in) != 1)
|
||||
{
|
||||
fprintf(stderr, "%s: Read error on colormap.\n", argv[optind]);
|
||||
fclose(in);
|
||||
(void)TIFFClose(out);
|
||||
return (-6);
|
||||
}
|
||||
out = TIFFOpen(argv[optind+1], "w");
|
||||
if (out == NULL)
|
||||
{
|
||||
fclose(in);
|
||||
return (-4);
|
||||
}
|
||||
TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32_t) h.ras_width);
|
||||
TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32_t) h.ras_height);
|
||||
TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
|
||||
TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, h.ras_depth > 8 ? 3 : 1);
|
||||
TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, h.ras_depth > 1 ? 8 : 1);
|
||||
TIFFSetField(out, TIFFTAG_PLANARCONFIG, config);
|
||||
if (h.ras_maptype != RMT_NONE) {
|
||||
uint16_t* red;
|
||||
register uint16_t* map;
|
||||
register int i, j;
|
||||
int mapsize;
|
||||
|
||||
buf = (unsigned char *)_TIFFmalloc(h.ras_maplength);
|
||||
if (buf == NULL) {
|
||||
fprintf(stderr, "No space to read in colormap.\n");
|
||||
fclose(in);
|
||||
(void) TIFFClose(out);
|
||||
return (-5);
|
||||
}
|
||||
if (fread(buf, h.ras_maplength, 1, in) != 1) {
|
||||
fprintf(stderr, "%s: Read error on colormap.\n",
|
||||
argv[optind]);
|
||||
fclose(in);
|
||||
(void) TIFFClose(out);
|
||||
return (-6);
|
||||
}
|
||||
mapsize = 1<<h.ras_depth;
|
||||
if (h.ras_maplength > mapsize*3) {
|
||||
fprintf(stderr,
|
||||
"%s: Huh, %d colormap entries, should be %d?\n",
|
||||
argv[optind], h.ras_maplength, mapsize*3);
|
||||
fclose(in);
|
||||
(void) TIFFClose(out);
|
||||
return (-7);
|
||||
}
|
||||
red = (uint16_t*)_TIFFmalloc(mapsize * 3 * sizeof (uint16_t));
|
||||
if (red == NULL) {
|
||||
fprintf(stderr, "No space for colormap.\n");
|
||||
fclose(in);
|
||||
(void) TIFFClose(out);
|
||||
return (-8);
|
||||
}
|
||||
map = red;
|
||||
for (j = 0; j < 3; j++) {
|
||||
#define SCALE(x) (((x)*((1L<<16)-1))/255)
|
||||
for (i = h.ras_maplength/3; i-- > 0;)
|
||||
*map++ = SCALE(*buf++);
|
||||
if ((i = h.ras_maplength/3) < mapsize) {
|
||||
i = mapsize - i;
|
||||
_TIFFmemset(map, 0, i*sizeof (uint16_t));
|
||||
map += i;
|
||||
}
|
||||
}
|
||||
TIFFSetField(out, TIFFTAG_COLORMAP,
|
||||
red, red + mapsize, red + 2*mapsize);
|
||||
photometric = PHOTOMETRIC_PALETTE;
|
||||
if (compression == (uint16_t) -1)
|
||||
compression = COMPRESSION_PACKBITS;
|
||||
TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
|
||||
} else {
|
||||
/* XXX this is bogus... */
|
||||
photometric = h.ras_depth == 24 ?
|
||||
PHOTOMETRIC_RGB : PHOTOMETRIC_MINISBLACK;
|
||||
if (compression == (uint16_t) -1)
|
||||
compression = COMPRESSION_LZW;
|
||||
TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
|
||||
}
|
||||
switch (compression) {
|
||||
case COMPRESSION_JPEG:
|
||||
if (photometric == PHOTOMETRIC_RGB && jpegcolormode == JPEGCOLORMODE_RGB)
|
||||
photometric = PHOTOMETRIC_YCBCR;
|
||||
TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality);
|
||||
TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode);
|
||||
break;
|
||||
case COMPRESSION_LZW:
|
||||
case COMPRESSION_ADOBE_DEFLATE:
|
||||
case COMPRESSION_DEFLATE:
|
||||
if (predictor != 0)
|
||||
TIFFSetField(out, TIFFTAG_PREDICTOR, predictor);
|
||||
break;
|
||||
}
|
||||
TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric);
|
||||
linebytes = ((h.ras_depth*h.ras_width+15) >> 3) &~ 1;
|
||||
scanline = TIFFScanlineSize(out);
|
||||
if (scanline > linebytes) {
|
||||
buf = (unsigned char *)_TIFFmalloc(scanline);
|
||||
_TIFFmemset(buf+linebytes, 0, scanline-linebytes);
|
||||
} else
|
||||
buf = (unsigned char *)_TIFFmalloc(linebytes);
|
||||
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP,
|
||||
TIFFDefaultStripSize(out, rowsperstrip));
|
||||
for (row = 0; row < h.ras_height; row++) {
|
||||
if (fread(buf, linebytes, 1, in) != 1) {
|
||||
fprintf(stderr, "%s: scanline %ld: Read error.\n",
|
||||
argv[optind], row);
|
||||
break;
|
||||
}
|
||||
if (h.ras_type == RT_STANDARD && h.ras_depth == 24) {
|
||||
tsize_t cc = h.ras_width;
|
||||
unsigned char* cp = buf;
|
||||
#define SWAP(a,b) { unsigned char t = (a); (a) = (b); (b) = t; }
|
||||
do {
|
||||
SWAP(cp[0], cp[2]);
|
||||
cp += 3;
|
||||
} while (--cc);
|
||||
}
|
||||
if (TIFFWriteScanline(out, buf, row, 0) < 0)
|
||||
break;
|
||||
}
|
||||
(void) TIFFClose(out);
|
||||
fclose(in);
|
||||
return (0);
|
||||
mapsize = 1 << h.ras_depth;
|
||||
if (h.ras_maplength > mapsize * 3)
|
||||
{
|
||||
fprintf(stderr, "%s: Huh, %d colormap entries, should be %d?\n",
|
||||
argv[optind], h.ras_maplength, mapsize * 3);
|
||||
fclose(in);
|
||||
(void)TIFFClose(out);
|
||||
return (-7);
|
||||
}
|
||||
red = (uint16_t *)_TIFFmalloc(mapsize * 3 * sizeof(uint16_t));
|
||||
if (red == NULL)
|
||||
{
|
||||
fprintf(stderr, "No space for colormap.\n");
|
||||
fclose(in);
|
||||
(void)TIFFClose(out);
|
||||
return (-8);
|
||||
}
|
||||
map = red;
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
#define SCALE(x) (((x) * ((1L << 16) - 1)) / 255)
|
||||
for (i = h.ras_maplength / 3; i-- > 0;)
|
||||
*map++ = SCALE(*buf++);
|
||||
if ((i = h.ras_maplength / 3) < mapsize)
|
||||
{
|
||||
i = mapsize - i;
|
||||
_TIFFmemset(map, 0, i * sizeof(uint16_t));
|
||||
map += i;
|
||||
}
|
||||
}
|
||||
TIFFSetField(out, TIFFTAG_COLORMAP, red, red + mapsize,
|
||||
red + 2 * mapsize);
|
||||
photometric = PHOTOMETRIC_PALETTE;
|
||||
if (compression == (uint16_t)-1)
|
||||
compression = COMPRESSION_PACKBITS;
|
||||
TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* XXX this is bogus... */
|
||||
photometric =
|
||||
h.ras_depth == 24 ? PHOTOMETRIC_RGB : PHOTOMETRIC_MINISBLACK;
|
||||
if (compression == (uint16_t)-1)
|
||||
compression = COMPRESSION_LZW;
|
||||
TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
|
||||
}
|
||||
switch (compression)
|
||||
{
|
||||
case COMPRESSION_JPEG:
|
||||
if (photometric == PHOTOMETRIC_RGB &&
|
||||
jpegcolormode == JPEGCOLORMODE_RGB)
|
||||
photometric = PHOTOMETRIC_YCBCR;
|
||||
TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality);
|
||||
TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode);
|
||||
break;
|
||||
case COMPRESSION_LZW:
|
||||
case COMPRESSION_ADOBE_DEFLATE:
|
||||
case COMPRESSION_DEFLATE:
|
||||
if (predictor != 0)
|
||||
TIFFSetField(out, TIFFTAG_PREDICTOR, predictor);
|
||||
break;
|
||||
}
|
||||
TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric);
|
||||
linebytes = ((h.ras_depth * h.ras_width + 15) >> 3) & ~1;
|
||||
scanline = TIFFScanlineSize(out);
|
||||
if (scanline > linebytes)
|
||||
{
|
||||
buf = (unsigned char *)_TIFFmalloc(scanline);
|
||||
_TIFFmemset(buf + linebytes, 0, scanline - linebytes);
|
||||
}
|
||||
else
|
||||
buf = (unsigned char *)_TIFFmalloc(linebytes);
|
||||
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP,
|
||||
TIFFDefaultStripSize(out, rowsperstrip));
|
||||
for (row = 0; row < h.ras_height; row++)
|
||||
{
|
||||
if (fread(buf, linebytes, 1, in) != 1)
|
||||
{
|
||||
fprintf(stderr, "%s: scanline %ld: Read error.\n", argv[optind],
|
||||
row);
|
||||
break;
|
||||
}
|
||||
if (h.ras_type == RT_STANDARD && h.ras_depth == 24)
|
||||
{
|
||||
tsize_t cc = h.ras_width;
|
||||
unsigned char *cp = buf;
|
||||
#define SWAP(a, b) \
|
||||
{ \
|
||||
unsigned char t = (a); \
|
||||
(a) = (b); \
|
||||
(b) = t; \
|
||||
}
|
||||
do
|
||||
{
|
||||
SWAP(cp[0], cp[2]);
|
||||
cp += 3;
|
||||
} while (--cc);
|
||||
}
|
||||
if (TIFFWriteScanline(out, buf, row, 0) < 0)
|
||||
break;
|
||||
}
|
||||
(void)TIFFClose(out);
|
||||
fclose(in);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
processCompressOptions(char* opt)
|
||||
static int processCompressOptions(char *opt)
|
||||
{
|
||||
if (streq(opt, "none"))
|
||||
compression = COMPRESSION_NONE;
|
||||
else if (streq(opt, "packbits"))
|
||||
compression = COMPRESSION_PACKBITS;
|
||||
else if (strneq(opt, "jpeg", 4)) {
|
||||
char* cp = strchr(opt, ':');
|
||||
if (streq(opt, "none"))
|
||||
compression = COMPRESSION_NONE;
|
||||
else if (streq(opt, "packbits"))
|
||||
compression = COMPRESSION_PACKBITS;
|
||||
else if (strneq(opt, "jpeg", 4))
|
||||
{
|
||||
char *cp = strchr(opt, ':');
|
||||
|
||||
compression = COMPRESSION_JPEG;
|
||||
while( cp )
|
||||
{
|
||||
if (isdigit((int)cp[1]))
|
||||
quality = atoi(cp+1);
|
||||
else if (cp[1] == 'r' )
|
||||
jpegcolormode = JPEGCOLORMODE_RAW;
|
||||
else
|
||||
usage();
|
||||
compression = COMPRESSION_JPEG;
|
||||
while (cp)
|
||||
{
|
||||
if (isdigit((int)cp[1]))
|
||||
quality = atoi(cp + 1);
|
||||
else if (cp[1] == 'r')
|
||||
jpegcolormode = JPEGCOLORMODE_RAW;
|
||||
else
|
||||
usage();
|
||||
|
||||
cp = strchr(cp+1,':');
|
||||
}
|
||||
} else if (strneq(opt, "lzw", 3)) {
|
||||
char* cp = strchr(opt, ':');
|
||||
if (cp)
|
||||
predictor = atoi(cp+1);
|
||||
compression = COMPRESSION_LZW;
|
||||
} else if (strneq(opt, "zip", 3)) {
|
||||
char* cp = strchr(opt, ':');
|
||||
if (cp)
|
||||
predictor = atoi(cp+1);
|
||||
compression = COMPRESSION_ADOBE_DEFLATE;
|
||||
} else
|
||||
return (0);
|
||||
return (1);
|
||||
cp = strchr(cp + 1, ':');
|
||||
}
|
||||
}
|
||||
else if (strneq(opt, "lzw", 3))
|
||||
{
|
||||
char *cp = strchr(opt, ':');
|
||||
if (cp)
|
||||
predictor = atoi(cp + 1);
|
||||
compression = COMPRESSION_LZW;
|
||||
}
|
||||
else if (strneq(opt, "zip", 3))
|
||||
{
|
||||
char *cp = strchr(opt, ':');
|
||||
if (cp)
|
||||
predictor = atoi(cp + 1);
|
||||
compression = COMPRESSION_ADOBE_DEFLATE;
|
||||
}
|
||||
else
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
char* stuff[] = {
|
||||
"usage: ras2tiff [options] input.ras output.tif",
|
||||
"where options are:",
|
||||
" -r # make each strip have no more than # rows",
|
||||
"",
|
||||
" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
|
||||
" -c zip[:opts] compress output with deflate encoding",
|
||||
" -c jpeg[:opts] compress output with JPEG encoding",
|
||||
" -c packbits compress output with packbits encoding",
|
||||
" -c none use no compression algorithm on output",
|
||||
"",
|
||||
"JPEG options:",
|
||||
" # set compression quality level (0-100, default 75)",
|
||||
" r output color image as RGB rather than YCbCr",
|
||||
"For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. quality",
|
||||
"",
|
||||
"LZW and deflate options:",
|
||||
" # set predictor value",
|
||||
"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing",
|
||||
" -h this help message",
|
||||
NULL
|
||||
};
|
||||
char *stuff[] = {
|
||||
"usage: ras2tiff [options] input.ras output.tif",
|
||||
"where options are:",
|
||||
" -r # make each strip have no more than # rows",
|
||||
"",
|
||||
" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
|
||||
" -c zip[:opts] compress output with deflate encoding",
|
||||
" -c jpeg[:opts] compress output with JPEG encoding",
|
||||
" -c packbits compress output with packbits encoding",
|
||||
" -c none use no compression algorithm on output",
|
||||
"",
|
||||
"JPEG options:",
|
||||
" # set compression quality level (0-100, default 75)",
|
||||
" r output color image as RGB rather than YCbCr",
|
||||
"For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. "
|
||||
"quality",
|
||||
"",
|
||||
"LZW and deflate options:",
|
||||
" # set predictor value",
|
||||
"For example, -c lzw:2 to get LZW-encoded data with horizontal "
|
||||
"differencing",
|
||||
" -h this help message",
|
||||
NULL};
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
static void usage(void)
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
int i;
|
||||
char buf[BUFSIZ];
|
||||
int i;
|
||||
|
||||
setbuf(stderr, buf);
|
||||
fprintf(stderr, "%s\n\n", TIFFGetVersion());
|
||||
for (i = 0; stuff[i] != NULL; i++)
|
||||
fprintf(stderr, "%s\n", stuff[i]);
|
||||
exit(-1);
|
||||
setbuf(stderr, buf);
|
||||
fprintf(stderr, "%s\n\n", TIFFGetVersion());
|
||||
for (i = 0; stuff[i] != NULL; i++)
|
||||
fprintf(stderr, "%s\n", stuff[i]);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sts=8 sw=8 noet: */
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
+23
-22
@@ -3,31 +3,32 @@
|
||||
/*
|
||||
* Description of header for files containing raster images
|
||||
*/
|
||||
struct rasterfile {
|
||||
char ras_magic[4]; /* magic number */
|
||||
int32_t ras_width; /* width (pixels) of image */
|
||||
int32_t ras_height; /* height (pixels) of image */
|
||||
int32_t ras_depth; /* depth (1, 8, or 24 bits) of pixel */
|
||||
int32_t ras_length; /* length (bytes) of image */
|
||||
int32_t ras_type; /* type of file; see RT_* below */
|
||||
int32_t ras_maptype; /* type of colormap; see RMT_* below */
|
||||
int32_t ras_maplength; /* length (bytes) of following map */
|
||||
/* color map follows for ras_maplength bytes, followed by image */
|
||||
struct rasterfile
|
||||
{
|
||||
char ras_magic[4]; /* magic number */
|
||||
int32_t ras_width; /* width (pixels) of image */
|
||||
int32_t ras_height; /* height (pixels) of image */
|
||||
int32_t ras_depth; /* depth (1, 8, or 24 bits) of pixel */
|
||||
int32_t ras_length; /* length (bytes) of image */
|
||||
int32_t ras_type; /* type of file; see RT_* below */
|
||||
int32_t ras_maptype; /* type of colormap; see RMT_* below */
|
||||
int32_t ras_maplength; /* length (bytes) of following map */
|
||||
/* color map follows for ras_maplength bytes, followed by image */
|
||||
};
|
||||
#define RAS_MAGIC "\x59\xa6\x6a\x95"
|
||||
#define RAS_MAGIC_INV "\x95\x6a\xa6\x59"
|
||||
#define RAS_MAGIC "\x59\xa6\x6a\x95"
|
||||
#define RAS_MAGIC_INV "\x95\x6a\xa6\x59"
|
||||
|
||||
/* Sun supported ras_type's */
|
||||
#define RT_OLD 0 /* Raw pixrect image in 68000 byte order */
|
||||
#define RT_STANDARD 1 /* Raw pixrect image in 68000 byte order */
|
||||
#define RT_BYTE_ENCODED 2 /* Run-length compression of bytes */
|
||||
#define RT_EXPERIMENTAL 0xffff /* Reserved for testing */
|
||||
/* Sun supported ras_type's */
|
||||
#define RT_OLD 0 /* Raw pixrect image in 68000 byte order */
|
||||
#define RT_STANDARD 1 /* Raw pixrect image in 68000 byte order */
|
||||
#define RT_BYTE_ENCODED 2 /* Run-length compression of bytes */
|
||||
#define RT_EXPERIMENTAL 0xffff /* Reserved for testing */
|
||||
|
||||
/* Sun registered ras_maptype's */
|
||||
#define RMT_RAW 2
|
||||
/* Sun supported ras_maptype's */
|
||||
#define RMT_NONE 0 /* ras_maplength is expected to be 0 */
|
||||
#define RMT_EQUAL_RGB 1 /* red[ras_maplength/3],green[],blue[] */
|
||||
/* Sun registered ras_maptype's */
|
||||
#define RMT_RAW 2
|
||||
/* Sun supported ras_maptype's */
|
||||
#define RMT_NONE 0 /* ras_maplength is expected to be 0 */
|
||||
#define RMT_EQUAL_RGB 1 /* red[ras_maplength/3],green[],blue[] */
|
||||
|
||||
/*
|
||||
* NOTES:
|
||||
|
||||
+289
-279
@@ -2,335 +2,345 @@
|
||||
* Copyright (c) 1991-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <gl/image.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <gl/image.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "tiffio.h"
|
||||
|
||||
#define streq(a,b) (strcmp(a,b) == 0)
|
||||
#define strneq(a,b,n) (strncmp(a,b,n) == 0)
|
||||
#define streq(a, b) (strcmp(a, b) == 0)
|
||||
#define strneq(a, b, n) (strncmp(a, b, n) == 0)
|
||||
|
||||
static short config = PLANARCONFIG_CONTIG;
|
||||
static uint16_t compression = COMPRESSION_PACKBITS;
|
||||
static uint16_t predictor = 0;
|
||||
static uint16_t fillorder = 0;
|
||||
static uint32_t rowsperstrip = (uint32_t) -1;
|
||||
static int jpegcolormode = JPEGCOLORMODE_RGB;
|
||||
static int quality = 75; /* JPEG quality */
|
||||
static uint16_t photometric;
|
||||
static short config = PLANARCONFIG_CONTIG;
|
||||
static uint16_t compression = COMPRESSION_PACKBITS;
|
||||
static uint16_t predictor = 0;
|
||||
static uint16_t fillorder = 0;
|
||||
static uint32_t rowsperstrip = (uint32_t)-1;
|
||||
static int jpegcolormode = JPEGCOLORMODE_RGB;
|
||||
static int quality = 75; /* JPEG quality */
|
||||
static uint16_t photometric;
|
||||
|
||||
static void usage(void);
|
||||
static int cpContig(IMAGE*, TIFF*);
|
||||
static int cpSeparate(IMAGE*, TIFF*);
|
||||
static int processCompressOptions(char*);
|
||||
static void usage(void);
|
||||
static int cpContig(IMAGE *, TIFF *);
|
||||
static int cpSeparate(IMAGE *, TIFF *);
|
||||
static int processCompressOptions(char *);
|
||||
|
||||
/* XXX image library has no prototypes */
|
||||
extern IMAGE* iopen(const char*, const char*);
|
||||
extern void iclose(IMAGE*);
|
||||
extern void getrow(IMAGE*, short*, int, int);
|
||||
extern IMAGE *iopen(const char *, const char *);
|
||||
extern void iclose(IMAGE *);
|
||||
extern void getrow(IMAGE *, short *, int, int);
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
IMAGE *in;
|
||||
TIFF *out;
|
||||
int c;
|
||||
IMAGE *in;
|
||||
TIFF *out;
|
||||
int c;
|
||||
#if !HAVE_DECL_OPTARG
|
||||
extern int optind;
|
||||
extern char* optarg;
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
#endif
|
||||
|
||||
while ((c = getopt(argc, argv, "c:p:r:")) != -1)
|
||||
switch (c) {
|
||||
case 'c': /* compression scheme */
|
||||
if (!processCompressOptions(optarg))
|
||||
usage();
|
||||
break;
|
||||
case 'f': /* fill order */
|
||||
if (streq(optarg, "lsb2msb"))
|
||||
fillorder = FILLORDER_LSB2MSB;
|
||||
else if (streq(optarg, "msb2lsb"))
|
||||
fillorder = FILLORDER_MSB2LSB;
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
case 'p': /* planar configuration */
|
||||
if (streq(optarg, "separate"))
|
||||
config = PLANARCONFIG_SEPARATE;
|
||||
else if (streq(optarg, "contig"))
|
||||
config = PLANARCONFIG_CONTIG;
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
case 'r': /* rows/strip */
|
||||
rowsperstrip = atoi(optarg);
|
||||
break;
|
||||
case '?':
|
||||
usage();
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
if (argc - optind != 2)
|
||||
usage();
|
||||
in = iopen(argv[optind], "r");
|
||||
if (in == NULL)
|
||||
return (-1);
|
||||
out = TIFFOpen(argv[optind+1], "w");
|
||||
if (out == NULL)
|
||||
return (-2);
|
||||
TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32_t) in->xsize);
|
||||
TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32_t) in->ysize);
|
||||
TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8);
|
||||
TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
|
||||
if (in->zsize == 1)
|
||||
photometric = PHOTOMETRIC_MINISBLACK;
|
||||
else
|
||||
photometric = PHOTOMETRIC_RGB;
|
||||
switch (compression) {
|
||||
case COMPRESSION_JPEG:
|
||||
if (photometric == PHOTOMETRIC_RGB && jpegcolormode == JPEGCOLORMODE_RGB)
|
||||
photometric = PHOTOMETRIC_YCBCR;
|
||||
TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality);
|
||||
TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode);
|
||||
break;
|
||||
case COMPRESSION_LZW:
|
||||
case COMPRESSION_ADOBE_DEFLATE:
|
||||
case COMPRESSION_DEFLATE:
|
||||
if (predictor != 0)
|
||||
TIFFSetField(out, TIFFTAG_PREDICTOR, predictor);
|
||||
break;
|
||||
}
|
||||
TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric);
|
||||
if (fillorder != 0)
|
||||
TIFFSetField(out, TIFFTAG_FILLORDER, fillorder);
|
||||
TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
|
||||
TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, in->zsize);
|
||||
if (in->zsize > 3) {
|
||||
uint16_t v[1];
|
||||
v[0] = EXTRASAMPLE_UNASSALPHA;
|
||||
TIFFSetField(out, TIFFTAG_EXTRASAMPLES, 1, v);
|
||||
}
|
||||
TIFFSetField(out, TIFFTAG_MINSAMPLEVALUE, (uint16_t) in->min);
|
||||
TIFFSetField(out, TIFFTAG_MAXSAMPLEVALUE, (uint16_t) in->max);
|
||||
TIFFSetField(out, TIFFTAG_PLANARCONFIG, config);
|
||||
if (config != PLANARCONFIG_SEPARATE)
|
||||
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP,
|
||||
TIFFDefaultStripSize(out, rowsperstrip));
|
||||
else /* force 1 row/strip for library limitation */
|
||||
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, 1L);
|
||||
if (in->name[0] != '\0')
|
||||
TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, in->name);
|
||||
if (config == PLANARCONFIG_CONTIG)
|
||||
cpContig(in, out);
|
||||
else
|
||||
cpSeparate(in, out);
|
||||
(void) iclose(in);
|
||||
(void) TIFFClose(out);
|
||||
return (0);
|
||||
while ((c = getopt(argc, argv, "c:p:r:")) != -1)
|
||||
switch (c)
|
||||
{
|
||||
case 'c': /* compression scheme */
|
||||
if (!processCompressOptions(optarg))
|
||||
usage();
|
||||
break;
|
||||
case 'f': /* fill order */
|
||||
if (streq(optarg, "lsb2msb"))
|
||||
fillorder = FILLORDER_LSB2MSB;
|
||||
else if (streq(optarg, "msb2lsb"))
|
||||
fillorder = FILLORDER_MSB2LSB;
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
case 'p': /* planar configuration */
|
||||
if (streq(optarg, "separate"))
|
||||
config = PLANARCONFIG_SEPARATE;
|
||||
else if (streq(optarg, "contig"))
|
||||
config = PLANARCONFIG_CONTIG;
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
case 'r': /* rows/strip */
|
||||
rowsperstrip = atoi(optarg);
|
||||
break;
|
||||
case '?':
|
||||
usage();
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
if (argc - optind != 2)
|
||||
usage();
|
||||
in = iopen(argv[optind], "r");
|
||||
if (in == NULL)
|
||||
return (-1);
|
||||
out = TIFFOpen(argv[optind + 1], "w");
|
||||
if (out == NULL)
|
||||
return (-2);
|
||||
TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32_t)in->xsize);
|
||||
TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32_t)in->ysize);
|
||||
TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8);
|
||||
TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
|
||||
if (in->zsize == 1)
|
||||
photometric = PHOTOMETRIC_MINISBLACK;
|
||||
else
|
||||
photometric = PHOTOMETRIC_RGB;
|
||||
switch (compression)
|
||||
{
|
||||
case COMPRESSION_JPEG:
|
||||
if (photometric == PHOTOMETRIC_RGB &&
|
||||
jpegcolormode == JPEGCOLORMODE_RGB)
|
||||
photometric = PHOTOMETRIC_YCBCR;
|
||||
TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality);
|
||||
TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode);
|
||||
break;
|
||||
case COMPRESSION_LZW:
|
||||
case COMPRESSION_ADOBE_DEFLATE:
|
||||
case COMPRESSION_DEFLATE:
|
||||
if (predictor != 0)
|
||||
TIFFSetField(out, TIFFTAG_PREDICTOR, predictor);
|
||||
break;
|
||||
}
|
||||
TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric);
|
||||
if (fillorder != 0)
|
||||
TIFFSetField(out, TIFFTAG_FILLORDER, fillorder);
|
||||
TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
|
||||
TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, in->zsize);
|
||||
if (in->zsize > 3)
|
||||
{
|
||||
uint16_t v[1];
|
||||
v[0] = EXTRASAMPLE_UNASSALPHA;
|
||||
TIFFSetField(out, TIFFTAG_EXTRASAMPLES, 1, v);
|
||||
}
|
||||
TIFFSetField(out, TIFFTAG_MINSAMPLEVALUE, (uint16_t)in->min);
|
||||
TIFFSetField(out, TIFFTAG_MAXSAMPLEVALUE, (uint16_t)in->max);
|
||||
TIFFSetField(out, TIFFTAG_PLANARCONFIG, config);
|
||||
if (config != PLANARCONFIG_SEPARATE)
|
||||
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP,
|
||||
TIFFDefaultStripSize(out, rowsperstrip));
|
||||
else /* force 1 row/strip for library limitation */
|
||||
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, 1L);
|
||||
if (in->name[0] != '\0')
|
||||
TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, in->name);
|
||||
if (config == PLANARCONFIG_CONTIG)
|
||||
cpContig(in, out);
|
||||
else
|
||||
cpSeparate(in, out);
|
||||
(void)iclose(in);
|
||||
(void)TIFFClose(out);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
processCompressOptions(char* opt)
|
||||
static int processCompressOptions(char *opt)
|
||||
{
|
||||
if (streq(opt, "none"))
|
||||
compression = COMPRESSION_NONE;
|
||||
else if (streq(opt, "packbits"))
|
||||
compression = COMPRESSION_PACKBITS;
|
||||
else if (strneq(opt, "jpeg", 4)) {
|
||||
char* cp = strchr(opt, ':');
|
||||
if (streq(opt, "none"))
|
||||
compression = COMPRESSION_NONE;
|
||||
else if (streq(opt, "packbits"))
|
||||
compression = COMPRESSION_PACKBITS;
|
||||
else if (strneq(opt, "jpeg", 4))
|
||||
{
|
||||
char *cp = strchr(opt, ':');
|
||||
|
||||
defcompression = COMPRESSION_JPEG;
|
||||
while( cp )
|
||||
{
|
||||
if (isdigit((int)cp[1]))
|
||||
quality = atoi(cp+1);
|
||||
else if (cp[1] == 'r' )
|
||||
jpegcolormode = JPEGCOLORMODE_RAW;
|
||||
else
|
||||
usage();
|
||||
defcompression = COMPRESSION_JPEG;
|
||||
while (cp)
|
||||
{
|
||||
if (isdigit((int)cp[1]))
|
||||
quality = atoi(cp + 1);
|
||||
else if (cp[1] == 'r')
|
||||
jpegcolormode = JPEGCOLORMODE_RAW;
|
||||
else
|
||||
usage();
|
||||
|
||||
cp = strchr(cp+1,':');
|
||||
}
|
||||
} else if (strneq(opt, "lzw", 3)) {
|
||||
char* cp = strchr(opt, ':');
|
||||
if (cp)
|
||||
predictor = atoi(cp+1);
|
||||
compression = COMPRESSION_LZW;
|
||||
} else if (strneq(opt, "zip", 3)) {
|
||||
char* cp = strchr(opt, ':');
|
||||
if (cp)
|
||||
predictor = atoi(cp+1);
|
||||
compression = COMPRESSION_ADOBE_DEFLATE;
|
||||
} else
|
||||
return (0);
|
||||
return (1);
|
||||
cp = strchr(cp + 1, ':');
|
||||
}
|
||||
}
|
||||
else if (strneq(opt, "lzw", 3))
|
||||
{
|
||||
char *cp = strchr(opt, ':');
|
||||
if (cp)
|
||||
predictor = atoi(cp + 1);
|
||||
compression = COMPRESSION_LZW;
|
||||
}
|
||||
else if (strneq(opt, "zip", 3))
|
||||
{
|
||||
char *cp = strchr(opt, ':');
|
||||
if (cp)
|
||||
predictor = atoi(cp + 1);
|
||||
compression = COMPRESSION_ADOBE_DEFLATE;
|
||||
}
|
||||
else
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
cpContig(IMAGE* in, TIFF* out)
|
||||
static int cpContig(IMAGE *in, TIFF *out)
|
||||
{
|
||||
tdata_t buf = _TIFFmalloc(TIFFScanlineSize(out));
|
||||
short *r = NULL;
|
||||
int x, y;
|
||||
tdata_t buf = _TIFFmalloc(TIFFScanlineSize(out));
|
||||
short *r = NULL;
|
||||
int x, y;
|
||||
|
||||
if (in->zsize == 3) {
|
||||
short *g, *b;
|
||||
if (in->zsize == 3)
|
||||
{
|
||||
short *g, *b;
|
||||
|
||||
r = (short *)_TIFFmalloc(3 * in->xsize * sizeof (short));
|
||||
g = r + in->xsize;
|
||||
b = g + in->xsize;
|
||||
for (y = in->ysize-1; y >= 0; y--) {
|
||||
uint8_t* pp = (uint8_t*) buf;
|
||||
r = (short *)_TIFFmalloc(3 * in->xsize * sizeof(short));
|
||||
g = r + in->xsize;
|
||||
b = g + in->xsize;
|
||||
for (y = in->ysize - 1; y >= 0; y--)
|
||||
{
|
||||
uint8_t *pp = (uint8_t *)buf;
|
||||
|
||||
getrow(in, r, y, 0);
|
||||
getrow(in, g, y, 1);
|
||||
getrow(in, b, y, 2);
|
||||
for (x = 0; x < in->xsize; x++) {
|
||||
pp[0] = r[x];
|
||||
pp[1] = g[x];
|
||||
pp[2] = b[x];
|
||||
pp += 3;
|
||||
}
|
||||
if (TIFFWriteScanline(out, buf, in->ysize-y-1, 0) < 0)
|
||||
goto bad;
|
||||
}
|
||||
} else if (in->zsize == 4) {
|
||||
short *g, *b, *a;
|
||||
getrow(in, r, y, 0);
|
||||
getrow(in, g, y, 1);
|
||||
getrow(in, b, y, 2);
|
||||
for (x = 0; x < in->xsize; x++)
|
||||
{
|
||||
pp[0] = r[x];
|
||||
pp[1] = g[x];
|
||||
pp[2] = b[x];
|
||||
pp += 3;
|
||||
}
|
||||
if (TIFFWriteScanline(out, buf, in->ysize - y - 1, 0) < 0)
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
else if (in->zsize == 4)
|
||||
{
|
||||
short *g, *b, *a;
|
||||
|
||||
r = (short *)_TIFFmalloc(4 * in->xsize * sizeof (short));
|
||||
g = r + in->xsize;
|
||||
b = g + in->xsize;
|
||||
a = b + in->xsize;
|
||||
for (y = in->ysize-1; y >= 0; y--) {
|
||||
uint8_t* pp = (uint8_t*) buf;
|
||||
r = (short *)_TIFFmalloc(4 * in->xsize * sizeof(short));
|
||||
g = r + in->xsize;
|
||||
b = g + in->xsize;
|
||||
a = b + in->xsize;
|
||||
for (y = in->ysize - 1; y >= 0; y--)
|
||||
{
|
||||
uint8_t *pp = (uint8_t *)buf;
|
||||
|
||||
getrow(in, r, y, 0);
|
||||
getrow(in, g, y, 1);
|
||||
getrow(in, b, y, 2);
|
||||
getrow(in, a, y, 3);
|
||||
for (x = 0; x < in->xsize; x++) {
|
||||
pp[0] = r[x];
|
||||
pp[1] = g[x];
|
||||
pp[2] = b[x];
|
||||
pp[3] = a[x];
|
||||
pp += 4;
|
||||
}
|
||||
if (TIFFWriteScanline(out, buf, in->ysize-y-1, 0) < 0)
|
||||
goto bad;
|
||||
}
|
||||
} else {
|
||||
uint8_t* pp = (uint8_t*) buf;
|
||||
getrow(in, r, y, 0);
|
||||
getrow(in, g, y, 1);
|
||||
getrow(in, b, y, 2);
|
||||
getrow(in, a, y, 3);
|
||||
for (x = 0; x < in->xsize; x++)
|
||||
{
|
||||
pp[0] = r[x];
|
||||
pp[1] = g[x];
|
||||
pp[2] = b[x];
|
||||
pp[3] = a[x];
|
||||
pp += 4;
|
||||
}
|
||||
if (TIFFWriteScanline(out, buf, in->ysize - y - 1, 0) < 0)
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t *pp = (uint8_t *)buf;
|
||||
|
||||
r = (short *)_TIFFmalloc(in->xsize * sizeof (short));
|
||||
for (y = in->ysize-1; y >= 0; y--) {
|
||||
getrow(in, r, y, 0);
|
||||
for (x = in->xsize-1; x >= 0; x--)
|
||||
pp[x] = r[x];
|
||||
if (TIFFWriteScanline(out, buf, in->ysize-y-1, 0) < 0)
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
if (r)
|
||||
_TIFFfree(r);
|
||||
_TIFFfree(buf);
|
||||
return (1);
|
||||
r = (short *)_TIFFmalloc(in->xsize * sizeof(short));
|
||||
for (y = in->ysize - 1; y >= 0; y--)
|
||||
{
|
||||
getrow(in, r, y, 0);
|
||||
for (x = in->xsize - 1; x >= 0; x--)
|
||||
pp[x] = r[x];
|
||||
if (TIFFWriteScanline(out, buf, in->ysize - y - 1, 0) < 0)
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
if (r)
|
||||
_TIFFfree(r);
|
||||
_TIFFfree(buf);
|
||||
return (1);
|
||||
bad:
|
||||
if (r)
|
||||
_TIFFfree(r);
|
||||
_TIFFfree(buf);
|
||||
return (0);
|
||||
if (r)
|
||||
_TIFFfree(r);
|
||||
_TIFFfree(buf);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
cpSeparate(IMAGE* in, TIFF* out)
|
||||
static int cpSeparate(IMAGE *in, TIFF *out)
|
||||
{
|
||||
tdata_t buf = _TIFFmalloc(TIFFScanlineSize(out));
|
||||
short *r = (short *)_TIFFmalloc(in->xsize * sizeof (short));
|
||||
uint8_t* pp = (uint8_t*) buf;
|
||||
int x, y, z;
|
||||
tdata_t buf = _TIFFmalloc(TIFFScanlineSize(out));
|
||||
short *r = (short *)_TIFFmalloc(in->xsize * sizeof(short));
|
||||
uint8_t *pp = (uint8_t *)buf;
|
||||
int x, y, z;
|
||||
|
||||
for (z = 0; z < in->zsize; z++) {
|
||||
for (y = in->ysize-1; y >= 0; y--) {
|
||||
getrow(in, r, y, z);
|
||||
for (x = 0; x < in->xsize; x++)
|
||||
pp[x] = r[x];
|
||||
if (TIFFWriteScanline(out, buf, in->ysize-y-1, z) < 0)
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
_TIFFfree(r);
|
||||
_TIFFfree(buf);
|
||||
return (1);
|
||||
for (z = 0; z < in->zsize; z++)
|
||||
{
|
||||
for (y = in->ysize - 1; y >= 0; y--)
|
||||
{
|
||||
getrow(in, r, y, z);
|
||||
for (x = 0; x < in->xsize; x++)
|
||||
pp[x] = r[x];
|
||||
if (TIFFWriteScanline(out, buf, in->ysize - y - 1, z) < 0)
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
_TIFFfree(r);
|
||||
_TIFFfree(buf);
|
||||
return (1);
|
||||
bad:
|
||||
_TIFFfree(r);
|
||||
_TIFFfree(buf);
|
||||
return (0);
|
||||
_TIFFfree(r);
|
||||
_TIFFfree(buf);
|
||||
return (0);
|
||||
}
|
||||
|
||||
char* stuff[] = {
|
||||
"usage: sgi2tiff [options] input.rgb output.tif",
|
||||
"where options are:",
|
||||
" -r # make each strip have no more than # rows",
|
||||
"",
|
||||
" -p contig pack samples contiguously (e.g. RGBRGB...)",
|
||||
" -p separate store samples separately (e.g. RRR...GGG...BBB...)",
|
||||
"",
|
||||
" -f lsb2msb force lsb-to-msb FillOrder for output",
|
||||
" -f msb2lsb force msb-to-lsb FillOrder for output",
|
||||
"",
|
||||
" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
|
||||
" -c zip[:opts] compress output with deflate encoding",
|
||||
" -c jpeg[:opts]compress output with JPEG encoding",
|
||||
" -c packbits compress output with packbits encoding",
|
||||
" -c none use no compression algorithm on output",
|
||||
"",
|
||||
"JPEG options:",
|
||||
" # set compression quality level (0-100, default 75)",
|
||||
" r output color image as RGB rather than YCbCr",
|
||||
"",
|
||||
"LZW and deflate options:",
|
||||
" # set predictor value",
|
||||
"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing",
|
||||
NULL
|
||||
};
|
||||
char *stuff[] = {
|
||||
"usage: sgi2tiff [options] input.rgb output.tif",
|
||||
"where options are:",
|
||||
" -r # make each strip have no more than # rows",
|
||||
"",
|
||||
" -p contig pack samples contiguously (e.g. RGBRGB...)",
|
||||
" -p separate store samples separately (e.g. RRR...GGG...BBB...)",
|
||||
"",
|
||||
" -f lsb2msb force lsb-to-msb FillOrder for output",
|
||||
" -f msb2lsb force msb-to-lsb FillOrder for output",
|
||||
"",
|
||||
" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
|
||||
" -c zip[:opts] compress output with deflate encoding",
|
||||
" -c jpeg[:opts]compress output with JPEG encoding",
|
||||
" -c packbits compress output with packbits encoding",
|
||||
" -c none use no compression algorithm on output",
|
||||
"",
|
||||
"JPEG options:",
|
||||
" # set compression quality level (0-100, default 75)",
|
||||
" r output color image as RGB rather than YCbCr",
|
||||
"",
|
||||
"LZW and deflate options:",
|
||||
" # set predictor value",
|
||||
"For example, -c lzw:2 to get LZW-encoded data with horizontal "
|
||||
"differencing",
|
||||
NULL};
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
static void usage(void)
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
int i;
|
||||
char buf[BUFSIZ];
|
||||
int i;
|
||||
|
||||
setbuf(stderr, buf);
|
||||
for (i = 0; stuff[i] != NULL; i++)
|
||||
fprintf(stderr, "%s\n", stuff[i]);
|
||||
exit(-1);
|
||||
setbuf(stderr, buf);
|
||||
for (i = 0; stuff[i] != NULL; i++)
|
||||
fprintf(stderr, "%s\n", stuff[i]);
|
||||
exit(-1);
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
+259
-253
@@ -2,23 +2,23 @@
|
||||
* Copyright (c) 1990-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -26,291 +26,297 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gl.h>
|
||||
#include <ctype.h>
|
||||
#include <gl.h>
|
||||
|
||||
#include "tiffio.h"
|
||||
|
||||
typedef unsigned char unsigned char;
|
||||
typedef unsigned long uint32_t;
|
||||
|
||||
#define streq(a,b) (strcmp(a,b) == 0)
|
||||
#define strneq(a,b,n) (strncmp(a,b,n) == 0)
|
||||
#define streq(a, b) (strcmp(a, b) == 0)
|
||||
#define strneq(a, b, n) (strncmp(a, b, n) == 0)
|
||||
|
||||
uint32_t rowsperstrip = (uint32_t) -1;
|
||||
uint16_t compression = COMPRESSION_PACKBITS;
|
||||
uint16_t config = PLANARCONFIG_CONTIG;
|
||||
uint16_t predictor = 0;
|
||||
int xmaxscreen;
|
||||
int ymaxscreen;
|
||||
uint16_t photometric = PHOTOMETRIC_RGB;
|
||||
int jpegcolormode = JPEGCOLORMODE_RGB;
|
||||
int quality = 75; /* JPEG quality */
|
||||
uint32_t rowsperstrip = (uint32_t)-1;
|
||||
uint16_t compression = COMPRESSION_PACKBITS;
|
||||
uint16_t config = PLANARCONFIG_CONTIG;
|
||||
uint16_t predictor = 0;
|
||||
int xmaxscreen;
|
||||
int ymaxscreen;
|
||||
uint16_t photometric = PHOTOMETRIC_RGB;
|
||||
int jpegcolormode = JPEGCOLORMODE_RGB;
|
||||
int quality = 75; /* JPEG quality */
|
||||
|
||||
static void usage(void);
|
||||
static void tiffsv(char*, int, int, int, int);
|
||||
static void usage(void);
|
||||
static void tiffsv(char *, int, int, int, int);
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int c;
|
||||
int c;
|
||||
#if !HAVE_DECL_OPTARG
|
||||
extern int optind;
|
||||
extern char* optarg;
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
#endif
|
||||
|
||||
while ((c = getopt(argc, argv, "c:p:r:")) != -1)
|
||||
switch (c) {
|
||||
case 'b': /* save as b&w */
|
||||
photometric = PHOTOMETRIC_MINISBLACK;
|
||||
break;
|
||||
case 'c': /* compression scheme */
|
||||
if (streq(optarg, "none"))
|
||||
compression = COMPRESSION_NONE;
|
||||
else if (streq(optarg, "packbits"))
|
||||
compression = COMPRESSION_PACKBITS;
|
||||
else if (strneq(optarg, "jpeg", 4)) {
|
||||
char* cp = strchr(optarg, ':');
|
||||
if (cp && isdigit(cp[1]))
|
||||
quality = atoi(cp+1);
|
||||
if (cp && strchr(cp, 'r'))
|
||||
jpegcolormode = JPEGCOLORMODE_RAW;
|
||||
compression = COMPRESSION_JPEG;
|
||||
} else if (strneq(optarg, "lzw", 3)) {
|
||||
char* cp = strchr(optarg, ':');
|
||||
if (cp)
|
||||
predictor = atoi(cp+1);
|
||||
compression = COMPRESSION_LZW;
|
||||
} else
|
||||
usage();
|
||||
break;
|
||||
case 'p': /* planar configuration */
|
||||
if (streq(optarg, "separate"))
|
||||
config = PLANARCONFIG_SEPARATE;
|
||||
else if (streq(optarg, "contig"))
|
||||
config = PLANARCONFIG_CONTIG;
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
case 'r': /* rows/strip */
|
||||
rowsperstrip = atoi(optarg);
|
||||
break;
|
||||
case '?':
|
||||
usage();
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
if (argc - optind != 1 && argc - optind != 5)
|
||||
usage();
|
||||
xmaxscreen = getgdesc(GD_XPMAX)-1;
|
||||
ymaxscreen = getgdesc(GD_YPMAX)-1;
|
||||
foreground();
|
||||
noport();
|
||||
winopen("tiffsv");
|
||||
if (argc - optind == 5)
|
||||
tiffsv(argv[optind],
|
||||
atoi(argv[optind+1]), atoi(argv[optind+2]),
|
||||
atoi(argv[optind+3]), atoi(argv[optind+4]));
|
||||
else
|
||||
tiffsv(argv[optind], 0, xmaxscreen, 0, ymaxscreen);
|
||||
return (0);
|
||||
while ((c = getopt(argc, argv, "c:p:r:")) != -1)
|
||||
switch (c)
|
||||
{
|
||||
case 'b': /* save as b&w */
|
||||
photometric = PHOTOMETRIC_MINISBLACK;
|
||||
break;
|
||||
case 'c': /* compression scheme */
|
||||
if (streq(optarg, "none"))
|
||||
compression = COMPRESSION_NONE;
|
||||
else if (streq(optarg, "packbits"))
|
||||
compression = COMPRESSION_PACKBITS;
|
||||
else if (strneq(optarg, "jpeg", 4))
|
||||
{
|
||||
char *cp = strchr(optarg, ':');
|
||||
if (cp && isdigit(cp[1]))
|
||||
quality = atoi(cp + 1);
|
||||
if (cp && strchr(cp, 'r'))
|
||||
jpegcolormode = JPEGCOLORMODE_RAW;
|
||||
compression = COMPRESSION_JPEG;
|
||||
}
|
||||
else if (strneq(optarg, "lzw", 3))
|
||||
{
|
||||
char *cp = strchr(optarg, ':');
|
||||
if (cp)
|
||||
predictor = atoi(cp + 1);
|
||||
compression = COMPRESSION_LZW;
|
||||
}
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
case 'p': /* planar configuration */
|
||||
if (streq(optarg, "separate"))
|
||||
config = PLANARCONFIG_SEPARATE;
|
||||
else if (streq(optarg, "contig"))
|
||||
config = PLANARCONFIG_CONTIG;
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
case 'r': /* rows/strip */
|
||||
rowsperstrip = atoi(optarg);
|
||||
break;
|
||||
case '?':
|
||||
usage();
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
if (argc - optind != 1 && argc - optind != 5)
|
||||
usage();
|
||||
xmaxscreen = getgdesc(GD_XPMAX) - 1;
|
||||
ymaxscreen = getgdesc(GD_YPMAX) - 1;
|
||||
foreground();
|
||||
noport();
|
||||
winopen("tiffsv");
|
||||
if (argc - optind == 5)
|
||||
tiffsv(argv[optind], atoi(argv[optind + 1]), atoi(argv[optind + 2]),
|
||||
atoi(argv[optind + 3]), atoi(argv[optind + 4]));
|
||||
else
|
||||
tiffsv(argv[optind], 0, xmaxscreen, 0, ymaxscreen);
|
||||
return (0);
|
||||
}
|
||||
|
||||
char* stuff[] = {
|
||||
"usage: tiffsv [options] outimage.tif [x1 x2 y1 y2] [-b]",
|
||||
"where options are:",
|
||||
" -p contig pack samples contiguously (e.g. RGBRGB...)",
|
||||
" -p separate store samples separately (e.g. RRR...GGG...BBB...)",
|
||||
"",
|
||||
" -r # make each strip have no more than # rows",
|
||||
"",
|
||||
" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
|
||||
" -c jpeg[:opts]compress output with JPEG encoding",
|
||||
" -c packbits compress output with packbits encoding",
|
||||
" -c none use no compression algorithm on output",
|
||||
"",
|
||||
"JPEG options:",
|
||||
" # set compression quality level (0-100, default 75)",
|
||||
" r output color image as RGB rather than YCbCr",
|
||||
"",
|
||||
"LZW options:",
|
||||
" # set predictor value for Lempel-Ziv & Welch encoding",
|
||||
"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing",
|
||||
NULL
|
||||
};
|
||||
char *stuff[] = {
|
||||
"usage: tiffsv [options] outimage.tif [x1 x2 y1 y2] [-b]",
|
||||
"where options are:",
|
||||
" -p contig pack samples contiguously (e.g. RGBRGB...)",
|
||||
" -p separate store samples separately (e.g. RRR...GGG...BBB...)",
|
||||
"",
|
||||
" -r # make each strip have no more than # rows",
|
||||
"",
|
||||
" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
|
||||
" -c jpeg[:opts]compress output with JPEG encoding",
|
||||
" -c packbits compress output with packbits encoding",
|
||||
" -c none use no compression algorithm on output",
|
||||
"",
|
||||
"JPEG options:",
|
||||
" # set compression quality level (0-100, default 75)",
|
||||
" r output color image as RGB rather than YCbCr",
|
||||
"",
|
||||
"LZW options:",
|
||||
" # set predictor value for Lempel-Ziv & Welch encoding",
|
||||
"For example, -c lzw:2 to get LZW-encoded data with horizontal "
|
||||
"differencing",
|
||||
NULL};
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
static void usage(void)
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
int i;
|
||||
char buf[BUFSIZ];
|
||||
int i;
|
||||
|
||||
setbuf(stderr, buf);
|
||||
for (i = 0; stuff[i] != NULL; i++)
|
||||
fprintf(stderr, "%s\n", stuff[i]);
|
||||
exit(-1);
|
||||
setbuf(stderr, buf);
|
||||
for (i = 0; stuff[i] != NULL; i++)
|
||||
fprintf(stderr, "%s\n", stuff[i]);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
static void
|
||||
svRGBSeparate(TIFF* tif, uint32_t* ss, int xsize, int ysize)
|
||||
static void svRGBSeparate(TIFF *tif, uint32_t *ss, int xsize, int ysize)
|
||||
{
|
||||
tsize_t stripsize = TIFFStripSize(tif);
|
||||
unsigned char *rbuf = (unsigned char *)_TIFFmalloc(3*stripsize);
|
||||
unsigned char *gbuf = rbuf + stripsize;
|
||||
unsigned char *bbuf = gbuf + stripsize;
|
||||
register int y;
|
||||
tsize_t stripsize = TIFFStripSize(tif);
|
||||
unsigned char *rbuf = (unsigned char *)_TIFFmalloc(3 * stripsize);
|
||||
unsigned char *gbuf = rbuf + stripsize;
|
||||
unsigned char *bbuf = gbuf + stripsize;
|
||||
register int y;
|
||||
|
||||
for (y = 0; y <= ysize; y += rowsperstrip) {
|
||||
unsigned char *rp, *gp, *bp;
|
||||
register int x;
|
||||
register uint32_t n;
|
||||
for (y = 0; y <= ysize; y += rowsperstrip)
|
||||
{
|
||||
unsigned char *rp, *gp, *bp;
|
||||
register int x;
|
||||
register uint32_t n;
|
||||
|
||||
n = rowsperstrip;
|
||||
if (n > ysize-y+1)
|
||||
n = ysize-y+1;
|
||||
rp = rbuf; gp = gbuf; bp = bbuf;
|
||||
do {
|
||||
for (x = 0; x <= xsize; x++) {
|
||||
uint32_t v = ss[x];
|
||||
rp[x] = v;
|
||||
gp[x] = v >> 8;
|
||||
bp[x] = v >> 16;
|
||||
}
|
||||
rp += xsize+1, gp += xsize+1, bp += xsize+1;
|
||||
ss += xsize+1;
|
||||
} while (--n);
|
||||
if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif,y,0),
|
||||
rbuf, stripsize) < 0)
|
||||
break;
|
||||
if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif,y,1),
|
||||
gbuf, stripsize) < 0)
|
||||
break;
|
||||
if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif,y,2),
|
||||
bbuf, stripsize) < 0)
|
||||
break;
|
||||
}
|
||||
_TIFFfree(rbuf);
|
||||
n = rowsperstrip;
|
||||
if (n > ysize - y + 1)
|
||||
n = ysize - y + 1;
|
||||
rp = rbuf;
|
||||
gp = gbuf;
|
||||
bp = bbuf;
|
||||
do
|
||||
{
|
||||
for (x = 0; x <= xsize; x++)
|
||||
{
|
||||
uint32_t v = ss[x];
|
||||
rp[x] = v;
|
||||
gp[x] = v >> 8;
|
||||
bp[x] = v >> 16;
|
||||
}
|
||||
rp += xsize + 1, gp += xsize + 1, bp += xsize + 1;
|
||||
ss += xsize + 1;
|
||||
} while (--n);
|
||||
if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif, y, 0), rbuf,
|
||||
stripsize) < 0)
|
||||
break;
|
||||
if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif, y, 1), gbuf,
|
||||
stripsize) < 0)
|
||||
break;
|
||||
if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif, y, 2), bbuf,
|
||||
stripsize) < 0)
|
||||
break;
|
||||
}
|
||||
_TIFFfree(rbuf);
|
||||
}
|
||||
|
||||
static void
|
||||
svRGBContig(TIFF* tif, uint32_t* ss, int xsize, int ysize)
|
||||
static void svRGBContig(TIFF *tif, uint32_t *ss, int xsize, int ysize)
|
||||
{
|
||||
register int x, y;
|
||||
tsize_t stripsize = TIFFStripSize(tif);
|
||||
unsigned char *strip = (unsigned char *)_TIFFmalloc(stripsize);
|
||||
register int x, y;
|
||||
tsize_t stripsize = TIFFStripSize(tif);
|
||||
unsigned char *strip = (unsigned char *)_TIFFmalloc(stripsize);
|
||||
|
||||
for (y = 0; y <= ysize; y += rowsperstrip) {
|
||||
register unsigned char *pp = strip;
|
||||
register uint32_t n;
|
||||
for (y = 0; y <= ysize; y += rowsperstrip)
|
||||
{
|
||||
register unsigned char *pp = strip;
|
||||
register uint32_t n;
|
||||
|
||||
n = rowsperstrip;
|
||||
if (n > ysize-y+1)
|
||||
n = ysize-y+1;
|
||||
do {
|
||||
for (x = 0; x <= xsize; x++) {
|
||||
uint32_t v = ss[x];
|
||||
pp[0] = v;
|
||||
pp[1] = v >> 8;
|
||||
pp[2] = v >> 16;
|
||||
pp += 3;
|
||||
}
|
||||
ss += xsize+1;
|
||||
} while (--n);
|
||||
if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif,y,0),
|
||||
strip, stripsize) < 0)
|
||||
break;
|
||||
}
|
||||
_TIFFfree(strip);
|
||||
n = rowsperstrip;
|
||||
if (n > ysize - y + 1)
|
||||
n = ysize - y + 1;
|
||||
do
|
||||
{
|
||||
for (x = 0; x <= xsize; x++)
|
||||
{
|
||||
uint32_t v = ss[x];
|
||||
pp[0] = v;
|
||||
pp[1] = v >> 8;
|
||||
pp[2] = v >> 16;
|
||||
pp += 3;
|
||||
}
|
||||
ss += xsize + 1;
|
||||
} while (--n);
|
||||
if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif, y, 0), strip,
|
||||
stripsize) < 0)
|
||||
break;
|
||||
}
|
||||
_TIFFfree(strip);
|
||||
}
|
||||
|
||||
#undef RED
|
||||
#undef GREEN
|
||||
#undef BLUE
|
||||
#define CVT(x) (((x)*255)/100)
|
||||
#define RED CVT(28) /* 28% */
|
||||
#define GREEN CVT(59) /* 59% */
|
||||
#define BLUE CVT(11) /* 11% */
|
||||
#define CVT(x) (((x)*255) / 100)
|
||||
#define RED CVT(28) /* 28% */
|
||||
#define GREEN CVT(59) /* 59% */
|
||||
#define BLUE CVT(11) /* 11% */
|
||||
|
||||
static void
|
||||
svGrey(TIFF* tif, uint32_t* ss, int xsize, int ysize)
|
||||
static void svGrey(TIFF *tif, uint32_t *ss, int xsize, int ysize)
|
||||
{
|
||||
register int x, y;
|
||||
unsigned char *buf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(tif));
|
||||
register int x, y;
|
||||
unsigned char *buf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(tif));
|
||||
|
||||
for (y = 0; y <= ysize; y++) {
|
||||
for (x = 0; x <= xsize; x++) {
|
||||
unsigned char *cp = (unsigned char *)&ss[x];
|
||||
buf[x] = (RED*cp[3] + GREEN*cp[2] + BLUE*cp[1]) >> 8;
|
||||
}
|
||||
if (TIFFWriteScanline(tif, buf, (uint32_t) y, 0) < 0)
|
||||
break;
|
||||
ss += xsize+1;
|
||||
}
|
||||
_TIFFfree(buf);
|
||||
for (y = 0; y <= ysize; y++)
|
||||
{
|
||||
for (x = 0; x <= xsize; x++)
|
||||
{
|
||||
unsigned char *cp = (unsigned char *)&ss[x];
|
||||
buf[x] = (RED * cp[3] + GREEN * cp[2] + BLUE * cp[1]) >> 8;
|
||||
}
|
||||
if (TIFFWriteScanline(tif, buf, (uint32_t)y, 0) < 0)
|
||||
break;
|
||||
ss += xsize + 1;
|
||||
}
|
||||
_TIFFfree(buf);
|
||||
}
|
||||
|
||||
#define MIN(a,b) ((a)<(b)?(a):(b))
|
||||
#define ABS(x) ((x)<0?-(x):(x))
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define ABS(x) ((x) < 0 ? -(x) : (x))
|
||||
|
||||
static void
|
||||
tiffsv(char* name, int x1, int x2, int y1, int y2)
|
||||
static void tiffsv(char *name, int x1, int x2, int y1, int y2)
|
||||
{
|
||||
TIFF *tif;
|
||||
int xsize, ysize;
|
||||
int xorg, yorg;
|
||||
uint32_t *scrbuf;
|
||||
TIFF *tif;
|
||||
int xsize, ysize;
|
||||
int xorg, yorg;
|
||||
uint32_t *scrbuf;
|
||||
|
||||
xorg = MIN(x1,x2);
|
||||
yorg = MIN(y1,y2);
|
||||
if (xorg<0)
|
||||
xorg = 0;
|
||||
if (yorg<0)
|
||||
yorg = 0;
|
||||
xsize = ABS(x2-x1);
|
||||
ysize = ABS(y2-y1);
|
||||
if (xorg+xsize > xmaxscreen)
|
||||
xsize = xmaxscreen-xorg;
|
||||
if (yorg+ysize > ymaxscreen)
|
||||
ysize = ymaxscreen-yorg;
|
||||
tif = TIFFOpen(name, "w");
|
||||
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, (uint32_t) (xsize+1));
|
||||
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, (uint32_t) (ysize+1));
|
||||
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
|
||||
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL,
|
||||
photometric == PHOTOMETRIC_RGB ? 3 : 1);
|
||||
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, config);
|
||||
TIFFSetField(tif, TIFFTAG_COMPRESSION, compression);
|
||||
switch (compression) {
|
||||
case COMPRESSION_JPEG:
|
||||
if (photometric == PHOTOMETRIC_RGB && jpegcolormode == JPEGCOLORMODE_RGB)
|
||||
photometric = PHOTOMETRIC_YCBCR;
|
||||
TIFFSetField(tif, TIFFTAG_JPEGQUALITY, quality);
|
||||
TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, jpegcolormode);
|
||||
break;
|
||||
case COMPRESSION_LZW:
|
||||
if (predictor != 0)
|
||||
TIFFSetField(tif, TIFFTAG_PREDICTOR, predictor);
|
||||
break;
|
||||
}
|
||||
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric);
|
||||
TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_BOTLEFT);
|
||||
rowsperstrip = TIFFDefaultStripSize(tif, rowsperstrip);
|
||||
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
|
||||
scrbuf = (uint32_t *)_TIFFmalloc((xsize+1)*(ysize+1)*sizeof (uint32_t));
|
||||
readdisplay(xorg, yorg, xorg+xsize, yorg+ysize, scrbuf, RD_FREEZE);
|
||||
if (photometric == PHOTOMETRIC_RGB) {
|
||||
if (config == PLANARCONFIG_SEPARATE)
|
||||
svRGBSeparate(tif, scrbuf, xsize, ysize);
|
||||
else
|
||||
svRGBContig(tif, scrbuf, xsize, ysize);
|
||||
} else
|
||||
svGrey(tif, scrbuf, xsize, ysize);
|
||||
(void) TIFFClose(tif);
|
||||
_TIFFfree((char *)scrbuf);
|
||||
xorg = MIN(x1, x2);
|
||||
yorg = MIN(y1, y2);
|
||||
if (xorg < 0)
|
||||
xorg = 0;
|
||||
if (yorg < 0)
|
||||
yorg = 0;
|
||||
xsize = ABS(x2 - x1);
|
||||
ysize = ABS(y2 - y1);
|
||||
if (xorg + xsize > xmaxscreen)
|
||||
xsize = xmaxscreen - xorg;
|
||||
if (yorg + ysize > ymaxscreen)
|
||||
ysize = ymaxscreen - yorg;
|
||||
tif = TIFFOpen(name, "w");
|
||||
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, (uint32_t)(xsize + 1));
|
||||
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, (uint32_t)(ysize + 1));
|
||||
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
|
||||
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL,
|
||||
photometric == PHOTOMETRIC_RGB ? 3 : 1);
|
||||
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, config);
|
||||
TIFFSetField(tif, TIFFTAG_COMPRESSION, compression);
|
||||
switch (compression)
|
||||
{
|
||||
case COMPRESSION_JPEG:
|
||||
if (photometric == PHOTOMETRIC_RGB &&
|
||||
jpegcolormode == JPEGCOLORMODE_RGB)
|
||||
photometric = PHOTOMETRIC_YCBCR;
|
||||
TIFFSetField(tif, TIFFTAG_JPEGQUALITY, quality);
|
||||
TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, jpegcolormode);
|
||||
break;
|
||||
case COMPRESSION_LZW:
|
||||
if (predictor != 0)
|
||||
TIFFSetField(tif, TIFFTAG_PREDICTOR, predictor);
|
||||
break;
|
||||
}
|
||||
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric);
|
||||
TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_BOTLEFT);
|
||||
rowsperstrip = TIFFDefaultStripSize(tif, rowsperstrip);
|
||||
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
|
||||
scrbuf =
|
||||
(uint32_t *)_TIFFmalloc((xsize + 1) * (ysize + 1) * sizeof(uint32_t));
|
||||
readdisplay(xorg, yorg, xorg + xsize, yorg + ysize, scrbuf, RD_FREEZE);
|
||||
if (photometric == PHOTOMETRIC_RGB)
|
||||
{
|
||||
if (config == PLANARCONFIG_SEPARATE)
|
||||
svRGBSeparate(tif, scrbuf, xsize, ysize);
|
||||
else
|
||||
svRGBContig(tif, scrbuf, xsize, ysize);
|
||||
}
|
||||
else
|
||||
svGrey(tif, scrbuf, xsize, ysize);
|
||||
(void)TIFFClose(tif);
|
||||
_TIFFfree((char *)scrbuf);
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
+79
-99
@@ -1,17 +1,17 @@
|
||||
float ycbcrCoeffs[3] = { .299, .587, .114 };
|
||||
float ycbcrCoeffs[3] = {.299, .587, .114};
|
||||
/* default coding range is CCIR Rec 601-1 with no headroom/footroom */
|
||||
unsigned long refBlackWhite[6] = { 0, 255, 128, 255, 128, 255 };
|
||||
unsigned long refBlackWhite[6] = {0, 255, 128, 255, 128, 255};
|
||||
|
||||
#define LumaRed ycbcrCoeffs[0]
|
||||
#define LumaGreen ycbcrCoeffs[1]
|
||||
#define LumaBlue ycbcrCoeffs[2]
|
||||
#define LumaRed ycbcrCoeffs[0]
|
||||
#define LumaGreen ycbcrCoeffs[1]
|
||||
#define LumaBlue ycbcrCoeffs[2]
|
||||
|
||||
long eRtotal = 0;
|
||||
long eGtotal = 0;
|
||||
long eBtotal = 0;
|
||||
long preveRtotal = 0;
|
||||
long preveGtotal = 0;
|
||||
long preveBtotal = 0;
|
||||
long eRtotal = 0;
|
||||
long eGtotal = 0;
|
||||
long eBtotal = 0;
|
||||
long preveRtotal = 0;
|
||||
long preveGtotal = 0;
|
||||
long preveBtotal = 0;
|
||||
unsigned long AbseRtotal = 0;
|
||||
unsigned long AbseGtotal = 0;
|
||||
unsigned long AbseBtotal = 0;
|
||||
@@ -20,101 +20,90 @@ unsigned long preveCodes = 0;
|
||||
unsigned long eBits = 0;
|
||||
unsigned long preveBits = 0;
|
||||
|
||||
static void setupLumaTables();
|
||||
static void setupLumaTables();
|
||||
static int abs(int v) { return (v < 0 ? -v : v); }
|
||||
static double pct(int v,double range) { return (v*100. / range); }
|
||||
static double pct(int v, double range) { return (v * 100. / range); }
|
||||
static void check(int R, int G, int B);
|
||||
|
||||
float D1, D2;
|
||||
float D3, D4;
|
||||
float D5, D6;
|
||||
float D1, D2;
|
||||
float D3, D4;
|
||||
float D5, D6;
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int R, G, B;
|
||||
|
||||
if (argc > 1) {
|
||||
refBlackWhite[0] = 16;
|
||||
refBlackWhite[1] = 235;
|
||||
refBlackWhite[2] = 128;
|
||||
refBlackWhite[3] = 240;
|
||||
refBlackWhite[4] = 128;
|
||||
refBlackWhite[5] = 240;
|
||||
if (argc > 1)
|
||||
{
|
||||
refBlackWhite[0] = 16;
|
||||
refBlackWhite[1] = 235;
|
||||
refBlackWhite[2] = 128;
|
||||
refBlackWhite[3] = 240;
|
||||
refBlackWhite[4] = 128;
|
||||
refBlackWhite[5] = 240;
|
||||
}
|
||||
D3 = 2 - 2*LumaRed;
|
||||
D4 = 2 - 2*LumaBlue;
|
||||
D3 = 2 - 2 * LumaRed;
|
||||
D4 = 2 - 2 * LumaBlue;
|
||||
D1 = 1. / D3;
|
||||
D2 = 1. / D4;
|
||||
D5 = D3*LumaRed / LumaGreen;
|
||||
D6 = D4*LumaBlue / LumaGreen;
|
||||
D5 = D3 * LumaRed / LumaGreen;
|
||||
D6 = D4 * LumaBlue / LumaGreen;
|
||||
setupLumaTables();
|
||||
for (R = 0; R < 256; R++) {
|
||||
for (G = 0; G < 256; G++)
|
||||
for (B = 0; B < 256; B++)
|
||||
check(R, G, B);
|
||||
printf("[%3u] c %u/%u b %u/%u (R %u/%d/%u G %u/%d/%u B %u/%d/%u)\n"
|
||||
, R
|
||||
, eCodes - preveCodes, eCodes
|
||||
, eBits - preveBits, eBits
|
||||
, abs(AbseRtotal - preveRtotal), eRtotal , AbseRtotal
|
||||
, abs(AbseGtotal - preveGtotal), eGtotal , AbseGtotal
|
||||
, abs(AbseBtotal - preveBtotal), eBtotal , AbseBtotal
|
||||
);
|
||||
preveRtotal = AbseRtotal;
|
||||
preveGtotal = AbseGtotal;
|
||||
preveBtotal = AbseBtotal;
|
||||
preveCodes = eCodes;
|
||||
preveBits = eBits;
|
||||
for (R = 0; R < 256; R++)
|
||||
{
|
||||
for (G = 0; G < 256; G++)
|
||||
for (B = 0; B < 256; B++)
|
||||
check(R, G, B);
|
||||
printf("[%3u] c %u/%u b %u/%u (R %u/%d/%u G %u/%d/%u B %u/%d/%u)\n", R,
|
||||
eCodes - preveCodes, eCodes, eBits - preveBits, eBits,
|
||||
abs(AbseRtotal - preveRtotal), eRtotal, AbseRtotal,
|
||||
abs(AbseGtotal - preveGtotal), eGtotal, AbseGtotal,
|
||||
abs(AbseBtotal - preveBtotal), eBtotal, AbseBtotal);
|
||||
preveRtotal = AbseRtotal;
|
||||
preveGtotal = AbseGtotal;
|
||||
preveBtotal = AbseBtotal;
|
||||
preveCodes = eCodes;
|
||||
preveBits = eBits;
|
||||
}
|
||||
printf("%u total codes\n", 256*256*256);
|
||||
printf("total error: %u codes %u bits (R %d/%u G %d/%u B %d/%u)\n"
|
||||
, eCodes
|
||||
, eBits
|
||||
, eRtotal , AbseRtotal
|
||||
, eGtotal , AbseGtotal
|
||||
, eBtotal , AbseBtotal
|
||||
);
|
||||
printf("%u total codes\n", 256 * 256 * 256);
|
||||
printf("total error: %u codes %u bits (R %d/%u G %d/%u B %d/%u)\n", eCodes,
|
||||
eBits, eRtotal, AbseRtotal, eGtotal, AbseGtotal, eBtotal,
|
||||
AbseBtotal);
|
||||
return (0);
|
||||
}
|
||||
|
||||
float *lumaRed;
|
||||
float *lumaGreen;
|
||||
float *lumaBlue;
|
||||
float *lumaRed;
|
||||
float *lumaGreen;
|
||||
float *lumaBlue;
|
||||
|
||||
static float*
|
||||
setupLuma(float c)
|
||||
static float *setupLuma(float c)
|
||||
{
|
||||
float *v = (float *)_TIFFmalloc(256 * sizeof (float));
|
||||
float *v = (float *)_TIFFmalloc(256 * sizeof(float));
|
||||
int i;
|
||||
for (i = 0; i < 256; i++)
|
||||
v[i] = c * i;
|
||||
v[i] = c * i;
|
||||
return (v);
|
||||
}
|
||||
|
||||
static void
|
||||
setupLumaTables(void)
|
||||
static void setupLumaTables(void)
|
||||
{
|
||||
lumaRed = setupLuma(LumaRed);
|
||||
lumaGreen = setupLuma(LumaGreen);
|
||||
lumaBlue = setupLuma(LumaBlue);
|
||||
}
|
||||
|
||||
static unsigned
|
||||
V2Code(float f, unsigned long RB, unsigned long RW, int CR)
|
||||
static unsigned V2Code(float f, unsigned long RB, unsigned long RW, int CR)
|
||||
{
|
||||
unsigned int c = (unsigned int)((((f)*(RW-RB)/CR)+RB)+.5);
|
||||
unsigned int c = (unsigned int)((((f) * (RW - RB) / CR) + RB) + .5);
|
||||
return (c > 255 ? 255 : c);
|
||||
}
|
||||
|
||||
#define Code2V(c, RB, RW, CR) ((((c)-(int)RB)*(float)CR)/(float)(RW-RB))
|
||||
#define Code2V(c, RB, RW, CR) ((((c) - (int)RB) * (float)CR) / (float)(RW - RB))
|
||||
|
||||
#define CLAMP(f,min,max) \
|
||||
(int)((f)+.5 < (min) ? (min) : (f)+.5 > (max) ? (max) : (f)+.5)
|
||||
#define CLAMP(f, min, max) \
|
||||
(int)((f) + .5 < (min) ? (min) : (f) + .5 > (max) ? (max) : (f) + .5)
|
||||
|
||||
static
|
||||
void
|
||||
check(int R, int G, int B)
|
||||
static void check(int R, int G, int B)
|
||||
{
|
||||
float Y, Cb, Cr;
|
||||
int iY, iCb, iCr;
|
||||
@@ -123,31 +112,29 @@ check(int R, int G, int B)
|
||||
int eR, eG, eB;
|
||||
|
||||
Y = lumaRed[R] + lumaGreen[G] + lumaBlue[B];
|
||||
Cb = (B - Y)*D2;
|
||||
Cr = (R - Y)*D1;
|
||||
Cb = (B - Y) * D2;
|
||||
Cr = (R - Y) * D1;
|
||||
iY = V2Code(Y, refBlackWhite[0], refBlackWhite[1], 255);
|
||||
iCb = V2Code(Cb, refBlackWhite[2], refBlackWhite[3], 127);
|
||||
iCr = V2Code(Cr, refBlackWhite[4], refBlackWhite[5], 127);
|
||||
rCb = Code2V(iCb, refBlackWhite[2], refBlackWhite[3], 127);
|
||||
rCr = Code2V(iCr, refBlackWhite[4], refBlackWhite[5], 127);
|
||||
rY = Code2V(iY, refBlackWhite[0], refBlackWhite[1], 255);
|
||||
rR = rY + rCr*D3;
|
||||
rB = rY + rCb*D4;
|
||||
rG = rY - rCb*D6 - rCr*D5;
|
||||
eR = R - CLAMP(rR,0,255);
|
||||
eG = G - CLAMP(rG,0,255);
|
||||
eB = B - CLAMP(rB,0,255);
|
||||
if (abs(eR) > 1 || abs(eG) > 1 || abs(eB) > 1) {
|
||||
printf("R %u G %u B %u", R, G, B);
|
||||
printf(" Y %g Cb %g Cr %g", Y, Cb, Cr);
|
||||
printf(" iY %u iCb %u iCr %u", iY, iCb, iCr);
|
||||
printf("\n -> Y %g Cb %g Cr %g", rY, rCb, rCr);
|
||||
printf(" R %g (%u) G %g (%u) B %g (%u) E=[%d %d %d])\n"
|
||||
, rR, CLAMP(rR,0,255)
|
||||
, rG, CLAMP(rG,0,255)
|
||||
, rB, CLAMP(rB,0,255)
|
||||
, eR, eG, eB
|
||||
);
|
||||
rR = rY + rCr * D3;
|
||||
rB = rY + rCb * D4;
|
||||
rG = rY - rCb * D6 - rCr * D5;
|
||||
eR = R - CLAMP(rR, 0, 255);
|
||||
eG = G - CLAMP(rG, 0, 255);
|
||||
eB = B - CLAMP(rB, 0, 255);
|
||||
if (abs(eR) > 1 || abs(eG) > 1 || abs(eB) > 1)
|
||||
{
|
||||
printf("R %u G %u B %u", R, G, B);
|
||||
printf(" Y %g Cb %g Cr %g", Y, Cb, Cr);
|
||||
printf(" iY %u iCb %u iCr %u", iY, iCb, iCr);
|
||||
printf("\n -> Y %g Cb %g Cr %g", rY, rCb, rCr);
|
||||
printf(" R %g (%u) G %g (%u) B %g (%u) E=[%d %d %d])\n", rR,
|
||||
CLAMP(rR, 0, 255), rG, CLAMP(rG, 0, 255), rB, CLAMP(rB, 0, 255),
|
||||
eR, eG, eB);
|
||||
}
|
||||
eRtotal += eR;
|
||||
eGtotal += eG;
|
||||
@@ -156,13 +143,6 @@ check(int R, int G, int B)
|
||||
AbseGtotal += abs(eG);
|
||||
AbseBtotal += abs(eB);
|
||||
if (eR | eG | eB)
|
||||
eCodes++;
|
||||
eCodes++;
|
||||
eBits += abs(eR) + abs(eG) + abs(eB);
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
+19
-8
@@ -1,10 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
retval=0
|
||||
|
||||
set -x
|
||||
libtoolize --force --copy
|
||||
aclocal -I ./m4
|
||||
autoheader
|
||||
automake --foreign --add-missing --copy
|
||||
autoconf
|
||||
|
||||
case `uname` in
|
||||
Darwin*)
|
||||
glibtoolize --force --copy || retval=$?
|
||||
;;
|
||||
*)
|
||||
libtoolize --force --copy || retval=$?
|
||||
;;
|
||||
esac
|
||||
aclocal -I ./m4 || retval=$?
|
||||
autoheader || retval=$?
|
||||
automake --foreign --add-missing --copy || retval=$?
|
||||
autoconf || retval=$?
|
||||
# Get latest config.guess and config.sub from upstream master since
|
||||
# these are often out of date.
|
||||
for file in config.guess config.sub
|
||||
@@ -13,8 +24,8 @@ do
|
||||
wget -q --timeout=5 -O config/$file.tmp \
|
||||
"https://git.savannah.gnu.org/cgit/config.git/plain/${file}" \
|
||||
&& mv -f config/$file.tmp config/$file \
|
||||
&& chmod a+x config/$file
|
||||
retval=$?
|
||||
&& chmod a+x config/$file || retval=$?
|
||||
rm -f config/$file.tmp
|
||||
test $retval -eq 0 || exit $retval
|
||||
done
|
||||
|
||||
exit $retval
|
||||
|
||||
+46
-3
@@ -13,11 +13,27 @@ autoconf_build()
|
||||
mkdir autoconf-build
|
||||
cd autoconf-build
|
||||
echo "Running ../configure --prefix=$(pwd)/../autoconf-install) ${opts}"
|
||||
../configure --prefix=$(pwd)/../autoconf-install ${opts}
|
||||
CFLAGS="-Wall -Wextra -Werror" ../configure --prefix=$(pwd)/../autoconf-install ${opts}
|
||||
make
|
||||
make install
|
||||
make check
|
||||
make distcheck
|
||||
mkdir ../distribution
|
||||
cp tiff-*.tar.* tiff*.zip ../distribution
|
||||
}
|
||||
|
||||
# Test autoconf build (minimal; no distcheck)
|
||||
autoconf_build_minimal()
|
||||
{
|
||||
autoreconf -ivf
|
||||
|
||||
mkdir autoconf-build
|
||||
cd autoconf-build
|
||||
echo "Running ../configure --prefix=$(pwd)/../autoconf-install) ${opts}"
|
||||
CFLAGS="-Wall -Wextra -Werror" ../configure --prefix=$(pwd)/../autoconf-install ${opts}
|
||||
make
|
||||
make install
|
||||
make check
|
||||
}
|
||||
|
||||
# Test cmake build
|
||||
@@ -30,11 +46,34 @@ cmake_build()
|
||||
mkdir cmake-build
|
||||
cd cmake-build
|
||||
opts="-Dfatal-warnings=ON"
|
||||
echo "Running cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../cmake-install ${opts} .."
|
||||
cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../cmake-install ${opts} ..
|
||||
para3=`echo "$3" | sed 's/./\L&/g'`
|
||||
if [ "$para3" = "static" ]; then
|
||||
opts2="-DBUILD_SHARED_LIBS:BOOL=OFF"
|
||||
else
|
||||
opts2=""
|
||||
fi
|
||||
echo "Running cmake -G "$1" -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../cmake-install ${opts} ${opts2} .."
|
||||
cmake -G "$1" -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../cmake-install -DCMAKE_C_FLAGS="-Wall -Wextra -Werror" ${opts} ${opts2} ..
|
||||
$COVERITY_BUILD cmake --build .
|
||||
cmake --build . --target install
|
||||
ctest -V
|
||||
cd ..
|
||||
if [ "$para3" = "static" ]; then
|
||||
echo No test project build for STATIC CI/CD build - skipped -.
|
||||
else
|
||||
# Build test project using find_package(Tiff CONFIG)
|
||||
mkdir cmake-test-build
|
||||
cd cmake-test-build
|
||||
cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" "-DTiff_DIR=$PWD/../cmake-install/lib/cmake/tiff" -S ../build/test_cmake -B .
|
||||
cmake --build .
|
||||
cd ..
|
||||
mkdir cmake-test-no-target-build
|
||||
cd cmake-test-no-target-build
|
||||
cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" "-DTiff_DIR=$PWD/../cmake-install/lib/cmake/tiff" -S ../build/test_cmake_no_target -B .
|
||||
cmake --build .
|
||||
# Return to cmake-build for coverity_build()
|
||||
cd ../cmake-build
|
||||
fi
|
||||
}
|
||||
|
||||
# Static-analysis with coverity
|
||||
@@ -64,6 +103,10 @@ case $build in
|
||||
echo "Testing Autoconf build"
|
||||
autoconf_build "$@"
|
||||
;;
|
||||
autoconf-minimal)
|
||||
echo "Testing Autoconf build (minimal)"
|
||||
autoconf_build_minimal "$@"
|
||||
;;
|
||||
cmake)
|
||||
echo "Testing CMake build"
|
||||
cmake_build "$@"
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.9.0)
|
||||
project(test)
|
||||
|
||||
find_package(Tiff CONFIG REQUIRED)
|
||||
|
||||
add_executable(test test.c)
|
||||
target_link_libraries(test PRIVATE TIFF::tiff)
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "tiffio.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
TIFFGetVersion();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.9.0)
|
||||
project(test)
|
||||
|
||||
find_package(Tiff CONFIG REQUIRED)
|
||||
|
||||
add_executable(test test.c)
|
||||
target_include_directories(test PRIVATE ${TIFF_INCLUDE_DIR})
|
||||
target_link_libraries(test PRIVATE ${TIFF_LIBRARIES})
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "tiffio.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
TIFFGetVersion();
|
||||
return 0;
|
||||
}
|
||||
@@ -29,4 +29,4 @@ set(PACKAGE_NAME "LibTIFF Software")
|
||||
set(PACKAGE_TARNAME "${PROJECT_NAME}")
|
||||
set(PACKAGE_VERSION "${PROJECT_VERSION}${LIBTIFF_ALPHA_VERSION}")
|
||||
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
|
||||
set(PACKAGE_BUGREPORT "tiff@lists.maptools.org")
|
||||
set(PACKAGE_BUGREPORT "tiff@lists.osgeo.org")
|
||||
|
||||
@@ -40,6 +40,12 @@ endforeach()
|
||||
set(LIBTIFF_VERSION "${LIBTIFF_MAJOR_VERSION}.${LIBTIFF_MINOR_VERSION}.${LIBTIFF_MICRO_VERSION}")
|
||||
set(LIBTIFF_VERSION_FULL "${LIBTIFF_VERSION}${LIBTIFF_ALPHA_VERSION}")
|
||||
|
||||
# Get release version from file VERSION
|
||||
FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" LIBTIFF_RELEASE_VERSION)
|
||||
|
||||
# Package date - get it from file RELEASE-DATE
|
||||
FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/RELEASE-DATE" LIBTIFF_RELEASE_DATE)
|
||||
|
||||
# Convert the libtool version variables to proper major and minor versions
|
||||
math(EXPR SO_MAJOR "${LIBTIFF_CURRENT} - ${LIBTIFF_AGE}")
|
||||
set(SO_MINOR "${LIBTIFF_AGE}")
|
||||
|
||||
@@ -31,9 +31,9 @@ include(CheckSymbolExists)
|
||||
include(CheckLibraryExists)
|
||||
|
||||
check_symbol_exists(pow "math.h" CMath_HAVE_LIBC_POW)
|
||||
if(NOT CMath_HAVE_LIBC_POW)
|
||||
find_library(CMath_LIBRARY NAMES m)
|
||||
find_library(CMath_LIBRARY NAMES m)
|
||||
|
||||
if(NOT CMath_HAVE_LIBC_POW)
|
||||
set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${CMath_LIBRARY})
|
||||
check_symbol_exists(pow "math.h" CMath_HAVE_LIBM_POW)
|
||||
|
||||
@@ -66,15 +66,14 @@ unset(Deflate_OLD_FIND_LIBRARY_PREFIXES)
|
||||
|
||||
mark_as_advanced(Deflate_INCLUDE_DIR)
|
||||
|
||||
if(Deflate_INCLUDE_DIR AND EXISTS "${Deflate_INCLUDE_DIR}/deflate.h")
|
||||
file(STRINGS "${Deflate_INCLUDE_DIR}/libdeflate.h" Deflate_H REGEX "^#define LIBDEFLATE_VERSION_STRING\s+\"[^\"]*\"$")
|
||||
|
||||
string(REGEX REPLACE "^.*Deflate_VERSION \"([0-9]+).*$" "\\1" Deflate_MAJOR_VERSION "${Deflate_H}")
|
||||
string(REGEX REPLACE "^.*Deflate_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" Deflate_MINOR_VERSION "${Deflate_H}")
|
||||
if(Deflate_INCLUDE_DIR AND EXISTS "${Deflate_INCLUDE_DIR}/libdeflate.h")
|
||||
file(STRINGS "${Deflate_INCLUDE_DIR}/libdeflate.h" Deflate_H REGEX "^#define[\t ]+LIBDEFLATE_VERSION_STRING[\t ]+.*")
|
||||
string(REGEX REPLACE "^.*LIBDEFLATE_VERSION_STRING[\t ]+\"([0-9]+).*$" "\\1" Deflate_MAJOR_VERSION "${Deflate_H}")
|
||||
string(REGEX REPLACE "^.*LIBDEFLATE_VERSION_STRING[\t ]\"[0-9]+\\.([0-9]+).*$" "\\1" Deflate_MINOR_VERSION "${Deflate_H}")
|
||||
set(Deflate_VERSION_STRING "${Deflate_MAJOR_VERSION}.${Deflate_MINOR_VERSION}")
|
||||
|
||||
set(Deflate_MAJOR_VERSION "${Deflate_VERSION_MAJOR}")
|
||||
set(Deflate_MINOR_VERSION "${Deflate_VERSION_MINOR}")
|
||||
set(Deflate_VERSION_MAJOR "${Deflate_MAJOR_VERSION}")
|
||||
set(Deflate_VERSION_MINOR "${Deflate_MINOR_VERSION}")
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
@@ -110,7 +109,7 @@ if(Deflate_FOUND)
|
||||
|
||||
if(NOT Deflate_LIBRARY_RELEASE AND NOT Deflate_LIBRARY_DEBUG)
|
||||
set_target_properties(Deflate::Deflate PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${Deflate_LIBRARY}")
|
||||
IMPORTED_LOCATION "${Deflate_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -110,7 +110,7 @@ if(JBIG_FOUND)
|
||||
|
||||
if(NOT JBIG_LIBRARY_RELEASE AND NOT JBIG_LIBRARY_DEBUG)
|
||||
set_target_properties(JBIG::JBIG PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${JBIG_LIBRARY}")
|
||||
IMPORTED_LOCATION "${JBIG_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
+16
-2
@@ -11,7 +11,7 @@ IMPORTED Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module defines :prop_tgt:`IMPORTED` target ``LERC::LERC``, if
|
||||
CMath has been found.
|
||||
LERC has been found.
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
@@ -23,6 +23,7 @@ This module defines the following variables:
|
||||
LERC_INCLUDE_DIRS - where to find Lerc_c_api.h, etc.
|
||||
LERC_LIBRARIES - List of libraries when using LERC.
|
||||
LERC_FOUND - True if LERC found.
|
||||
LERC_VERSION_STRING - version number as a string (ex: "4.0.1")
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
@@ -47,6 +48,19 @@ unset(LERC_NAMES)
|
||||
|
||||
mark_as_advanced(LERC_INCLUDE_DIR)
|
||||
|
||||
if(LERC_INCLUDE_DIR AND EXISTS "${LERC_INCLUDE_DIR}/Lerc_c_api.h")
|
||||
file(STRINGS "${LERC_INCLUDE_DIR}/Lerc_c_api.h" LERC_H REGEX "^#define[\t ]+LERC_VERSION_[A-Z]+[\t ]+[0-9]+")
|
||||
string(REGEX REPLACE "^.*#define[\t ]+LERC_VERSION_MAJOR[\t ]+([0-9]+).*$" "\\1" LERC_VERSION_MAJOR "${LERC_H}")
|
||||
string(REGEX REPLACE "^.*#define[\t ]+LERC_VERSION_MINOR[\t ]+([0-9]+).*$" "\\1" LERC_VERSION_MINOR "${LERC_H}")
|
||||
string(REGEX REPLACE "^.*#define[\t ]+LERC_VERSION_PATCH[\t ]+([0-9]+).*$" "\\1" LERC_VERSION_PATCH "${LERC_H}")
|
||||
set(LERC_VERSION_STRING "${LERC_VERSION_MAJOR}.${LERC_VERSION_MINOR}.${LERC_VERSION_PATCH}")
|
||||
unset(LERC_H)
|
||||
unset(LERC_VERSION_MAJOR)
|
||||
unset(LERC_VERSION_MINOR)
|
||||
unset(LERC_VERSION_PATCH)
|
||||
endif()
|
||||
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LERC
|
||||
REQUIRED_VARS LERC_LIBRARY LERC_INCLUDE_DIR
|
||||
@@ -80,7 +94,7 @@ if(LERC_FOUND)
|
||||
|
||||
if(NOT LERC_LIBRARY_RELEASE AND NOT LERC_LIBRARY_DEBUG)
|
||||
set_target_properties(LERC::LERC PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${LERC_LIBRARY}")
|
||||
IMPORTED_LOCATION "${LERC_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
+10
-10
@@ -10,7 +10,7 @@ Find the native WebP includes and library.
|
||||
IMPORTED Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module defines :prop_tgt:`IMPORTED` target ``WebP::WebP``, if
|
||||
This module defines :prop_tgt:`IMPORTED` target ``WebP::webp``, if
|
||||
WebP has been found.
|
||||
|
||||
Result Variables
|
||||
@@ -64,28 +64,28 @@ if(WebP_FOUND)
|
||||
set(WebP_LIBRARIES ${WebP_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(NOT TARGET WebP::WebP)
|
||||
add_library(WebP::WebP UNKNOWN IMPORTED)
|
||||
set_target_properties(WebP::WebP PROPERTIES
|
||||
if(NOT TARGET WebP::webp)
|
||||
add_library(WebP::webp UNKNOWN IMPORTED)
|
||||
set_target_properties(WebP::webp PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIRS}")
|
||||
|
||||
if(WebP_LIBRARY_RELEASE)
|
||||
set_property(TARGET WebP::WebP APPEND PROPERTY
|
||||
set_property(TARGET WebP::webp APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(WebP::WebP PROPERTIES
|
||||
set_target_properties(WebP::webp PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${WebP_LIBRARY_RELEASE}")
|
||||
endif()
|
||||
|
||||
if(WebP_LIBRARY_DEBUG)
|
||||
set_property(TARGET WebP::WebP APPEND PROPERTY
|
||||
set_property(TARGET WebP::webp APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS DEBUG)
|
||||
set_target_properties(WebP::WebP PROPERTIES
|
||||
set_target_properties(WebP::webp PROPERTIES
|
||||
IMPORTED_LOCATION_DEBUG "${WebP_LIBRARY_DEBUG}")
|
||||
endif()
|
||||
|
||||
if(NOT WebP_LIBRARY_RELEASE AND NOT WebP_LIBRARY_DEBUG)
|
||||
set_target_properties(WebP::WebP PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${WebP_LIBRARY}")
|
||||
set_target_properties(WebP::webp PROPERTIES
|
||||
IMPORTED_LOCATION "${WebP_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -101,7 +101,7 @@ if(ZSTD_FOUND)
|
||||
|
||||
if(NOT ZSTD_LIBRARY_RELEASE AND NOT ZSTD_LIBRARY_DEBUG)
|
||||
set_target_properties(ZSTD::ZSTD PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${ZSTD_LIBRARY}")
|
||||
IMPORTED_LOCATION "${ZSTD_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindLibLZMA
|
||||
Findliblzma
|
||||
-----------
|
||||
|
||||
Find LZMA compression algorithm headers and library.
|
||||
@@ -13,7 +13,7 @@ Imported Targets
|
||||
|
||||
.. versionadded:: 3.14
|
||||
|
||||
This module defines :prop_tgt:`IMPORTED` target ``LibLZMA::LibLZMA``, if
|
||||
This module defines :prop_tgt:`IMPORTED` target ``liblzma::liblzma``, if
|
||||
liblzma has been found.
|
||||
|
||||
Result variables
|
||||
@@ -21,7 +21,7 @@ Result variables
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
``LIBLZMA_FOUND``
|
||||
``liblzma_FOUND``
|
||||
True if liblzma headers and library were found.
|
||||
``LIBLZMA_INCLUDE_DIRS``
|
||||
Directory where liblzma headers are located.
|
||||
@@ -70,7 +70,7 @@ endif()
|
||||
if (LIBLZMA_LIBRARY)
|
||||
include(CheckLibraryExists)
|
||||
set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
|
||||
set(CMAKE_REQUIRED_QUIET ${LibLZMA_FIND_QUIETLY})
|
||||
set(CMAKE_REQUIRED_QUIET ${liblzma_FIND_QUIETLY})
|
||||
if(NOT LIBLZMA_LIBRARY_RELEASE AND NOT LIBLZMA_LIBRARY_DEBUG)
|
||||
set(LIBLZMA_LIBRARY_check ${LIBLZMA_LIBRARY})
|
||||
elseif(LIBLZMA_LIBRARY_RELEASE)
|
||||
@@ -86,7 +86,7 @@ if (LIBLZMA_LIBRARY)
|
||||
endif ()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(LibLZMA REQUIRED_VARS LIBLZMA_LIBRARY
|
||||
find_package_handle_standard_args(liblzma REQUIRED_VARS LIBLZMA_LIBRARY
|
||||
LIBLZMA_INCLUDE_DIR
|
||||
LIBLZMA_HAS_AUTO_DECODER
|
||||
LIBLZMA_HAS_EASY_ENCODER
|
||||
@@ -95,31 +95,31 @@ find_package_handle_standard_args(LibLZMA REQUIRED_VARS LIBLZMA_LIBRARY
|
||||
)
|
||||
mark_as_advanced( LIBLZMA_INCLUDE_DIR LIBLZMA_LIBRARY )
|
||||
|
||||
if (LIBLZMA_FOUND)
|
||||
if (liblzma_FOUND)
|
||||
set(LIBLZMA_LIBRARIES ${LIBLZMA_LIBRARY})
|
||||
set(LIBLZMA_INCLUDE_DIRS ${LIBLZMA_INCLUDE_DIR})
|
||||
if(NOT TARGET LibLZMA::LibLZMA)
|
||||
add_library(LibLZMA::LibLZMA UNKNOWN IMPORTED)
|
||||
set_target_properties(LibLZMA::LibLZMA PROPERTIES
|
||||
if(NOT TARGET liblzma::liblzma)
|
||||
add_library(liblzma::liblzma UNKNOWN IMPORTED)
|
||||
set_target_properties(liblzma::liblzma PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${LIBLZMA_INCLUDE_DIR}
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES C)
|
||||
|
||||
if(LIBLZMA_LIBRARY_RELEASE)
|
||||
set_property(TARGET LibLZMA::LibLZMA APPEND PROPERTY
|
||||
set_property(TARGET liblzma::liblzma APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(LibLZMA::LibLZMA PROPERTIES
|
||||
set_target_properties(liblzma::liblzma PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${LIBLZMA_LIBRARY_RELEASE}")
|
||||
endif()
|
||||
|
||||
if(LIBLZMA_LIBRARY_DEBUG)
|
||||
set_property(TARGET LibLZMA::LibLZMA APPEND PROPERTY
|
||||
set_property(TARGET liblzma::liblzma APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS DEBUG)
|
||||
set_target_properties(LibLZMA::LibLZMA PROPERTIES
|
||||
set_target_properties(liblzma::liblzma PROPERTIES
|
||||
IMPORTED_LOCATION_DEBUG "${LIBLZMA_LIBRARY_DEBUG}")
|
||||
endif()
|
||||
|
||||
if(NOT LIBLZMA_LIBRARY_RELEASE AND NOT LIBLZMA_LIBRARY_DEBUG)
|
||||
set_target_properties(LibLZMA::LibLZMA PROPERTIES
|
||||
set_target_properties(liblzma::liblzma PROPERTIES
|
||||
IMPORTED_LOCATION "${LIBLZMA_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
+41
-13
@@ -39,18 +39,46 @@ if (old-jpeg AND JPEG_SUPPORT)
|
||||
set(OJPEG_SUPPORT TRUE)
|
||||
endif()
|
||||
|
||||
# 8/12-bit jpeg mode
|
||||
set(JPEG12_INCLUDE_DIR JPEG12_INCLUDE_DIR-NOTFOUND CACHE PATH "Include directory for 12-bit libjpeg")
|
||||
set(JPEG12_LIBRARY JPEG12_LIBRARY-NOTFOUND CACHE FILEPATH "12-bit libjpeg library")
|
||||
set(JPEG_DUAL_MODE_8_12 FALSE)
|
||||
if (JPEG12_INCLUDE_DIR AND JPEG12_LIBRARY)
|
||||
set(JPEG12_LIBRARIES ${JPEG12_LIBRARY})
|
||||
set(JPEG12_FOUND TRUE)
|
||||
else()
|
||||
set(JPEG12_FOUND FALSE)
|
||||
if (JPEG_SUPPORT)
|
||||
# Check for jpeg12_read_scanlines() which has been added in libjpeg-turbo 2.2
|
||||
# for dual 8/12 bit mode.
|
||||
include(CheckCSourceCompiles)
|
||||
include(CMakePushCheckState)
|
||||
cmake_push_check_state(RESET)
|
||||
set(CMAKE_REQUIRED_INCLUDES "${JPEG_INCLUDE_DIRS}")
|
||||
set(CMAKE_REQUIRED_LIBRARIES "${JPEG_LIBRARIES}")
|
||||
check_c_source_compiles(
|
||||
"
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include \"jpeglib.h\"
|
||||
int main()
|
||||
{
|
||||
jpeg_read_scanlines(0,0,0);
|
||||
jpeg12_read_scanlines(0,0,0);
|
||||
return 0;
|
||||
}
|
||||
"
|
||||
HAVE_JPEGTURBO_DUAL_MODE_8_12)
|
||||
cmake_pop_check_state()
|
||||
endif()
|
||||
option(jpeg12 "enable libjpeg 8/12-bit dual mode (requires separate 12-bit libjpeg build)" ${JPEG12_FOUND})
|
||||
if (jpeg12 AND JPEG12_FOUND)
|
||||
set(JPEG_DUAL_MODE_8_12 TRUE)
|
||||
set(LIBJPEG_12_PATH "${JPEG12_INCLUDE_DIR}/jpeglib.h")
|
||||
|
||||
if (NOT HAVE_JPEGTURBO_DUAL_MODE_8_12)
|
||||
|
||||
# 12-bit jpeg mode in a dedicated libjpeg12 library
|
||||
set(JPEG12_INCLUDE_DIR JPEG12_INCLUDE_DIR-NOTFOUND CACHE PATH "Include directory for 12-bit libjpeg")
|
||||
set(JPEG12_LIBRARY JPEG12_LIBRARY-NOTFOUND CACHE FILEPATH "12-bit libjpeg library")
|
||||
set(JPEG_DUAL_MODE_8_12 FALSE)
|
||||
if (JPEG12_INCLUDE_DIR AND JPEG12_LIBRARY)
|
||||
set(JPEG12_LIBRARIES ${JPEG12_LIBRARY})
|
||||
set(JPEG12_FOUND TRUE)
|
||||
else()
|
||||
set(JPEG12_FOUND FALSE)
|
||||
endif()
|
||||
option(jpeg12 "enable libjpeg 8/12-bit dual mode (requires separate 12-bit libjpeg build)" ${JPEG12_FOUND})
|
||||
if (jpeg12 AND JPEG12_FOUND)
|
||||
set(JPEG_DUAL_MODE_8_12 TRUE)
|
||||
set(LIBJPEG_12_PATH "${JPEG12_INCLUDE_DIR}/jpeglib.h")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
@@ -26,8 +26,9 @@
|
||||
|
||||
# liblzma2
|
||||
set(LZMA_SUPPORT FALSE)
|
||||
find_package(LibLZMA)
|
||||
option(lzma "use liblzma (required for LZMA2 compression)" ${LZMA_FOUND})
|
||||
find_package(liblzma)
|
||||
|
||||
option(lzma "use liblzma (required for LZMA2 compression)" ${LIBLZMA_FOUND})
|
||||
if (lzma AND LIBLZMA_FOUND)
|
||||
set(LZMA_SUPPORT TRUE)
|
||||
endif()
|
||||
|
||||
@@ -35,6 +35,8 @@ if(strip-chopping)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(TIFF_MAX_DIR_COUNT 1048576 CACHE STRING "Maximum number of TIFF directories that libtiff can browse through")
|
||||
|
||||
# Defer loading of strip/tile offsets
|
||||
option(defer-strile-load "enable deferred strip/tile offset/size loading (also available at runtime with the 'D' flag of TIFFOpen())" OFF)
|
||||
set(DEFER_STRILE_LOAD ${defer-strile-load})
|
||||
|
||||
@@ -29,6 +29,7 @@ set(OpenGL_GL_PREFERENCE LEGACY)
|
||||
find_package(OpenGL COMPONENTS OpenGL)
|
||||
find_package(GLUT)
|
||||
|
||||
set(OPENGL_SUPPORT FALSE)
|
||||
set(HAVE_OPENGL FALSE)
|
||||
if(OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND)
|
||||
set(HAVE_OPENGL TRUE)
|
||||
@@ -41,3 +42,9 @@ check_include_file(GL/glut.h HAVE_GL_GLUT_H)
|
||||
check_include_file(GLUT/glut.h HAVE_GLUT_GLUT_H)
|
||||
check_include_file(OpenGL/gl.h HAVE_OPENGL_GL_H)
|
||||
check_include_file(OpenGL/glu.h HAVE_OPENGL_GLU_H)
|
||||
|
||||
option(tiff-opengl "use OpenGL (required for tiffgt viewer)" ${HAVE_OPENGL})
|
||||
|
||||
if (tiff-opengl AND HAVE_OPENGL)
|
||||
set(OPENGL_SUPPORT TRUE)
|
||||
endif()
|
||||
|
||||
@@ -29,13 +29,13 @@ function(set_libs_private out_var)
|
||||
foreach(lib IN LISTS ARGN)
|
||||
get_filename_component(name "${lib}" NAME)
|
||||
foreach(prefix IN LISTS CMAKE_FIND_LIBRARY_PREFIXES)
|
||||
if(name MATCHES "^${prefix}")
|
||||
if(NOT("${prefix}" STREQUAL "") AND name MATCHES "^${prefix}")
|
||||
string(REGEX REPLACE "^${prefix}" "" name "${name}")
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
foreach(suffix IN LISTS CMAKE_FIND_LIBRARY_SUFFIXES)
|
||||
if(name MATCHES "${suffix}$")
|
||||
if(NOT("${suffix}" STREQUAL "") AND name MATCHES "${suffix}$")
|
||||
string(REGEX REPLACE "${suffix}$" "" name "${name}")
|
||||
break()
|
||||
endif()
|
||||
@@ -63,5 +63,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libtiff-4.pc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc @ONLY)
|
||||
|
||||
# Install pkg-config file
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
if (tiff-install)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
endif()
|
||||
|
||||
@@ -26,17 +26,6 @@
|
||||
|
||||
include(TestBigEndian)
|
||||
|
||||
|
||||
# CPU bit order
|
||||
set(HOST_FILLORDER FILLORDER_MSB2LSB)
|
||||
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i.*86.*" OR
|
||||
CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64.*" OR
|
||||
# AMD64 on Windows
|
||||
CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "AMD64" OR
|
||||
CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64.*")
|
||||
set(HOST_FILLORDER FILLORDER_LSB2MSB)
|
||||
endif()
|
||||
|
||||
# CPU endianness
|
||||
test_big_endian(HOST_BIG_ENDIAN)
|
||||
if(HOST_BIG_ENDIAN)
|
||||
|
||||
+22
-6
@@ -22,10 +22,26 @@
|
||||
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
# OF THIS SOFTWARE.
|
||||
|
||||
# Add target tiff_release to update the version information in the root files
|
||||
# VERSION and RELEASE-DATE.
|
||||
add_custom_target(tiff_release
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
"-DSOURCE_DIR:PATH=${PROJECT_SOURCE_DIR}"
|
||||
"-DLIBTIFF_VERSION=${PROJECT_VERSION}"
|
||||
"-DLIBTIFF_BASIC_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"-DLIBTIFF_BASIC_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}"
|
||||
-P "${CMAKE_CURRENT_LIST_DIR}/ReleaseScript.cmake"
|
||||
COMMENT "Releasing ${PROJECT_NAME} ${PROJECT_VERSION} ...")
|
||||
|
||||
# Version information is taken from configure.ac
|
||||
# Note: Single command "cmake --build . --target tiff_release"
|
||||
# does not work correctly, because version information is taken from CMakeCache.txt,
|
||||
# which is not updated by cmake --build.
|
||||
# Therefore, force CMake re-configure if configure.ac has changed.
|
||||
# By the way, release-date and VERSION will not change but only when --targt tiff_release is called.
|
||||
set_property(
|
||||
DIRECTORY
|
||||
APPEND
|
||||
PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/configure.ac
|
||||
)
|
||||
|
||||
add_custom_target(release
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
"-DSOURCE_DIR:PATH=${PROJECT_SOURCE_DIR}"
|
||||
"-DLIBTIFF_VERSION=${PROJECT_VERSION}"
|
||||
-P "${CMAKE_CURRENT_LIST_DIR}/ReleaseScript.cmake"
|
||||
COMMENT "Releasing ${PROJECT_NAME} ${PROJECT_VERSION}")
|
||||
|
||||
@@ -22,11 +22,21 @@
|
||||
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
# OF THIS SOFTWARE.
|
||||
|
||||
# Update release date to current date
|
||||
string(TIMESTAMP LIBTIFF_RELEASE_DATE "%Y%m%d")
|
||||
|
||||
# Update version information in all relevant files
|
||||
message(STATUS "Setting release version to ${LIBTIFF_VERSION}")
|
||||
message(STATUS "Setting release date to ${LIBTIFF_RELEASE_DATE}")
|
||||
|
||||
configure_file("${SOURCE_DIR}/libtiff/tiffvers.h.cmake.in"
|
||||
"${SOURCE_DIR}/libtiff/tiffvers.h"
|
||||
@ONLY)
|
||||
# Only needed here, for manual build of target tiff_release
|
||||
# because otherwise tiffvers.h is generated when building all targets.
|
||||
configure_file(${LIBTIFF_BASIC_SOURCE_DIR}/libtiff/tiffvers.h.cmake.in
|
||||
${LIBTIFF_BASIC_BINARY_DIR}/libtiff/tiffvers.h
|
||||
@ONLY)
|
||||
|
||||
# Write version information and release date to root files.
|
||||
FILE(WRITE ${LIBTIFF_BASIC_SOURCE_DIR}/VERSION "${LIBTIFF_VERSION}" \n)
|
||||
FILE(WRITE ${LIBTIFF_BASIC_SOURCE_DIR}/RELEASE-DATE "${LIBTIFF_RELEASE_DATE}" \n)
|
||||
message(STATUS "Files tiffvers.h, VERSION and RELEASE-DATE updated.")
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
# #%L
|
||||
# OME Files C++ libraries (cmake build infrastructure)
|
||||
# %%
|
||||
# Copyright © 2015 Open Microscopy Environment:
|
||||
# - Massachusetts Institute of Technology
|
||||
# - National Institutes of Health
|
||||
# - University of Dundee
|
||||
# - Board of Regents of the University of Wisconsin-Madison
|
||||
# - Glencoe Software, Inc.
|
||||
# %%
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# The views and conclusions contained in the software and documentation are
|
||||
# those of the authors and should not be interpreted as representing official
|
||||
# policies, either expressed or implied, of any organization.
|
||||
# #L%
|
||||
|
||||
find_package(Python3 COMPONENTS Interpreter)
|
||||
|
||||
# Sphinx documentation generator
|
||||
find_program(SPHINX_BUILD sphinx-build)
|
||||
if (SPHINX_BUILD)
|
||||
message(STATUS "Looking for sphinx-build - ${SPHINX_BUILD}")
|
||||
else()
|
||||
message(STATUS "Looking for sphinx-build - not found")
|
||||
endif()
|
||||
|
||||
set(SPHINX_DEFAULT OFF)
|
||||
if(SPHINX_BUILD)
|
||||
set(SPHINX_DEFAULT ON)
|
||||
endif()
|
||||
option(sphinx "Enable sphinx manual page and HTML documentation" ${SPHINX_DEFAULT})
|
||||
option(sphinx-linkcheck "Check sphinx documentation links by default" OFF)
|
||||
|
||||
set(BUILD_SPHINX ${sphinx})
|
||||
set(SPHINX_LIST_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
function(sphinx_manpages srcdir builddir manvar)
|
||||
execute_process(COMMAND "${Python3_EXECUTABLE}" -B ${SPHINX_LIST_DIR}/list-manpages.py
|
||||
"${srcdir}" "${builddir}"
|
||||
RESULT_VARIABLE sphinx_man_fail
|
||||
OUTPUT_VARIABLE MAN_PAGES)
|
||||
if (sphinx_man_fail)
|
||||
message(WARNING "Failed to get generated sphinx manual pages from ${confdir}")
|
||||
endif()
|
||||
string(REPLACE "\n" ";" MAN_PAGES "${MAN_PAGES}")
|
||||
set(${manvar} "${MAN_PAGES}" PARENT_SCOPE)
|
||||
|
||||
message(STATUS "Sphinx manual pages: ${MAN_PAGES}")
|
||||
endfunction(sphinx_manpages)
|
||||
|
||||
function(sphinx_manpage_dependencies srcdir depvar)
|
||||
execute_process(COMMAND "${Python3_EXECUTABLE}" -B ${SPHINX_LIST_DIR}/list-manpage-dependencies.py
|
||||
"${srcdir}"
|
||||
RESULT_VARIABLE sphinx_dep_fail
|
||||
OUTPUT_VARIABLE SPHINX_MAN_DEPENDENCIES)
|
||||
if (sphinx_dep_fail)
|
||||
message(WARNING "Failed to get Sphinx dependencies from ${confdir}")
|
||||
endif()
|
||||
string(REPLACE "\n" ";" SPHINX_MAN_DEPENDENCIES "${SPHINX_MAN_DEPENDENCIES}")
|
||||
|
||||
set(${depvar} "${SPHINX_MAN_DEPENDENCIES}" PARENT_SCOPE)
|
||||
endfunction(sphinx_manpage_dependencies)
|
||||
|
||||
function(sphinx_dependencies srcdir depvar)
|
||||
file(GLOB_RECURSE CRUDE_SPHINX_DEPENDENCIES "${srcdir}/*.rst")
|
||||
foreach(file ${CRUDE_SPHINX_DEPENDENCIES})
|
||||
string(FIND "${file}" "_build" FILE_MATCH)
|
||||
if(FILE_MATCH EQUAL -1)
|
||||
list(APPEND SPHINX_DEPENDENCIES "${file}")
|
||||
endif()
|
||||
endforeach()
|
||||
set(${depvar} "${SPHINX_DEPENDENCIES}" PARENT_SCOPE)
|
||||
endfunction(sphinx_dependencies)
|
||||
@@ -0,0 +1,87 @@
|
||||
# Check "local" sphinx links, using files in the build tree and in the
|
||||
# install tree (other components)
|
||||
|
||||
message(STATUS "Checking internal links")
|
||||
|
||||
set(failed OFF)
|
||||
|
||||
file(STRINGS "${OUTPUT}" output)
|
||||
file(REMOVE "${OUTPUT}.new")
|
||||
foreach(line IN LISTS output)
|
||||
# Parse the filename, link type, link and anchor from each line
|
||||
string(REGEX MATCH "^.*: \\[.*\\] .*" line_match "${line}")
|
||||
string(REGEX MATCH "^.*: \\[.*\\] .*#.*" anchor_match "${line}")
|
||||
if(line_match)
|
||||
string(REGEX REPLACE "^(.*): \\[(.*)\\] (.*)" "\\1" filename "${line}")
|
||||
string(REGEX REPLACE "^(.*): \\[(.*)\\] (.*)" "\\2" type "${line}")
|
||||
if(anchor_match)
|
||||
string(REGEX REPLACE "^(.*): \\[(.*)\\] (.*)#(.*)" "\\3" link "${line}")
|
||||
string(REGEX REPLACE "^(.*): \\[(.*)\\] (.*)#(.*)" "\\4" link "${anchor}")
|
||||
else()
|
||||
string(REGEX REPLACE "^(.*): \\[(.*)\\] (.*)" "\\3" link "${line}")
|
||||
unset(anchor)
|
||||
endif()
|
||||
|
||||
# Only check local links
|
||||
if(type STREQUAL "local")
|
||||
# Compute path relative to our install path
|
||||
file(RELATIVE_PATH relpath "/" "/${SPHINX_INSTALL_PATH}/${link}")
|
||||
|
||||
# Check sphinx link in the install tree
|
||||
unset(linkfile)
|
||||
if(EXISTS "${EXTERNAL_REFERENCE}/${relpath}")
|
||||
set(linkfile "${EXTERNAL_REFERENCE}/${relpath}")
|
||||
endif()
|
||||
# Check sphinx link in the build tree
|
||||
if(EXISTS "${INTERNAL_REFERENCE}/${link}")
|
||||
set(linkfile "${INTERNAL_REFERENCE}/${link}")
|
||||
endif()
|
||||
# Check doxygen link in the install tree
|
||||
if(EXISTS "${DOXYGEN_REFERENCE}/${link}")
|
||||
set(linkfile "${DOXYGEN_REFERENCE}/${link}")
|
||||
endif()
|
||||
# Check doxygen link in the build tree
|
||||
if(DOXYGEN_REFERENCE AND DOXYGEN_INSTALL_PATH)
|
||||
string(REGEX REPLACE "^${DOXYGEN_INSTALL_PATH}/(.*)" "\\1" doxygen_path "${relpath}")
|
||||
if(EXISTS "${DOXYGEN_REFERENCE}/${doxygen_path}")
|
||||
set(linkfile "${DOXYGEN_REFERENCE}/${doxygen_path}")
|
||||
endif()
|
||||
endif()
|
||||
# Check link and any anchor. If the link does not exist, or the
|
||||
# anchor does not exist, set the link type to broken when
|
||||
# rewriting the output file with our test results.
|
||||
if(linkfile)
|
||||
if(anchor)
|
||||
file(STRINGS "${linkfile}" anchor_matches REGEX "<a +class=\"anchor\" +id=\"${anchor}\"")
|
||||
if(anchor_matches)
|
||||
file(APPEND "${OUTPUT}.new" "${filename}: [${type}] ${link}#${anchor}\n")
|
||||
else()
|
||||
set(failed ON)
|
||||
file(APPEND "${OUTPUT}.new" "${filename}: [broken] ${link}#${anchor}\n")
|
||||
message(STATUS "Broken link: ${filename}: ${link}#${anchor}")
|
||||
endif()
|
||||
else()
|
||||
file(APPEND "${OUTPUT}.new" "${filename}: [${type}] ${link}\n")
|
||||
endif()
|
||||
else()
|
||||
set(failed ON)
|
||||
file(APPEND "${OUTPUT}.new" "${filename}: [broken] ${link}\n")
|
||||
message(STATUS "Broken link: ${filename}: ${link}")
|
||||
endif()
|
||||
else()
|
||||
if(type STREQUAL "broken")
|
||||
set(failed ON)
|
||||
message(STATUS "Broken link: ${filename}: ${link}")
|
||||
endif()
|
||||
file(APPEND "${OUTPUT}.new" "${filename}: [${type}] ${link}\n")
|
||||
endif()
|
||||
else()
|
||||
file(APPEND "${OUTPUT}.new" "${line}\n")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
file(RENAME "${OUTPUT}.new" "${OUTPUT}")
|
||||
|
||||
if(failed)
|
||||
message(FATAL_ERROR "Broken links detected")
|
||||
endif()
|
||||
@@ -0,0 +1,27 @@
|
||||
if(NOT "@BUILD_SHARED_LIBS@")
|
||||
# TODO: import dependencies
|
||||
endif()
|
||||
|
||||
function(set_variable_from_rel_or_absolute_path var root rel_or_abs_path)
|
||||
if(IS_ABSOLUTE "${rel_or_abs_path}")
|
||||
set(${var} "${rel_or_abs_path}" PARENT_SCOPE)
|
||||
else()
|
||||
set(${var} "${root}/${rel_or_abs_path}" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Tell the user project where to find our headers and libraries
|
||||
get_filename_component(_DIR "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE)
|
||||
get_filename_component(_ROOT "${_DIR}/@PROJECT_ROOT_DIR@" ABSOLUTE)
|
||||
# Use _ROOT as prefix here for the possibility of relocation after installation.
|
||||
set_variable_from_rel_or_absolute_path("TIFF_INCLUDE_DIR" "${_ROOT}" "@CMAKE_INSTALL_INCLUDEDIR@")
|
||||
set(TIFF_INCLUDE_DIRS ${TIFF_INCLUDE_DIR})
|
||||
|
||||
set(TIFF_LIBRARIES TIFF::tiff)
|
||||
|
||||
if(NOT TARGET TIFF::tiff)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/TiffTargets.cmake")
|
||||
endif()
|
||||
|
||||
unset (_ROOT)
|
||||
unset (_DIR)
|
||||
@@ -23,13 +23,17 @@
|
||||
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
# OF THIS SOFTWARE.
|
||||
|
||||
# Debug postfix
|
||||
if(MSVC)
|
||||
# Debug postfix
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
# disable deprecation warnings
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
# suppress deprecation warning for MSVC POSIX names
|
||||
add_definitions(-D_CRT_NONSTDC_NO_WARNINGS)
|
||||
|
||||
# disable deprecation warnings
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
|
||||
# suppress deprecation warning for MSVC POSIX names
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
|
||||
|
||||
# Don't warn about use of deprecated functions
|
||||
add_compile_options(/wd4996)
|
||||
endif()
|
||||
|
||||
# Win32 file I/O
|
||||
|
||||
+18
-7
@@ -31,13 +31,24 @@ set(ZSTD_USABLE FALSE)
|
||||
find_package(ZSTD)
|
||||
|
||||
if(ZSTD_FOUND)
|
||||
set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES})
|
||||
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ZSTD_INCLUDE_DIRS})
|
||||
set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${ZSTD_LIBRARIES})
|
||||
check_symbol_exists(ZSTD_decompressStream "zstd.h" ZSTD_RECENT_ENOUGH)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
|
||||
if(TARGET zstd::libzstd_shared)
|
||||
add_library(ZSTD::ZSTD ALIAS zstd::libzstd_shared)
|
||||
set(ZSTD_HAVE_DECOMPRESS_STREAM ON)
|
||||
elseif(TARGET zstd::libzstd_static)
|
||||
add_library(ZSTD::ZSTD ALIAS zstd::libzstd_static)
|
||||
set(ZSTD_HAVE_DECOMPRESS_STREAM ON)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED ZSTD_HAVE_DECOMPRESS_STREAM)
|
||||
set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES})
|
||||
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ZSTD_INCLUDE_DIRS})
|
||||
set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${ZSTD_LIBRARIES})
|
||||
check_symbol_exists(ZSTD_decompressStream "zstd.h" ZSTD_HAVE_DECOMPRESS_STREAM)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
|
||||
endif()
|
||||
set(ZSTD_RECENT_ENOUGH ${ZSTD_HAVE_DECOMPRESS_STREAM})
|
||||
|
||||
if (ZSTD_RECENT_ENOUGH)
|
||||
set(ZSTD_USABLE TRUE)
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Find manual page dependencies
|
||||
# argv1 = doc dir containing conf.py
|
||||
|
||||
import importlib.util
|
||||
import os.path
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
sys.exit("Usage: %s sphinx-srcdir" % (sys.argv[0]))
|
||||
|
||||
conf_dir = os.path.abspath(sys.argv[1])
|
||||
conf_path = os.path.join(conf_dir, 'conf.py')
|
||||
spec = importlib.util.spec_from_file_location('conf', conf_path)
|
||||
conf = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(conf)
|
||||
|
||||
if hasattr(conf, 'man_pages'):
|
||||
for man in conf.man_pages:
|
||||
man_path = os.path.join(sys.argv[1], "{}{}".format(man[0], '.rst'))
|
||||
man_path_posix = pathlib.PureWindowsPath(man_path).as_posix()
|
||||
print(man_path_posix)
|
||||
|
||||
print(pathlib.PureWindowsPath(conf_path).as_posix())
|
||||
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Find manual pages to be generated
|
||||
# argv1 = doc dir containing conf.py
|
||||
# argv2 = manpage directory to contain generated manpages
|
||||
|
||||
import importlib.util
|
||||
import os.path
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print("Usage: {} sphinx-srcdir sphinx-builddir".format(sys.argv[0]), file=sys.stderr)
|
||||
sys.exit(2)
|
||||
|
||||
conf_dir = os.path.abspath(sys.argv[1])
|
||||
conf_path = os.path.join(conf_dir, 'conf.py')
|
||||
spec = importlib.util.spec_from_file_location('conf', conf_path)
|
||||
conf = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(conf)
|
||||
|
||||
if hasattr(conf, 'man_pages'):
|
||||
for man in conf.man_pages:
|
||||
man_path = os.path.join(sys.argv[2], "%s.%s" % (man[1], man[4]))
|
||||
man_path_posix = pathlib.PureWindowsPath(man_path).as_posix()
|
||||
print(man_path_posix)
|
||||
else:
|
||||
print("No man_pages array in {}".format(conf_path), file=sys.stderr)
|
||||
sys.exit(3)
|
||||
+185
-67
@@ -25,7 +25,7 @@ dnl OF THIS SOFTWARE.
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.64)
|
||||
AC_INIT([LibTIFF Software],[4.4.0],[tiff@lists.maptools.org],[tiff])
|
||||
AC_INIT([LibTIFF Software],[4.7.0],[tiff@lists.osgeo.org],[tiff])
|
||||
AC_CONFIG_AUX_DIR(config)
|
||||
AC_CONFIG_MACRO_DIR(m4)
|
||||
AC_LANG(C)
|
||||
@@ -40,12 +40,13 @@ AM_MAINTAINER_MODE
|
||||
dnl Versioning.
|
||||
dnl Don't fill the ALPHA_VERSION field, if not applicable.
|
||||
LIBTIFF_MAJOR_VERSION=4
|
||||
LIBTIFF_MINOR_VERSION=4
|
||||
LIBTIFF_MINOR_VERSION=7
|
||||
LIBTIFF_MICRO_VERSION=0
|
||||
LIBTIFF_ALPHA_VERSION=
|
||||
LIBTIFF_VERSION=$LIBTIFF_MAJOR_VERSION.$LIBTIFF_MINOR_VERSION.$LIBTIFF_MICRO_VERSION$LIBTIFF_ALPHA_VERSION
|
||||
dnl This will be used with the 'make release' target
|
||||
LIBTIFF_RELEASE_DATE=`date +"%Y%m%d"`
|
||||
dnl This (LIBTIFF_RELEASE_DATE) is used to set the #define TIFFLIB_VERSION in tiffvers.h.
|
||||
LIBTIFF_RELEASE_DATE=$(cat ${srcdir}/RELEASE-DATE)
|
||||
|
||||
|
||||
dnl Libtool library revision control info
|
||||
dnl See the libtool documentation under the heading "Libtool's versioning
|
||||
@@ -76,9 +77,9 @@ dnl 5. If any interfaces have been added since the last public release, then
|
||||
dnl increment age.
|
||||
dnl 6. If any interfaces have been removed since the last public release,
|
||||
dnl then set age to 0.
|
||||
LIBTIFF_CURRENT=13
|
||||
LIBTIFF_CURRENT=7
|
||||
LIBTIFF_REVISION=0
|
||||
LIBTIFF_AGE=8
|
||||
LIBTIFF_AGE=1
|
||||
LIBTIFF_VERSION_INFO=$LIBTIFF_CURRENT:$LIBTIFF_REVISION:$LIBTIFF_AGE
|
||||
|
||||
# This is a special hack for OpenBSD and MirOS systems. The dynamic linker
|
||||
@@ -121,9 +122,9 @@ AC_PATH_PROG(CMAKE, cmake)
|
||||
# constrained to compilers using GNU ld on ELF systems or systems
|
||||
# which provide an adequate emulation thereof.
|
||||
AC_ARG_ENABLE([ld-version-script],
|
||||
AS_HELP_STRING([--enable-ld-version-script],
|
||||
[enable linker version script (default is disabled)]),
|
||||
[have_ld_version_script=$enableval], [have_ld_version_script=no])
|
||||
AS_HELP_STRING([--disable-ld-version-script],
|
||||
[disable linker version script (default is enabled if supported)]),
|
||||
[have_ld_version_script=$enableval], [have_ld_version_script=yes])
|
||||
if test "$have_ld_version_script" != no; then
|
||||
AC_MSG_CHECKING([if LD -Wl,--version-script works])
|
||||
save_LDFLAGS="$LDFLAGS"
|
||||
@@ -163,6 +164,13 @@ AC_SUBST(tiff_libs_private)
|
||||
tiff_requires_private=
|
||||
AC_SUBST(tiff_requires_private)
|
||||
|
||||
|
||||
AM_CONDITIONAL(BUILD_STATIC, test "$enable_static" = "yes")
|
||||
|
||||
dnl Avoid -Werror to interfere with feature detection
|
||||
SAVED_CFLAGS="$CFLAGS"
|
||||
CFLAGS=$(echo "$CFLAGS " | sed "s/-Werror //")
|
||||
|
||||
dnl We don't need to add math library to all targets
|
||||
case "${host_os}" in
|
||||
cygwin* | mingw32* | beos* | darwin*)
|
||||
@@ -195,11 +203,18 @@ dnl Check if optarg (and presumably related externs) already declared in headers
|
||||
AC_CHECK_DECLS([optarg])
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl Deprecated features and backward compatibilty
|
||||
dnl Deprecated features and backward compatibility
|
||||
dnl ---------------------------------------------------------------------------
|
||||
|
||||
# Disable deprecated features to ensure clean build
|
||||
CPPFLAGS="-DTIFF_DISABLE_DEPRECATED $CPPFLAGS"
|
||||
AC_ARG_ENABLE([deprecated],
|
||||
AS_HELP_STRING([--enable-deprecated],
|
||||
[enable deprecated features (default is disabled)]),
|
||||
[enable_deprecated=$enableval], [enable_deprecated=no])
|
||||
|
||||
if test "$enable_deprecated" = "yes"; then
|
||||
# Disable deprecated features to ensure clean build
|
||||
CPPFLAGS="-DTIFF_DISABLE_DEPRECATED $CPPFLAGS"
|
||||
fi
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl Compute sized types for current CPU and compiler options
|
||||
@@ -245,22 +260,6 @@ AC_CHECK_FUNCS([mmap setmode])
|
||||
dnl Will use local replacements for unavailable functions
|
||||
AC_REPLACE_FUNCS(getopt)
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl Check the native cpu bit order.
|
||||
dnl ---------------------------------------------------------------------------
|
||||
AC_MSG_CHECKING([native cpu bit order])
|
||||
case "$host_cpu" in
|
||||
i*86*|x86_64*)
|
||||
HOST_FILLORDER=FILLORDER_LSB2MSB
|
||||
AC_MSG_RESULT([lsb2msb])
|
||||
;;
|
||||
*)
|
||||
HOST_FILLORDER=FILLORDER_MSB2LSB
|
||||
AC_MSG_RESULT([msb2lsb])
|
||||
;;
|
||||
esac
|
||||
AC_DEFINE_UNQUOTED(HOST_FILLORDER, $HOST_FILLORDER, [Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB)])
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl Configure legacy tifconf.h HOST_BIGENDIAN.
|
||||
dnl ---------------------------------------------------------------------------
|
||||
@@ -316,6 +315,34 @@ fi
|
||||
AC_SUBST(LIBTIFF_DOCDIR)
|
||||
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl Enable or disable parts of the build
|
||||
dnl ---------------------------------------------------------------------------
|
||||
|
||||
AC_ARG_ENABLE(tools,
|
||||
AS_HELP_STRING([--disable-tools],
|
||||
[Disable building of tools]),
|
||||
[TIFF_TOOLS=$enableval], [TIFF_TOOLS=yes])
|
||||
AM_CONDITIONAL(TIFF_TOOLS, test "$TIFF_TOOLS" = "yes")
|
||||
|
||||
AC_ARG_ENABLE(tests,
|
||||
AS_HELP_STRING([--disable-tests],
|
||||
[Disable building of tests]),
|
||||
[TIFF_TESTS=$enableval], [TIFF_TESTS=yes])
|
||||
AM_CONDITIONAL(TIFF_TESTS, test "$TIFF_TESTS" = "yes")
|
||||
|
||||
AC_ARG_ENABLE(contrib,
|
||||
AS_HELP_STRING([--disable-contrib],
|
||||
[Disable building of contrib]),
|
||||
[TIFF_CONTRIB=$enableval], [TIFF_CONTRIB=yes])
|
||||
AM_CONDITIONAL(TIFF_CONTRIB, test "$TIFF_CONTRIB" = "yes")
|
||||
|
||||
AC_ARG_ENABLE(docs,
|
||||
AS_HELP_STRING([--disable-docs],
|
||||
[Disable building of docs]),
|
||||
[TIFF_DOCS=$enableval], [TIFF_DOCS=yes])
|
||||
AM_CONDITIONAL(TIFF_DOCS, test "$TIFF_DOCS" = "yes")
|
||||
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl Switch on/off internal codecs.
|
||||
@@ -435,6 +462,7 @@ if test "$HAVE_ZLIB" = "yes" ; then
|
||||
AC_DEFINE(ZIP_SUPPORT,1,[Support Deflate compression])
|
||||
LIBS="-lz $LIBS"
|
||||
tiff_libs_private="-lz ${tiff_libs_private}"
|
||||
tiff_requires_private="zlib ${tiff_requires_private}"
|
||||
|
||||
if test "$HAVE_RPATH" = "yes" -a "x$with_zlib_lib_dir" != "x" ; then
|
||||
LIBDIR="-R $with_zlib_lib_dir $LIBDIR"
|
||||
@@ -492,6 +520,7 @@ if test "$HAVE_LIBDEFLATE" = "yes" ; then
|
||||
AC_DEFINE(LIBDEFLATE_SUPPORT,1,[Support libdeflate enhanced compression])
|
||||
LIBS="-ldeflate $LIBS"
|
||||
tiff_libs_private="-ldeflate ${tiff_libs_private}"
|
||||
tiff_requires_private="libdeflate ${tiff_requires_private}"
|
||||
|
||||
if test "$HAVE_RPATH" = "yes" -a "x$with_libdeflate_lib_dir" != "x" ; then
|
||||
LIBDIR="-R $with_libdeflate_lib_dir $LIBDIR"
|
||||
@@ -520,6 +549,7 @@ dnl Check for JPEG.
|
||||
dnl ---------------------------------------------------------------------------
|
||||
|
||||
HAVE_JPEG=no
|
||||
HAVE_JPEGTURBO_DUAL_MODE_8_12=no
|
||||
|
||||
AC_ARG_ENABLE(jpeg,
|
||||
AS_HELP_STRING([--disable-jpeg],
|
||||
@@ -552,6 +582,9 @@ if test "x$enable_jpeg" != "xno" ; then
|
||||
fi
|
||||
|
||||
if test "$jpeg_lib" = "yes" -a "$jpeg_h" = "yes" ; then
|
||||
dnl Check for jpeg12_read_scanlines which has been added in libjpeg-turbo 3.0
|
||||
dnl for dual 8/12 bit mode.
|
||||
AC_CHECK_LIB(jpeg, jpeg12_read_scanlines, [HAVE_JPEGTURBO_DUAL_MODE_8_12=yes], [HAVE_JPEGTURBO_DUAL_MODE_8_12=no],)
|
||||
HAVE_JPEG=yes
|
||||
fi
|
||||
|
||||
@@ -561,14 +594,19 @@ if test "$HAVE_JPEG" = "yes" ; then
|
||||
AC_DEFINE(JPEG_SUPPORT,1,[Support JPEG compression (requires IJG JPEG library)])
|
||||
LIBS="-ljpeg $LIBS"
|
||||
tiff_libs_private="-ljpeg ${tiff_libs_private}"
|
||||
tiff_requires_private="libjpeg ${tiff_requires_private}"
|
||||
|
||||
if test "$HAVE_RPATH" = "yes" -a "x$with_jpeg_lib_dir" != "x" ; then
|
||||
LIBDIR="-R $with_jpeg_lib_dir $LIBDIR"
|
||||
fi
|
||||
|
||||
if test "$HAVE_JPEGTURBO_DUAL_MODE_8_12" = "yes"; then
|
||||
AC_DEFINE(HAVE_JPEGTURBO_DUAL_MODE_8_12,1,[libjpeg-turbo >= 3.0 dual mode enabled])
|
||||
fi
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(HAVE_JPEG, test "$HAVE_JPEG" = 'yes')
|
||||
AM_CONDITIONAL(HAVE_JPEGTURBO_DUAL_MODE_8_12, test "$HAVE_JPEGTURBO_DUAL_MODE_8_12" = 'yes')
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl Check for Old JPEG.
|
||||
@@ -702,6 +740,7 @@ if test "$HAVE_LERC" = "yes" ; then
|
||||
AC_DEFINE(LERC_SUPPORT,1,[Support lerc compression])
|
||||
LIBS="-l${lerc_lib_name} $LIBS"
|
||||
tiff_libs_private="-l${lerc_lib_name} ${tiff_libs_private}"
|
||||
tiff_requires_private="Lerc ${tiff_requires_private}"
|
||||
|
||||
if test "$HAVE_RPATH" = "yes" -a "x$with_lerc_lib_dir" != "x" ; then
|
||||
LIBDIR="-R $with_lerc_lib_dir $LIBDIR"
|
||||
@@ -756,6 +795,7 @@ if test "$HAVE_LZMA" = "yes" ; then
|
||||
AC_DEFINE(LZMA_SUPPORT,1,[Support LZMA2 compression])
|
||||
LIBS="-llzma $LIBS"
|
||||
tiff_libs_private="-llzma ${tiff_libs_private}"
|
||||
tiff_requires_private="liblzma ${tiff_requires_private}"
|
||||
|
||||
if test "$HAVE_RPATH" = "yes" -a "x$with_lzma_lib_dir" != "x" ; then
|
||||
LIBDIR="-R $with_lzma_lib_dir $LIBDIR"
|
||||
@@ -810,6 +850,7 @@ if test "$HAVE_ZSTD" = "yes" ; then
|
||||
AC_DEFINE(ZSTD_SUPPORT,1,[Support zstd compression])
|
||||
LIBS="-lzstd $LIBS"
|
||||
tiff_libs_private="-lzstd ${tiff_libs_private}"
|
||||
tiff_requires_private="libzstd ${tiff_requires_private}"
|
||||
|
||||
if test "$HAVE_RPATH" = "yes" -a "x$with_zstd_lib_dir" != "x" ; then
|
||||
LIBDIR="-R $with_zstd_lib_dir $LIBDIR"
|
||||
@@ -864,6 +905,7 @@ if test "$HAVE_WEBP" = "yes" ; then
|
||||
AC_DEFINE(WEBP_SUPPORT,1,[Support webp compression])
|
||||
LIBS="-lwebp $LIBS"
|
||||
tiff_libs_private="-lwebp ${tiff_libs_private}"
|
||||
tiff_requires_private="libwebp ${tiff_requires_private}"
|
||||
|
||||
if test "$HAVE_RPATH" = "yes" -a "x$with_webp_lib_dir" != "x" ; then
|
||||
LIBDIR="-R $with_webp_lib_dir $LIBDIR"
|
||||
@@ -875,35 +917,38 @@ AM_CONDITIONAL(HAVE_WEBP, test "$HAVE_WEBP" = 'yes')
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl Should 8/12 bit jpeg mode be enabled?
|
||||
dnl This should not be used starting with libjpeg-turbo >= 3.0 that has
|
||||
dnl built-in support for dual mode.
|
||||
dnl ---------------------------------------------------------------------------
|
||||
|
||||
HAVE_JPEG12=no
|
||||
if test "$HAVE_JPEGTURBO_DUAL_MODE_8_12" = "no"; then
|
||||
HAVE_JPEG12=no
|
||||
|
||||
AC_ARG_ENABLE(jpeg12,
|
||||
AS_HELP_STRING([--enable-jpeg12],
|
||||
[enable libjpeg 8/12bit dual mode]),,)
|
||||
AC_ARG_WITH(jpeg12-include-dir,
|
||||
AS_HELP_STRING([--with-jpeg12-include-dir=DIR],
|
||||
[location of libjpeg 12bit headers]),,)
|
||||
AC_ARG_WITH(jpeg12-lib,
|
||||
AS_HELP_STRING([--with-jpeg12-lib=LIBRARY],
|
||||
[path to libjpeg 12bit library]),,)
|
||||
AC_ARG_ENABLE(jpeg12,
|
||||
AS_HELP_STRING([--enable-jpeg12],
|
||||
[enable libjpeg 8/12bit dual mode (not to be used with libjpeg-turbo >= 3.0)]),,)
|
||||
AC_ARG_WITH(jpeg12-include-dir,
|
||||
AS_HELP_STRING([--with-jpeg12-include-dir=DIR],
|
||||
[location of libjpeg 12bit headers]),,)
|
||||
AC_ARG_WITH(jpeg12-lib,
|
||||
AS_HELP_STRING([--with-jpeg12-lib=LIBRARY],
|
||||
[path to libjpeg 12bit library]),,)
|
||||
|
||||
if test "x$enable_jpeg12" = "xyes" ; then
|
||||
if test "x$enable_jpeg12" = "xyes" ; then
|
||||
|
||||
if test "x$with_jpeg12_lib" != "x" ; then
|
||||
LIBS="$with_jpeg12_lib $LIBS"
|
||||
fi
|
||||
|
||||
HAVE_JPEG12=yes
|
||||
if test "x$with_jpeg12_lib" != "x" ; then
|
||||
LIBS="$with_jpeg12_lib $LIBS"
|
||||
fi
|
||||
|
||||
HAVE_JPEG12=yes
|
||||
|
||||
AC_DEFINE(JPEG_DUAL_MODE_8_12,1,[8/12 bit libjpeg dual mode enabled])
|
||||
if test "x$with_jpeg12_include_dir" != "x" ; then
|
||||
AC_DEFINE_UNQUOTED(LIBJPEG_12_PATH,"$with_jpeg12_include_dir/jpeglib.h",[12bit libjpeg primary include file with path])
|
||||
fi
|
||||
AC_DEFINE(JPEG_DUAL_MODE_8_12,1,[8/12 bit libjpeg dual mode enabled])
|
||||
if test "x$with_jpeg12_include_dir" != "x" ; then
|
||||
AC_DEFINE_UNQUOTED(LIBJPEG_12_PATH,"$with_jpeg12_include_dir/jpeglib.h",[12bit libjpeg primary include file with path])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl Check for C++.
|
||||
dnl ---------------------------------------------------------------------------
|
||||
@@ -927,36 +972,42 @@ dnl ---------------------------------------------------------------------------
|
||||
|
||||
HAVE_OPENGL=no
|
||||
|
||||
AC_ARG_ENABLE(opengl,
|
||||
AS_HELP_STRING([--disable-opengl],
|
||||
[disable OpenGL usage (required by tiffgt, enabled by default)]),,)
|
||||
|
||||
AC_PATH_XTRA
|
||||
if test "x$enable_opengl" != "xno" ; then
|
||||
|
||||
dnl AX_CHECK_GL sets GL_CFLAGS & GL_LIBS. Also PTHREAD_LIBS,
|
||||
dnl PTHREAD_CFLAGS, & PTHREAD_CC as a side-effect
|
||||
AX_CHECK_GL
|
||||
AC_PATH_XTRA
|
||||
|
||||
dnl AX_CHECK_GLU sets GLU_CFLAGS & GLU_LIBS
|
||||
AX_CHECK_GLU
|
||||
dnl AX_CHECK_GL sets GL_CFLAGS & GL_LIBS. Also PTHREAD_LIBS,
|
||||
dnl PTHREAD_CFLAGS, & PTHREAD_CC as a side-effect
|
||||
AX_CHECK_GL
|
||||
|
||||
dnl AX_CHECK_GLUT sets GLUT_CFLAGS & GLUT_LIBS
|
||||
AX_CHECK_GLUT
|
||||
dnl AX_CHECK_GLU sets GLU_CFLAGS & GLU_LIBS
|
||||
AX_CHECK_GLU
|
||||
|
||||
if test "$no_x" != "yes" -a "$no_gl" != "yes" \
|
||||
-a "$no_glu" != "yes" -a "$no_glut" != "yes" ; then
|
||||
HAVE_OPENGL=yes
|
||||
dnl AX_CHECK_GLUT sets GLUT_CFLAGS & GLUT_LIBS
|
||||
AX_CHECK_GLUT
|
||||
|
||||
if test "$no_x" != "yes" -a "$no_gl" != "yes" \
|
||||
-a "$no_glu" != "yes" -a "$no_glut" != "yes" ; then
|
||||
HAVE_OPENGL=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(HAVE_OPENGL, test "$HAVE_OPENGL" = "yes")
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl Check for Win32 IO: make sure we have windows.h but not cygwin
|
||||
dnl this must be after the ogl test, since that looks for windows.h and we
|
||||
dnl test it
|
||||
dnl ---------------------------------------------------------------------------
|
||||
|
||||
AC_ARG_ENABLE(win32-io,
|
||||
AS_HELP_STRING([--disable-win32-io],
|
||||
[disable Win32 I/O (Windows only, enabled by default except for Cygwin)]),,)
|
||||
|
||||
AC_CHECK_HEADER(windows.h)
|
||||
|
||||
win32_io_ok=no
|
||||
case "${host_os}" in
|
||||
cygwin*)
|
||||
@@ -1020,6 +1071,20 @@ if test "$HAVE_STRIPCHOP" = "yes" \
|
||||
|
||||
fi
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl Maximum number of TIFF directories that libtiff can browse through
|
||||
dnl ---------------------------------------------------------------------------
|
||||
|
||||
AC_ARG_WITH(max-dir-count,
|
||||
AS_HELP_STRING([--with-max-dir-count=SIZE],
|
||||
[Maximum number of TIFF directories that libtiff can browse through [[default=1048576]]]),,)
|
||||
|
||||
if test "x$with_max_dir_count" = "x" -o "x$with_max_dir_count" = "xyes"; then
|
||||
with_max_dir_count="1048576"
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED(TIFF_MAX_DIR_COUNT,$with_max_dir_count,[Maximum number of TIFF directories that libtiff can browse through])
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl Should we try to defer loading of strip/tile offsets and sizes to
|
||||
dnl optimize directory scanning?
|
||||
@@ -1087,8 +1152,50 @@ if test "$CHECK_JPEG_YCBCR_SUBSAMPLING" = "yes" ; then
|
||||
[Pick up YCbCr subsampling info from the JPEG data stream to support files lacking the tag (default enabled).])
|
||||
fi
|
||||
|
||||
for python in python3.16 python3.15 python3.14 python3.13 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python3 python; do
|
||||
AC_CHECK_PROGS(PYTHON_BIN, [$python])
|
||||
if test "x$PYTHON_BIN" != "x"; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
AC_ARG_ENABLE(sphinx,
|
||||
AS_HELP_STRING([--disable-sphinx],
|
||||
[disable building of the sphinx documentation]),
|
||||
[BUILD_SPHINX=$enableval],
|
||||
[BUILD_SPHINX=yes])
|
||||
|
||||
|
||||
|
||||
AC_PATH_PROG(SPHINX_BUILD, [sphinx-build], [no])
|
||||
|
||||
AM_CONDITIONAL([SPHINX], [test "$BUILD_SPHINX" = yes -a "$SPHINX_BUILD" != no -a "x$PYTHON_BIN" != "x"])
|
||||
|
||||
if test "x$PYTHON_BIN" != "x"; then
|
||||
AC_MSG_CHECKING([generated manual pages])
|
||||
TIFF_MAN1_GEN=$(echo $("$PYTHON_BIN" "${srcdir}/cmake/list-manpages.py" "${srcdir}/doc" man | grep "\.1$"))
|
||||
TIFF_MAN3_GEN=$(echo $("$PYTHON_BIN" "${srcdir}/cmake/list-manpages.py" "${srcdir}/doc" man | grep "\.3tiff$"))
|
||||
TIFF_MAN_RULES=$("$PYTHON_BIN" "${srcdir}/cmake/list-manpages.py" "${srcdir}/doc" man | sed -e 's;$;: all-local;')
|
||||
AC_SUBST([TIFF_MAN1_GEN])
|
||||
AC_SUBST([TIFF_MAN3_GEN])
|
||||
AC_SUBST([TIFF_MAN_RULES])
|
||||
AM_SUBST_NOTMAKE([TIFF_MAN_RULES])
|
||||
AC_MSG_RESULT([done])
|
||||
fi
|
||||
|
||||
if test -d "${srcdir}/doc/man-prebuilt"; then
|
||||
AC_MSG_CHECKING([prebuilt manual pages])
|
||||
TIFF_MAN1_PREBUILT=$(echo $(cd "${srcdir}/doc" && ls -1 man-prebuilt/*.1))
|
||||
TIFF_MAN3_PREBUILT=$(echo $(cd "${srcdir}/doc" && ls -1 man-prebuilt/*.3tiff))
|
||||
AC_SUBST([TIFF_MAN1_PREBUILT])
|
||||
AC_SUBST([TIFF_MAN3_PREBUILT])
|
||||
AC_MSG_RESULT([done])
|
||||
fi
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
|
||||
CFLAGS="$SAVED_CFLAGS"
|
||||
|
||||
AC_SUBST(LIBDIR)
|
||||
|
||||
AC_CONFIG_HEADERS([config/config.h libtiff/tif_config.h libtiff/tiffconf.h port/libport_config.h])
|
||||
@@ -1106,12 +1213,10 @@ AC_CONFIG_FILES([Makefile \
|
||||
contrib/stream/Makefile \
|
||||
contrib/tags/Makefile \
|
||||
contrib/win_dib/Makefile \
|
||||
html/Makefile \
|
||||
html/images/Makefile \
|
||||
html/man/Makefile \
|
||||
doc/Makefile \
|
||||
libtiff-4.pc \
|
||||
libtiff/Makefile \
|
||||
man/Makefile \
|
||||
libtiff/tiffvers.h \
|
||||
port/Makefile \
|
||||
test/Makefile \
|
||||
tools/Makefile])
|
||||
@@ -1124,10 +1229,19 @@ dnl ---------------------------------------------------------------------------
|
||||
LOC_MSG()
|
||||
LOC_MSG([Libtiff is now configured for ${host}])
|
||||
LOC_MSG()
|
||||
LOC_MSG([ Libtiff build version: ${LIBTIFF_VERSION}])
|
||||
LOC_MSG([ Libtiff library version: ${LIBTIFF_VERSION_INFO}])
|
||||
LOC_MSG([ Libtiff release date: ${LIBTIFF_RELEASE_DATE}])
|
||||
LOC_MSG()
|
||||
LOC_MSG([ Installation directory: ${prefix}])
|
||||
LOC_MSG([ Documentation directory: ${LIBTIFF_DOCDIR}])
|
||||
LOC_MSG([ C compiler: ${CC} ${CFLAGS}])
|
||||
LOC_MSG([ C++ compiler: ${CXX} ${CXXFLAGS}])
|
||||
LOC_MSG([ Build tools: ${TIFF_TOOLS}])
|
||||
LOC_MSG([ Build tests: ${TIFF_TESTS}])
|
||||
LOC_MSG([ Build contrib: ${TIFF_CONTRIB}])
|
||||
LOC_MSG([ Build docs: ${TIFF_DOCS}])
|
||||
LOC_MSG([ Build deprecated features: ${enable_deprecated}])
|
||||
LOC_MSG([ Enable runtime linker paths: ${HAVE_RPATH}])
|
||||
LOC_MSG([ Enable linker symbol versioning: ${have_ld_version_script}])
|
||||
LOC_MSG([ Support Microsoft Document Imaging: ${HAVE_MDI}])
|
||||
@@ -1147,7 +1261,11 @@ LOC_MSG([ libdeflate support: ${HAVE_LIBDEFLATE}])
|
||||
LOC_MSG([ Pixar log-format algorithm: ${HAVE_PIXARLOG}])
|
||||
LOC_MSG([ JPEG support: ${HAVE_JPEG}])
|
||||
LOC_MSG([ Old JPEG support: ${HAVE_OJPEG}])
|
||||
LOC_MSG([ JPEG 8/12 bit dual mode: ${HAVE_JPEG12}])
|
||||
if test "$HAVE_JPEGTURBO_DUAL_MODE_8_12" = "yes"; then
|
||||
LOC_MSG([ JPEG 8/12 bit dual mode: ${HAVE_JPEGTURBO_DUAL_MODE_8_12} (libjpeg turbo >= 2.2 dual mode)])
|
||||
else
|
||||
LOC_MSG([ JPEG 8/12 bit dual mode: ${HAVE_JPEG12}])
|
||||
fi
|
||||
LOC_MSG([ ISO JBIG support: ${HAVE_JBIG}])
|
||||
LOC_MSG([ LERC support: ${HAVE_LERC}])
|
||||
LOC_MSG([ LZMA2 support: ${HAVE_LZMA}])
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
# OF THIS SOFTWARE.
|
||||
|
||||
add_executable(addtiffo addtiffo.c tif_overview.c tif_ovrcache.c tif_ovrcache.h)
|
||||
target_link_libraries(addtiffo tiff port)
|
||||
target_link_libraries(addtiffo tiff tiff_port)
|
||||
|
||||
if(WEBP_SUPPORT AND EMSCRIPTEN)
|
||||
# Emscripten is pretty finnicky about linker flags.
|
||||
|
||||
@@ -29,7 +29,9 @@ EXTRA_DIST = \
|
||||
CMakeLists.txt \
|
||||
README
|
||||
|
||||
if TIFF_CONTRIB
|
||||
noinst_PROGRAMS = addtiffo
|
||||
endif
|
||||
|
||||
addtiffo_SOURCES = addtiffo.c tif_overview.c tif_ovrcache.c tif_ovrcache.h
|
||||
addtiffo_LDADD = $(LIBTIFF)
|
||||
|
||||
+51
-56
@@ -59,49 +59,50 @@
|
||||
* New
|
||||
*/
|
||||
|
||||
#include "tiffio.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "tiffio.h"
|
||||
|
||||
void TIFFBuildOverviews( TIFF *, int, int *, int, const char *,
|
||||
int (*)(double,void*), void * );
|
||||
void TIFFBuildOverviews(TIFF *, int, int *, int, const char *,
|
||||
int (*)(double, void *), void *);
|
||||
|
||||
/************************************************************************/
|
||||
/* main() */
|
||||
/************************************************************************/
|
||||
|
||||
int main( int argc, char ** argv )
|
||||
int main(int argc, char **argv)
|
||||
|
||||
{
|
||||
int anOverviews[100]; /* TODO: un-hardwire array length, flexible allocate */
|
||||
int nOverviewCount = 0;
|
||||
int bUseSubIFD = 0;
|
||||
TIFF *hTIFF;
|
||||
const char *pszResampling = "nearest";
|
||||
int anOverviews[100]; /* TODO: un-hardwire array length, flexible allocate
|
||||
*/
|
||||
int nOverviewCount = 0;
|
||||
int bUseSubIFD = 0;
|
||||
TIFF *hTIFF;
|
||||
const char *pszResampling = "nearest";
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Usage: */
|
||||
/* -------------------------------------------------------------------- */
|
||||
if( argc < 2 )
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Usage: */
|
||||
/* -------------------------------------------------------------------- */
|
||||
if (argc < 2)
|
||||
{
|
||||
printf( "Usage: addtiffo [-r {nearest,average,mode}]\n"
|
||||
" tiff_filename [resolution_reductions]\n"
|
||||
"\n"
|
||||
"Example:\n"
|
||||
" %% addtiffo abc.tif 2 4 8 16\n" );
|
||||
return( 1 );
|
||||
printf("Usage: addtiffo [-r {nearest,average,mode}]\n"
|
||||
" tiff_filename [resolution_reductions]\n"
|
||||
"\n"
|
||||
"Example:\n"
|
||||
" %% addtiffo abc.tif 2 4 8 16\n");
|
||||
return (1);
|
||||
}
|
||||
|
||||
while( argv[1][0] == '-' )
|
||||
while (argv[1][0] == '-')
|
||||
{
|
||||
if( strcmp(argv[1],"-subifd") == 0 )
|
||||
if (strcmp(argv[1], "-subifd") == 0)
|
||||
{
|
||||
bUseSubIFD = 1;
|
||||
argv++;
|
||||
argc--;
|
||||
}
|
||||
else if( strcmp(argv[1],"-r") == 0 )
|
||||
else if (strcmp(argv[1], "-r") == 0)
|
||||
{
|
||||
argv += 2;
|
||||
argc -= 2;
|
||||
@@ -109,34 +110,35 @@ int main( int argc, char ** argv )
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( stderr, "Incorrect parameters\n" );
|
||||
return( 1 );
|
||||
fprintf(stderr, "Incorrect parameters\n");
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: resampling mode parameter needs to be encoded in an integer from this point on */
|
||||
/* TODO: resampling mode parameter needs to be encoded in an integer from
|
||||
* this point on */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Collect the user requested reduction factors. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
while( nOverviewCount < argc - 2 && nOverviewCount < 100 )
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Collect the user requested reduction factors. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
while (nOverviewCount < argc - 2 && nOverviewCount < 100)
|
||||
{
|
||||
anOverviews[nOverviewCount] = atoi(argv[nOverviewCount+2]);
|
||||
if( (anOverviews[nOverviewCount] <= 0) ||
|
||||
anOverviews[nOverviewCount] = atoi(argv[nOverviewCount + 2]);
|
||||
if ((anOverviews[nOverviewCount] <= 0) ||
|
||||
((anOverviews[nOverviewCount] > 1024)))
|
||||
{
|
||||
fprintf( stderr, "Incorrect parameters\n" );
|
||||
return(1);
|
||||
fprintf(stderr, "Incorrect parameters\n");
|
||||
return (1);
|
||||
}
|
||||
nOverviewCount++;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Default to four overview levels. It would be nicer if it */
|
||||
/* defaulted based on the size of the source image. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Default to four overview levels. It would be nicer if it */
|
||||
/* defaulted based on the size of the source image. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* TODO: make it default based on the size of the source image */
|
||||
if( nOverviewCount == 0 )
|
||||
if (nOverviewCount == 0)
|
||||
{
|
||||
nOverviewCount = 4;
|
||||
|
||||
@@ -146,20 +148,20 @@ int main( int argc, char ** argv )
|
||||
anOverviews[3] = 16;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Build the overview. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
hTIFF = TIFFOpen( argv[1], "r+" );
|
||||
if( hTIFF == NULL )
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Build the overview. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
hTIFF = TIFFOpen(argv[1], "r+");
|
||||
if (hTIFF == NULL)
|
||||
{
|
||||
fprintf( stderr, "TIFFOpen(%s) failed.\n", argv[1] );
|
||||
return( 1 );
|
||||
fprintf(stderr, "TIFFOpen(%s) failed.\n", argv[1]);
|
||||
return (1);
|
||||
}
|
||||
|
||||
TIFFBuildOverviews( hTIFF, nOverviewCount, anOverviews, bUseSubIFD,
|
||||
pszResampling, NULL, NULL );
|
||||
TIFFBuildOverviews(hTIFF, nOverviewCount, anOverviews, bUseSubIFD,
|
||||
pszResampling, NULL, NULL);
|
||||
|
||||
TIFFClose( hTIFF );
|
||||
TIFFClose(hTIFF);
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Optionally test for memory leaks. */
|
||||
@@ -168,12 +170,5 @@ int main( int argc, char ** argv )
|
||||
malloc_dump(1);
|
||||
#endif
|
||||
|
||||
return( 0 );
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 4
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
+461
-458
File diff suppressed because it is too large
Load Diff
+199
-189
@@ -1,7 +1,7 @@
|
||||
/******************************************************************************
|
||||
* Project: TIFF Overview Builder
|
||||
* Purpose: Library functions to maintain two rows of tiles or two strips
|
||||
* of data for output overviews as an output cache.
|
||||
* of data for output overviews as an output cache.
|
||||
* Author: Frank Warmerdam, warmerdam@pobox.com
|
||||
*
|
||||
******************************************************************************
|
||||
@@ -27,8 +27,8 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "tiffiop.h"
|
||||
#include "tif_ovrcache.h"
|
||||
#include "tiffiop.h"
|
||||
#include <assert.h>
|
||||
|
||||
/************************************************************************/
|
||||
@@ -38,89 +38,95 @@
|
||||
/* existing TIFF directory. */
|
||||
/************************************************************************/
|
||||
|
||||
TIFFOvrCache *TIFFCreateOvrCache( TIFF *hTIFF, toff_t nDirOffset )
|
||||
TIFFOvrCache *TIFFCreateOvrCache(TIFF *hTIFF, toff_t nDirOffset)
|
||||
|
||||
{
|
||||
TIFFOvrCache *psCache;
|
||||
toff_t nBaseDirOffset;
|
||||
TIFFOvrCache *psCache;
|
||||
toff_t nBaseDirOffset;
|
||||
int nRet;
|
||||
|
||||
psCache = (TIFFOvrCache *) _TIFFmalloc(sizeof(TIFFOvrCache));
|
||||
psCache = (TIFFOvrCache *)_TIFFmalloc(sizeof(TIFFOvrCache));
|
||||
psCache->nDirOffset = nDirOffset;
|
||||
psCache->hTIFF = hTIFF;
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Get definition of this raster from the TIFF file itself. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
nBaseDirOffset = TIFFCurrentDirOffset( psCache->hTIFF );
|
||||
TIFFSetSubDirectory( hTIFF, nDirOffset );
|
||||
|
||||
TIFFGetField( hTIFF, TIFFTAG_IMAGEWIDTH, &(psCache->nXSize) );
|
||||
TIFFGetField( hTIFF, TIFFTAG_IMAGELENGTH, &(psCache->nYSize) );
|
||||
|
||||
TIFFGetField( hTIFF, TIFFTAG_BITSPERSAMPLE, &(psCache->nBitsPerPixel) );
|
||||
TIFFGetField( hTIFF, TIFFTAG_SAMPLESPERPIXEL, &(psCache->nSamples) );
|
||||
TIFFGetField( hTIFF, TIFFTAG_PLANARCONFIG, &(psCache->nPlanarConfig) );
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Get definition of this raster from the TIFF file itself. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
nBaseDirOffset = TIFFCurrentDirOffset(psCache->hTIFF);
|
||||
nRet = TIFFSetSubDirectory(hTIFF, nDirOffset);
|
||||
(void)nRet;
|
||||
assert(nRet == 1);
|
||||
|
||||
if( !TIFFIsTiled( hTIFF ) )
|
||||
TIFFGetField(hTIFF, TIFFTAG_IMAGEWIDTH, &(psCache->nXSize));
|
||||
TIFFGetField(hTIFF, TIFFTAG_IMAGELENGTH, &(psCache->nYSize));
|
||||
|
||||
TIFFGetField(hTIFF, TIFFTAG_BITSPERSAMPLE, &(psCache->nBitsPerPixel));
|
||||
TIFFGetField(hTIFF, TIFFTAG_SAMPLESPERPIXEL, &(psCache->nSamples));
|
||||
TIFFGetField(hTIFF, TIFFTAG_PLANARCONFIG, &(psCache->nPlanarConfig));
|
||||
|
||||
if (!TIFFIsTiled(hTIFF))
|
||||
{
|
||||
TIFFGetField( hTIFF, TIFFTAG_ROWSPERSTRIP, &(psCache->nBlockYSize) );
|
||||
TIFFGetField(hTIFF, TIFFTAG_ROWSPERSTRIP, &(psCache->nBlockYSize));
|
||||
psCache->nBlockXSize = psCache->nXSize;
|
||||
psCache->nBytesPerBlock = TIFFStripSize(hTIFF);
|
||||
psCache->bTiled = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
TIFFGetField( hTIFF, TIFFTAG_TILEWIDTH, &(psCache->nBlockXSize) );
|
||||
TIFFGetField( hTIFF, TIFFTAG_TILELENGTH, &(psCache->nBlockYSize) );
|
||||
TIFFGetField(hTIFF, TIFFTAG_TILEWIDTH, &(psCache->nBlockXSize));
|
||||
TIFFGetField(hTIFF, TIFFTAG_TILELENGTH, &(psCache->nBlockYSize));
|
||||
psCache->nBytesPerBlock = TIFFTileSize(hTIFF);
|
||||
psCache->bTiled = TRUE;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Compute some values from this. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Compute some values from this. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
psCache->nBlocksPerRow = (psCache->nXSize + psCache->nBlockXSize - 1)
|
||||
/ psCache->nBlockXSize;
|
||||
psCache->nBlocksPerColumn = (psCache->nYSize + psCache->nBlockYSize - 1)
|
||||
/ psCache->nBlockYSize;
|
||||
psCache->nBlocksPerRow =
|
||||
(psCache->nXSize + psCache->nBlockXSize - 1) / psCache->nBlockXSize;
|
||||
psCache->nBlocksPerColumn =
|
||||
(psCache->nYSize + psCache->nBlockYSize - 1) / psCache->nBlockYSize;
|
||||
|
||||
if (psCache->nPlanarConfig == PLANARCONFIG_SEPARATE)
|
||||
psCache->nBytesPerRow = psCache->nBytesPerBlock
|
||||
* psCache->nBlocksPerRow * psCache->nSamples;
|
||||
psCache->nBytesPerRow = psCache->nBytesPerBlock *
|
||||
psCache->nBlocksPerRow * psCache->nSamples;
|
||||
else
|
||||
psCache->nBytesPerRow =
|
||||
psCache->nBytesPerBlock * psCache->nBlocksPerRow;
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Allocate and initialize the data buffers. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Allocate and initialize the data buffers. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
psCache->pabyRow1Blocks =
|
||||
(unsigned char *) _TIFFmalloc(psCache->nBytesPerRow);
|
||||
(unsigned char *)_TIFFmalloc(psCache->nBytesPerRow);
|
||||
psCache->pabyRow2Blocks =
|
||||
(unsigned char *) _TIFFmalloc(psCache->nBytesPerRow);
|
||||
(unsigned char *)_TIFFmalloc(psCache->nBytesPerRow);
|
||||
|
||||
if ( psCache->pabyRow1Blocks == NULL
|
||||
|| psCache->pabyRow2Blocks == NULL )
|
||||
if (psCache->pabyRow1Blocks == NULL || psCache->pabyRow2Blocks == NULL)
|
||||
{
|
||||
TIFFErrorExt( hTIFF->tif_clientdata, hTIFF->tif_name,
|
||||
"Can't allocate memory for overview cache." );
|
||||
/* TODO: use of TIFFError is inconsistent with use of fprintf in addtiffo.c, sort out */
|
||||
if (psCache->pabyRow1Blocks) _TIFFfree(psCache->pabyRow1Blocks);
|
||||
if (psCache->pabyRow2Blocks) _TIFFfree(psCache->pabyRow2Blocks);
|
||||
_TIFFfree( psCache );
|
||||
TIFFErrorExt(hTIFF->tif_clientdata, hTIFF->tif_name,
|
||||
"Can't allocate memory for overview cache.");
|
||||
/* TODO: use of TIFFError is inconsistent with use of fprintf in
|
||||
* addtiffo.c, sort out */
|
||||
if (psCache->pabyRow1Blocks)
|
||||
_TIFFfree(psCache->pabyRow1Blocks);
|
||||
if (psCache->pabyRow2Blocks)
|
||||
_TIFFfree(psCache->pabyRow2Blocks);
|
||||
_TIFFfree(psCache);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_TIFFmemset( psCache->pabyRow1Blocks, 0, psCache->nBytesPerRow );
|
||||
_TIFFmemset( psCache->pabyRow2Blocks, 0, psCache->nBytesPerRow );
|
||||
_TIFFmemset(psCache->pabyRow1Blocks, 0, psCache->nBytesPerRow);
|
||||
_TIFFmemset(psCache->pabyRow2Blocks, 0, psCache->nBytesPerRow);
|
||||
|
||||
psCache->nBlockOffset = 0;
|
||||
|
||||
TIFFSetSubDirectory( psCache->hTIFF, nBaseDirOffset );
|
||||
|
||||
nRet = TIFFSetSubDirectory(psCache->hTIFF, nBaseDirOffset);
|
||||
(void)nRet;
|
||||
assert(nRet == 1);
|
||||
|
||||
return psCache;
|
||||
}
|
||||
|
||||
@@ -132,130 +138,140 @@ TIFFOvrCache *TIFFCreateOvrCache( TIFF *hTIFF, toff_t nDirOffset )
|
||||
/* down by one block. */
|
||||
/************************************************************************/
|
||||
|
||||
static void TIFFWriteOvrRow( TIFFOvrCache * psCache )
|
||||
static void TIFFWriteOvrRow(TIFFOvrCache *psCache)
|
||||
|
||||
{
|
||||
int nRet, iTileX, iTileY = psCache->nBlockOffset;
|
||||
int nRet, iTileX, iTileY = psCache->nBlockOffset;
|
||||
unsigned char *pabyData;
|
||||
toff_t nBaseDirOffset;
|
||||
uint32_t RowsInStrip;
|
||||
toff_t nBaseDirOffset;
|
||||
uint32_t RowsInStrip;
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* If the output cache is multi-byte per sample, and the file */
|
||||
/* being written to is of a different byte order than the current */
|
||||
/* platform, we will need to byte swap the data. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
if( TIFFIsByteSwapped(psCache->hTIFF) )
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* If the output cache is multi-byte per sample, and the file */
|
||||
/* being written to is of a different byte order than the current */
|
||||
/* platform, we will need to byte swap the data. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
if (TIFFIsByteSwapped(psCache->hTIFF))
|
||||
{
|
||||
if( psCache->nBitsPerPixel == 16 )
|
||||
TIFFSwabArrayOfShort( (uint16_t *) psCache->pabyRow1Blocks,
|
||||
(psCache->nBytesPerBlock * psCache->nSamples) / 2 );
|
||||
if (psCache->nBitsPerPixel == 16)
|
||||
TIFFSwabArrayOfShort((uint16_t *)psCache->pabyRow1Blocks,
|
||||
(psCache->nBytesPerBlock * psCache->nSamples) /
|
||||
2);
|
||||
|
||||
else if( psCache->nBitsPerPixel == 32 )
|
||||
TIFFSwabArrayOfLong( (uint32_t *) psCache->pabyRow1Blocks,
|
||||
(psCache->nBytesPerBlock * psCache->nSamples) / 4 );
|
||||
else if (psCache->nBitsPerPixel == 32)
|
||||
TIFFSwabArrayOfLong((uint32_t *)psCache->pabyRow1Blocks,
|
||||
(psCache->nBytesPerBlock * psCache->nSamples) /
|
||||
4);
|
||||
|
||||
else if( psCache->nBitsPerPixel == 64 )
|
||||
TIFFSwabArrayOfDouble( (double *) psCache->pabyRow1Blocks,
|
||||
(psCache->nBytesPerBlock * psCache->nSamples) / 8 );
|
||||
else if (psCache->nBitsPerPixel == 64)
|
||||
TIFFSwabArrayOfDouble(
|
||||
(double *)psCache->pabyRow1Blocks,
|
||||
(psCache->nBytesPerBlock * psCache->nSamples) / 8);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Record original directory position, so we can restore it at */
|
||||
/* end. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
nBaseDirOffset = TIFFCurrentDirOffset( psCache->hTIFF );
|
||||
nRet = TIFFSetSubDirectory( psCache->hTIFF, psCache->nDirOffset );
|
||||
(void) nRet;
|
||||
assert( nRet == 1 );
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Record original directory position, so we can restore it at */
|
||||
/* end. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
nBaseDirOffset = TIFFCurrentDirOffset(psCache->hTIFF);
|
||||
nRet = TIFFSetSubDirectory(psCache->hTIFF, psCache->nDirOffset);
|
||||
(void)nRet;
|
||||
assert(nRet == 1);
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Write blocks to TIFF file. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
for( iTileX = 0; iTileX < psCache->nBlocksPerRow; iTileX++ )
|
||||
{
|
||||
int nTileID;
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Write blocks to TIFF file. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
for (iTileX = 0; iTileX < psCache->nBlocksPerRow; iTileX++)
|
||||
{
|
||||
int nTileID;
|
||||
|
||||
if (psCache->nPlanarConfig == PLANARCONFIG_SEPARATE)
|
||||
{
|
||||
int iSample;
|
||||
if (psCache->nPlanarConfig == PLANARCONFIG_SEPARATE)
|
||||
{
|
||||
int iSample;
|
||||
|
||||
for( iSample = 0; iSample < psCache->nSamples; iSample++ )
|
||||
{
|
||||
pabyData = TIFFGetOvrBlock( psCache, iTileX, iTileY, iSample );
|
||||
for (iSample = 0; iSample < psCache->nSamples; iSample++)
|
||||
{
|
||||
pabyData = TIFFGetOvrBlock(psCache, iTileX, iTileY, iSample);
|
||||
|
||||
if( psCache->bTiled )
|
||||
{
|
||||
nTileID = TIFFComputeTile( psCache->hTIFF,
|
||||
iTileX * psCache->nBlockXSize,
|
||||
iTileY * psCache->nBlockYSize,
|
||||
0, (tsample_t) iSample );
|
||||
TIFFWriteEncodedTile( psCache->hTIFF, nTileID,
|
||||
pabyData,
|
||||
TIFFTileSize(psCache->hTIFF) );
|
||||
}
|
||||
else
|
||||
{
|
||||
nTileID = TIFFComputeStrip( psCache->hTIFF,
|
||||
iTileY * psCache->nBlockYSize,
|
||||
(tsample_t) iSample );
|
||||
RowsInStrip=psCache->nBlockYSize;
|
||||
if ((iTileY+1)*psCache->nBlockYSize>psCache->nYSize)
|
||||
RowsInStrip=psCache->nYSize-iTileY*psCache->nBlockYSize;
|
||||
TIFFWriteEncodedStrip( psCache->hTIFF, nTileID,
|
||||
pabyData,
|
||||
TIFFVStripSize(psCache->hTIFF,RowsInStrip) );
|
||||
}
|
||||
}
|
||||
if (psCache->bTiled)
|
||||
{
|
||||
nTileID = TIFFComputeTile(
|
||||
psCache->hTIFF, iTileX * psCache->nBlockXSize,
|
||||
iTileY * psCache->nBlockYSize, 0, (tsample_t)iSample);
|
||||
if (TIFFWriteEncodedTile(psCache->hTIFF, nTileID, pabyData,
|
||||
TIFFTileSize(psCache->hTIFF)) < 0)
|
||||
{
|
||||
fprintf(stderr, "TIFFWriteEncodedTile() failed\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nTileID = TIFFComputeStrip(psCache->hTIFF,
|
||||
iTileY * psCache->nBlockYSize,
|
||||
(tsample_t)iSample);
|
||||
RowsInStrip = psCache->nBlockYSize;
|
||||
if ((iTileY + 1) * psCache->nBlockYSize > psCache->nYSize)
|
||||
RowsInStrip =
|
||||
psCache->nYSize - iTileY * psCache->nBlockYSize;
|
||||
if (TIFFWriteEncodedStrip(
|
||||
psCache->hTIFF, nTileID, pabyData,
|
||||
TIFFVStripSize(psCache->hTIFF, RowsInStrip)) < 0)
|
||||
{
|
||||
fprintf(stderr, "TIFFWriteEncodedStrip() failed\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pabyData = TIFFGetOvrBlock(psCache, iTileX, iTileY, 0);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
pabyData = TIFFGetOvrBlock( psCache, iTileX, iTileY, 0 );
|
||||
if (psCache->bTiled)
|
||||
{
|
||||
nTileID = TIFFComputeTile(psCache->hTIFF,
|
||||
iTileX * psCache->nBlockXSize,
|
||||
iTileY * psCache->nBlockYSize, 0, 0);
|
||||
if (TIFFWriteEncodedTile(psCache->hTIFF, nTileID, pabyData,
|
||||
TIFFTileSize(psCache->hTIFF)) < 0)
|
||||
{
|
||||
fprintf(stderr, "TIFFWriteEncodedTile() failed\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nTileID = TIFFComputeStrip(psCache->hTIFF,
|
||||
iTileY * psCache->nBlockYSize, 0);
|
||||
RowsInStrip = psCache->nBlockYSize;
|
||||
if ((iTileY + 1) * psCache->nBlockYSize > psCache->nYSize)
|
||||
RowsInStrip =
|
||||
psCache->nYSize - iTileY * psCache->nBlockYSize;
|
||||
if (TIFFWriteEncodedStrip(
|
||||
psCache->hTIFF, nTileID, pabyData,
|
||||
TIFFVStripSize(psCache->hTIFF, RowsInStrip)) < 0)
|
||||
{
|
||||
fprintf(stderr, "TIFFWriteEncodedStrip() failed\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( psCache->bTiled )
|
||||
{
|
||||
nTileID = TIFFComputeTile( psCache->hTIFF,
|
||||
iTileX * psCache->nBlockXSize,
|
||||
iTileY * psCache->nBlockYSize,
|
||||
0, 0 );
|
||||
TIFFWriteEncodedTile( psCache->hTIFF, nTileID,
|
||||
pabyData,
|
||||
TIFFTileSize(psCache->hTIFF) );
|
||||
}
|
||||
else
|
||||
{
|
||||
nTileID = TIFFComputeStrip( psCache->hTIFF,
|
||||
iTileY * psCache->nBlockYSize,
|
||||
0 );
|
||||
RowsInStrip=psCache->nBlockYSize;
|
||||
if ((iTileY+1)*psCache->nBlockYSize>psCache->nYSize)
|
||||
RowsInStrip=psCache->nYSize-iTileY*psCache->nBlockYSize;
|
||||
TIFFWriteEncodedStrip( psCache->hTIFF, nTileID,
|
||||
pabyData,
|
||||
TIFFVStripSize(psCache->hTIFF,RowsInStrip) );
|
||||
}
|
||||
}
|
||||
}
|
||||
/* TODO: add checks on error status return of TIFFWriteEncodedTile and TIFFWriteEncodedStrip */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Rotate buffers. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Rotate buffers. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
pabyData = psCache->pabyRow1Blocks;
|
||||
psCache->pabyRow1Blocks = psCache->pabyRow2Blocks;
|
||||
psCache->pabyRow2Blocks = pabyData;
|
||||
|
||||
_TIFFmemset( pabyData, 0, psCache->nBytesPerRow );
|
||||
_TIFFmemset(pabyData, 0, psCache->nBytesPerRow);
|
||||
|
||||
psCache->nBlockOffset++;
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Restore access to original directory. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
TIFFFlush( psCache->hTIFF );
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Restore access to original directory. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
TIFFFlush(psCache->hTIFF);
|
||||
/* TODO: add checks on error status return of TIFFFlush */
|
||||
TIFFSetSubDirectory( psCache->hTIFF, nBaseDirOffset );
|
||||
TIFFSetSubDirectory(psCache->hTIFF, nBaseDirOffset);
|
||||
/* TODO: add checks on error status return of TIFFSetSubDirectory */
|
||||
}
|
||||
|
||||
@@ -264,30 +280,31 @@ static void TIFFWriteOvrRow( TIFFOvrCache * psCache )
|
||||
/************************************************************************/
|
||||
|
||||
/* TODO: make TIFF_Downsample handle iSample offset, so that we can
|
||||
* do with a single TIFFGetOvrBlock and no longer need TIFFGetOvrBlock_Subsampled */
|
||||
unsigned char *TIFFGetOvrBlock( TIFFOvrCache *psCache, int iTileX, int iTileY,
|
||||
int iSample )
|
||||
* do with a single TIFFGetOvrBlock and no longer need
|
||||
* TIFFGetOvrBlock_Subsampled */
|
||||
unsigned char *TIFFGetOvrBlock(TIFFOvrCache *psCache, int iTileX, int iTileY,
|
||||
int iSample)
|
||||
|
||||
{
|
||||
long nRowOffset;
|
||||
long nRowOffset;
|
||||
|
||||
if ( iTileY > psCache->nBlockOffset + 1 )
|
||||
TIFFWriteOvrRow( psCache );
|
||||
if (iTileY > psCache->nBlockOffset + 1)
|
||||
TIFFWriteOvrRow(psCache);
|
||||
|
||||
assert( iTileX >= 0 && iTileX < psCache->nBlocksPerRow );
|
||||
assert( iTileY >= 0 && iTileY < psCache->nBlocksPerColumn );
|
||||
assert( iTileY >= psCache->nBlockOffset
|
||||
&& iTileY < psCache->nBlockOffset+2 );
|
||||
assert( iSample >= 0 && iSample < psCache->nSamples );
|
||||
assert(iTileX >= 0 && iTileX < psCache->nBlocksPerRow);
|
||||
assert(iTileY >= 0 && iTileY < psCache->nBlocksPerColumn);
|
||||
assert(iTileY >= psCache->nBlockOffset &&
|
||||
iTileY < psCache->nBlockOffset + 2);
|
||||
assert(iSample >= 0 && iSample < psCache->nSamples);
|
||||
|
||||
if (psCache->nPlanarConfig == PLANARCONFIG_SEPARATE)
|
||||
nRowOffset = ((((toff_t) iTileX * psCache->nSamples) + iSample)
|
||||
* psCache->nBytesPerBlock);
|
||||
nRowOffset = ((((toff_t)iTileX * psCache->nSamples) + iSample) *
|
||||
psCache->nBytesPerBlock);
|
||||
else
|
||||
nRowOffset = iTileX * psCache->nBytesPerBlock +
|
||||
(psCache->nBitsPerPixel + 7) / 8 * iSample;
|
||||
(psCache->nBitsPerPixel + 7) / 8 * iSample;
|
||||
|
||||
if ( iTileY == psCache->nBlockOffset )
|
||||
if (iTileY == psCache->nBlockOffset)
|
||||
return psCache->pabyRow1Blocks + nRowOffset;
|
||||
else
|
||||
return psCache->pabyRow2Blocks + nRowOffset;
|
||||
@@ -297,24 +314,24 @@ unsigned char *TIFFGetOvrBlock( TIFFOvrCache *psCache, int iTileX, int iTileY,
|
||||
/* TIFFGetOvrBlock_Subsampled() */
|
||||
/************************************************************************/
|
||||
|
||||
unsigned char *TIFFGetOvrBlock_Subsampled( TIFFOvrCache *psCache,
|
||||
int iTileX, int iTileY )
|
||||
unsigned char *TIFFGetOvrBlock_Subsampled(TIFFOvrCache *psCache, int iTileX,
|
||||
int iTileY)
|
||||
|
||||
{
|
||||
int nRowOffset;
|
||||
int nRowOffset;
|
||||
|
||||
if( iTileY > psCache->nBlockOffset + 1 )
|
||||
TIFFWriteOvrRow( psCache );
|
||||
if (iTileY > psCache->nBlockOffset + 1)
|
||||
TIFFWriteOvrRow(psCache);
|
||||
|
||||
assert( iTileX >= 0 && iTileX < psCache->nBlocksPerRow );
|
||||
assert( iTileY >= 0 && iTileY < psCache->nBlocksPerColumn );
|
||||
assert( iTileY >= psCache->nBlockOffset
|
||||
&& iTileY < psCache->nBlockOffset+2 );
|
||||
assert( psCache->nPlanarConfig != PLANARCONFIG_SEPARATE );
|
||||
assert(iTileX >= 0 && iTileX < psCache->nBlocksPerRow);
|
||||
assert(iTileY >= 0 && iTileY < psCache->nBlocksPerColumn);
|
||||
assert(iTileY >= psCache->nBlockOffset &&
|
||||
iTileY < psCache->nBlockOffset + 2);
|
||||
assert(psCache->nPlanarConfig != PLANARCONFIG_SEPARATE);
|
||||
|
||||
nRowOffset = iTileX * psCache->nBytesPerBlock;
|
||||
|
||||
if( iTileY == psCache->nBlockOffset )
|
||||
if (iTileY == psCache->nBlockOffset)
|
||||
return psCache->pabyRow1Blocks + nRowOffset;
|
||||
else
|
||||
return psCache->pabyRow2Blocks + nRowOffset;
|
||||
@@ -324,20 +341,13 @@ unsigned char *TIFFGetOvrBlock_Subsampled( TIFFOvrCache *psCache,
|
||||
/* TIFFDestroyOvrCache() */
|
||||
/************************************************************************/
|
||||
|
||||
void TIFFDestroyOvrCache( TIFFOvrCache * psCache )
|
||||
void TIFFDestroyOvrCache(TIFFOvrCache *psCache)
|
||||
|
||||
{
|
||||
while( psCache->nBlockOffset < psCache->nBlocksPerColumn )
|
||||
TIFFWriteOvrRow( psCache );
|
||||
while (psCache->nBlockOffset < psCache->nBlocksPerColumn)
|
||||
TIFFWriteOvrRow(psCache);
|
||||
|
||||
_TIFFfree( psCache->pabyRow1Blocks );
|
||||
_TIFFfree( psCache->pabyRow2Blocks );
|
||||
_TIFFfree( psCache );
|
||||
_TIFFfree(psCache->pabyRow1Blocks);
|
||||
_TIFFfree(psCache->pabyRow2Blocks);
|
||||
_TIFFfree(psCache);
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 4
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
*
|
||||
* Project: TIFF Overview Builder
|
||||
* Purpose: Library functions to maintain two rows of tiles or two strips
|
||||
* of data for output overviews as an output cache.
|
||||
* of data for output overviews as an output cache.
|
||||
* Author: Frank Warmerdam, warmerdam@pobox.com
|
||||
*
|
||||
* This code could potentially be used by other applications wanting to
|
||||
* manage a once-through write cache.
|
||||
* manage a once-through write cache.
|
||||
*
|
||||
******************************************************************************
|
||||
* Copyright (c) 2000, Frank Warmerdam
|
||||
@@ -38,66 +38,58 @@
|
||||
#include "tiffio.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
extern "C"
|
||||
{
|
||||
uint32_t nXSize;
|
||||
uint32_t nYSize;
|
||||
#endif
|
||||
|
||||
uint16_t nBitsPerPixel;
|
||||
uint16_t nSamples;
|
||||
uint16_t nPlanarConfig;
|
||||
uint32_t nBlockXSize;
|
||||
uint32_t nBlockYSize;
|
||||
toff_t nBytesPerBlock;
|
||||
toff_t nBytesPerRow;
|
||||
typedef struct
|
||||
{
|
||||
uint32_t nXSize;
|
||||
uint32_t nYSize;
|
||||
|
||||
int nBlocksPerRow;
|
||||
int nBlocksPerColumn;
|
||||
uint16_t nBitsPerPixel;
|
||||
uint16_t nSamples;
|
||||
uint16_t nPlanarConfig;
|
||||
uint32_t nBlockXSize;
|
||||
uint32_t nBlockYSize;
|
||||
toff_t nBytesPerBlock;
|
||||
toff_t nBytesPerRow;
|
||||
|
||||
int nBlockOffset; /* what block is the first in papabyBlocks? */
|
||||
unsigned char *pabyRow1Blocks;
|
||||
unsigned char *pabyRow2Blocks;
|
||||
int nBlocksPerRow;
|
||||
int nBlocksPerColumn;
|
||||
|
||||
toff_t nDirOffset;
|
||||
TIFF *hTIFF;
|
||||
int bTiled;
|
||||
|
||||
} TIFFOvrCache;
|
||||
int nBlockOffset; /* what block is the first in papabyBlocks? */
|
||||
unsigned char *pabyRow1Blocks;
|
||||
unsigned char *pabyRow2Blocks;
|
||||
|
||||
TIFFOvrCache *TIFFCreateOvrCache( TIFF *hTIFF, toff_t nDirOffset );
|
||||
unsigned char *TIFFGetOvrBlock( TIFFOvrCache *psCache, int iTileX, int iTileY,
|
||||
int iSample );
|
||||
unsigned char *TIFFGetOvrBlock_Subsampled( TIFFOvrCache *psCache, int iTileX, int iTileY );
|
||||
void TIFFDestroyOvrCache( TIFFOvrCache * );
|
||||
toff_t nDirOffset;
|
||||
TIFF *hTIFF;
|
||||
int bTiled;
|
||||
|
||||
void TIFFBuildOverviews( TIFF *, int, int *, int, const char *,
|
||||
int (*)(double,void*), void * );
|
||||
} TIFFOvrCache;
|
||||
|
||||
void TIFF_ProcessFullResBlock( TIFF *, int, int, int, int, int, int *, int,
|
||||
int, TIFFOvrCache **, uint32_t, uint32_t,
|
||||
unsigned char *, uint32_t, uint32_t,
|
||||
int, const char * );
|
||||
TIFFOvrCache *TIFFCreateOvrCache(TIFF *hTIFF, toff_t nDirOffset);
|
||||
unsigned char *TIFFGetOvrBlock(TIFFOvrCache *psCache, int iTileX,
|
||||
int iTileY, int iSample);
|
||||
unsigned char *TIFFGetOvrBlock_Subsampled(TIFFOvrCache *psCache, int iTileX,
|
||||
int iTileY);
|
||||
void TIFFDestroyOvrCache(TIFFOvrCache *);
|
||||
|
||||
uint32_t TIFF_WriteOverview( TIFF *, uint32_t, uint32_t, int, int, int, int, int,
|
||||
int, int, int, int, unsigned short *,
|
||||
unsigned short *, unsigned short *, int,
|
||||
int, int);
|
||||
void TIFFBuildOverviews(TIFF *, int, int *, int, const char *,
|
||||
int (*)(double, void *), void *);
|
||||
|
||||
void TIFF_ProcessFullResBlock(TIFF *, int, int, int, int, int, int *, int,
|
||||
int, TIFFOvrCache **, uint32_t, uint32_t,
|
||||
unsigned char *, uint32_t, uint32_t, int,
|
||||
const char *);
|
||||
|
||||
uint32_t TIFF_WriteOverview(TIFF *, uint32_t, uint32_t, int, int, int, int,
|
||||
int, int, int, int, int, unsigned short *,
|
||||
unsigned short *, unsigned short *, int, int,
|
||||
int);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ndef TIF_OVRCACHE_H_INCLUDED */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
#endif /* ndef TIF_OVRCACHE_H_INCLUDED */
|
||||
|
||||
@@ -23,16 +23,16 @@
|
||||
# OF THIS SOFTWARE.
|
||||
|
||||
add_executable(tiff-bi tiff-bi.c)
|
||||
target_link_libraries(tiff-bi tiff port)
|
||||
target_link_libraries(tiff-bi tiff tiff_port)
|
||||
|
||||
add_executable(tiff-grayscale tiff-grayscale.c)
|
||||
target_link_libraries(tiff-grayscale tiff port CMath::CMath)
|
||||
target_link_libraries(tiff-grayscale tiff tiff_port CMath::CMath)
|
||||
|
||||
add_executable(tiff-palette tiff-palette.c)
|
||||
target_link_libraries(tiff-palette tiff port)
|
||||
target_link_libraries(tiff-palette tiff tiff_port)
|
||||
|
||||
add_executable(tiff-rgb tiff-rgb.c)
|
||||
target_link_libraries(tiff-rgb tiff port CMath::CMath)
|
||||
target_link_libraries(tiff-rgb tiff tiff_port CMath::CMath)
|
||||
|
||||
if(WEBP_SUPPORT AND EMSCRIPTEN)
|
||||
# Emscripten is pretty finnicky about linker flags.
|
||||
|
||||
@@ -31,7 +31,9 @@ EXTRA_DIST = \
|
||||
CMakeLists.txt \
|
||||
README
|
||||
|
||||
if TIFF_CONTRIB
|
||||
noinst_PROGRAMS = tiff-bi tiff-grayscale tiff-palette tiff-rgb
|
||||
endif
|
||||
|
||||
tiff_bi_SOURCES = tiff-bi.c
|
||||
tiff_bi_LDADD = $(LIBTIFF)
|
||||
|
||||
+10
-15
@@ -27,21 +27,23 @@
|
||||
|
||||
#include "tiffio.h"
|
||||
|
||||
#define WIDTH 512
|
||||
#define HEIGHT WIDTH
|
||||
#define WIDTH 512
|
||||
#define HEIGHT WIDTH
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
unsigned char * scan_line;
|
||||
TIFF * tif;
|
||||
int i;
|
||||
unsigned char *scan_line;
|
||||
TIFF *tif;
|
||||
|
||||
if (argc != 2) {
|
||||
if (argc != 2)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s tiff-image\n", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((tif = TIFFOpen(argv[1], "w")) == NULL) {
|
||||
if ((tif = TIFFOpen(argv[1], "w")) == NULL)
|
||||
{
|
||||
fprintf(stderr, "can't open %s as a TIFF file\n", argv[1]);
|
||||
return 0;
|
||||
}
|
||||
@@ -56,7 +58,7 @@ int main(int argc, char **argv)
|
||||
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||
TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE);
|
||||
|
||||
scan_line = (unsigned char *) malloc(WIDTH / 8);
|
||||
scan_line = (unsigned char *)malloc(WIDTH / 8);
|
||||
|
||||
for (i = 0; i < (WIDTH / 8) / 2; i++)
|
||||
scan_line[i] = 0;
|
||||
@@ -80,10 +82,3 @@ int main(int argc, char **argv)
|
||||
TIFFClose(tif);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
@@ -30,20 +30,20 @@
|
||||
|
||||
#include "tiffio.h"
|
||||
|
||||
#define WIDTH 512
|
||||
#define HEIGHT WIDTH
|
||||
#define WIDTH 512
|
||||
#define HEIGHT WIDTH
|
||||
|
||||
char * programName;
|
||||
void Usage();
|
||||
char *programName;
|
||||
void Usage();
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int bits_per_pixel = 8, cmsize, i, j, k,
|
||||
gray_index, chunk_size = 32, nchunks = 16;
|
||||
unsigned char * scan_line;
|
||||
uint16_t * gray;
|
||||
float refblackwhite[2*1];
|
||||
TIFF * tif;
|
||||
int bits_per_pixel = 8, cmsize, i, j, k, gray_index, chunk_size = 32,
|
||||
nchunks = 16;
|
||||
unsigned char *scan_line;
|
||||
uint16_t *gray;
|
||||
float refblackwhite[2 * 1];
|
||||
TIFF *tif;
|
||||
|
||||
programName = argv[0];
|
||||
|
||||
@@ -51,11 +51,12 @@ int main(int argc, char **argv)
|
||||
Usage();
|
||||
|
||||
if (!strcmp(argv[1], "-depth"))
|
||||
bits_per_pixel = atoi(argv[2]);
|
||||
bits_per_pixel = atoi(argv[2]);
|
||||
else
|
||||
Usage();
|
||||
Usage();
|
||||
|
||||
switch (bits_per_pixel) {
|
||||
switch (bits_per_pixel)
|
||||
{
|
||||
case 8:
|
||||
nchunks = 16;
|
||||
chunk_size = 32;
|
||||
@@ -73,18 +74,19 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
cmsize = nchunks * nchunks;
|
||||
gray = (uint16_t *) malloc(cmsize * sizeof(uint16_t));
|
||||
gray = (uint16_t *)malloc(cmsize * sizeof(uint16_t));
|
||||
|
||||
gray[0] = 3000;
|
||||
for (i = 1; i < cmsize; i++)
|
||||
gray[i] = (uint16_t) (-log10((double) i / (cmsize - 1)) * 1000);
|
||||
gray[i] = (uint16_t)(-log10((double)i / (cmsize - 1)) * 1000);
|
||||
|
||||
refblackwhite[0] = 0.0;
|
||||
refblackwhite[1] = (float)((1L<<bits_per_pixel) - 1);
|
||||
refblackwhite[1] = (float)((1L << bits_per_pixel) - 1);
|
||||
|
||||
if ((tif = TIFFOpen(argv[3], "w")) == NULL) {
|
||||
if ((tif = TIFFOpen(argv[3], "w")) == NULL)
|
||||
{
|
||||
fprintf(stderr, "can't open %s as a TIFF file\n", argv[3]);
|
||||
free(gray);
|
||||
free(gray);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -100,26 +102,29 @@ int main(int argc, char **argv)
|
||||
TIFFSetField(tif, TIFFTAG_TRANSFERFUNCTION, gray);
|
||||
TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE);
|
||||
|
||||
scan_line = (unsigned char *) malloc(WIDTH / (8 / bits_per_pixel));
|
||||
scan_line = (unsigned char *)malloc(WIDTH / (8 / bits_per_pixel));
|
||||
|
||||
for (i = 0; i < HEIGHT; i++) {
|
||||
for (j = 0, k = 0; j < WIDTH;) {
|
||||
for (i = 0; i < HEIGHT; i++)
|
||||
{
|
||||
for (j = 0, k = 0; j < WIDTH;)
|
||||
{
|
||||
gray_index = (j / chunk_size) + ((i / chunk_size) * nchunks);
|
||||
|
||||
switch (bits_per_pixel) {
|
||||
case 8:
|
||||
scan_line[k++] = gray_index;
|
||||
j++;
|
||||
break;
|
||||
case 4:
|
||||
scan_line[k++] = (gray_index << 4) + gray_index;
|
||||
j += 2;
|
||||
break;
|
||||
case 2:
|
||||
scan_line[k++] = (gray_index << 6) + (gray_index << 4)
|
||||
+ (gray_index << 2) + gray_index;
|
||||
j += 4;
|
||||
break;
|
||||
switch (bits_per_pixel)
|
||||
{
|
||||
case 8:
|
||||
scan_line[k++] = gray_index;
|
||||
j++;
|
||||
break;
|
||||
case 4:
|
||||
scan_line[k++] = (gray_index << 4) + gray_index;
|
||||
j += 2;
|
||||
break;
|
||||
case 2:
|
||||
scan_line[k++] = (gray_index << 6) + (gray_index << 4) +
|
||||
(gray_index << 2) + gray_index;
|
||||
j += 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
TIFFWriteScanline(tif, scan_line, i, 0);
|
||||
@@ -130,16 +135,8 @@ int main(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
Usage()
|
||||
void Usage()
|
||||
{
|
||||
fprintf(stderr, "Usage: %s -depth (8 | 4 | 2) tiff-image\n", programName);
|
||||
exit(0);
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
+180
-175
@@ -28,20 +28,20 @@
|
||||
|
||||
#include "tiffio.h"
|
||||
|
||||
#define WIDTH 512
|
||||
#define HEIGHT WIDTH
|
||||
#define SCALE(x) ((x) * 257L)
|
||||
#define WIDTH 512
|
||||
#define HEIGHT WIDTH
|
||||
#define SCALE(x) ((x)*257L)
|
||||
|
||||
char * programName;
|
||||
void Usage();
|
||||
char *programName;
|
||||
void Usage();
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int bits_per_pixel = 8, cmsize, i, j, k,
|
||||
cmap_index, chunk_size = 32, nchunks = 16;
|
||||
unsigned char * scan_line;
|
||||
uint16_t *red, *green, *blue;
|
||||
TIFF * tif;
|
||||
int bits_per_pixel = 8, cmsize, i, j, k, cmap_index, chunk_size = 32,
|
||||
nchunks = 16;
|
||||
unsigned char *scan_line;
|
||||
uint16_t *red, *green, *blue;
|
||||
TIFF *tif;
|
||||
|
||||
programName = argv[0];
|
||||
|
||||
@@ -49,11 +49,12 @@ int main(int argc, char **argv)
|
||||
Usage();
|
||||
|
||||
if (!strcmp(argv[1], "-depth"))
|
||||
bits_per_pixel = atoi(argv[2]);
|
||||
bits_per_pixel = atoi(argv[2]);
|
||||
else
|
||||
Usage();
|
||||
Usage();
|
||||
|
||||
switch (bits_per_pixel) {
|
||||
switch (bits_per_pixel)
|
||||
{
|
||||
case 8:
|
||||
nchunks = 16;
|
||||
chunk_size = 32;
|
||||
@@ -66,158 +67,166 @@ int main(int argc, char **argv)
|
||||
nchunks = 2;
|
||||
chunk_size = 256;
|
||||
break;
|
||||
case 1:
|
||||
nchunks = 2;
|
||||
chunk_size = 256;
|
||||
break;
|
||||
case 1:
|
||||
nchunks = 2;
|
||||
chunk_size = 256;
|
||||
break;
|
||||
default:
|
||||
Usage();
|
||||
}
|
||||
|
||||
if (bits_per_pixel != 1) {
|
||||
cmsize = nchunks * nchunks;
|
||||
} else {
|
||||
cmsize = 2;
|
||||
if (bits_per_pixel != 1)
|
||||
{
|
||||
cmsize = nchunks * nchunks;
|
||||
}
|
||||
red = (uint16_t *) malloc(cmsize * sizeof(uint16_t));
|
||||
green = (uint16_t *) malloc(cmsize * sizeof(uint16_t));
|
||||
blue = (uint16_t *) malloc(cmsize * sizeof(uint16_t));
|
||||
else
|
||||
{
|
||||
cmsize = 2;
|
||||
}
|
||||
red = (uint16_t *)malloc(cmsize * sizeof(uint16_t));
|
||||
green = (uint16_t *)malloc(cmsize * sizeof(uint16_t));
|
||||
blue = (uint16_t *)malloc(cmsize * sizeof(uint16_t));
|
||||
|
||||
switch (bits_per_pixel) {
|
||||
case 8:
|
||||
for (i = 0; i < cmsize; i++) {
|
||||
if (i < 32)
|
||||
red[i] = 0;
|
||||
else if (i < 64)
|
||||
red[i] = SCALE(36);
|
||||
else if (i < 96)
|
||||
red[i] = SCALE(73);
|
||||
else if (i < 128)
|
||||
red[i] = SCALE(109);
|
||||
else if (i < 160)
|
||||
red[i] = SCALE(146);
|
||||
else if (i < 192)
|
||||
red[i] = SCALE(182);
|
||||
else if (i < 224)
|
||||
red[i] = SCALE(219);
|
||||
else if (i < 256)
|
||||
red[i] = SCALE(255);
|
||||
switch (bits_per_pixel)
|
||||
{
|
||||
case 8:
|
||||
for (i = 0; i < cmsize; i++)
|
||||
{
|
||||
if (i < 32)
|
||||
red[i] = 0;
|
||||
else if (i < 64)
|
||||
red[i] = SCALE(36);
|
||||
else if (i < 96)
|
||||
red[i] = SCALE(73);
|
||||
else if (i < 128)
|
||||
red[i] = SCALE(109);
|
||||
else if (i < 160)
|
||||
red[i] = SCALE(146);
|
||||
else if (i < 192)
|
||||
red[i] = SCALE(182);
|
||||
else if (i < 224)
|
||||
red[i] = SCALE(219);
|
||||
else if (i < 256)
|
||||
red[i] = SCALE(255);
|
||||
|
||||
if ((i % 32) < 4)
|
||||
green[i] = 0;
|
||||
else if (i < 8)
|
||||
green[i] = SCALE(36);
|
||||
else if ((i % 32) < 12)
|
||||
green[i] = SCALE(73);
|
||||
else if ((i % 32) < 16)
|
||||
green[i] = SCALE(109);
|
||||
else if ((i % 32) < 20)
|
||||
green[i] = SCALE(146);
|
||||
else if ((i % 32) < 24)
|
||||
green[i] = SCALE(182);
|
||||
else if ((i % 32) < 28)
|
||||
green[i] = SCALE(219);
|
||||
else if ((i % 32) < 32)
|
||||
green[i] = SCALE(255);
|
||||
if ((i % 32) < 4)
|
||||
green[i] = 0;
|
||||
else if (i < 8)
|
||||
green[i] = SCALE(36);
|
||||
else if ((i % 32) < 12)
|
||||
green[i] = SCALE(73);
|
||||
else if ((i % 32) < 16)
|
||||
green[i] = SCALE(109);
|
||||
else if ((i % 32) < 20)
|
||||
green[i] = SCALE(146);
|
||||
else if ((i % 32) < 24)
|
||||
green[i] = SCALE(182);
|
||||
else if ((i % 32) < 28)
|
||||
green[i] = SCALE(219);
|
||||
else if ((i % 32) < 32)
|
||||
green[i] = SCALE(255);
|
||||
|
||||
if ((i % 4) == 0)
|
||||
blue[i] = SCALE(0);
|
||||
else if ((i % 4) == 1)
|
||||
blue[i] = SCALE(85);
|
||||
else if ((i % 4) == 2)
|
||||
blue[i] = SCALE(170);
|
||||
else if ((i % 4) == 3)
|
||||
blue[i] = SCALE(255);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
red[0] = SCALE(255);
|
||||
green[0] = 0;
|
||||
blue[0] = 0;
|
||||
if ((i % 4) == 0)
|
||||
blue[i] = SCALE(0);
|
||||
else if ((i % 4) == 1)
|
||||
blue[i] = SCALE(85);
|
||||
else if ((i % 4) == 2)
|
||||
blue[i] = SCALE(170);
|
||||
else if ((i % 4) == 3)
|
||||
blue[i] = SCALE(255);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
red[0] = SCALE(255);
|
||||
green[0] = 0;
|
||||
blue[0] = 0;
|
||||
|
||||
red[1] = 0;
|
||||
green[1] = SCALE(255);
|
||||
blue[1] = 0;
|
||||
red[1] = 0;
|
||||
green[1] = SCALE(255);
|
||||
blue[1] = 0;
|
||||
|
||||
red[2] = 0;
|
||||
green[2] = 0;
|
||||
blue[2] = SCALE(255);
|
||||
red[2] = 0;
|
||||
green[2] = 0;
|
||||
blue[2] = SCALE(255);
|
||||
|
||||
red[3] = SCALE(255);
|
||||
green[3] = SCALE(255);
|
||||
blue[3] = SCALE(255);
|
||||
red[3] = SCALE(255);
|
||||
green[3] = SCALE(255);
|
||||
blue[3] = SCALE(255);
|
||||
|
||||
red[4] = 0;
|
||||
green[4] = SCALE(255);
|
||||
blue[4] = SCALE(255);
|
||||
red[4] = 0;
|
||||
green[4] = SCALE(255);
|
||||
blue[4] = SCALE(255);
|
||||
|
||||
red[5] = SCALE(255);
|
||||
green[5] = 0;
|
||||
blue[5] = SCALE(255);
|
||||
red[5] = SCALE(255);
|
||||
green[5] = 0;
|
||||
blue[5] = SCALE(255);
|
||||
|
||||
red[6] = SCALE(255);
|
||||
green[6] = SCALE(255);
|
||||
blue[6] = 0;
|
||||
red[6] = SCALE(255);
|
||||
green[6] = SCALE(255);
|
||||
blue[6] = 0;
|
||||
|
||||
red[7] = 0;
|
||||
green[7] = 0;
|
||||
blue[7] = 0;
|
||||
red[7] = 0;
|
||||
green[7] = 0;
|
||||
blue[7] = 0;
|
||||
|
||||
red[8] = SCALE(176);
|
||||
green[8] = SCALE(224);
|
||||
blue[8] = SCALE(230);
|
||||
red[9] = SCALE(100);
|
||||
green[9] = SCALE(149);
|
||||
blue[9] = SCALE(237);
|
||||
red[10] = SCALE(46);
|
||||
green[10] = SCALE(139);
|
||||
blue[10] = SCALE(87);
|
||||
red[11] = SCALE(160);
|
||||
green[11] = SCALE(82);
|
||||
blue[11] = SCALE(45);
|
||||
red[12] = SCALE(238);
|
||||
green[12] = SCALE(130);
|
||||
blue[12] = SCALE(238);
|
||||
red[13] = SCALE(176);
|
||||
green[13] = SCALE(48);
|
||||
blue[13] = SCALE(96);
|
||||
red[14] = SCALE(50);
|
||||
green[14] = SCALE(205);
|
||||
blue[14] = SCALE(50);
|
||||
red[15] = SCALE(240);
|
||||
green[15] = SCALE(152);
|
||||
blue[15] = SCALE(35);
|
||||
break;
|
||||
case 2:
|
||||
red[0] = SCALE(255);
|
||||
green[0] = 0;
|
||||
blue[0] = 0;
|
||||
red[8] = SCALE(176);
|
||||
green[8] = SCALE(224);
|
||||
blue[8] = SCALE(230);
|
||||
red[9] = SCALE(100);
|
||||
green[9] = SCALE(149);
|
||||
blue[9] = SCALE(237);
|
||||
red[10] = SCALE(46);
|
||||
green[10] = SCALE(139);
|
||||
blue[10] = SCALE(87);
|
||||
red[11] = SCALE(160);
|
||||
green[11] = SCALE(82);
|
||||
blue[11] = SCALE(45);
|
||||
red[12] = SCALE(238);
|
||||
green[12] = SCALE(130);
|
||||
blue[12] = SCALE(238);
|
||||
red[13] = SCALE(176);
|
||||
green[13] = SCALE(48);
|
||||
blue[13] = SCALE(96);
|
||||
red[14] = SCALE(50);
|
||||
green[14] = SCALE(205);
|
||||
blue[14] = SCALE(50);
|
||||
red[15] = SCALE(240);
|
||||
green[15] = SCALE(152);
|
||||
blue[15] = SCALE(35);
|
||||
break;
|
||||
case 2:
|
||||
red[0] = SCALE(255);
|
||||
green[0] = 0;
|
||||
blue[0] = 0;
|
||||
|
||||
red[1] = 0;
|
||||
green[1] = SCALE(255);
|
||||
blue[1] = 0;
|
||||
red[1] = 0;
|
||||
green[1] = SCALE(255);
|
||||
blue[1] = 0;
|
||||
|
||||
red[2] = 0;
|
||||
green[2] = 0;
|
||||
blue[2] = SCALE(255);
|
||||
red[3] = SCALE(255);
|
||||
green[3] = SCALE(255);
|
||||
blue[3] = SCALE(255);
|
||||
break;
|
||||
case 1:
|
||||
red[0] = 0;
|
||||
green[0] = 0;
|
||||
blue[0] = 0;
|
||||
red[2] = 0;
|
||||
green[2] = 0;
|
||||
blue[2] = SCALE(255);
|
||||
red[3] = SCALE(255);
|
||||
green[3] = SCALE(255);
|
||||
blue[3] = SCALE(255);
|
||||
break;
|
||||
case 1:
|
||||
red[0] = 0;
|
||||
green[0] = 0;
|
||||
blue[0] = 0;
|
||||
|
||||
red[1] = SCALE(255);
|
||||
green[1] = SCALE(255);
|
||||
blue[1] = SCALE(255);
|
||||
break;
|
||||
red[1] = SCALE(255);
|
||||
green[1] = SCALE(255);
|
||||
blue[1] = SCALE(255);
|
||||
break;
|
||||
}
|
||||
|
||||
if ((tif = TIFFOpen(argv[3], "w")) == NULL) {
|
||||
if ((tif = TIFFOpen(argv[3], "w")) == NULL)
|
||||
{
|
||||
fprintf(stderr, "can't open %s as a TIFF file\n", argv[3]);
|
||||
free(red);free(green);free(blue);
|
||||
free(red);
|
||||
free(green);
|
||||
free(blue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -232,31 +241,34 @@ int main(int argc, char **argv)
|
||||
TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE);
|
||||
TIFFSetField(tif, TIFFTAG_COLORMAP, red, green, blue);
|
||||
|
||||
scan_line = (unsigned char *) malloc(WIDTH / (8 / bits_per_pixel));
|
||||
scan_line = (unsigned char *)malloc(WIDTH / (8 / bits_per_pixel));
|
||||
|
||||
for (i = 0; i < HEIGHT; i++) {
|
||||
for (j = 0, k = 0; j < WIDTH;) {
|
||||
for (i = 0; i < HEIGHT; i++)
|
||||
{
|
||||
for (j = 0, k = 0; j < WIDTH;)
|
||||
{
|
||||
cmap_index = (j / chunk_size) + ((i / chunk_size) * nchunks);
|
||||
|
||||
switch (bits_per_pixel) {
|
||||
case 8:
|
||||
scan_line[k++] = cmap_index;
|
||||
j++;
|
||||
break;
|
||||
case 4:
|
||||
scan_line[k++] = (cmap_index << 4) + cmap_index;
|
||||
j += 2;
|
||||
break;
|
||||
case 2:
|
||||
scan_line[k++] = (cmap_index << 6) + (cmap_index << 4)
|
||||
+ (cmap_index << 2) + cmap_index;
|
||||
j += 4;
|
||||
break;
|
||||
case 1:
|
||||
scan_line[k++] =
|
||||
((j / chunk_size) == (i / chunk_size)) ? 0x00 : 0xff;
|
||||
j += 8;
|
||||
break;
|
||||
switch (bits_per_pixel)
|
||||
{
|
||||
case 8:
|
||||
scan_line[k++] = cmap_index;
|
||||
j++;
|
||||
break;
|
||||
case 4:
|
||||
scan_line[k++] = (cmap_index << 4) + cmap_index;
|
||||
j += 2;
|
||||
break;
|
||||
case 2:
|
||||
scan_line[k++] = (cmap_index << 6) + (cmap_index << 4) +
|
||||
(cmap_index << 2) + cmap_index;
|
||||
j += 4;
|
||||
break;
|
||||
case 1:
|
||||
scan_line[k++] =
|
||||
((j / chunk_size) == (i / chunk_size)) ? 0x00 : 0xff;
|
||||
j += 8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
TIFFWriteScanline(tif, scan_line, i, 0);
|
||||
@@ -267,16 +279,9 @@ int main(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
Usage()
|
||||
void Usage()
|
||||
{
|
||||
fprintf(stderr, "Usage: %s -depth (8 | 4 | 2 | 1) tiff-image\n", programName);
|
||||
fprintf(stderr, "Usage: %s -depth (8 | 4 | 2 | 1) tiff-image\n",
|
||||
programName);
|
||||
exit(0);
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
+118
-101
@@ -29,57 +29,66 @@
|
||||
|
||||
#include "tiffio.h"
|
||||
|
||||
#define ROUND(x) (uint16_t) ((x) + 0.5)
|
||||
#define CMSIZE 256
|
||||
#define WIDTH 525
|
||||
#define HEIGHT 512
|
||||
#define TIFF_GAMMA 2.2
|
||||
#define ROUND(x) (uint16_t)((x) + 0.5)
|
||||
#define CMSIZE 256
|
||||
#define WIDTH 525
|
||||
#define HEIGHT 512
|
||||
#define TIFF_GAMMA 2.2
|
||||
|
||||
void Usage();
|
||||
char * programName;
|
||||
void Usage();
|
||||
char *programName;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char * input_file = NULL;
|
||||
double image_gamma = TIFF_GAMMA;
|
||||
int i, j;
|
||||
TIFF * tif;
|
||||
unsigned char * scan_line;
|
||||
uint16_t red[CMSIZE], green[CMSIZE], blue[CMSIZE];
|
||||
float refblackwhite[2*3];
|
||||
char *input_file = NULL;
|
||||
double image_gamma = TIFF_GAMMA;
|
||||
int i, j;
|
||||
TIFF *tif;
|
||||
unsigned char *scan_line;
|
||||
uint16_t red[CMSIZE], green[CMSIZE], blue[CMSIZE];
|
||||
float refblackwhite[2 * 3];
|
||||
|
||||
programName = argv[0];
|
||||
|
||||
switch (argc) {
|
||||
case 2:
|
||||
image_gamma = TIFF_GAMMA;
|
||||
input_file = argv[1];
|
||||
break;
|
||||
case 4:
|
||||
if (!strcmp(argv[1], "-gamma")) {
|
||||
image_gamma = atof(argv[2]);
|
||||
input_file = argv[3];
|
||||
} else
|
||||
switch (argc)
|
||||
{
|
||||
case 2:
|
||||
image_gamma = TIFF_GAMMA;
|
||||
input_file = argv[1];
|
||||
break;
|
||||
case 4:
|
||||
if (!strcmp(argv[1], "-gamma"))
|
||||
{
|
||||
image_gamma = atof(argv[2]);
|
||||
input_file = argv[3];
|
||||
}
|
||||
else
|
||||
Usage();
|
||||
break;
|
||||
default:
|
||||
Usage();
|
||||
break;
|
||||
default:
|
||||
Usage();
|
||||
}
|
||||
|
||||
for (i = 0; i < CMSIZE; i++) {
|
||||
for (i = 0; i < CMSIZE; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
red[i] = green[i] = blue[i] = 0;
|
||||
else {
|
||||
else
|
||||
{
|
||||
red[i] = ROUND((pow(i / 255.0, 1.0 / image_gamma) * 65535.0));
|
||||
green[i] = ROUND((pow(i / 255.0, 1.0 / image_gamma) * 65535.0));
|
||||
blue[i] = ROUND((pow(i / 255.0, 1.0 / image_gamma) * 65535.0));
|
||||
}
|
||||
}
|
||||
refblackwhite[0] = 0.0; refblackwhite[1] = 255.0;
|
||||
refblackwhite[2] = 0.0; refblackwhite[3] = 255.0;
|
||||
refblackwhite[4] = 0.0; refblackwhite[5] = 255.0;
|
||||
refblackwhite[0] = 0.0;
|
||||
refblackwhite[1] = 255.0;
|
||||
refblackwhite[2] = 0.0;
|
||||
refblackwhite[3] = 255.0;
|
||||
refblackwhite[4] = 0.0;
|
||||
refblackwhite[5] = 255.0;
|
||||
|
||||
if ((tif = TIFFOpen(input_file, "w")) == NULL) {
|
||||
if ((tif = TIFFOpen(input_file, "w")) == NULL)
|
||||
{
|
||||
fprintf(stderr, "can't open %s as a TIFF file\n", input_file);
|
||||
exit(0);
|
||||
}
|
||||
@@ -100,81 +109,97 @@ int main(int argc, char **argv)
|
||||
TIFFSetField(tif, TIFFTAG_REFERENCEBLACKWHITE, refblackwhite);
|
||||
TIFFSetField(tif, TIFFTAG_TRANSFERFUNCTION, red, green, blue);
|
||||
|
||||
scan_line = (unsigned char *) malloc(WIDTH * 3);
|
||||
scan_line = (unsigned char *)malloc(WIDTH * 3);
|
||||
|
||||
for (i = 0; i < 255; i++) {
|
||||
for (j = 0; j < 75; j++) {
|
||||
scan_line[j * 3] = 255;
|
||||
scan_line[(j * 3) + 1] = 255 - i;
|
||||
scan_line[(j * 3) + 2] = 255 - i;
|
||||
for (i = 0; i < 255; i++)
|
||||
{
|
||||
for (j = 0; j < 75; j++)
|
||||
{
|
||||
scan_line[j * 3] = 255;
|
||||
scan_line[(j * 3) + 1] = 255 - i;
|
||||
scan_line[(j * 3) + 2] = 255 - i;
|
||||
}
|
||||
for (j = 75; j < 150; j++) {
|
||||
scan_line[j * 3] = 255 - i;
|
||||
scan_line[(j * 3) + 1] = 255;
|
||||
scan_line[(j * 3) + 2] = 255 - i;
|
||||
for (j = 75; j < 150; j++)
|
||||
{
|
||||
scan_line[j * 3] = 255 - i;
|
||||
scan_line[(j * 3) + 1] = 255;
|
||||
scan_line[(j * 3) + 2] = 255 - i;
|
||||
}
|
||||
for (j = 150; j < 225; j++) {
|
||||
scan_line[j * 3] = 255 - i;
|
||||
scan_line[(j * 3) + 1] = 255 - i;
|
||||
scan_line[(j * 3) + 2] = 255;
|
||||
for (j = 150; j < 225; j++)
|
||||
{
|
||||
scan_line[j * 3] = 255 - i;
|
||||
scan_line[(j * 3) + 1] = 255 - i;
|
||||
scan_line[(j * 3) + 2] = 255;
|
||||
}
|
||||
for (j = 225; j < 300; j++) {
|
||||
scan_line[j * 3] = (i - 1) / 2;
|
||||
scan_line[(j * 3) + 1] = (i - 1) / 2;
|
||||
scan_line[(j * 3) + 2] = (i - 1) / 2;
|
||||
for (j = 225; j < 300; j++)
|
||||
{
|
||||
scan_line[j * 3] = (i - 1) / 2;
|
||||
scan_line[(j * 3) + 1] = (i - 1) / 2;
|
||||
scan_line[(j * 3) + 2] = (i - 1) / 2;
|
||||
}
|
||||
for (j = 300; j < 375; j++) {
|
||||
scan_line[j * 3] = 255 - i;
|
||||
scan_line[(j * 3) + 1] = 255;
|
||||
scan_line[(j * 3) + 2] = 255;
|
||||
for (j = 300; j < 375; j++)
|
||||
{
|
||||
scan_line[j * 3] = 255 - i;
|
||||
scan_line[(j * 3) + 1] = 255;
|
||||
scan_line[(j * 3) + 2] = 255;
|
||||
}
|
||||
for (j = 375; j < 450; j++) {
|
||||
scan_line[j * 3] = 255;
|
||||
scan_line[(j * 3) + 1] = 255 - i;
|
||||
scan_line[(j * 3) + 2] = 255;
|
||||
for (j = 375; j < 450; j++)
|
||||
{
|
||||
scan_line[j * 3] = 255;
|
||||
scan_line[(j * 3) + 1] = 255 - i;
|
||||
scan_line[(j * 3) + 2] = 255;
|
||||
}
|
||||
for (j = 450; j < 525; j++) {
|
||||
scan_line[j * 3] = 255;
|
||||
scan_line[(j * 3) + 1] = 255;
|
||||
scan_line[(j * 3) + 2] = 255 - i;
|
||||
for (j = 450; j < 525; j++)
|
||||
{
|
||||
scan_line[j * 3] = 255;
|
||||
scan_line[(j * 3) + 1] = 255;
|
||||
scan_line[(j * 3) + 2] = 255 - i;
|
||||
}
|
||||
TIFFWriteScanline(tif, scan_line, i, 0);
|
||||
}
|
||||
for (i = 255; i < 512; i++) {
|
||||
for (j = 0; j < 75; j++) {
|
||||
scan_line[j * 3] = i;
|
||||
scan_line[(j * 3) + 1] = 0;
|
||||
scan_line[(j * 3) + 2] = 0;
|
||||
for (i = 255; i < 512; i++)
|
||||
{
|
||||
for (j = 0; j < 75; j++)
|
||||
{
|
||||
scan_line[j * 3] = i;
|
||||
scan_line[(j * 3) + 1] = 0;
|
||||
scan_line[(j * 3) + 2] = 0;
|
||||
}
|
||||
for (j = 75; j < 150; j++) {
|
||||
scan_line[j * 3] = 0;
|
||||
scan_line[(j * 3) + 1] = i;
|
||||
scan_line[(j * 3) + 2] = 0;
|
||||
for (j = 75; j < 150; j++)
|
||||
{
|
||||
scan_line[j * 3] = 0;
|
||||
scan_line[(j * 3) + 1] = i;
|
||||
scan_line[(j * 3) + 2] = 0;
|
||||
}
|
||||
for (j = 150; j < 225; j++) {
|
||||
scan_line[j * 3] = 0;
|
||||
scan_line[(j * 3) + 1] = 0;
|
||||
scan_line[(j * 3) + 2] = i;
|
||||
for (j = 150; j < 225; j++)
|
||||
{
|
||||
scan_line[j * 3] = 0;
|
||||
scan_line[(j * 3) + 1] = 0;
|
||||
scan_line[(j * 3) + 2] = i;
|
||||
}
|
||||
for (j = 225; j < 300; j++) {
|
||||
scan_line[j * 3] = (i - 1) / 2;
|
||||
scan_line[(j * 3) + 1] = (i - 1) / 2;
|
||||
scan_line[(j * 3) + 2] = (i - 1) / 2;
|
||||
for (j = 225; j < 300; j++)
|
||||
{
|
||||
scan_line[j * 3] = (i - 1) / 2;
|
||||
scan_line[(j * 3) + 1] = (i - 1) / 2;
|
||||
scan_line[(j * 3) + 2] = (i - 1) / 2;
|
||||
}
|
||||
for (j = 300; j < 375; j++) {
|
||||
scan_line[j * 3] = 0;
|
||||
scan_line[(j * 3) + 1] = i;
|
||||
scan_line[(j * 3) + 2] = i;
|
||||
for (j = 300; j < 375; j++)
|
||||
{
|
||||
scan_line[j * 3] = 0;
|
||||
scan_line[(j * 3) + 1] = i;
|
||||
scan_line[(j * 3) + 2] = i;
|
||||
}
|
||||
for (j = 375; j < 450; j++) {
|
||||
scan_line[j * 3] = i;
|
||||
scan_line[(j * 3) + 1] = 0;
|
||||
scan_line[(j * 3) + 2] = i;
|
||||
for (j = 375; j < 450; j++)
|
||||
{
|
||||
scan_line[j * 3] = i;
|
||||
scan_line[(j * 3) + 1] = 0;
|
||||
scan_line[(j * 3) + 2] = i;
|
||||
}
|
||||
for (j = 450; j < 525; j++) {
|
||||
scan_line[j * 3] = i;
|
||||
scan_line[(j * 3) + 1] = i;
|
||||
scan_line[(j * 3) + 2] = 0;
|
||||
for (j = 450; j < 525; j++)
|
||||
{
|
||||
scan_line[j * 3] = i;
|
||||
scan_line[(j * 3) + 1] = i;
|
||||
scan_line[(j * 3) + 2] = 0;
|
||||
}
|
||||
TIFFWriteScanline(tif, scan_line, i, 0);
|
||||
}
|
||||
@@ -184,16 +209,8 @@ int main(int argc, char **argv)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
Usage()
|
||||
void Usage()
|
||||
{
|
||||
fprintf(stderr, "Usage: %s -gamma gamma tiff-image\n", programName);
|
||||
exit(0);
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
@@ -1,8 +1 @@
|
||||
#define PATCHLEVEL 0
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
+658
-601
File diff suppressed because it is too large
Load Diff
@@ -1,21 +1,14 @@
|
||||
#define xtifficon_width 32
|
||||
#define xtifficon_height 32
|
||||
static char xtifficon_bits[] = {
|
||||
0xff, 0x00, 0x00, 0xc0, 0xfe, 0x01, 0x7e, 0xc0, 0xfc, 0x03, 0x7e, 0x60,
|
||||
0xf8, 0x07, 0x06, 0x30, 0xf8, 0x07, 0x1e, 0x18, 0xf0, 0x0f, 0x1e, 0x0c,
|
||||
0xe0, 0x1f, 0x06, 0x06, 0xc0, 0x3f, 0x06, 0x06, 0xc0, 0x3f, 0x06, 0x03,
|
||||
0x80, 0x7f, 0x80, 0x01, 0x00, 0xff, 0xc0, 0x00, 0x00, 0xfe, 0x61, 0x00,
|
||||
0x00, 0xfe, 0x31, 0x7e, 0x7e, 0xfc, 0x33, 0x7e, 0x7e, 0xf8, 0x1b, 0x06,
|
||||
0x18, 0xf0, 0x0d, 0x1e, 0x18, 0xf0, 0x0e, 0x1e, 0x18, 0x60, 0x1f, 0x06,
|
||||
0x18, 0xb0, 0x3f, 0x06, 0x18, 0x98, 0x7f, 0x06, 0x18, 0x98, 0x7f, 0x00,
|
||||
0x00, 0x0c, 0xff, 0x00, 0x00, 0x06, 0xfe, 0x01, 0x00, 0x63, 0xfc, 0x03,
|
||||
0x80, 0x61, 0xfc, 0x03, 0xc0, 0x60, 0xf8, 0x07, 0xc0, 0x60, 0xf0, 0x0f,
|
||||
0x60, 0x60, 0xe0, 0x1f, 0x30, 0x60, 0xe0, 0x1f, 0x18, 0x60, 0xc0, 0x3f,
|
||||
0x0c, 0x60, 0x80, 0x7f, 0x06, 0x00, 0x00, 0xff};
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
0xff, 0x00, 0x00, 0xc0, 0xfe, 0x01, 0x7e, 0xc0, 0xfc, 0x03, 0x7e, 0x60,
|
||||
0xf8, 0x07, 0x06, 0x30, 0xf8, 0x07, 0x1e, 0x18, 0xf0, 0x0f, 0x1e, 0x0c,
|
||||
0xe0, 0x1f, 0x06, 0x06, 0xc0, 0x3f, 0x06, 0x06, 0xc0, 0x3f, 0x06, 0x03,
|
||||
0x80, 0x7f, 0x80, 0x01, 0x00, 0xff, 0xc0, 0x00, 0x00, 0xfe, 0x61, 0x00,
|
||||
0x00, 0xfe, 0x31, 0x7e, 0x7e, 0xfc, 0x33, 0x7e, 0x7e, 0xf8, 0x1b, 0x06,
|
||||
0x18, 0xf0, 0x0d, 0x1e, 0x18, 0xf0, 0x0e, 0x1e, 0x18, 0x60, 0x1f, 0x06,
|
||||
0x18, 0xb0, 0x3f, 0x06, 0x18, 0x98, 0x7f, 0x06, 0x18, 0x98, 0x7f, 0x00,
|
||||
0x00, 0x0c, 0xff, 0x00, 0x00, 0x06, 0xfe, 0x01, 0x00, 0x63, 0xfc, 0x03,
|
||||
0x80, 0x61, 0xfc, 0x03, 0xc0, 0x60, 0xf8, 0x07, 0xc0, 0x60, 0xf0, 0x0f,
|
||||
0x60, 0x60, 0xe0, 0x1f, 0x30, 0x60, 0xe0, 0x1f, 0x18, 0x60, 0xc0, 0x3f,
|
||||
0x0c, 0x60, 0x80, 0x7f, 0x06, 0x00, 0x00, 0xff};
|
||||
|
||||
@@ -23,4 +23,4 @@
|
||||
# OF THIS SOFTWARE.
|
||||
|
||||
add_executable(iptcutil iptcutil.c)
|
||||
target_link_libraries(iptcutil tiff port)
|
||||
target_link_libraries(iptcutil tiff tiff_port)
|
||||
|
||||
@@ -31,7 +31,9 @@ EXTRA_DIST = \
|
||||
test.iptc \
|
||||
test.txt
|
||||
|
||||
if TIFF_CONTRIB
|
||||
noinst_PROGRAMS = iptcutil
|
||||
endif
|
||||
|
||||
iptcutil_SOURCES = iptcutil.c
|
||||
iptcutil_LDADD = $(LIBTIFF)
|
||||
|
||||
+617
-674
File diff suppressed because it is too large
Load Diff
+76
-89
@@ -5,11 +5,11 @@
|
||||
- as if it were a file.
|
||||
- mfs_ stands for memory file system.
|
||||
- Author : Mike Johnson - Banctec AB 03/07/96
|
||||
-
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
|
||||
Copyright (c) 1996 Mike Johnson
|
||||
Copyright (c) 1996 BancTec AB
|
||||
@@ -21,29 +21,28 @@ all copies of the software and related documentation, and (ii) the names of
|
||||
Mike Johnson and BancTec may not be used in any advertising or
|
||||
publicity relating to the software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
IN NO EVENT SHALL MIKE JOHNSON OR BANCTEC BE LIABLE FOR
|
||||
ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
OF THIS SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
- Includes
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
@@ -51,9 +50,9 @@ OF THIS SOFTWARE.
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define MAX_BUFFS 20
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
#define MAX_BUFFS 20
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
@@ -61,31 +60,30 @@ OF THIS SOFTWARE.
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static char *buf[MAX_BUFFS]; /* Memory for each open buf */
|
||||
static long buf_off[MAX_BUFFS]; /* File pointer for each buf */
|
||||
static long buf_size[MAX_BUFFS]; /* Count of bytes allocated for each buf */
|
||||
static long fds[MAX_BUFFS]; /* File descriptor status */
|
||||
static int buf_mode[MAX_BUFFS]; /* Mode of buffer (r, w, a) */
|
||||
static char *buf[MAX_BUFFS]; /* Memory for each open buf */
|
||||
static long buf_off[MAX_BUFFS]; /* File pointer for each buf */
|
||||
static long buf_size[MAX_BUFFS]; /* Count of bytes allocated for each buf */
|
||||
static long fds[MAX_BUFFS]; /* File descriptor status */
|
||||
static int buf_mode[MAX_BUFFS]; /* Mode of buffer (r, w, a) */
|
||||
|
||||
static int library_init_done = FALSE;
|
||||
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
- Function prototypes
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int mfs_open (void *ptr, int size, char *mode);
|
||||
int mfs_lseek (int fd, int offset, int whence);
|
||||
int mfs_read (int fd, void *buf, int size);
|
||||
int mfs_write (int fd, void *buf, int size);
|
||||
int mfs_size (int fd);
|
||||
int mfs_map (int fd, char **addr, size_t *len);
|
||||
int mfs_unmap (int fd);
|
||||
int mfs_close (int fd);
|
||||
static int extend_mem_file (int fd, int size);
|
||||
static void mem_init ();
|
||||
int mfs_open(void *ptr, int size, char *mode);
|
||||
int mfs_lseek(int fd, int offset, int whence);
|
||||
int mfs_read(int fd, void *buf, int size);
|
||||
int mfs_write(int fd, void *buf, int size);
|
||||
int mfs_size(int fd);
|
||||
int mfs_map(int fd, char **addr, size_t *len);
|
||||
int mfs_unmap(int fd);
|
||||
int mfs_close(int fd);
|
||||
static int extend_mem_file(int fd, int size);
|
||||
static void mem_init();
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
@@ -97,7 +95,7 @@ static void mem_init ();
|
||||
--------------------------------------------------------------------------------
|
||||
- Function : mfs_open ()
|
||||
-
|
||||
- Arguments : Pointer to allocated buffer, initial size of buffer,
|
||||
- Arguments : Pointer to allocated buffer, initial size of buffer,
|
||||
- mode spec (r, w, a)
|
||||
-
|
||||
- Returns : File descriptor or -1 if error.
|
||||
@@ -108,22 +106,22 @@ static void mem_init ();
|
||||
- back to TIFFClientOpen and used as if it was a disk
|
||||
- based fd.
|
||||
- If the call is for mode 'w' then pass (void *)NULL as
|
||||
- the buffer and zero size and the library will
|
||||
- the buffer and zero size and the library will
|
||||
- allocate memory for you.
|
||||
- If the mode is append then pass (void *)NULL and size
|
||||
- zero or with a valid address.
|
||||
-
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int mfs_open (void *buffer, int size, char *mode)
|
||||
int mfs_open(void *buffer, int size, char *mode)
|
||||
{
|
||||
int ret, i;
|
||||
void *tmp;
|
||||
|
||||
if (library_init_done == FALSE)
|
||||
{
|
||||
mem_init ();
|
||||
mem_init();
|
||||
library_init_done = TRUE;
|
||||
}
|
||||
|
||||
@@ -140,7 +138,7 @@ int mfs_open (void *buffer, int size, char *mode)
|
||||
}
|
||||
}
|
||||
|
||||
if (i == MAX_BUFFS) /* No more free descriptors */
|
||||
if (i == MAX_BUFFS) /* No more free descriptors */
|
||||
{
|
||||
ret = -1;
|
||||
errno = EMFILE;
|
||||
@@ -171,7 +169,7 @@ int mfs_open (void *buffer, int size, char *mode)
|
||||
|
||||
else
|
||||
{
|
||||
tmp = malloc (0); /* Get a pointer */
|
||||
tmp = malloc(0); /* Get a pointer */
|
||||
if (tmp == (void *)NULL)
|
||||
{
|
||||
ret = -1;
|
||||
@@ -187,9 +185,9 @@ int mfs_open (void *buffer, int size, char *mode)
|
||||
}
|
||||
else if (ret >= 0 && *mode == 'a')
|
||||
{
|
||||
if (buffer == (void *) NULL) /* Create space for client */
|
||||
if (buffer == (void *)NULL) /* Create space for client */
|
||||
{
|
||||
tmp = malloc (0); /* Get a pointer */
|
||||
tmp = malloc(0); /* Get a pointer */
|
||||
if (tmp == (void *)NULL)
|
||||
{
|
||||
ret = -1;
|
||||
@@ -202,14 +200,14 @@ int mfs_open (void *buffer, int size, char *mode)
|
||||
buf_off[ret] = 0;
|
||||
}
|
||||
}
|
||||
else /* Client has file read in already */
|
||||
else /* Client has file read in already */
|
||||
{
|
||||
buf[ret] = (char *)buffer;
|
||||
buf_size[ret] = size;
|
||||
buf_off[ret] = 0;
|
||||
}
|
||||
}
|
||||
else /* Some other invalid combination of parameters */
|
||||
else /* Some other invalid combination of parameters */
|
||||
{
|
||||
ret = -1;
|
||||
errno = EINVAL;
|
||||
@@ -235,16 +233,16 @@ int mfs_open (void *buffer, int size, char *mode)
|
||||
- Description : Does the same as lseek (2) except on a memory based file.
|
||||
- Note: the memory area will be extended if the caller
|
||||
- attempts to seek past the current end of file (memory).
|
||||
-
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int mfs_lseek (int fd, int offset, int whence)
|
||||
int mfs_lseek(int fd, int offset, int whence)
|
||||
{
|
||||
int ret;
|
||||
long test_off;
|
||||
|
||||
if (fds[fd] == -1) /* Not open */
|
||||
if (fds[fd] == -1) /* Not open */
|
||||
{
|
||||
ret = -1;
|
||||
errno = EBADF;
|
||||
@@ -260,7 +258,7 @@ int mfs_lseek (int fd, int offset, int whence)
|
||||
{
|
||||
case SEEK_SET:
|
||||
if (offset > buf_size[fd])
|
||||
extend_mem_file (fd, offset);
|
||||
extend_mem_file(fd, offset);
|
||||
buf_off[fd] = offset;
|
||||
ret = offset;
|
||||
break;
|
||||
@@ -276,7 +274,7 @@ int mfs_lseek (int fd, int offset, int whence)
|
||||
else
|
||||
{
|
||||
if (test_off > buf_size[fd])
|
||||
extend_mem_file (fd, test_off);
|
||||
extend_mem_file(fd, test_off);
|
||||
buf_off[fd] = test_off;
|
||||
ret = test_off;
|
||||
}
|
||||
@@ -293,7 +291,7 @@ int mfs_lseek (int fd, int offset, int whence)
|
||||
else
|
||||
{
|
||||
if (test_off > buf_size[fd])
|
||||
extend_mem_file (fd, test_off);
|
||||
extend_mem_file(fd, test_off);
|
||||
buf_off[fd] = test_off;
|
||||
ret = test_off;
|
||||
}
|
||||
@@ -307,7 +305,7 @@ int mfs_lseek (int fd, int offset, int whence)
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
@@ -320,11 +318,11 @@ int mfs_lseek (int fd, int offset, int whence)
|
||||
- Description : Does the same as read (2) except on a memory based file.
|
||||
- Note: An attempt to read past the end of memory currently
|
||||
- allocated to the file will return 0 (End Of File)
|
||||
-
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int mfs_read (int fd, void *clnt_buf, int size)
|
||||
int mfs_read(int fd, void *clnt_buf, int size)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -337,11 +335,11 @@ int mfs_read (int fd, void *clnt_buf, int size)
|
||||
}
|
||||
else if (buf_off[fd] + size > buf_size[fd])
|
||||
{
|
||||
ret = 0; /* EOF */
|
||||
ret = 0; /* EOF */
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy (clnt_buf, (void *) (buf[fd] + buf_off[fd]), size);
|
||||
memcpy(clnt_buf, (void *)(buf[fd] + buf_off[fd]), size);
|
||||
buf_off[fd] = buf_off[fd] + size;
|
||||
ret = size;
|
||||
}
|
||||
@@ -360,11 +358,11 @@ int mfs_read (int fd, void *clnt_buf, int size)
|
||||
- Description : Does the same as write (2) except on a memory based file.
|
||||
- Note: the memory area will be extended if the caller
|
||||
- attempts to write past the current end of file (memory).
|
||||
-
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int mfs_write (int fd, void *clnt_buf, int size)
|
||||
int mfs_write(int fd, void *clnt_buf, int size)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -380,12 +378,12 @@ int mfs_write (int fd, void *clnt_buf, int size)
|
||||
/* Write */
|
||||
|
||||
if (buf_off[fd] + size > buf_size[fd])
|
||||
{
|
||||
extend_mem_file (fd, buf_off[fd] + size);
|
||||
{
|
||||
extend_mem_file(fd, buf_off[fd] + size);
|
||||
buf_size[fd] = (buf_off[fd] + size);
|
||||
}
|
||||
|
||||
memcpy ((buf[fd] + buf_off[fd]), clnt_buf, size);
|
||||
memcpy((buf[fd] + buf_off[fd]), clnt_buf, size);
|
||||
buf_off[fd] = buf_off[fd] + size;
|
||||
|
||||
ret = size;
|
||||
@@ -397,10 +395,10 @@ int mfs_write (int fd, void *clnt_buf, int size)
|
||||
if (buf_off[fd] != buf_size[fd])
|
||||
buf_off[fd] = buf_size[fd];
|
||||
|
||||
extend_mem_file (fd, buf_off[fd] + size);
|
||||
extend_mem_file(fd, buf_off[fd] + size);
|
||||
buf_size[fd] += size;
|
||||
|
||||
memcpy ((buf[fd] + buf_off[fd]), clnt_buf, size);
|
||||
memcpy((buf[fd] + buf_off[fd]), clnt_buf, size);
|
||||
buf_off[fd] = buf_off[fd] + size;
|
||||
|
||||
ret = size;
|
||||
@@ -418,15 +416,15 @@ int mfs_write (int fd, void *clnt_buf, int size)
|
||||
- Returns : integer file size
|
||||
-
|
||||
- Description : This function returns the current size of the file in bytes.
|
||||
-
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int mfs_size (int fd)
|
||||
int mfs_size(int fd)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (fds[fd] == -1) /* Not open */
|
||||
if (fds[fd] == -1) /* Not open */
|
||||
{
|
||||
ret = -1;
|
||||
errno = EBADF;
|
||||
@@ -449,15 +447,15 @@ int mfs_size (int fd)
|
||||
- in memory and what size the mapped area is. It is provided
|
||||
- to satisfy the MapProc function in libtiff. It pretends
|
||||
- that the file has been mmap (2)ped.
|
||||
-
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int mfs_map (int fd, char **addr, size_t *len)
|
||||
int mfs_map(int fd, char **addr, size_t *len)
|
||||
{
|
||||
int ret;
|
||||
int ret;
|
||||
|
||||
if (fds[fd] == -1) /* Not open */
|
||||
if (fds[fd] == -1) /* Not open */
|
||||
{
|
||||
ret = -1;
|
||||
errno = EBADF;
|
||||
@@ -482,14 +480,11 @@ int mfs_map (int fd, char **addr, size_t *len)
|
||||
-
|
||||
- Description : This function does nothing as the file is always
|
||||
- in memory.
|
||||
-
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int mfs_unmap (int fd)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
int mfs_unmap(int fd) { return (0); }
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
@@ -500,15 +495,15 @@ int mfs_unmap (int fd)
|
||||
- Returns : close status (succeeded or otherwise)
|
||||
-
|
||||
- Description : Close the open memory file. (Make fd available again.)
|
||||
-
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int mfs_close (int fd)
|
||||
int mfs_close(int fd)
|
||||
{
|
||||
int ret;
|
||||
int ret;
|
||||
|
||||
if (fds[fd] == -1) /* Not open */
|
||||
if (fds[fd] == -1) /* Not open */
|
||||
{
|
||||
ret = -1;
|
||||
errno = EBADF;
|
||||
@@ -531,20 +526,20 @@ int mfs_close (int fd)
|
||||
- Returns : 0 - All OK, -1 - realloc () failed.
|
||||
-
|
||||
- Description : Increase the amount of memory allocated to a file.
|
||||
-
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int extend_mem_file (int fd, int size)
|
||||
static int extend_mem_file(int fd, int size)
|
||||
{
|
||||
void *new_mem;
|
||||
int ret;
|
||||
|
||||
if ((new_mem = realloc (buf[fd], size)) == (void *) NULL)
|
||||
if ((new_mem = realloc(buf[fd], size)) == (void *)NULL)
|
||||
ret = -1;
|
||||
else
|
||||
{
|
||||
buf[fd] = (char *) new_mem;
|
||||
buf[fd] = (char *)new_mem;
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
@@ -560,11 +555,11 @@ static int extend_mem_file (int fd, int size)
|
||||
- Returns : void
|
||||
-
|
||||
- Description : Initialise the library.
|
||||
-
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static void mem_init ()
|
||||
static void mem_init()
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -576,11 +571,3 @@ static void mem_init ()
|
||||
buf_off[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
@@ -28,112 +28,126 @@
|
||||
#include <tiffio.h>
|
||||
#include <tiffio.hxx>
|
||||
|
||||
|
||||
/* stolen from tiffiop.h, which is a private header so we can't just include it */
|
||||
/* stolen from tiffiop.h, which is a private header so we can't just include it
|
||||
*/
|
||||
/* safe multiply returns either the multiplied value or 0 if it overflowed */
|
||||
#define __TIFFSafeMultiply(t,v,m) ((((t)(m) != (t)0) && (((t)(((v)*(m))/(m))) == (t)(v))) ? (t)((v)*(m)) : (t)0)
|
||||
#define __TIFFSafeMultiply(t, v, m) \
|
||||
((((t)(m) != (t)0) && (((t)(((v) * (m)) / (m))) == (t)(v))) \
|
||||
? (t)((v) * (m)) \
|
||||
: (t)0)
|
||||
|
||||
const uint64_t MAX_SIZE = 500000000;
|
||||
|
||||
extern "C" void handle_error(const char *unused, const char *unused2, va_list unused3) {
|
||||
extern "C" void handle_error(const char *unused, const char *unused2,
|
||||
va_list unused3)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
|
||||
{
|
||||
#ifndef STANDALONE
|
||||
TIFFSetErrorHandler(handle_error);
|
||||
TIFFSetWarningHandler(handle_error);
|
||||
TIFFSetErrorHandler(handle_error);
|
||||
TIFFSetWarningHandler(handle_error);
|
||||
#endif
|
||||
#if defined(__has_feature)
|
||||
# if __has_feature(memory_sanitizer)
|
||||
// libjpeg-turbo has issues with MSAN and SIMD code
|
||||
// See https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=7547
|
||||
// and https://github.com/libjpeg-turbo/libjpeg-turbo/pull/365
|
||||
setenv("JSIMD_FORCENONE" ,"1", 1);
|
||||
# endif
|
||||
#if __has_feature(memory_sanitizer)
|
||||
// libjpeg-turbo has issues with MSAN and SIMD code
|
||||
// See https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=7547
|
||||
// and https://github.com/libjpeg-turbo/libjpeg-turbo/pull/365
|
||||
setenv("JSIMD_FORCENONE", "1", 1);
|
||||
#endif
|
||||
std::istringstream s(std::string(Data,Data+Size));
|
||||
TIFF* tif = TIFFStreamOpen("MemTIFF", &s);
|
||||
if (!tif) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t w, h;
|
||||
uint32_t* raster;
|
||||
#endif
|
||||
std::istringstream s(std::string(Data, Data + Size));
|
||||
TIFF *tif = TIFFStreamOpen("MemTIFF", &s);
|
||||
if (!tif)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
uint32_t w, h;
|
||||
uint32_t *raster;
|
||||
|
||||
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
|
||||
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
|
||||
/* don't continue if file size is ludicrous */
|
||||
if (TIFFTileSize64(tif) > MAX_SIZE) {
|
||||
TIFFClose(tif);
|
||||
return 0;
|
||||
}
|
||||
uint64_t bufsize = TIFFTileSize64(tif);
|
||||
/* don't continue if the buffer size greater than the max allowed by the fuzzer */
|
||||
if (bufsize > MAX_SIZE || bufsize == 0) {
|
||||
TIFFClose(tif);
|
||||
return 0;
|
||||
}
|
||||
/* another hack to work around an OOM in tif_fax3.c */
|
||||
uint32_t tilewidth = 0;
|
||||
uint32_t imagewidth = 0;
|
||||
TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tilewidth);
|
||||
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imagewidth);
|
||||
tilewidth = __TIFFSafeMultiply(uint32_t, tilewidth, 2);
|
||||
imagewidth = __TIFFSafeMultiply(uint32_t, imagewidth, 2);
|
||||
if (tilewidth * 2 > MAX_SIZE || imagewidth * 2 > MAX_SIZE || tilewidth == 0 || imagewidth == 0) {
|
||||
TIFFClose(tif);
|
||||
return 0;
|
||||
}
|
||||
uint32_t size = __TIFFSafeMultiply(uint32_t, w, h);
|
||||
if (size > MAX_SIZE || size == 0) {
|
||||
TIFFClose(tif);
|
||||
return 0;
|
||||
}
|
||||
raster = (uint32_t*) _TIFFmalloc(size * sizeof (uint32_t));
|
||||
if (raster != NULL) {
|
||||
TIFFReadRGBAImage(tif, w, h, raster, 0);
|
||||
_TIFFfree(raster);
|
||||
}
|
||||
TIFFClose(tif);
|
||||
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
|
||||
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
|
||||
/* don't continue if file size is ludicrous */
|
||||
if (TIFFTileSize64(tif) > MAX_SIZE)
|
||||
{
|
||||
TIFFClose(tif);
|
||||
return 0;
|
||||
}
|
||||
uint64_t bufsize = TIFFTileSize64(tif);
|
||||
/* don't continue if the buffer size greater than the max allowed by the
|
||||
* fuzzer */
|
||||
if (bufsize > MAX_SIZE || bufsize == 0)
|
||||
{
|
||||
TIFFClose(tif);
|
||||
return 0;
|
||||
}
|
||||
/* another hack to work around an OOM in tif_fax3.c */
|
||||
uint32_t tilewidth = 0;
|
||||
uint32_t imagewidth = 0;
|
||||
TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tilewidth);
|
||||
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imagewidth);
|
||||
tilewidth = __TIFFSafeMultiply(uint32_t, tilewidth, 2);
|
||||
imagewidth = __TIFFSafeMultiply(uint32_t, imagewidth, 2);
|
||||
if (tilewidth * 2 > MAX_SIZE || imagewidth * 2 > MAX_SIZE ||
|
||||
tilewidth == 0 || imagewidth == 0)
|
||||
{
|
||||
TIFFClose(tif);
|
||||
return 0;
|
||||
}
|
||||
uint32_t size = __TIFFSafeMultiply(uint32_t, w, h);
|
||||
if (size > MAX_SIZE || size == 0)
|
||||
{
|
||||
TIFFClose(tif);
|
||||
return 0;
|
||||
}
|
||||
raster = (uint32_t *)_TIFFmalloc(size * sizeof(uint32_t));
|
||||
if (raster != NULL)
|
||||
{
|
||||
TIFFReadRGBAImage(tif, w, h, raster, 0);
|
||||
_TIFFfree(raster);
|
||||
}
|
||||
TIFFClose(tif);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef STANDALONE
|
||||
|
||||
template<class T> static void CPL_IGNORE_RET_VAL(T) {}
|
||||
template <class T> static void CPL_IGNORE_RET_VAL(T) {}
|
||||
|
||||
static void Usage(int, char* argv[])
|
||||
static void Usage(int, char *argv[])
|
||||
{
|
||||
fprintf(stderr, "%s [--help] [-repeat N] filename.\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int nRet = 0;
|
||||
void* buf = NULL;
|
||||
void *buf = NULL;
|
||||
int nLen = 0;
|
||||
int nLoops = 1;
|
||||
const char* pszFilename = NULL;
|
||||
const char *pszFilename = NULL;
|
||||
|
||||
for(int i = 1; i < argc; i++ )
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
if( i + 1 < argc && strcmp(argv[i], "-repeat") == 0 )
|
||||
if (i + 1 < argc && strcmp(argv[i], "-repeat") == 0)
|
||||
{
|
||||
nLoops = atoi(argv[i+1]);
|
||||
nLoops = atoi(argv[i + 1]);
|
||||
i++;
|
||||
}
|
||||
else if( strcmp(argv[i], "-dummy") == 0 )
|
||||
else if (strcmp(argv[i], "-dummy") == 0)
|
||||
{
|
||||
uint8_t dummy = ' ';
|
||||
return LLVMFuzzerTestOneInput(&dummy, 1);
|
||||
}
|
||||
else if( strcmp(argv[i], "--help") == 0 )
|
||||
else if (strcmp(argv[i], "--help") == 0)
|
||||
{
|
||||
Usage(argc, argv);
|
||||
}
|
||||
else if( argv[i][0] == '-' )
|
||||
else if (argv[i][0] == '-')
|
||||
{
|
||||
fprintf(stderr, "Unrecognized option: %s", argv[i]);
|
||||
Usage(argc, argv);
|
||||
@@ -143,13 +157,13 @@ int main(int argc, char* argv[])
|
||||
pszFilename = argv[i];
|
||||
}
|
||||
}
|
||||
if( pszFilename == nullptr )
|
||||
if (pszFilename == nullptr)
|
||||
{
|
||||
fprintf(stderr, "No filename specified\n");
|
||||
Usage(argc, argv);
|
||||
}
|
||||
FILE* f = fopen(pszFilename, "rb");
|
||||
if( !f )
|
||||
FILE *f = fopen(pszFilename, "rb");
|
||||
if (!f)
|
||||
{
|
||||
fprintf(stderr, "%s does not exist.\n", pszFilename);
|
||||
exit(1);
|
||||
@@ -158,7 +172,7 @@ int main(int argc, char* argv[])
|
||||
nLen = (int)ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
buf = malloc(nLen);
|
||||
if( !buf )
|
||||
if (!buf)
|
||||
{
|
||||
fprintf(stderr, "malloc failed.\n");
|
||||
fclose(f);
|
||||
@@ -166,10 +180,10 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
CPL_IGNORE_RET_VAL(fread(buf, nLen, 1, f));
|
||||
fclose(f);
|
||||
for( int i = 0; i < nLoops; i++ )
|
||||
for (int i = 0; i < nLoops; i++)
|
||||
{
|
||||
nRet = LLVMFuzzerTestOneInput(static_cast<const uint8_t*>(buf), nLen);
|
||||
if( nRet != 0 )
|
||||
nRet = LLVMFuzzerTestOneInput(static_cast<const uint8_t *>(buf), nLen);
|
||||
if (nRet != 0)
|
||||
break;
|
||||
}
|
||||
free(buf);
|
||||
|
||||
+335
-294
@@ -2,23 +2,23 @@
|
||||
* Copyright (c) 1991-1996 Sam Leffler
|
||||
* Copyright (c) 1991-1996 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -34,43 +34,41 @@
|
||||
* ignore those details. The calling program does, however, need to be
|
||||
* conscious of the type of the pixel data that it is receiving.
|
||||
*
|
||||
* For reasons of efficiency, the callback function actually gets called for
|
||||
* For reasons of efficiency, the callback function actually gets called for
|
||||
* "blocks" of pixels rather than for individual pixels. The format of the
|
||||
* callback arguments is given below.
|
||||
*
|
||||
* This code was taken from TIFFReadRGBAImage() in tif_getimage.c of the original
|
||||
* TIFF distribution, and simplified and generalized to provide this general
|
||||
* iteration capability. Those routines could certainly be re-implemented in terms
|
||||
* of a TIFFImageIter if desired.
|
||||
* This code was taken from TIFFReadRGBAImage() in tif_getimage.c of the
|
||||
* original TIFF distribution, and simplified and generalized to provide this
|
||||
* general iteration capability. Those routines could certainly be
|
||||
* re-implemented in terms of a TIFFImageIter if desired.
|
||||
*
|
||||
*/
|
||||
#include "tiffiop.h"
|
||||
#include "tif_imageiter.h"
|
||||
#include "tiffiop.h"
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static int gtTileContig(TIFFImageIter*, void *udata, uint32_t, uint32_t);
|
||||
static int gtTileSeparate(TIFFImageIter*, void *udata, uint32_t, uint32_t);
|
||||
static int gtStripContig(TIFFImageIter*, void *udata, uint32_t, uint32_t);
|
||||
static int gtStripSeparate(TIFFImageIter*, void *udata, uint32_t, uint32_t);
|
||||
static int gtTileContig(TIFFImageIter *, void *udata, uint32_t, uint32_t);
|
||||
static int gtTileSeparate(TIFFImageIter *, void *udata, uint32_t, uint32_t);
|
||||
static int gtStripContig(TIFFImageIter *, void *udata, uint32_t, uint32_t);
|
||||
static int gtStripSeparate(TIFFImageIter *, void *udata, uint32_t, uint32_t);
|
||||
|
||||
static const char photoTag[] = "PhotometricInterpretation";
|
||||
static const char photoTag[] = "PhotometricInterpretation";
|
||||
|
||||
static int
|
||||
isCCITTCompression(TIFF* tif)
|
||||
static int isCCITTCompression(TIFF *tif)
|
||||
{
|
||||
uint16_t compress;
|
||||
TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress);
|
||||
return (compress == COMPRESSION_CCITTFAX3 ||
|
||||
compress == COMPRESSION_CCITTFAX4 ||
|
||||
compress == COMPRESSION_CCITTRLE ||
|
||||
compress == COMPRESSION_CCITTRLEW);
|
||||
compress == COMPRESSION_CCITTFAX4 ||
|
||||
compress == COMPRESSION_CCITTRLE ||
|
||||
compress == COMPRESSION_CCITTRLEW);
|
||||
}
|
||||
|
||||
int
|
||||
TIFFImageIterBegin(TIFFImageIter* img, TIFF* tif, int stop, char emsg[1024])
|
||||
int TIFFImageIterBegin(TIFFImageIter *img, TIFF *tif, int stop, char emsg[1024])
|
||||
{
|
||||
uint16_t* sampleinfo;
|
||||
uint16_t *sampleinfo;
|
||||
uint16_t extrasamples;
|
||||
uint16_t planarconfig;
|
||||
int colorchannels;
|
||||
@@ -80,217 +78,244 @@ TIFFImageIterBegin(TIFFImageIter* img, TIFF* tif, int stop, char emsg[1024])
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &img->bitspersample);
|
||||
img->alpha = 0;
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &img->samplesperpixel);
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES,
|
||||
&extrasamples, &sampleinfo);
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES, &extrasamples,
|
||||
&sampleinfo);
|
||||
if (extrasamples == 1)
|
||||
switch (sampleinfo[0]) {
|
||||
case EXTRASAMPLE_ASSOCALPHA: /* data is pre-multiplied */
|
||||
case EXTRASAMPLE_UNASSALPHA: /* data is not pre-multiplied */
|
||||
img->alpha = sampleinfo[0];
|
||||
break;
|
||||
}
|
||||
switch (sampleinfo[0])
|
||||
{
|
||||
case EXTRASAMPLE_ASSOCALPHA: /* data is pre-multiplied */
|
||||
case EXTRASAMPLE_UNASSALPHA: /* data is not pre-multiplied */
|
||||
img->alpha = sampleinfo[0];
|
||||
break;
|
||||
}
|
||||
colorchannels = img->samplesperpixel - extrasamples;
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarconfig);
|
||||
if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric)) {
|
||||
switch (colorchannels) {
|
||||
case 1:
|
||||
if (isCCITTCompression(tif))
|
||||
img->photometric = PHOTOMETRIC_MINISWHITE;
|
||||
else
|
||||
img->photometric = PHOTOMETRIC_MINISBLACK;
|
||||
break;
|
||||
case 3:
|
||||
img->photometric = PHOTOMETRIC_RGB;
|
||||
break;
|
||||
default:
|
||||
sprintf(emsg, "Missing needed %s tag", photoTag);
|
||||
return (0);
|
||||
}
|
||||
if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric))
|
||||
{
|
||||
switch (colorchannels)
|
||||
{
|
||||
case 1:
|
||||
if (isCCITTCompression(tif))
|
||||
img->photometric = PHOTOMETRIC_MINISWHITE;
|
||||
else
|
||||
img->photometric = PHOTOMETRIC_MINISBLACK;
|
||||
break;
|
||||
case 3:
|
||||
img->photometric = PHOTOMETRIC_RGB;
|
||||
break;
|
||||
default:
|
||||
sprintf(emsg, "Missing needed %s tag", photoTag);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
switch (img->photometric) {
|
||||
case PHOTOMETRIC_PALETTE:
|
||||
if (!TIFFGetField(tif, TIFFTAG_COLORMAP,
|
||||
&img->redcmap, &img->greencmap, &img->bluecmap)) {
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Missing required \"Colormap\" tag");
|
||||
return (0);
|
||||
}
|
||||
/* fall through... */
|
||||
case PHOTOMETRIC_MINISWHITE:
|
||||
case PHOTOMETRIC_MINISBLACK:
|
||||
/* This should work now so skip the check - BSR
|
||||
if (planarconfig == PLANARCONFIG_CONTIG && img->samplesperpixel != 1) {
|
||||
sprintf(emsg,
|
||||
"Sorry, can not handle contiguous data with %s=%d, and %s=%d",
|
||||
photoTag, img->photometric,
|
||||
"Samples/pixel", img->samplesperpixel);
|
||||
return (0);
|
||||
}
|
||||
*/
|
||||
break;
|
||||
case PHOTOMETRIC_YCBCR:
|
||||
if (planarconfig != PLANARCONFIG_CONTIG) {
|
||||
sprintf(emsg, "Sorry, can not handle YCbCr images with %s=%d",
|
||||
"Planarconfiguration", planarconfig);
|
||||
return (0);
|
||||
}
|
||||
/* It would probably be nice to have a reality check here. */
|
||||
{ uint16_t compress;
|
||||
TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress);
|
||||
if (compress == COMPRESSION_JPEG && planarconfig == PLANARCONFIG_CONTIG) {
|
||||
/* can rely on libjpeg to convert to RGB */
|
||||
/* XXX should restore current state on exit */
|
||||
TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB);
|
||||
img->photometric = PHOTOMETRIC_RGB;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PHOTOMETRIC_RGB:
|
||||
if (colorchannels < 3) {
|
||||
sprintf(emsg, "Sorry, can not handle RGB image with %s=%d",
|
||||
"Color channels", colorchannels);
|
||||
return (0);
|
||||
}
|
||||
break;
|
||||
case PHOTOMETRIC_SEPARATED: {
|
||||
uint16_t inkset;
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset);
|
||||
if (inkset != INKSET_CMYK) {
|
||||
sprintf(emsg, "Sorry, can not handle separated image with %s=%d",
|
||||
"InkSet", inkset);
|
||||
return (0);
|
||||
}
|
||||
if (img->samplesperpixel != 4) {
|
||||
sprintf(emsg, "Sorry, can not handle separated image with %s=%d",
|
||||
"Samples/pixel", img->samplesperpixel);
|
||||
return (0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sprintf(emsg, "Sorry, can not handle image with %s=%d",
|
||||
photoTag, img->photometric);
|
||||
return (0);
|
||||
switch (img->photometric)
|
||||
{
|
||||
case PHOTOMETRIC_PALETTE:
|
||||
if (!TIFFGetField(tif, TIFFTAG_COLORMAP, &img->redcmap,
|
||||
&img->greencmap, &img->bluecmap))
|
||||
{
|
||||
TIFFErrorExtR(tif, TIFFFileName(tif),
|
||||
"Missing required \"Colormap\" tag");
|
||||
return (0);
|
||||
}
|
||||
/* fall through... */
|
||||
case PHOTOMETRIC_MINISWHITE:
|
||||
case PHOTOMETRIC_MINISBLACK:
|
||||
/* This should work now so skip the check - BSR
|
||||
if (planarconfig == PLANARCONFIG_CONTIG &&
|
||||
img->samplesperpixel != 1) { sprintf(emsg, "Sorry, can not handle
|
||||
contiguous data with %s=%d, and %s=%d", photoTag,
|
||||
img->photometric, "Samples/pixel", img->samplesperpixel); return
|
||||
(0);
|
||||
}
|
||||
*/
|
||||
break;
|
||||
case PHOTOMETRIC_YCBCR:
|
||||
if (planarconfig != PLANARCONFIG_CONTIG)
|
||||
{
|
||||
sprintf(emsg, "Sorry, can not handle YCbCr images with %s=%d",
|
||||
"Planarconfiguration", planarconfig);
|
||||
return (0);
|
||||
}
|
||||
/* It would probably be nice to have a reality check here. */
|
||||
{
|
||||
uint16_t compress;
|
||||
TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress);
|
||||
if (compress == COMPRESSION_JPEG &&
|
||||
planarconfig == PLANARCONFIG_CONTIG)
|
||||
{
|
||||
/* can rely on libjpeg to convert to RGB */
|
||||
/* XXX should restore current state on exit */
|
||||
TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB);
|
||||
img->photometric = PHOTOMETRIC_RGB;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PHOTOMETRIC_RGB:
|
||||
if (colorchannels < 3)
|
||||
{
|
||||
sprintf(emsg, "Sorry, can not handle RGB image with %s=%d",
|
||||
"Color channels", colorchannels);
|
||||
return (0);
|
||||
}
|
||||
break;
|
||||
case PHOTOMETRIC_SEPARATED:
|
||||
{
|
||||
uint16_t inkset;
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset);
|
||||
if (inkset != INKSET_CMYK)
|
||||
{
|
||||
sprintf(emsg,
|
||||
"Sorry, can not handle separated image with %s=%d",
|
||||
"InkSet", inkset);
|
||||
return (0);
|
||||
}
|
||||
if (img->samplesperpixel != 4)
|
||||
{
|
||||
sprintf(emsg,
|
||||
"Sorry, can not handle separated image with %s=%d",
|
||||
"Samples/pixel", img->samplesperpixel);
|
||||
return (0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sprintf(emsg, "Sorry, can not handle image with %s=%d", photoTag,
|
||||
img->photometric);
|
||||
return (0);
|
||||
}
|
||||
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &img->width);
|
||||
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &img->height);
|
||||
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_ORIENTATION, &img->orientation);
|
||||
switch (img->orientation) {
|
||||
case ORIENTATION_BOTRIGHT:
|
||||
case ORIENTATION_RIGHTBOT: /* XXX */
|
||||
case ORIENTATION_LEFTBOT: /* XXX */
|
||||
TIFFWarning(TIFFFileName(tif), "using bottom-left orientation");
|
||||
img->orientation = ORIENTATION_BOTLEFT;
|
||||
/* fall through... */
|
||||
case ORIENTATION_BOTLEFT:
|
||||
break;
|
||||
case ORIENTATION_TOPRIGHT:
|
||||
case ORIENTATION_RIGHTTOP: /* XXX */
|
||||
case ORIENTATION_LEFTTOP: /* XXX */
|
||||
default:
|
||||
TIFFWarning(TIFFFileName(tif), "using top-left orientation");
|
||||
img->orientation = ORIENTATION_TOPLEFT;
|
||||
/* fall through... */
|
||||
case ORIENTATION_TOPLEFT:
|
||||
break;
|
||||
switch (img->orientation)
|
||||
{
|
||||
case ORIENTATION_BOTRIGHT:
|
||||
case ORIENTATION_RIGHTBOT: /* XXX */
|
||||
case ORIENTATION_LEFTBOT: /* XXX */
|
||||
TIFFWarning(TIFFFileName(tif), "using bottom-left orientation");
|
||||
img->orientation = ORIENTATION_BOTLEFT;
|
||||
/* fall through... */
|
||||
case ORIENTATION_BOTLEFT:
|
||||
break;
|
||||
case ORIENTATION_TOPRIGHT:
|
||||
case ORIENTATION_RIGHTTOP: /* XXX */
|
||||
case ORIENTATION_LEFTTOP: /* XXX */
|
||||
default:
|
||||
TIFFWarning(TIFFFileName(tif), "using top-left orientation");
|
||||
img->orientation = ORIENTATION_TOPLEFT;
|
||||
/* fall through... */
|
||||
case ORIENTATION_TOPLEFT:
|
||||
break;
|
||||
}
|
||||
|
||||
img->isContig =
|
||||
!(planarconfig == PLANARCONFIG_SEPARATE && colorchannels > 1);
|
||||
if (img->isContig) {
|
||||
img->get = TIFFIsTiled(tif) ? gtTileContig : gtStripContig;
|
||||
} else {
|
||||
img->get = TIFFIsTiled(tif) ? gtTileSeparate : gtStripSeparate;
|
||||
!(planarconfig == PLANARCONFIG_SEPARATE && colorchannels > 1);
|
||||
if (img->isContig)
|
||||
{
|
||||
img->get = TIFFIsTiled(tif) ? gtTileContig : gtStripContig;
|
||||
}
|
||||
else
|
||||
{
|
||||
img->get = TIFFIsTiled(tif) ? gtTileSeparate : gtStripSeparate;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
int
|
||||
TIFFImageIterGet(TIFFImageIter* img, void *udata, uint32_t w, uint32_t h)
|
||||
int TIFFImageIterGet(TIFFImageIter *img, void *udata, uint32_t w, uint32_t h)
|
||||
{
|
||||
if (img->get == NULL) {
|
||||
TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif), "No \"get\" routine setup");
|
||||
return (0);
|
||||
if (img->get == NULL)
|
||||
{
|
||||
TIFFErrorExtR(img->tif, TIFFFileName(img->tif),
|
||||
"No \"get\" routine setup");
|
||||
return (0);
|
||||
}
|
||||
if (img->callback.any == NULL) {
|
||||
TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif),
|
||||
"No \"put\" routine setupl; probably can not handle image format");
|
||||
return (0);
|
||||
if (img->callback.any == NULL)
|
||||
{
|
||||
TIFFErrorExtR(
|
||||
img->tif, TIFFFileName(img->tif),
|
||||
"No \"put\" routine setupl; probably can not handle image format");
|
||||
return (0);
|
||||
}
|
||||
return (*img->get)(img, udata, w, h);
|
||||
}
|
||||
|
||||
TIFFImageIterEnd(TIFFImageIter* img)
|
||||
{
|
||||
/* Nothing to free... ? */
|
||||
TIFFImageIterEnd(TIFFImageIter *img)
|
||||
{ /* Nothing to free... ? */
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the specified image into an ABGR-format raster.
|
||||
*/
|
||||
int
|
||||
TIFFReadImageIter(TIFF* tif,
|
||||
uint32_t rwidth, uint32_t rheight, uint8_t* raster, int stop)
|
||||
int TIFFReadImageIter(TIFF *tif, uint32_t rwidth, uint32_t rheight,
|
||||
uint8_t *raster, int stop)
|
||||
{
|
||||
char emsg[1024];
|
||||
TIFFImageIter img;
|
||||
int ok;
|
||||
|
||||
if (TIFFImageIterBegin(&img, tif, stop, emsg)) {
|
||||
/* XXX verify rwidth and rheight against width and height */
|
||||
ok = TIFFImageIterGet(&img, raster, rwidth, img.height);
|
||||
TIFFImageIterEnd(&img);
|
||||
} else {
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), emsg);
|
||||
ok = 0;
|
||||
if (TIFFImageIterBegin(&img, tif, stop, emsg))
|
||||
{
|
||||
/* XXX verify rwidth and rheight against width and height */
|
||||
ok = TIFFImageIterGet(&img, raster, rwidth, img.height);
|
||||
TIFFImageIterEnd(&img);
|
||||
}
|
||||
else
|
||||
{
|
||||
TIFFErrorExtR(tif, TIFFFileName(tif), emsg);
|
||||
ok = 0;
|
||||
}
|
||||
return (ok);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get an tile-organized image that has
|
||||
* PlanarConfiguration contiguous if SamplesPerPixel > 1
|
||||
* or
|
||||
* SamplesPerPixel == 1
|
||||
*/
|
||||
static int
|
||||
gtTileContig(TIFFImageIter* img, void *udata, uint32_t w, uint32_t h)
|
||||
*/
|
||||
static int gtTileContig(TIFFImageIter *img, void *udata, uint32_t w, uint32_t h)
|
||||
{
|
||||
TIFF* tif = img->tif;
|
||||
TIFF *tif = img->tif;
|
||||
ImageIterTileContigRoutine callback = img->callback.contig;
|
||||
uint16_t orientation;
|
||||
uint32_t col, row;
|
||||
uint32_t tw, th;
|
||||
u_char* buf;
|
||||
u_char *buf;
|
||||
int32_t fromskew;
|
||||
uint32_t nrow;
|
||||
|
||||
buf = (u_char*) _TIFFmalloc(TIFFTileSize(tif));
|
||||
if (buf == 0) {
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for tile buffer");
|
||||
return (0);
|
||||
buf = (u_char *)_TIFFmalloc(TIFFTileSize(tif));
|
||||
if (buf == 0)
|
||||
{
|
||||
TIFFErrorExtR(tif, TIFFFileName(tif), "No space for tile buffer");
|
||||
return (0);
|
||||
}
|
||||
TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw);
|
||||
TIFFGetField(tif, TIFFTAG_TILELENGTH, &th);
|
||||
orientation = img->orientation;
|
||||
for (row = 0; row < h; row += th) {
|
||||
nrow = (row + th > h ? h - row : th);
|
||||
for (col = 0; col < w; col += tw) {
|
||||
if (TIFFReadTile(tif, buf, col, row, 0, 0) < 0 && img->stoponerr)
|
||||
break;
|
||||
if (col + tw > w) {
|
||||
/*
|
||||
* Tile is clipped horizontally. Calculate
|
||||
* visible portion and skewing factors.
|
||||
*/
|
||||
uint32_t npix = w - col;
|
||||
fromskew = tw - npix;
|
||||
(*callback)(img, udata, col, row, npix, nrow, fromskew, buf);
|
||||
} else {
|
||||
(*callback)(img, udata, col, row, tw, nrow, 0, buf);
|
||||
}
|
||||
}
|
||||
for (row = 0; row < h; row += th)
|
||||
{
|
||||
nrow = (row + th > h ? h - row : th);
|
||||
for (col = 0; col < w; col += tw)
|
||||
{
|
||||
if (TIFFReadTile(tif, buf, col, row, 0, 0) < 0 && img->stoponerr)
|
||||
break;
|
||||
if (col + tw > w)
|
||||
{
|
||||
/*
|
||||
* Tile is clipped horizontally. Calculate
|
||||
* visible portion and skewing factors.
|
||||
*/
|
||||
uint32_t npix = w - col;
|
||||
fromskew = tw - npix;
|
||||
(*callback)(img, udata, col, row, npix, nrow, fromskew, buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
(*callback)(img, udata, col, row, tw, nrow, 0, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
_TIFFfree(buf);
|
||||
return (1);
|
||||
@@ -301,63 +326,71 @@ gtTileContig(TIFFImageIter* img, void *udata, uint32_t w, uint32_t h)
|
||||
* SamplesPerPixel > 1
|
||||
* PlanarConfiguration separated
|
||||
* We assume that all such images are RGB.
|
||||
*/
|
||||
static int
|
||||
gtTileSeparate(TIFFImageIter* img, void *udata, uint32_t w, uint32_t h)
|
||||
*/
|
||||
static int gtTileSeparate(TIFFImageIter *img, void *udata, uint32_t w,
|
||||
uint32_t h)
|
||||
{
|
||||
TIFF* tif = img->tif;
|
||||
TIFF *tif = img->tif;
|
||||
ImageIterTileSeparateRoutine callback = img->callback.separate;
|
||||
uint16_t orientation;
|
||||
uint32_t col, row;
|
||||
uint32_t tw, th;
|
||||
u_char* buf;
|
||||
u_char* r;
|
||||
u_char* g;
|
||||
u_char* b;
|
||||
u_char* a;
|
||||
u_char *buf;
|
||||
u_char *r;
|
||||
u_char *g;
|
||||
u_char *b;
|
||||
u_char *a;
|
||||
tsize_t tilesize;
|
||||
int32_t fromskew;
|
||||
int alpha = img->alpha;
|
||||
uint32_t nrow;
|
||||
|
||||
tilesize = TIFFTileSize(tif);
|
||||
buf = (u_char*) _TIFFmalloc(4*tilesize);
|
||||
if (buf == 0) {
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for tile buffer");
|
||||
return (0);
|
||||
buf = (u_char *)_TIFFmalloc(4 * tilesize);
|
||||
if (buf == 0)
|
||||
{
|
||||
TIFFErrorExtR(tif, TIFFFileName(tif), "No space for tile buffer");
|
||||
return (0);
|
||||
}
|
||||
r = buf;
|
||||
g = r + tilesize;
|
||||
b = g + tilesize;
|
||||
a = b + tilesize;
|
||||
if (!alpha)
|
||||
memset(a, 0xff, tilesize);
|
||||
memset(a, 0xff, tilesize);
|
||||
TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw);
|
||||
TIFFGetField(tif, TIFFTAG_TILELENGTH, &th);
|
||||
orientation = img->orientation;
|
||||
for (row = 0; row < h; row += th) {
|
||||
nrow = (row + th > h ? h - row : th);
|
||||
for (col = 0; col < w; col += tw) {
|
||||
if (TIFFReadTile(tif, r, col, row,0,0) < 0 && img->stoponerr)
|
||||
break;
|
||||
if (TIFFReadTile(tif, g, col, row,0,1) < 0 && img->stoponerr)
|
||||
break;
|
||||
if (TIFFReadTile(tif, b, col, row,0,2) < 0 && img->stoponerr)
|
||||
break;
|
||||
if (alpha && TIFFReadTile(tif,a,col,row,0,3) < 0 && img->stoponerr)
|
||||
break;
|
||||
if (col + tw > w) {
|
||||
/*
|
||||
* Tile is clipped horizontally. Calculate
|
||||
* visible portion and skewing factors.
|
||||
*/
|
||||
uint32_t npix = w - col;
|
||||
fromskew = tw - npix;
|
||||
(*callback)(img, udata, col, row, npix, nrow, fromskew, r, g, b, a);
|
||||
} else {
|
||||
(*callback)(img, udata, col, row, tw, nrow, 0, r, g, b, a);
|
||||
}
|
||||
}
|
||||
for (row = 0; row < h; row += th)
|
||||
{
|
||||
nrow = (row + th > h ? h - row : th);
|
||||
for (col = 0; col < w; col += tw)
|
||||
{
|
||||
if (TIFFReadTile(tif, r, col, row, 0, 0) < 0 && img->stoponerr)
|
||||
break;
|
||||
if (TIFFReadTile(tif, g, col, row, 0, 1) < 0 && img->stoponerr)
|
||||
break;
|
||||
if (TIFFReadTile(tif, b, col, row, 0, 2) < 0 && img->stoponerr)
|
||||
break;
|
||||
if (alpha && TIFFReadTile(tif, a, col, row, 0, 3) < 0 &&
|
||||
img->stoponerr)
|
||||
break;
|
||||
if (col + tw > w)
|
||||
{
|
||||
/*
|
||||
* Tile is clipped horizontally. Calculate
|
||||
* visible portion and skewing factors.
|
||||
*/
|
||||
uint32_t npix = w - col;
|
||||
fromskew = tw - npix;
|
||||
(*callback)(img, udata, col, row, npix, nrow, fromskew, r, g, b,
|
||||
a);
|
||||
}
|
||||
else
|
||||
{
|
||||
(*callback)(img, udata, col, row, tw, nrow, 0, r, g, b, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
_TIFFfree(buf);
|
||||
return (1);
|
||||
@@ -368,35 +401,38 @@ gtTileSeparate(TIFFImageIter* img, void *udata, uint32_t w, uint32_t h)
|
||||
* PlanarConfiguration contiguous if SamplesPerPixel > 1
|
||||
* or
|
||||
* SamplesPerPixel == 1
|
||||
*/
|
||||
static int
|
||||
gtStripContig(TIFFImageIter* img, void *udata, uint32_t w, uint32_t h)
|
||||
*/
|
||||
static int gtStripContig(TIFFImageIter *img, void *udata, uint32_t w,
|
||||
uint32_t h)
|
||||
{
|
||||
TIFF* tif = img->tif;
|
||||
TIFF *tif = img->tif;
|
||||
ImageIterTileContigRoutine callback = img->callback.contig;
|
||||
uint16_t orientation;
|
||||
uint32_t row, nrow;
|
||||
u_char* buf;
|
||||
u_char *buf;
|
||||
uint32_t rowsperstrip;
|
||||
uint32_t imagewidth = img->width;
|
||||
tsize_t scanline;
|
||||
int32_t fromskew;
|
||||
|
||||
buf = (u_char*) _TIFFmalloc(TIFFStripSize(tif));
|
||||
if (buf == 0) {
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for strip buffer");
|
||||
return (0);
|
||||
buf = (u_char *)_TIFFmalloc(TIFFStripSize(tif));
|
||||
if (buf == 0)
|
||||
{
|
||||
TIFFErrorExtR(tif, TIFFFileName(tif), "No space for strip buffer");
|
||||
return (0);
|
||||
}
|
||||
orientation = img->orientation;
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
|
||||
scanline = TIFFScanlineSize(tif);
|
||||
fromskew = (w < imagewidth ? imagewidth - w : 0);
|
||||
for (row = 0; row < h; row += rowsperstrip) {
|
||||
nrow = (row + rowsperstrip > h ? h - row : rowsperstrip);
|
||||
if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0),
|
||||
buf, nrow*scanline) < 0 && img->stoponerr)
|
||||
break;
|
||||
(*callback)(img, udata, 0, row, w, nrow, fromskew, buf);
|
||||
for (row = 0; row < h; row += rowsperstrip)
|
||||
{
|
||||
nrow = (row + rowsperstrip > h ? h - row : rowsperstrip);
|
||||
if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0), buf,
|
||||
nrow * scanline) < 0 &&
|
||||
img->stoponerr)
|
||||
break;
|
||||
(*callback)(img, udata, 0, row, w, nrow, fromskew, buf);
|
||||
}
|
||||
_TIFFfree(buf);
|
||||
return (1);
|
||||
@@ -408,10 +444,10 @@ gtStripContig(TIFFImageIter* img, void *udata, uint32_t w, uint32_t h)
|
||||
* PlanarConfiguration separated
|
||||
* We assume that all such images are RGB.
|
||||
*/
|
||||
static int
|
||||
gtStripSeparate(TIFFImageIter* img, void *udata, uint32_t w, uint32_t h)
|
||||
static int gtStripSeparate(TIFFImageIter *img, void *udata, uint32_t w,
|
||||
uint32_t h)
|
||||
{
|
||||
TIFF* tif = img->tif;
|
||||
TIFF *tif = img->tif;
|
||||
ImageIterTileSeparateRoutine callback = img->callback.separate;
|
||||
uint16_t orientation;
|
||||
u_char *buf;
|
||||
@@ -425,36 +461,41 @@ gtStripSeparate(TIFFImageIter* img, void *udata, uint32_t w, uint32_t h)
|
||||
int alpha = img->alpha;
|
||||
|
||||
stripsize = TIFFStripSize(tif);
|
||||
r = buf = (u_char *)_TIFFmalloc(4*stripsize);
|
||||
if (buf == 0) {
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for tile buffer");
|
||||
return (0);
|
||||
r = buf = (u_char *)_TIFFmalloc(4 * stripsize);
|
||||
if (buf == 0)
|
||||
{
|
||||
TIFFErrorExtR(tif, TIFFFileName(tif), "No space for tile buffer");
|
||||
return (0);
|
||||
}
|
||||
g = r + stripsize;
|
||||
b = g + stripsize;
|
||||
a = b + stripsize;
|
||||
if (!alpha)
|
||||
memset(a, 0xff, stripsize);
|
||||
memset(a, 0xff, stripsize);
|
||||
orientation = img->orientation;
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
|
||||
scanline = TIFFScanlineSize(tif);
|
||||
fromskew = (w < imagewidth ? imagewidth - w : 0);
|
||||
for (row = 0; row < h; row += rowsperstrip) {
|
||||
nrow = (row + rowsperstrip > h ? h - row : rowsperstrip);
|
||||
if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0),
|
||||
r, nrow*scanline) < 0 && img->stoponerr)
|
||||
break;
|
||||
if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 1),
|
||||
g, nrow*scanline) < 0 && img->stoponerr)
|
||||
break;
|
||||
if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 2),
|
||||
b, nrow*scanline) < 0 && img->stoponerr)
|
||||
break;
|
||||
if (alpha &&
|
||||
(TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 3),
|
||||
a, nrow*scanline) < 0 && img->stoponerr))
|
||||
break;
|
||||
(*callback)(img, udata, 0, row, w, nrow, fromskew, r, g, b, a);
|
||||
for (row = 0; row < h; row += rowsperstrip)
|
||||
{
|
||||
nrow = (row + rowsperstrip > h ? h - row : rowsperstrip);
|
||||
if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0), r,
|
||||
nrow * scanline) < 0 &&
|
||||
img->stoponerr)
|
||||
break;
|
||||
if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 1), g,
|
||||
nrow * scanline) < 0 &&
|
||||
img->stoponerr)
|
||||
break;
|
||||
if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 2), b,
|
||||
nrow * scanline) < 0 &&
|
||||
img->stoponerr)
|
||||
break;
|
||||
if (alpha && (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 3),
|
||||
a, nrow * scanline) < 0 &&
|
||||
img->stoponerr))
|
||||
break;
|
||||
(*callback)(img, udata, 0, row, w, nrow, fromskew, r, g, b, a);
|
||||
}
|
||||
_TIFFfree(buf);
|
||||
return (1);
|
||||
@@ -462,18 +503,18 @@ gtStripSeparate(TIFFImageIter* img, void *udata, uint32_t w, uint32_t h)
|
||||
|
||||
DECLAREContigCallbackFunc(TestContigCallback)
|
||||
{
|
||||
printf("Contig Callback called with x = %d, y = %d, w = %d, h = %d, fromskew = %d\n",
|
||||
x, y, w, h, fromskew);
|
||||
printf("Contig Callback called with x = %d, y = %d, w = %d, h = %d, "
|
||||
"fromskew = %d\n",
|
||||
x, y, w, h, fromskew);
|
||||
}
|
||||
|
||||
|
||||
DECLARESepCallbackFunc(TestSepCallback)
|
||||
{
|
||||
printf("Sep Callback called with x = %d, y = %d, w = %d, h = %d, fromskew = %d\n",
|
||||
x, y, w, h, fromskew);
|
||||
printf("Sep Callback called with x = %d, y = %d, w = %d, h = %d, fromskew "
|
||||
"= %d\n",
|
||||
x, y, w, h, fromskew);
|
||||
}
|
||||
|
||||
|
||||
#ifdef MAIN
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
@@ -489,35 +530,35 @@ main(int argc, char **argv)
|
||||
unsigned char *ColorMap;
|
||||
unsigned char *data;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr,"usage: %s tiff_file\n",argv[0]);
|
||||
exit(1);
|
||||
if (argc < 2)
|
||||
{
|
||||
fprintf(stderr, "usage: %s tiff_file\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
tif = (TIFF *)PLIGetImage(argv[1], (void *) &data, &ColorMap,
|
||||
&nx, &ny, &BitsPerSample, &SamplesPerPixel,
|
||||
&isColorMapped, &isPliFile);
|
||||
if (tif != NULL) {
|
||||
tif = (TIFF *)PLIGetImage(argv[1], (void *)&data, &ColorMap, &nx, &ny,
|
||||
&BitsPerSample, &SamplesPerPixel, &isColorMapped,
|
||||
&isPliFile);
|
||||
if (tif != NULL)
|
||||
{
|
||||
|
||||
if (TIFFImageIterBegin(&img, tif, stop, emsg)) {
|
||||
/* Here need to set data and callback function! */
|
||||
if (img.isContig) {
|
||||
img.callback = TestContigCallback;
|
||||
} else {
|
||||
img.callback = TestSepCallback;
|
||||
}
|
||||
ok = TIFFImageIterGet(&img, NULL, img.width, img.height);
|
||||
TIFFImageIterEnd(&img);
|
||||
} else {
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), emsg);
|
||||
}
|
||||
if (TIFFImageIterBegin(&img, tif, stop, emsg))
|
||||
{
|
||||
/* Here need to set data and callback function! */
|
||||
if (img.isContig)
|
||||
{
|
||||
img.callback = TestContigCallback;
|
||||
}
|
||||
else
|
||||
{
|
||||
img.callback = TestSepCallback;
|
||||
}
|
||||
ok = TIFFImageIterGet(&img, NULL, img.width, img.height);
|
||||
TIFFImageIterEnd(&img);
|
||||
}
|
||||
else
|
||||
{
|
||||
TIFFErrorExtR(tif, TIFFFileName(tif), emsg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
+39
-52
@@ -7,58 +7,45 @@ typedef struct _TIFFImageIter TIFFImageIter;
|
||||
img->samplesperpixel consecutive samples each containing img->bitspersample
|
||||
bits of data. The array pp is ordered in h consecutive rows of w+fromskew
|
||||
pixels each. */
|
||||
typedef void (*ImageIterTileContigRoutine)
|
||||
(TIFFImageIter*, void *, uint32_t, uint32_t, uint32_t, uint32_t, int32_t,
|
||||
unsigned char*);
|
||||
#define DECLAREContigCallbackFunc(name) \
|
||||
static void name(\
|
||||
TIFFImageIter* img, \
|
||||
void* user_data, \
|
||||
uint32_t x, uint32_t y, \
|
||||
uint32_t w, uint32_t h, \
|
||||
int32_t fromskew, \
|
||||
u_char* pp \
|
||||
)
|
||||
typedef void (*ImageIterTileContigRoutine)(TIFFImageIter *, void *, uint32_t,
|
||||
uint32_t, uint32_t, uint32_t,
|
||||
int32_t, unsigned char *);
|
||||
#define DECLAREContigCallbackFunc(name) \
|
||||
static void name(TIFFImageIter *img, void *user_data, uint32_t x, \
|
||||
uint32_t y, uint32_t w, uint32_t h, int32_t fromskew, \
|
||||
u_char *pp)
|
||||
|
||||
typedef void (*ImageIterTileSeparateRoutine)
|
||||
(TIFFImageIter*, void *, uint32_t, uint32_t, uint32_t, uint32_t, int32_t,
|
||||
unsigned char*, unsigned char*, unsigned char*, unsigned char*);
|
||||
#define DECLARESepCallbackFunc(name) \
|
||||
static void name(\
|
||||
TIFFImageIter* img, \
|
||||
void* user_data, \
|
||||
uint32_t x, uint32_t y, \
|
||||
uint32_t w, uint32_t h,\
|
||||
int32_t fromskew, \
|
||||
u_char* r, u_char* g, u_char* b, u_char* a\
|
||||
)
|
||||
typedef void (*ImageIterTileSeparateRoutine)(TIFFImageIter *, void *, uint32_t,
|
||||
uint32_t, uint32_t, uint32_t,
|
||||
int32_t, unsigned char *,
|
||||
unsigned char *, unsigned char *,
|
||||
unsigned char *);
|
||||
#define DECLARESepCallbackFunc(name) \
|
||||
static void name(TIFFImageIter *img, void *user_data, uint32_t x, \
|
||||
uint32_t y, uint32_t w, uint32_t h, int32_t fromskew, \
|
||||
u_char *r, u_char *g, u_char *b, u_char *a)
|
||||
|
||||
struct _TIFFImageIter {
|
||||
TIFF* tif; /* image handle */
|
||||
int stoponerr; /* stop on read error */
|
||||
int isContig; /* data is packed/separate */
|
||||
int alpha; /* type of alpha data present */
|
||||
uint32_t width; /* image width */
|
||||
uint32_t height; /* image height */
|
||||
uint16_t bitspersample; /* image bits/sample */
|
||||
uint16_t samplesperpixel; /* image samples/pixel */
|
||||
uint16_t orientation; /* image orientation */
|
||||
uint16_t photometric; /* image photometric interp */
|
||||
uint16_t* redcmap; /* colormap palette */
|
||||
uint16_t* greencmap;
|
||||
uint16_t* bluecmap;
|
||||
/* get image data routine */
|
||||
int (*get)(TIFFImageIter*, void *udata, uint32_t, uint32_t);
|
||||
union {
|
||||
void (*any)(TIFFImageIter*);
|
||||
ImageIterTileContigRoutine contig;
|
||||
ImageIterTileSeparateRoutine separate;
|
||||
} callback; /* fn to exec for each block */
|
||||
struct _TIFFImageIter
|
||||
{
|
||||
TIFF *tif; /* image handle */
|
||||
int stoponerr; /* stop on read error */
|
||||
int isContig; /* data is packed/separate */
|
||||
int alpha; /* type of alpha data present */
|
||||
uint32_t width; /* image width */
|
||||
uint32_t height; /* image height */
|
||||
uint16_t bitspersample; /* image bits/sample */
|
||||
uint16_t samplesperpixel; /* image samples/pixel */
|
||||
uint16_t orientation; /* image orientation */
|
||||
uint16_t photometric; /* image photometric interp */
|
||||
uint16_t *redcmap; /* colormap palette */
|
||||
uint16_t *greencmap;
|
||||
uint16_t *bluecmap;
|
||||
/* get image data routine */
|
||||
int (*get)(TIFFImageIter *, void *udata, uint32_t, uint32_t);
|
||||
union
|
||||
{
|
||||
void (*any)(TIFFImageIter *);
|
||||
ImageIterTileContigRoutine contig;
|
||||
ImageIterTileSeparateRoutine separate;
|
||||
} callback; /* fn to exec for each block */
|
||||
};
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
+936
-855
File diff suppressed because it is too large
Load Diff
+785
-717
File diff suppressed because it is too large
Load Diff
+117
-127
@@ -43,157 +43,152 @@ static char sccsid[] = "@(#)ras2tif.c 1.2 90/03/06";
|
||||
* real file since seek(2) is used.
|
||||
*/
|
||||
|
||||
#include "tiffio.h"
|
||||
#include <pixrect/pixrect_hs.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include <pixrect/pixrect_hs.h>
|
||||
#include "tiffio.h"
|
||||
|
||||
typedef int boolean;
|
||||
#define True (1)
|
||||
#define False (0)
|
||||
#define SCALE(x) (((x)*((1L<<16)-1))/255)
|
||||
#define SCALE(x) (((x) * ((1L << 16) - 1)) / 255)
|
||||
|
||||
boolean Verbose = False;
|
||||
boolean dummyinput = False;
|
||||
char *pname; /* program name (used for error messages) */
|
||||
boolean Verbose = False;
|
||||
boolean dummyinput = False;
|
||||
char *pname; /* program name (used for error messages) */
|
||||
|
||||
void
|
||||
error(s1, s2)
|
||||
char *s1,
|
||||
*s2;
|
||||
void error(s1, s2) char *s1, *s2;
|
||||
{
|
||||
fprintf(stderr, s1, pname, s2);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
{
|
||||
error("usage: %s -[vq] [-|rasterfile] TIFFfile\n", NULL);
|
||||
}
|
||||
void usage() { error("usage: %s -[vq] [-|rasterfile] TIFFfile\n", NULL); }
|
||||
|
||||
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
main(argc, argv) int argc;
|
||||
char *argv[];
|
||||
{
|
||||
char *inf = NULL;
|
||||
char *outf = NULL;
|
||||
FILE *fp;
|
||||
int depth,
|
||||
i;
|
||||
long row;
|
||||
TIFF *tif;
|
||||
Pixrect *pix; /* The Sun Pixrect */
|
||||
colormap_t Colormap; /* The Pixrect Colormap */
|
||||
u_short red[256],
|
||||
green[256],
|
||||
blue[256];
|
||||
struct tm *ct;
|
||||
char *inf = NULL;
|
||||
char *outf = NULL;
|
||||
FILE *fp;
|
||||
int depth, i;
|
||||
long row;
|
||||
TIFF *tif;
|
||||
Pixrect *pix; /* The Sun Pixrect */
|
||||
colormap_t Colormap; /* The Pixrect Colormap */
|
||||
u_short red[256], green[256], blue[256];
|
||||
struct tm *ct;
|
||||
struct timeval tv;
|
||||
long width,
|
||||
height;
|
||||
long rowsperstrip;
|
||||
int year;
|
||||
short photometric;
|
||||
short samplesperpixel;
|
||||
short bitspersample;
|
||||
int bpsl;
|
||||
long width, height;
|
||||
long rowsperstrip;
|
||||
int year;
|
||||
short photometric;
|
||||
short samplesperpixel;
|
||||
short bitspersample;
|
||||
int bpsl;
|
||||
static char *version = "ras2tif 1.0";
|
||||
static char *datetime = "1990:01:01 12:00:00";
|
||||
|
||||
gettimeofday(&tv, (struct timezone *) NULL);
|
||||
gettimeofday(&tv, (struct timezone *)NULL);
|
||||
ct = localtime(&tv.tv_sec);
|
||||
year=1900 + ct->tm_year;
|
||||
sprintf(datetime, "%04d:%02d:%02d %02d:%02d:%02d",
|
||||
year, ct->tm_mon + 1, ct->tm_mday,
|
||||
ct->tm_hour, ct->tm_min, ct->tm_sec);
|
||||
year = 1900 + ct->tm_year;
|
||||
sprintf(datetime, "%04d:%02d:%02d %02d:%02d:%02d", year, ct->tm_mon + 1,
|
||||
ct->tm_mday, ct->tm_hour, ct->tm_min, ct->tm_sec);
|
||||
|
||||
setbuf(stderr, NULL);
|
||||
pname = argv[0];
|
||||
|
||||
while (--argc) {
|
||||
if ((++argv)[0][0] == '-') {
|
||||
switch (argv[0][1]) {
|
||||
case 'v':
|
||||
Verbose = True;
|
||||
break;
|
||||
case 'q':
|
||||
usage();
|
||||
break;
|
||||
case '\0':
|
||||
if (inf == NULL)
|
||||
dummyinput = True;
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s: illegal option -%c.\n", pname,
|
||||
argv[0][1]);
|
||||
exit(1);
|
||||
}
|
||||
} else if (inf == NULL && !dummyinput) {
|
||||
inf = argv[0];
|
||||
} else if (outf == NULL)
|
||||
outf = argv[0];
|
||||
else
|
||||
usage();
|
||||
while (--argc)
|
||||
{
|
||||
if ((++argv)[0][0] == '-')
|
||||
{
|
||||
switch (argv[0][1])
|
||||
{
|
||||
case 'v':
|
||||
Verbose = True;
|
||||
break;
|
||||
case 'q':
|
||||
usage();
|
||||
break;
|
||||
case '\0':
|
||||
if (inf == NULL)
|
||||
dummyinput = True;
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s: illegal option -%c.\n", pname,
|
||||
argv[0][1]);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else if (inf == NULL && !dummyinput)
|
||||
{
|
||||
inf = argv[0];
|
||||
}
|
||||
else if (outf == NULL)
|
||||
outf = argv[0];
|
||||
else
|
||||
usage();
|
||||
}
|
||||
|
||||
if (outf == NULL)
|
||||
error("%s: can't write output file to a stream.\n", NULL);
|
||||
error("%s: can't write output file to a stream.\n", NULL);
|
||||
|
||||
if (dummyinput || inf == NULL) {
|
||||
inf = "Standard Input";
|
||||
fp = stdin;
|
||||
} else if ((fp = fopen(inf, "r")) == NULL)
|
||||
error("%s: %s couldn't be opened.\n", inf);
|
||||
if (dummyinput || inf == NULL)
|
||||
{
|
||||
inf = "Standard Input";
|
||||
fp = stdin;
|
||||
}
|
||||
else if ((fp = fopen(inf, "r")) == NULL)
|
||||
error("%s: %s couldn't be opened.\n", inf);
|
||||
|
||||
if (Verbose)
|
||||
fprintf(stderr, "Reading rasterfile from %s...", inf);
|
||||
fprintf(stderr, "Reading rasterfile from %s...", inf);
|
||||
|
||||
pix = pr_load(fp, &Colormap);
|
||||
if (pix == NULL)
|
||||
error("%s: %s is not a raster file.\n", inf);
|
||||
error("%s: %s is not a raster file.\n", inf);
|
||||
|
||||
if (Verbose)
|
||||
fprintf(stderr, "done.\n");
|
||||
fprintf(stderr, "done.\n");
|
||||
|
||||
if (Verbose)
|
||||
fprintf(stderr, "Writing %s...", outf);
|
||||
fprintf(stderr, "Writing %s...", outf);
|
||||
|
||||
tif = TIFFOpen(outf, "w");
|
||||
|
||||
if (tif == NULL)
|
||||
error("%s: error opening TIFF file %s", outf);
|
||||
error("%s: error opening TIFF file %s", outf);
|
||||
|
||||
width = pix->pr_width;
|
||||
height = pix->pr_height;
|
||||
depth = pix->pr_depth;
|
||||
|
||||
switch (depth) {
|
||||
case 1:
|
||||
samplesperpixel = 1;
|
||||
bitspersample = 1;
|
||||
photometric = PHOTOMETRIC_MINISBLACK;
|
||||
break;
|
||||
case 8:
|
||||
samplesperpixel = 1;
|
||||
bitspersample = 8;
|
||||
photometric = PHOTOMETRIC_PALETTE;
|
||||
break;
|
||||
case 24:
|
||||
samplesperpixel = 3;
|
||||
bitspersample = 8;
|
||||
photometric = PHOTOMETRIC_RGB;
|
||||
break;
|
||||
case 32:
|
||||
samplesperpixel = 4;
|
||||
bitspersample = 8;
|
||||
photometric = PHOTOMETRIC_RGB;
|
||||
break;
|
||||
default:
|
||||
error("%s: bogus depth: %d\n", depth);
|
||||
switch (depth)
|
||||
{
|
||||
case 1:
|
||||
samplesperpixel = 1;
|
||||
bitspersample = 1;
|
||||
photometric = PHOTOMETRIC_MINISBLACK;
|
||||
break;
|
||||
case 8:
|
||||
samplesperpixel = 1;
|
||||
bitspersample = 8;
|
||||
photometric = PHOTOMETRIC_PALETTE;
|
||||
break;
|
||||
case 24:
|
||||
samplesperpixel = 3;
|
||||
bitspersample = 8;
|
||||
photometric = PHOTOMETRIC_RGB;
|
||||
break;
|
||||
case 32:
|
||||
samplesperpixel = 4;
|
||||
bitspersample = 8;
|
||||
photometric = PHOTOMETRIC_RGB;
|
||||
break;
|
||||
default:
|
||||
error("%s: bogus depth: %d\n", depth);
|
||||
}
|
||||
|
||||
bpsl = ((depth * width + 15) >> 3) & ~1;
|
||||
@@ -217,38 +212,33 @@ main(argc, argv)
|
||||
memset(red, 0, sizeof(red));
|
||||
memset(green, 0, sizeof(green));
|
||||
memset(blue, 0, sizeof(blue));
|
||||
if (depth == 8) {
|
||||
TIFFSetField(tif, TIFFTAG_COLORMAP, red, green, blue);
|
||||
for (i = 0; i < Colormap.length; i++) {
|
||||
red[i] = SCALE(Colormap.map[0][i]);
|
||||
green[i] = SCALE(Colormap.map[1][i]);
|
||||
blue[i] = SCALE(Colormap.map[2][i]);
|
||||
}
|
||||
if (depth == 8)
|
||||
{
|
||||
TIFFSetField(tif, TIFFTAG_COLORMAP, red, green, blue);
|
||||
for (i = 0; i < Colormap.length; i++)
|
||||
{
|
||||
red[i] = SCALE(Colormap.map[0][i]);
|
||||
green[i] = SCALE(Colormap.map[1][i]);
|
||||
blue[i] = SCALE(Colormap.map[2][i]);
|
||||
}
|
||||
}
|
||||
if (Verbose)
|
||||
fprintf(stderr, "%dx%dx%d image, ", width, height, depth);
|
||||
fprintf(stderr, "%dx%dx%d image, ", width, height, depth);
|
||||
|
||||
for (row = 0; row < height; row++)
|
||||
if (TIFFWriteScanline(tif,
|
||||
(u_char *) mprd_addr(mpr_d(pix), 0, row),
|
||||
row, 0) < 0) {
|
||||
fprintf("failed a scanline write (%d)\n", row);
|
||||
break;
|
||||
}
|
||||
if (TIFFWriteScanline(tif, (u_char *)mprd_addr(mpr_d(pix), 0, row), row,
|
||||
0) < 0)
|
||||
{
|
||||
fprintf("failed a scanline write (%d)\n", row);
|
||||
break;
|
||||
}
|
||||
TIFFFlushData(tif);
|
||||
TIFFClose(tif);
|
||||
|
||||
if (Verbose)
|
||||
fprintf(stderr, "done.\n");
|
||||
fprintf(stderr, "done.\n");
|
||||
|
||||
pr_destroy(pix);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
+219
-226
@@ -40,302 +40,295 @@
|
||||
* file since seek(2) is used.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <pixrect/pixrect_hs.h>
|
||||
#include "tiffio.h"
|
||||
#include <pixrect/pixrect_hs.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef int boolean;
|
||||
#define True (1)
|
||||
#define False (0)
|
||||
#define CVT(x) (((x) * 255) / ((1L<<16)-1))
|
||||
#define CVT(x) (((x)*255) / ((1L << 16) - 1))
|
||||
|
||||
boolean Verbose = False;
|
||||
char *pname; /* program name (used for error messages) */
|
||||
boolean Verbose = False;
|
||||
char *pname; /* program name (used for error messages) */
|
||||
|
||||
void
|
||||
error(s1, s2)
|
||||
char *s1,
|
||||
*s2;
|
||||
void error(s1, s2) char *s1, *s2;
|
||||
{
|
||||
fprintf(stderr, s1, pname, s2);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
{
|
||||
error("usage: %s -[vq] TIFFfile [rasterfile]\n", NULL);
|
||||
}
|
||||
void usage() { error("usage: %s -[vq] TIFFfile [rasterfile]\n", NULL); }
|
||||
|
||||
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
main(argc, argv) int argc;
|
||||
char *argv[];
|
||||
{
|
||||
char *inf = NULL;
|
||||
char *outf = NULL;
|
||||
FILE *fp;
|
||||
long width,
|
||||
height;
|
||||
int depth,
|
||||
numcolors;
|
||||
char *inf = NULL;
|
||||
char *outf = NULL;
|
||||
FILE *fp;
|
||||
long width, height;
|
||||
int depth, numcolors;
|
||||
register TIFF *tif;
|
||||
TIFFDirectory *td;
|
||||
register u_char *inp,
|
||||
*outp;
|
||||
register int col,
|
||||
i;
|
||||
register u_char *inp, *outp;
|
||||
register int col, i;
|
||||
register long row;
|
||||
u_char *Map = NULL;
|
||||
u_char *buf;
|
||||
short bitspersample;
|
||||
short samplesperpixel;
|
||||
short photometric;
|
||||
u_short *redcolormap,
|
||||
*bluecolormap,
|
||||
*greencolormap;
|
||||
u_char *Map = NULL;
|
||||
u_char *buf;
|
||||
short bitspersample;
|
||||
short samplesperpixel;
|
||||
short photometric;
|
||||
u_short *redcolormap, *bluecolormap, *greencolormap;
|
||||
|
||||
Pixrect *pix; /* The Sun Pixrect */
|
||||
colormap_t Colormap; /* The Pixrect Colormap */
|
||||
u_char red[256],
|
||||
green[256],
|
||||
blue[256];
|
||||
Pixrect *pix; /* The Sun Pixrect */
|
||||
colormap_t Colormap; /* The Pixrect Colormap */
|
||||
u_char red[256], green[256], blue[256];
|
||||
|
||||
setbuf(stderr, NULL);
|
||||
pname = argv[0];
|
||||
|
||||
while (--argc) {
|
||||
if ((++argv)[0][0] == '-')
|
||||
switch (argv[0][1]) {
|
||||
case 'v':
|
||||
Verbose = True;
|
||||
break;
|
||||
case 'q':
|
||||
usage();
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s: illegal option -%c.\n", pname,
|
||||
argv[0][1]);
|
||||
exit(1);
|
||||
}
|
||||
else if (inf == NULL)
|
||||
inf = argv[0];
|
||||
else if (outf == NULL)
|
||||
outf = argv[0];
|
||||
else
|
||||
usage();
|
||||
|
||||
while (--argc)
|
||||
{
|
||||
if ((++argv)[0][0] == '-')
|
||||
switch (argv[0][1])
|
||||
{
|
||||
case 'v':
|
||||
Verbose = True;
|
||||
break;
|
||||
case 'q':
|
||||
usage();
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s: illegal option -%c.\n", pname,
|
||||
argv[0][1]);
|
||||
exit(1);
|
||||
}
|
||||
else if (inf == NULL)
|
||||
inf = argv[0];
|
||||
else if (outf == NULL)
|
||||
outf = argv[0];
|
||||
else
|
||||
usage();
|
||||
}
|
||||
|
||||
if (inf == NULL)
|
||||
error("%s: can't read input file from a stream.\n", NULL);
|
||||
error("%s: can't read input file from a stream.\n", NULL);
|
||||
|
||||
if (Verbose)
|
||||
fprintf(stderr, "Reading %s...", inf);
|
||||
fprintf(stderr, "Reading %s...", inf);
|
||||
|
||||
tif = TIFFOpen(inf, "r");
|
||||
|
||||
if (tif == NULL)
|
||||
error("%s: error opening TIFF file %s", inf);
|
||||
error("%s: error opening TIFF file %s", inf);
|
||||
|
||||
if (Verbose)
|
||||
TIFFPrintDirectory(tif, stderr, True, False, False);
|
||||
TIFFPrintDirectory(tif, stderr, True, False, False);
|
||||
TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bitspersample);
|
||||
if (bitspersample > 8)
|
||||
error("%s: can't handle more than 8-bits per sample\n", NULL);
|
||||
error("%s: can't handle more than 8-bits per sample\n", NULL);
|
||||
|
||||
TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel);
|
||||
switch (samplesperpixel) {
|
||||
case 1:
|
||||
if (bitspersample == 1)
|
||||
depth = 1;
|
||||
else
|
||||
depth = 8;
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
depth = 24;
|
||||
break;
|
||||
default:
|
||||
error("%s: only handle 1-channel gray scale or 3-channel color\n");
|
||||
switch (samplesperpixel)
|
||||
{
|
||||
case 1:
|
||||
if (bitspersample == 1)
|
||||
depth = 1;
|
||||
else
|
||||
depth = 8;
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
depth = 24;
|
||||
break;
|
||||
default:
|
||||
error("%s: only handle 1-channel gray scale or 3-channel color\n");
|
||||
}
|
||||
|
||||
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
|
||||
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);
|
||||
|
||||
if (Verbose)
|
||||
fprintf(stderr, "%dx%dx%d image, ", width, height, depth);
|
||||
fprintf(stderr, "%dx%dx%d image, ", width, height, depth);
|
||||
if (Verbose)
|
||||
fprintf(stderr, "%d bits/sample, %d samples/pixel, ",
|
||||
bitspersample, samplesperpixel);
|
||||
fprintf(stderr, "%d bits/sample, %d samples/pixel, ", bitspersample,
|
||||
samplesperpixel);
|
||||
|
||||
pix = mem_create(width, height, depth);
|
||||
if (pix == (Pixrect *) NULL)
|
||||
error("%s: can't allocate memory for output pixrect...\n", NULL);
|
||||
if (pix == (Pixrect *)NULL)
|
||||
error("%s: can't allocate memory for output pixrect...\n", NULL);
|
||||
|
||||
numcolors = (1 << bitspersample);
|
||||
|
||||
TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric);
|
||||
if (numcolors == 2) {
|
||||
if (Verbose)
|
||||
fprintf(stderr, "monochrome ");
|
||||
Colormap.type = RMT_NONE;
|
||||
Colormap.length = 0;
|
||||
Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = NULL;
|
||||
} else {
|
||||
switch (photometric) {
|
||||
case PHOTOMETRIC_MINISBLACK:
|
||||
if (Verbose)
|
||||
fprintf(stderr, "%d graylevels (min=black), ", numcolors);
|
||||
Map = (u_char *) malloc(numcolors * sizeof(u_char));
|
||||
for (i = 0; i < numcolors; i++)
|
||||
Map[i] = (255 * i) / numcolors;
|
||||
Colormap.type = RMT_EQUAL_RGB;
|
||||
Colormap.length = numcolors;
|
||||
Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = Map;
|
||||
break;
|
||||
case PHOTOMETRIC_MINISWHITE:
|
||||
if (Verbose)
|
||||
fprintf(stderr, "%d graylevels (min=white), ", numcolors);
|
||||
Map = (u_char *) malloc(numcolors * sizeof(u_char));
|
||||
for (i = 0; i < numcolors; i++)
|
||||
Map[i] = 255 - ((255 * i) / numcolors);
|
||||
Colormap.type = RMT_EQUAL_RGB;
|
||||
Colormap.length = numcolors;
|
||||
Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = Map;
|
||||
break;
|
||||
case PHOTOMETRIC_RGB:
|
||||
if (Verbose)
|
||||
fprintf(stderr, "truecolor ");
|
||||
Colormap.type = RMT_NONE;
|
||||
Colormap.length = 0;
|
||||
Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = NULL;
|
||||
break;
|
||||
case PHOTOMETRIC_PALETTE:
|
||||
if (Verbose)
|
||||
fprintf(stderr, "colormapped ");
|
||||
Colormap.type = RMT_EQUAL_RGB;
|
||||
Colormap.length = numcolors;
|
||||
memset(red, 0, sizeof(red));
|
||||
memset(green, 0, sizeof(green));
|
||||
memset(blue, 0, sizeof(blue));
|
||||
TIFFGetField(tif, TIFFTAG_COLORMAP,
|
||||
&redcolormap, &greencolormap, &bluecolormap);
|
||||
for (i = 0; i < numcolors; i++) {
|
||||
red[i] = (u_char) CVT(redcolormap[i]);
|
||||
green[i] = (u_char) CVT(greencolormap[i]);
|
||||
blue[i] = (u_char) CVT(bluecolormap[i]);
|
||||
}
|
||||
Colormap.map[0] = red;
|
||||
Colormap.map[1] = green;
|
||||
Colormap.map[2] = blue;
|
||||
break;
|
||||
case PHOTOMETRIC_MASK:
|
||||
error("%s: Don't know how to handle PHOTOMETRIC_MASK\n");
|
||||
break;
|
||||
case PHOTOMETRIC_DEPTH:
|
||||
error("%s: Don't know how to handle PHOTOMETRIC_DEPTH\n");
|
||||
break;
|
||||
default:
|
||||
error("%s: unknown photometric (cmap): %d\n", photometric);
|
||||
}
|
||||
if (numcolors == 2)
|
||||
{
|
||||
if (Verbose)
|
||||
fprintf(stderr, "monochrome ");
|
||||
Colormap.type = RMT_NONE;
|
||||
Colormap.length = 0;
|
||||
Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (photometric)
|
||||
{
|
||||
case PHOTOMETRIC_MINISBLACK:
|
||||
if (Verbose)
|
||||
fprintf(stderr, "%d graylevels (min=black), ", numcolors);
|
||||
Map = (u_char *)malloc(numcolors * sizeof(u_char));
|
||||
for (i = 0; i < numcolors; i++)
|
||||
Map[i] = (255 * i) / numcolors;
|
||||
Colormap.type = RMT_EQUAL_RGB;
|
||||
Colormap.length = numcolors;
|
||||
Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = Map;
|
||||
break;
|
||||
case PHOTOMETRIC_MINISWHITE:
|
||||
if (Verbose)
|
||||
fprintf(stderr, "%d graylevels (min=white), ", numcolors);
|
||||
Map = (u_char *)malloc(numcolors * sizeof(u_char));
|
||||
for (i = 0; i < numcolors; i++)
|
||||
Map[i] = 255 - ((255 * i) / numcolors);
|
||||
Colormap.type = RMT_EQUAL_RGB;
|
||||
Colormap.length = numcolors;
|
||||
Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = Map;
|
||||
break;
|
||||
case PHOTOMETRIC_RGB:
|
||||
if (Verbose)
|
||||
fprintf(stderr, "truecolor ");
|
||||
Colormap.type = RMT_NONE;
|
||||
Colormap.length = 0;
|
||||
Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = NULL;
|
||||
break;
|
||||
case PHOTOMETRIC_PALETTE:
|
||||
if (Verbose)
|
||||
fprintf(stderr, "colormapped ");
|
||||
Colormap.type = RMT_EQUAL_RGB;
|
||||
Colormap.length = numcolors;
|
||||
memset(red, 0, sizeof(red));
|
||||
memset(green, 0, sizeof(green));
|
||||
memset(blue, 0, sizeof(blue));
|
||||
TIFFGetField(tif, TIFFTAG_COLORMAP, &redcolormap,
|
||||
&greencolormap, &bluecolormap);
|
||||
for (i = 0; i < numcolors; i++)
|
||||
{
|
||||
red[i] = (u_char)CVT(redcolormap[i]);
|
||||
green[i] = (u_char)CVT(greencolormap[i]);
|
||||
blue[i] = (u_char)CVT(bluecolormap[i]);
|
||||
}
|
||||
Colormap.map[0] = red;
|
||||
Colormap.map[1] = green;
|
||||
Colormap.map[2] = blue;
|
||||
break;
|
||||
case PHOTOMETRIC_MASK:
|
||||
error("%s: Don't know how to handle PHOTOMETRIC_MASK\n");
|
||||
break;
|
||||
case PHOTOMETRIC_DEPTH:
|
||||
error("%s: Don't know how to handle PHOTOMETRIC_DEPTH\n");
|
||||
break;
|
||||
default:
|
||||
error("%s: unknown photometric (cmap): %d\n", photometric);
|
||||
}
|
||||
}
|
||||
|
||||
buf = (u_char *) malloc(TIFFScanlineSize(tif));
|
||||
buf = (u_char *)malloc(TIFFScanlineSize(tif));
|
||||
if (buf == NULL)
|
||||
error("%s: can't allocate memory for scanline buffer...\n", NULL);
|
||||
error("%s: can't allocate memory for scanline buffer...\n", NULL);
|
||||
|
||||
for (row = 0; row < height; row++) {
|
||||
if (TIFFReadScanline(tif, buf, row, 0) < 0)
|
||||
error("%s: bad data read on line: %d\n", row);
|
||||
inp = buf;
|
||||
outp = (u_char *) mprd_addr(mpr_d(pix), 0, row);
|
||||
switch (photometric) {
|
||||
case PHOTOMETRIC_RGB:
|
||||
if (samplesperpixel == 4)
|
||||
for (col = 0; col < width; col++) {
|
||||
*outp++ = *inp++; /* Blue */
|
||||
*outp++ = *inp++; /* Green */
|
||||
*outp++ = *inp++; /* Red */
|
||||
inp++; /* skip alpha channel */
|
||||
}
|
||||
else
|
||||
for (col = 0; col < width; col++) {
|
||||
*outp++ = *inp++; /* Blue */
|
||||
*outp++ = *inp++; /* Green */
|
||||
*outp++ = *inp++; /* Red */
|
||||
}
|
||||
break;
|
||||
case PHOTOMETRIC_MINISWHITE:
|
||||
case PHOTOMETRIC_MINISBLACK:
|
||||
switch (bitspersample) {
|
||||
case 1:
|
||||
for (col = 0; col < ((width + 7) / 8); col++)
|
||||
*outp++ = *inp++;
|
||||
break;
|
||||
case 2:
|
||||
for (col = 0; col < ((width + 3) / 4); col++) {
|
||||
*outp++ = (*inp >> 6) & 3;
|
||||
*outp++ = (*inp >> 4) & 3;
|
||||
*outp++ = (*inp >> 2) & 3;
|
||||
*outp++ = *inp++ & 3;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
for (col = 0; col < width / 2; col++) {
|
||||
*outp++ = *inp >> 4;
|
||||
*outp++ = *inp++ & 0xf;
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
for (col = 0; col < width; col++)
|
||||
*outp++ = *inp++;
|
||||
break;
|
||||
default:
|
||||
error("%s: bad bits/sample: %d\n", bitspersample);
|
||||
}
|
||||
break;
|
||||
case PHOTOMETRIC_PALETTE:
|
||||
memcpy(outp, inp, width);
|
||||
break;
|
||||
default:
|
||||
error("%s: unknown photometric (write): %d\n", photometric);
|
||||
}
|
||||
for (row = 0; row < height; row++)
|
||||
{
|
||||
if (TIFFReadScanline(tif, buf, row, 0) < 0)
|
||||
error("%s: bad data read on line: %d\n", row);
|
||||
inp = buf;
|
||||
outp = (u_char *)mprd_addr(mpr_d(pix), 0, row);
|
||||
switch (photometric)
|
||||
{
|
||||
case PHOTOMETRIC_RGB:
|
||||
if (samplesperpixel == 4)
|
||||
for (col = 0; col < width; col++)
|
||||
{
|
||||
*outp++ = *inp++; /* Blue */
|
||||
*outp++ = *inp++; /* Green */
|
||||
*outp++ = *inp++; /* Red */
|
||||
inp++; /* skip alpha channel */
|
||||
}
|
||||
else
|
||||
for (col = 0; col < width; col++)
|
||||
{
|
||||
*outp++ = *inp++; /* Blue */
|
||||
*outp++ = *inp++; /* Green */
|
||||
*outp++ = *inp++; /* Red */
|
||||
}
|
||||
break;
|
||||
case PHOTOMETRIC_MINISWHITE:
|
||||
case PHOTOMETRIC_MINISBLACK:
|
||||
switch (bitspersample)
|
||||
{
|
||||
case 1:
|
||||
for (col = 0; col < ((width + 7) / 8); col++)
|
||||
*outp++ = *inp++;
|
||||
break;
|
||||
case 2:
|
||||
for (col = 0; col < ((width + 3) / 4); col++)
|
||||
{
|
||||
*outp++ = (*inp >> 6) & 3;
|
||||
*outp++ = (*inp >> 4) & 3;
|
||||
*outp++ = (*inp >> 2) & 3;
|
||||
*outp++ = *inp++ & 3;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
for (col = 0; col < width / 2; col++)
|
||||
{
|
||||
*outp++ = *inp >> 4;
|
||||
*outp++ = *inp++ & 0xf;
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
for (col = 0; col < width; col++)
|
||||
*outp++ = *inp++;
|
||||
break;
|
||||
default:
|
||||
error("%s: bad bits/sample: %d\n", bitspersample);
|
||||
}
|
||||
break;
|
||||
case PHOTOMETRIC_PALETTE:
|
||||
memcpy(outp, inp, width);
|
||||
break;
|
||||
default:
|
||||
error("%s: unknown photometric (write): %d\n", photometric);
|
||||
}
|
||||
}
|
||||
|
||||
free((char *) buf);
|
||||
free((char *)buf);
|
||||
|
||||
if (Verbose)
|
||||
fprintf(stderr, "done.\n");
|
||||
fprintf(stderr, "done.\n");
|
||||
|
||||
if (outf == NULL || strcmp(outf, "Standard Output") == 0) {
|
||||
outf = "Standard Output";
|
||||
fp = stdout;
|
||||
} else {
|
||||
if (!(fp = fopen(outf, "w")))
|
||||
error("%s: %s couldn't be opened for writing.\n", outf);
|
||||
if (outf == NULL || strcmp(outf, "Standard Output") == 0)
|
||||
{
|
||||
outf = "Standard Output";
|
||||
fp = stdout;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(fp = fopen(outf, "w")))
|
||||
error("%s: %s couldn't be opened for writing.\n", outf);
|
||||
}
|
||||
|
||||
if (Verbose)
|
||||
fprintf(stderr, "Writing rasterfile in %s...", outf);
|
||||
fprintf(stderr, "Writing rasterfile in %s...", outf);
|
||||
|
||||
if (pr_dump(pix, fp, &Colormap, RT_BYTE_ENCODED, 0) == PIX_ERR)
|
||||
error("%s: error writing Sun Rasterfile: %s\n", outf);
|
||||
error("%s: error writing Sun Rasterfile: %s\n", outf);
|
||||
|
||||
if (Verbose)
|
||||
fprintf(stderr, "done.\n");
|
||||
fprintf(stderr, "done.\n");
|
||||
|
||||
pr_destroy(pix);
|
||||
|
||||
if (fp != stdout)
|
||||
fclose(fp);
|
||||
fclose(fp);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
+146
-170
@@ -2,237 +2,213 @@
|
||||
|
||||
#include "tiffstream.h"
|
||||
|
||||
const char* TiffStream::m_name = "TiffStream";
|
||||
const char *TiffStream::m_name = "TiffStream";
|
||||
|
||||
TiffStream::TiffStream()
|
||||
{
|
||||
m_tif = NULL;
|
||||
|
||||
|
||||
m_inStream = NULL;
|
||||
m_outStream = NULL;
|
||||
m_ioStream = NULL;
|
||||
m_outStream = NULL;
|
||||
m_ioStream = NULL;
|
||||
|
||||
m_streamLength = 0;
|
||||
m_streamLength = 0;
|
||||
|
||||
m_this = reinterpret_cast<thandle_t>(this);
|
||||
m_this = reinterpret_cast<thandle_t>(this);
|
||||
};
|
||||
|
||||
TiffStream::~TiffStream()
|
||||
{
|
||||
if(m_tif != NULL) TIFFClose(m_tif);
|
||||
if (m_tif != NULL)
|
||||
TIFFClose(m_tif);
|
||||
}
|
||||
|
||||
TIFF*
|
||||
TiffStream::makeFileStream(istream* str)
|
||||
TIFF *TiffStream::makeFileStream(istream *str)
|
||||
{
|
||||
m_inStream = str;
|
||||
m_outStream = NULL;
|
||||
m_ioStream = NULL;
|
||||
m_outStream = NULL;
|
||||
m_ioStream = NULL;
|
||||
m_streamLength = getSize(m_this);
|
||||
|
||||
m_tif = TIFFClientOpen(m_name,
|
||||
"r",
|
||||
m_this,
|
||||
read,
|
||||
write,
|
||||
seek,
|
||||
close,
|
||||
size,
|
||||
map,
|
||||
unmap);
|
||||
m_tif = TIFFClientOpen(m_name, "r", m_this, read, write, seek, close, size,
|
||||
map, unmap);
|
||||
return m_tif;
|
||||
}
|
||||
|
||||
TIFF*
|
||||
TiffStream::makeFileStream(ostream* str)
|
||||
TIFF *TiffStream::makeFileStream(ostream *str)
|
||||
{
|
||||
m_inStream = NULL;
|
||||
m_inStream = NULL;
|
||||
m_outStream = str;
|
||||
m_ioStream = NULL;
|
||||
m_streamLength = getSize(m_this);
|
||||
m_ioStream = NULL;
|
||||
m_streamLength = getSize(m_this);
|
||||
|
||||
m_tif = TIFFClientOpen(m_name,
|
||||
"w",
|
||||
m_this,
|
||||
read,
|
||||
write,
|
||||
seek,
|
||||
close,
|
||||
size,
|
||||
map,
|
||||
unmap);
|
||||
m_tif = TIFFClientOpen(m_name, "w", m_this, read, write, seek, close, size,
|
||||
map, unmap);
|
||||
return m_tif;
|
||||
}
|
||||
|
||||
TIFF*
|
||||
TiffStream::makeFileStream(iostream* str)
|
||||
TIFF *TiffStream::makeFileStream(iostream *str)
|
||||
{
|
||||
m_inStream = NULL;
|
||||
m_outStream = NULL;
|
||||
m_inStream = NULL;
|
||||
m_outStream = NULL;
|
||||
m_ioStream = str;
|
||||
m_streamLength = getSize(m_this);
|
||||
m_streamLength = getSize(m_this);
|
||||
|
||||
m_tif = TIFFClientOpen(m_name,
|
||||
"r+w",
|
||||
m_this,
|
||||
read,
|
||||
write,
|
||||
seek,
|
||||
close,
|
||||
size,
|
||||
map,
|
||||
unmap);
|
||||
m_tif = TIFFClientOpen(m_name, "r+w", m_this, read, write, seek, close,
|
||||
size, map, unmap);
|
||||
return m_tif;
|
||||
}
|
||||
|
||||
tsize_t
|
||||
TiffStream::read(thandle_t fd, tdata_t buf, tsize_t size)
|
||||
tsize_t TiffStream::read(thandle_t fd, tdata_t buf, tsize_t size)
|
||||
{
|
||||
istream* istr;
|
||||
TiffStream* ts = reinterpret_cast<TiffStream*>(fd);
|
||||
if(ts->m_inStream != NULL) {
|
||||
istr = ts->m_inStream;
|
||||
} else if(ts->m_ioStream != NULL) {
|
||||
istr = ts->m_ioStream;
|
||||
}
|
||||
istream *istr;
|
||||
TiffStream *ts = reinterpret_cast<TiffStream *>(fd);
|
||||
if (ts->m_inStream != NULL)
|
||||
{
|
||||
istr = ts->m_inStream;
|
||||
}
|
||||
else if (ts->m_ioStream != NULL)
|
||||
{
|
||||
istr = ts->m_ioStream;
|
||||
}
|
||||
|
||||
int remain = ts->m_streamLength - ts->tell(fd);
|
||||
int actual = remain < size ? remain : size;
|
||||
istr->read(reinterpret_cast<char*>(buf), actual);
|
||||
int remain = ts->m_streamLength - ts->tell(fd);
|
||||
int actual = remain < size ? remain : size;
|
||||
istr->read(reinterpret_cast<char *>(buf), actual);
|
||||
return istr->gcount();
|
||||
}
|
||||
|
||||
tsize_t
|
||||
TiffStream::write(thandle_t fd, tdata_t buf, tsize_t size)
|
||||
tsize_t TiffStream::write(thandle_t fd, tdata_t buf, tsize_t size)
|
||||
{
|
||||
TiffStream* ts = reinterpret_cast<TiffStream*>(fd);
|
||||
ostream* ostr;
|
||||
if(ts->m_outStream != NULL) {
|
||||
ostr = ts->m_outStream;
|
||||
} else if(ts->m_ioStream != NULL) {
|
||||
ostr = ts->m_ioStream;
|
||||
}
|
||||
TiffStream *ts = reinterpret_cast<TiffStream *>(fd);
|
||||
ostream *ostr;
|
||||
if (ts->m_outStream != NULL)
|
||||
{
|
||||
ostr = ts->m_outStream;
|
||||
}
|
||||
else if (ts->m_ioStream != NULL)
|
||||
{
|
||||
ostr = ts->m_ioStream;
|
||||
}
|
||||
|
||||
streampos start = ostr->tellp();
|
||||
ostr->write(reinterpret_cast<const char*>(buf), size);
|
||||
return ostr->tellp() - start;
|
||||
streampos start = ostr->tellp();
|
||||
ostr->write(reinterpret_cast<const char *>(buf), size);
|
||||
return ostr->tellp() - start;
|
||||
}
|
||||
|
||||
toff_t
|
||||
TiffStream::seek(thandle_t fd, toff_t offset, int origin)
|
||||
toff_t TiffStream::seek(thandle_t fd, toff_t offset, int origin)
|
||||
{
|
||||
TiffStream* ts = reinterpret_cast<TiffStream*>(fd);
|
||||
if(ts->seekInt(fd, offset, origin) == true) return offset;
|
||||
else return -1;
|
||||
TiffStream *ts = reinterpret_cast<TiffStream *>(fd);
|
||||
if (ts->seekInt(fd, offset, origin) == true)
|
||||
return offset;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
TiffStream::close(thandle_t fd)
|
||||
int TiffStream::close(thandle_t fd)
|
||||
{
|
||||
TiffStream* ts = reinterpret_cast<TiffStream*>(fd);
|
||||
if(ts->m_inStream != NULL) {
|
||||
ts->m_inStream = NULL;
|
||||
return 0;
|
||||
} else if(ts->m_outStream != NULL) {
|
||||
ts->m_outStream = NULL;
|
||||
return 0;
|
||||
} else if(ts->m_ioStream != NULL) {
|
||||
ts->m_ioStream = NULL;
|
||||
return 0;
|
||||
}
|
||||
TiffStream *ts = reinterpret_cast<TiffStream *>(fd);
|
||||
if (ts->m_inStream != NULL)
|
||||
{
|
||||
ts->m_inStream = NULL;
|
||||
return 0;
|
||||
}
|
||||
else if (ts->m_outStream != NULL)
|
||||
{
|
||||
ts->m_outStream = NULL;
|
||||
return 0;
|
||||
}
|
||||
else if (ts->m_ioStream != NULL)
|
||||
{
|
||||
ts->m_ioStream = NULL;
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
toff_t
|
||||
TiffStream::size(thandle_t fd)
|
||||
toff_t TiffStream::size(thandle_t fd)
|
||||
{
|
||||
TiffStream* ts = reinterpret_cast<TiffStream*>(fd);
|
||||
TiffStream *ts = reinterpret_cast<TiffStream *>(fd);
|
||||
return ts->getSize(fd);
|
||||
}
|
||||
|
||||
int
|
||||
TiffStream::map(thandle_t fd, tdata_t* phase, toff_t* psize)
|
||||
int TiffStream::map(thandle_t fd, tdata_t *phase, toff_t *psize) { return 0; }
|
||||
|
||||
void TiffStream::unmap(thandle_t fd, tdata_t base, tsize_t size) {}
|
||||
|
||||
unsigned int TiffStream::getSize(thandle_t fd)
|
||||
{
|
||||
if (!isOpen(fd))
|
||||
return 0;
|
||||
|
||||
unsigned int pos = tell(fd);
|
||||
seekInt(fd, 0, end);
|
||||
unsigned int size = tell(fd);
|
||||
seekInt(fd, pos, beg);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
unsigned int TiffStream::tell(thandle_t fd)
|
||||
{
|
||||
TiffStream *ts = reinterpret_cast<TiffStream *>(fd);
|
||||
if (ts->m_inStream != NULL)
|
||||
{
|
||||
return ts->m_inStream->tellg();
|
||||
}
|
||||
else if (ts->m_outStream != NULL)
|
||||
{
|
||||
return ts->m_outStream->tellp();
|
||||
}
|
||||
else if (ts->m_ioStream != NULL)
|
||||
{
|
||||
return ts->m_ioStream->tellg();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
TiffStream::unmap(thandle_t fd, tdata_t base, tsize_t size)
|
||||
bool TiffStream::seekInt(thandle_t fd, unsigned int offset, int origin)
|
||||
{
|
||||
}
|
||||
if (!isOpen(fd))
|
||||
return false;
|
||||
|
||||
unsigned int
|
||||
TiffStream::getSize(thandle_t fd)
|
||||
{
|
||||
if(!isOpen(fd)) return 0;
|
||||
ios::seek_dir org;
|
||||
switch (origin)
|
||||
{
|
||||
case beg:
|
||||
org = ios::beg;
|
||||
break;
|
||||
case cur:
|
||||
org = ios::cur;
|
||||
break;
|
||||
case end:
|
||||
org = ios::end;
|
||||
break;
|
||||
}
|
||||
|
||||
unsigned int pos = tell(fd);
|
||||
seekInt(fd, 0, end);
|
||||
unsigned int size = tell(fd);
|
||||
seekInt(fd, pos, beg);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
TiffStream::tell(thandle_t fd)
|
||||
{
|
||||
TiffStream* ts = reinterpret_cast<TiffStream*>(fd);
|
||||
if(ts->m_inStream != NULL) {
|
||||
return ts->m_inStream->tellg();
|
||||
} else if(ts->m_outStream != NULL) {
|
||||
return ts->m_outStream->tellp();
|
||||
} else if(ts->m_ioStream != NULL) {
|
||||
return ts->m_ioStream->tellg();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
TiffStream::seekInt(thandle_t fd, unsigned int offset, int origin)
|
||||
{
|
||||
if(!isOpen(fd)) return false;
|
||||
|
||||
ios::seek_dir org;
|
||||
switch(origin) {
|
||||
case beg:
|
||||
org = ios::beg;
|
||||
break;
|
||||
case cur:
|
||||
org = ios::cur;
|
||||
break;
|
||||
case end:
|
||||
org = ios::end;
|
||||
break;
|
||||
}
|
||||
|
||||
TiffStream* ts = reinterpret_cast<TiffStream*>(fd);
|
||||
if(ts->m_inStream != NULL) {
|
||||
ts->m_inStream->seekg(offset, org);
|
||||
return true;
|
||||
} else if(ts->m_outStream != NULL) {
|
||||
ts->m_outStream->seekp(offset, org);
|
||||
return true;
|
||||
} else if(ts->m_ioStream != NULL) {
|
||||
ts->m_ioStream->seekg(offset, org);
|
||||
ts->m_ioStream->seekp(offset, org);
|
||||
return true;
|
||||
}
|
||||
TiffStream *ts = reinterpret_cast<TiffStream *>(fd);
|
||||
if (ts->m_inStream != NULL)
|
||||
{
|
||||
ts->m_inStream->seekg(offset, org);
|
||||
return true;
|
||||
}
|
||||
else if (ts->m_outStream != NULL)
|
||||
{
|
||||
ts->m_outStream->seekp(offset, org);
|
||||
return true;
|
||||
}
|
||||
else if (ts->m_ioStream != NULL)
|
||||
{
|
||||
ts->m_ioStream->seekg(offset, org);
|
||||
ts->m_ioStream->seekp(offset, org);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
TiffStream::isOpen(thandle_t fd)
|
||||
bool TiffStream::isOpen(thandle_t fd)
|
||||
{
|
||||
TiffStream* ts = reinterpret_cast<TiffStream*>(fd);
|
||||
return (ts->m_inStream != NULL ||
|
||||
ts->m_outStream != NULL ||
|
||||
ts->m_ioStream != NULL);
|
||||
}/*
|
||||
* Local Variables:
|
||||
* mode: c++
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
TiffStream *ts = reinterpret_cast<TiffStream *>(fd);
|
||||
return (ts->m_inStream != NULL || ts->m_outStream != NULL ||
|
||||
ts->m_ioStream != NULL);
|
||||
}
|
||||
|
||||
+38
-44
@@ -7,64 +7,58 @@
|
||||
|
||||
#include "tiffio.h"
|
||||
|
||||
class TiffStream {
|
||||
class TiffStream
|
||||
{
|
||||
|
||||
public:
|
||||
public:
|
||||
// ctor/dtor
|
||||
TiffStream();
|
||||
~TiffStream();
|
||||
~TiffStream();
|
||||
|
||||
public:
|
||||
enum SeekDir {
|
||||
beg,
|
||||
cur,
|
||||
end,
|
||||
public:
|
||||
enum SeekDir
|
||||
{
|
||||
beg,
|
||||
cur,
|
||||
end,
|
||||
};
|
||||
|
||||
public:
|
||||
public:
|
||||
// factory methods
|
||||
TIFF* makeFileStream(iostream* str);
|
||||
TIFF* makeFileStream(istream* str);
|
||||
TIFF* makeFileStream(ostream* str);
|
||||
TIFF *makeFileStream(iostream *str);
|
||||
TIFF *makeFileStream(istream *str);
|
||||
TIFF *makeFileStream(ostream *str);
|
||||
|
||||
public:
|
||||
public:
|
||||
// tiff client methods
|
||||
static tsize_t read(thandle_t fd, tdata_t buf, tsize_t size);
|
||||
static tsize_t write(thandle_t fd, tdata_t buf, tsize_t size);
|
||||
static toff_t seek(thandle_t fd, toff_t offset, int origin);
|
||||
static toff_t size(thandle_t fd);
|
||||
static int close(thandle_t fd);
|
||||
static int map(thandle_t fd, tdata_t* phase, toff_t* psize);
|
||||
static void unmap(thandle_t fd, tdata_t base, tsize_t size);
|
||||
static tsize_t read(thandle_t fd, tdata_t buf, tsize_t size);
|
||||
static tsize_t write(thandle_t fd, tdata_t buf, tsize_t size);
|
||||
static toff_t seek(thandle_t fd, toff_t offset, int origin);
|
||||
static toff_t size(thandle_t fd);
|
||||
static int close(thandle_t fd);
|
||||
static int map(thandle_t fd, tdata_t *phase, toff_t *psize);
|
||||
static void unmap(thandle_t fd, tdata_t base, tsize_t size);
|
||||
|
||||
public:
|
||||
public:
|
||||
// query method
|
||||
TIFF* getTiffHandle() const { return m_tif; }
|
||||
unsigned int getStreamLength() { return m_streamLength; }
|
||||
TIFF *getTiffHandle() const { return m_tif; }
|
||||
unsigned int getStreamLength() { return m_streamLength; }
|
||||
|
||||
private:
|
||||
// internal methods
|
||||
private:
|
||||
// internal methods
|
||||
unsigned int getSize(thandle_t fd);
|
||||
unsigned int tell(thandle_t fd);
|
||||
bool seekInt(thandle_t fd, unsigned int offset, int origin);
|
||||
bool isOpen(thandle_t fd);
|
||||
unsigned int tell(thandle_t fd);
|
||||
bool seekInt(thandle_t fd, unsigned int offset, int origin);
|
||||
bool isOpen(thandle_t fd);
|
||||
|
||||
private:
|
||||
thandle_t m_this;
|
||||
TIFF* m_tif;
|
||||
static const char* m_name;
|
||||
istream* m_inStream;
|
||||
ostream* m_outStream;
|
||||
iostream* m_ioStream;
|
||||
int m_streamLength;
|
||||
|
||||
private:
|
||||
thandle_t m_this;
|
||||
TIFF *m_tif;
|
||||
static const char *m_name;
|
||||
istream *m_inStream;
|
||||
ostream *m_outStream;
|
||||
iostream *m_ioStream;
|
||||
int m_streamLength;
|
||||
};
|
||||
|
||||
#endif // _TIFF_STREAM_H_
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c++
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
+22
-27
@@ -5,35 +5,30 @@
|
||||
#include "xtiffio.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void main(int argc,char *argv[])
|
||||
void main(int argc, char *argv[])
|
||||
{
|
||||
char *fname="newtif.tif";
|
||||
int flags;
|
||||
char *fname = "newtif.tif";
|
||||
int flags;
|
||||
|
||||
TIFF *tif=(TIFF*)0; /* TIFF-level descriptor */
|
||||
TIFF *tif = (TIFF *)0; /* TIFF-level descriptor */
|
||||
|
||||
if (argc > 1)
|
||||
fname = argv[1];
|
||||
|
||||
tif = XTIFFOpen(fname, "r");
|
||||
if (!tif)
|
||||
goto failure;
|
||||
|
||||
/* We want the double array listed */
|
||||
flags = TIFFPRINT_MYMULTIDOUBLES;
|
||||
|
||||
TIFFPrintDirectory(tif, stdout, flags);
|
||||
XTIFFClose(tif);
|
||||
exit(0);
|
||||
|
||||
if (argc>1) fname=argv[1];
|
||||
|
||||
tif=XTIFFOpen(fname,"r");
|
||||
if (!tif) goto failure;
|
||||
|
||||
/* We want the double array listed */
|
||||
flags = TIFFPRINT_MYMULTIDOUBLES;
|
||||
|
||||
TIFFPrintDirectory(tif,stdout,flags);
|
||||
XTIFFClose(tif);
|
||||
exit (0);
|
||||
|
||||
failure:
|
||||
printf("failure in listtif\n");
|
||||
if (tif) XTIFFClose(tif);
|
||||
exit (-1);
|
||||
printf("failure in listtif\n");
|
||||
if (tif)
|
||||
XTIFFClose(tif);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
+39
-51
@@ -3,9 +3,8 @@
|
||||
* the XTIFF extended tiff example tags.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "xtiffio.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
void SetUpTIFFDirectory(TIFF *tif);
|
||||
void WriteImage(TIFF *tif);
|
||||
@@ -15,63 +14,52 @@ void WriteImage(TIFF *tif);
|
||||
|
||||
void main()
|
||||
{
|
||||
TIFF *tif=(TIFF*)0; /* TIFF-level descriptor */
|
||||
|
||||
tif=XTIFFOpen("newtif.tif","w");
|
||||
if (!tif) goto failure;
|
||||
|
||||
SetUpTIFFDirectory(tif);
|
||||
WriteImage(tif);
|
||||
|
||||
XTIFFClose(tif);
|
||||
exit (0);
|
||||
|
||||
failure:
|
||||
printf("failure in maketif\n");
|
||||
if (tif) XTIFFClose(tif);
|
||||
exit (-1);
|
||||
}
|
||||
TIFF *tif = (TIFF *)0; /* TIFF-level descriptor */
|
||||
|
||||
tif = XTIFFOpen("newtif.tif", "w");
|
||||
if (!tif)
|
||||
goto failure;
|
||||
|
||||
SetUpTIFFDirectory(tif);
|
||||
WriteImage(tif);
|
||||
|
||||
XTIFFClose(tif);
|
||||
exit(0);
|
||||
|
||||
failure:
|
||||
printf("failure in maketif\n");
|
||||
if (tif)
|
||||
XTIFFClose(tif);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
void SetUpTIFFDirectory(TIFF *tif)
|
||||
{
|
||||
double mymulti[6]={0.0,1.0,2.0, 3.1415926, 5.0,1.0};
|
||||
uint32_t mysingle=3456;
|
||||
char *ascii="This file was produced by Steven Spielberg. NOT";
|
||||
double mymulti[6] = {0.0, 1.0, 2.0, 3.1415926, 5.0, 1.0};
|
||||
uint32_t mysingle = 3456;
|
||||
char *ascii = "This file was produced by Steven Spielberg. NOT";
|
||||
|
||||
TIFFSetField(tif,TIFFTAG_IMAGEWIDTH,WIDTH);
|
||||
TIFFSetField(tif,TIFFTAG_IMAGELENGTH,HEIGHT);
|
||||
TIFFSetField(tif,TIFFTAG_COMPRESSION,COMPRESSION_NONE);
|
||||
TIFFSetField(tif,TIFFTAG_PHOTOMETRIC,PHOTOMETRIC_MINISBLACK);
|
||||
TIFFSetField(tif,TIFFTAG_PLANARCONFIG,PLANARCONFIG_CONTIG);
|
||||
TIFFSetField(tif,TIFFTAG_BITSPERSAMPLE,8);
|
||||
TIFFSetField(tif,TIFFTAG_ROWSPERSTRIP,20);
|
||||
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, WIDTH);
|
||||
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, HEIGHT);
|
||||
TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
|
||||
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
|
||||
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
|
||||
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 20);
|
||||
|
||||
/* Install the extended TIFF tag examples */
|
||||
TIFFSetField(tif,TIFFTAG_EXAMPLE_MULTI,6,mymulti);
|
||||
TIFFSetField(tif,TIFFTAG_EXAMPLE_SINGLE,mysingle);
|
||||
TIFFSetField(tif,TIFFTAG_EXAMPLE_ASCII,ascii);
|
||||
/* Install the extended TIFF tag examples */
|
||||
TIFFSetField(tif, TIFFTAG_EXAMPLE_MULTI, 6, mymulti);
|
||||
TIFFSetField(tif, TIFFTAG_EXAMPLE_SINGLE, mysingle);
|
||||
TIFFSetField(tif, TIFFTAG_EXAMPLE_ASCII, ascii);
|
||||
}
|
||||
|
||||
|
||||
void WriteImage(TIFF *tif)
|
||||
{
|
||||
int i;
|
||||
char buffer[WIDTH];
|
||||
|
||||
memset(buffer,0,sizeof(buffer));
|
||||
for (i=0;i<HEIGHT;i++)
|
||||
if (!TIFFWriteScanline(tif, buffer, i, 0))
|
||||
TIFFErrorExt(tif->tif_clientdata, "WriteImage","failure in WriteScanline\n");
|
||||
int i;
|
||||
char buffer[WIDTH];
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
for (i = 0; i < HEIGHT; i++)
|
||||
if (!TIFFWriteScanline(tif, buffer, i, 0))
|
||||
TIFFErrorExtR(tif, "WriteImage", "failure in WriteScanline\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
+231
-248
@@ -10,14 +10,14 @@
|
||||
*
|
||||
* Author: Niles D. Ritter
|
||||
*/
|
||||
|
||||
|
||||
#include "xtiffiop.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/* Tiff info structure.
|
||||
*
|
||||
* Entry format:
|
||||
* { TAGNUMBER, ReadCount, WriteCount, DataType, FIELDNUM,
|
||||
* { TAGNUMBER, ReadCount, WriteCount, DataType, FIELDNUM,
|
||||
* OkToChange, PassDirCountOnSet, AsciiName }
|
||||
*
|
||||
* For ReadCount, WriteCount, -1 = unknown; used for mult-valued
|
||||
@@ -25,219 +25,216 @@
|
||||
*/
|
||||
|
||||
static const TIFFFieldInfo xtiffFieldInfo[] = {
|
||||
|
||||
/* XXX Replace these example tags with your own extended tags */
|
||||
{ TIFFTAG_EXAMPLE_MULTI, -1,-1, TIFF_DOUBLE, FIELD_EXAMPLE_MULTI,
|
||||
TRUE, TRUE, "MyMultivaluedTag" },
|
||||
{ TIFFTAG_EXAMPLE_SINGLE, 1, 1, TIFF_LONG, FIELD_EXAMPLE_SINGLE,
|
||||
TRUE, FALSE, "MySingleLongTag" },
|
||||
{ TIFFTAG_EXAMPLE_ASCII, -1,-1, TIFF_ASCII, FIELD_EXAMPLE_ASCII,
|
||||
TRUE, FALSE, "MyAsciiTag" },
|
||||
|
||||
/* XXX Replace these example tags with your own extended tags */
|
||||
{TIFFTAG_EXAMPLE_MULTI, -1, -1, TIFF_DOUBLE, FIELD_EXAMPLE_MULTI, TRUE,
|
||||
TRUE, "MyMultivaluedTag"},
|
||||
{TIFFTAG_EXAMPLE_SINGLE, 1, 1, TIFF_LONG, FIELD_EXAMPLE_SINGLE, TRUE, FALSE,
|
||||
"MySingleLongTag"},
|
||||
{TIFFTAG_EXAMPLE_ASCII, -1, -1, TIFF_ASCII, FIELD_EXAMPLE_ASCII, TRUE,
|
||||
FALSE, "MyAsciiTag"},
|
||||
};
|
||||
#define N(a) (sizeof (a) / sizeof (a[0]))
|
||||
#define N(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
|
||||
static void
|
||||
_XTIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
|
||||
static void _XTIFFPrintDirectory(TIFF *tif, FILE *fd, long flags)
|
||||
{
|
||||
xtiff *xt = XTIFFDIR(tif);
|
||||
XTIFFDirectory *xd = &xt->xtif_dir;
|
||||
int i,num;
|
||||
xtiff *xt = XTIFFDIR(tif);
|
||||
XTIFFDirectory *xd = &xt->xtif_dir;
|
||||
int i, num;
|
||||
|
||||
/* call the inherited method */
|
||||
if (PARENT(xt,printdir))
|
||||
(PARENT(xt,printdir))(tif,fd,flags);
|
||||
/* call the inherited method */
|
||||
if (PARENT(xt, printdir))
|
||||
(PARENT(xt, printdir))(tif, fd, flags);
|
||||
|
||||
/* XXX Add field printing here. Replace the three example
|
||||
* tags implemented below with your own.
|
||||
*/
|
||||
/* XXX Add field printing here. Replace the three example
|
||||
* tags implemented below with your own.
|
||||
*/
|
||||
|
||||
fprintf(fd,"--My Example Tags--\n");
|
||||
fprintf(fd, "--My Example Tags--\n");
|
||||
|
||||
/* Our first example tag may have a lot of values, so we
|
||||
* will only print them out if the TIFFPRINT_MYMULTIDOUBLES
|
||||
* flag is passed into the print method.
|
||||
*/
|
||||
if (TIFFFieldSet(tif,FIELD_EXAMPLE_MULTI))
|
||||
{
|
||||
fprintf(fd, " My Multi-Valued Doubles:");
|
||||
if (flags & TIFFPRINT_MYMULTIDOUBLES)
|
||||
{
|
||||
double *value = xd->xd_example_multi;
|
||||
|
||||
num = xd->xd_num_multi;
|
||||
fprintf(fd,"(");
|
||||
for (i=0;i<num;i++) fprintf(fd, " %lg", *value++);
|
||||
fprintf(fd,")\n");
|
||||
} else
|
||||
fprintf(fd, "(present)\n");
|
||||
}
|
||||
/* Our first example tag may have a lot of values, so we
|
||||
* will only print them out if the TIFFPRINT_MYMULTIDOUBLES
|
||||
* flag is passed into the print method.
|
||||
*/
|
||||
if (TIFFFieldSet(tif, FIELD_EXAMPLE_MULTI))
|
||||
{
|
||||
fprintf(fd, " My Multi-Valued Doubles:");
|
||||
if (flags & TIFFPRINT_MYMULTIDOUBLES)
|
||||
{
|
||||
double *value = xd->xd_example_multi;
|
||||
|
||||
if (TIFFFieldSet(tif,FIELD_EXAMPLE_SINGLE))
|
||||
{
|
||||
fprintf(fd, " My Single Long Tag: %lu\n", xd->xd_example_single);
|
||||
}
|
||||
num = xd->xd_num_multi;
|
||||
fprintf(fd, "(");
|
||||
for (i = 0; i < num; i++)
|
||||
fprintf(fd, " %lg", *value++);
|
||||
fprintf(fd, ")\n");
|
||||
}
|
||||
else
|
||||
fprintf(fd, "(present)\n");
|
||||
}
|
||||
|
||||
if (TIFFFieldSet(tif,FIELD_EXAMPLE_ASCII))
|
||||
{
|
||||
_TIFFprintAsciiTag(fd,"My ASCII Tag",
|
||||
xd->xd_example_ascii);
|
||||
}
|
||||
if (TIFFFieldSet(tif, FIELD_EXAMPLE_SINGLE))
|
||||
{
|
||||
fprintf(fd, " My Single Long Tag: %lu\n", xd->xd_example_single);
|
||||
}
|
||||
|
||||
if (TIFFFieldSet(tif, FIELD_EXAMPLE_ASCII))
|
||||
{
|
||||
_TIFFprintAsciiTag(fd, "My ASCII Tag", xd->xd_example_ascii);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_XTIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
|
||||
static int _XTIFFVSetField(TIFF *tif, ttag_t tag, va_list ap)
|
||||
{
|
||||
xtiff *xt = XTIFFDIR(tif);
|
||||
XTIFFDirectory* xd = &xt->xtif_dir;
|
||||
int status = 1;
|
||||
uint32_t v32=0;
|
||||
int i=0, v=0;
|
||||
va_list ap1 = ap;
|
||||
xtiff *xt = XTIFFDIR(tif);
|
||||
XTIFFDirectory *xd = &xt->xtif_dir;
|
||||
int status = 1;
|
||||
uint32_t v32 = 0;
|
||||
int i = 0, v = 0;
|
||||
va_list ap1 = ap;
|
||||
|
||||
/* va_start is called by the calling routine */
|
||||
|
||||
switch (tag) {
|
||||
/*
|
||||
* XXX put your extended tags here; replace the implemented
|
||||
* example tags with your own.
|
||||
*/
|
||||
case TIFFTAG_EXAMPLE_MULTI:
|
||||
/* multi-valued tags need to store the count as well */
|
||||
xd->xd_num_multi = (uint16_t) va_arg(ap, int);
|
||||
_TIFFsetDoubleArray(&xd->xd_example_multi, va_arg(ap, double*),
|
||||
(long) xd->xd_num_multi);
|
||||
break;
|
||||
case TIFFTAG_EXAMPLE_SINGLE:
|
||||
xd->xd_example_single = va_arg(ap, uint32_t);
|
||||
break;
|
||||
case TIFFTAG_EXAMPLE_ASCII:
|
||||
_TIFFsetString(&xd->xd_example_ascii, va_arg(ap, char*));
|
||||
break;
|
||||
default:
|
||||
/* call the inherited method */
|
||||
return (PARENT(xt,vsetfield))(tif,tag,ap);
|
||||
break;
|
||||
}
|
||||
if (status) {
|
||||
/* we have to override the print method here,
|
||||
* after the compression tags have gotten to it.
|
||||
* This makes sense because the only time we would
|
||||
* need the extended print method is if an extended
|
||||
* tag is set by the reader.
|
||||
*/
|
||||
if (!(xt->xtif_flags & XTIFFP_PRINT))
|
||||
{
|
||||
PARENT(xt,printdir) = TIFFMEMBER(tif,printdir);
|
||||
TIFFMEMBER(tif,printdir) = _XTIFFPrintDirectory;
|
||||
xt->xtif_flags |= XTIFFP_PRINT;
|
||||
}
|
||||
TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit);
|
||||
tif->tif_flags |= TIFF_DIRTYDIRECT;
|
||||
}
|
||||
va_end(ap);
|
||||
return (status);
|
||||
/* va_start is called by the calling routine */
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
/*
|
||||
* XXX put your extended tags here; replace the implemented
|
||||
* example tags with your own.
|
||||
*/
|
||||
case TIFFTAG_EXAMPLE_MULTI:
|
||||
/* multi-valued tags need to store the count as well */
|
||||
xd->xd_num_multi = (uint16_t)va_arg(ap, int);
|
||||
_TIFFsetDoubleArray(&xd->xd_example_multi, va_arg(ap, double *),
|
||||
(long)xd->xd_num_multi);
|
||||
break;
|
||||
case TIFFTAG_EXAMPLE_SINGLE:
|
||||
xd->xd_example_single = va_arg(ap, uint32_t);
|
||||
break;
|
||||
case TIFFTAG_EXAMPLE_ASCII:
|
||||
_TIFFsetString(&xd->xd_example_ascii, va_arg(ap, char *));
|
||||
break;
|
||||
default:
|
||||
/* call the inherited method */
|
||||
return (PARENT(xt, vsetfield))(tif, tag, ap);
|
||||
break;
|
||||
}
|
||||
if (status)
|
||||
{
|
||||
/* we have to override the print method here,
|
||||
* after the compression tags have gotten to it.
|
||||
* This makes sense because the only time we would
|
||||
* need the extended print method is if an extended
|
||||
* tag is set by the reader.
|
||||
*/
|
||||
if (!(xt->xtif_flags & XTIFFP_PRINT))
|
||||
{
|
||||
PARENT(xt, printdir) = TIFFMEMBER(tif, printdir);
|
||||
TIFFMEMBER(tif, printdir) = _XTIFFPrintDirectory;
|
||||
xt->xtif_flags |= XTIFFP_PRINT;
|
||||
}
|
||||
TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit);
|
||||
tif->tif_flags |= TIFF_DIRTYDIRECT;
|
||||
}
|
||||
va_end(ap);
|
||||
return (status);
|
||||
badvalue:
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "%d: Bad value for \"%s\"", v,
|
||||
_TIFFFieldWithTag(tif, tag)->field_name);
|
||||
va_end(ap);
|
||||
return (0);
|
||||
TIFFErrorExtR(tif, tif->tif_name, "%d: Bad value for \"%s\"", v,
|
||||
_TIFFFieldWithTag(tif, tag)->field_name);
|
||||
va_end(ap);
|
||||
return (0);
|
||||
badvalue32:
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "%ld: Bad value for \"%s\"", v32,
|
||||
_TIFFFieldWithTag(tif, tag)->field_name);
|
||||
va_end(ap);
|
||||
return (0);
|
||||
TIFFErrorExtR(tif, tif->tif_name, "%ld: Bad value for \"%s\"", v32,
|
||||
_TIFFFieldWithTag(tif, tag)->field_name);
|
||||
va_end(ap);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
_XTIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
|
||||
static int _XTIFFVGetField(TIFF *tif, ttag_t tag, va_list ap)
|
||||
{
|
||||
xtiff *xt = XTIFFDIR(tif);
|
||||
XTIFFDirectory* xd = &xt->xtif_dir;
|
||||
xtiff *xt = XTIFFDIR(tif);
|
||||
XTIFFDirectory *xd = &xt->xtif_dir;
|
||||
|
||||
switch (tag) {
|
||||
/*
|
||||
* XXX put your extended tags here; replace the implemented
|
||||
* example tags with your own.
|
||||
*/
|
||||
case TIFFTAG_EXAMPLE_MULTI:
|
||||
*va_arg(ap, uint16_t*) = xd->xd_num_multi;
|
||||
*va_arg(ap, double**) = xd->xd_example_multi;
|
||||
break;
|
||||
case TIFFTAG_EXAMPLE_ASCII:
|
||||
*va_arg(ap, char**) = xd->xd_example_ascii;
|
||||
break;
|
||||
case TIFFTAG_EXAMPLE_SINGLE:
|
||||
*va_arg(ap, uint32_t*) = xd->xd_example_single;
|
||||
break;
|
||||
default:
|
||||
/* return inherited method */
|
||||
return (PARENT(xt,vgetfield))(tif,tag,ap);
|
||||
break;
|
||||
}
|
||||
return (1);
|
||||
switch (tag)
|
||||
{
|
||||
/*
|
||||
* XXX put your extended tags here; replace the implemented
|
||||
* example tags with your own.
|
||||
*/
|
||||
case TIFFTAG_EXAMPLE_MULTI:
|
||||
*va_arg(ap, uint16_t *) = xd->xd_num_multi;
|
||||
*va_arg(ap, double **) = xd->xd_example_multi;
|
||||
break;
|
||||
case TIFFTAG_EXAMPLE_ASCII:
|
||||
*va_arg(ap, char **) = xd->xd_example_ascii;
|
||||
break;
|
||||
case TIFFTAG_EXAMPLE_SINGLE:
|
||||
*va_arg(ap, uint32_t *) = xd->xd_example_single;
|
||||
break;
|
||||
default:
|
||||
/* return inherited method */
|
||||
return (PARENT(xt, vgetfield))(tif, tag, ap);
|
||||
break;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
#define CleanupField(member) { \
|
||||
if (xd->member) { \
|
||||
_TIFFfree(xd->member); \
|
||||
xd->member = 0; \
|
||||
} \
|
||||
}
|
||||
#define CleanupField(member) \
|
||||
{ \
|
||||
if (xd->member) \
|
||||
{ \
|
||||
_TIFFfree(xd->member); \
|
||||
xd->member = 0; \
|
||||
} \
|
||||
}
|
||||
/*
|
||||
* Release storage associated with a directory.
|
||||
*/
|
||||
static void
|
||||
_XTIFFFreeDirectory(xtiff* xt)
|
||||
static void _XTIFFFreeDirectory(xtiff *xt)
|
||||
{
|
||||
XTIFFDirectory* xd = &xt->xtif_dir;
|
||||
XTIFFDirectory *xd = &xt->xtif_dir;
|
||||
|
||||
/*
|
||||
* XXX - Purge all Your allocated memory except
|
||||
* for the xtiff directory itself. This includes
|
||||
* all fields that require a _TIFFsetXXX call in
|
||||
* _XTIFFVSetField().
|
||||
*/
|
||||
|
||||
CleanupField(xd_example_multi);
|
||||
CleanupField(xd_example_ascii);
|
||||
|
||||
/*
|
||||
* XXX - Purge all Your allocated memory except
|
||||
* for the xtiff directory itself. This includes
|
||||
* all fields that require a _TIFFsetXXX call in
|
||||
* _XTIFFVSetField().
|
||||
*/
|
||||
|
||||
CleanupField(xd_example_multi);
|
||||
CleanupField(xd_example_ascii);
|
||||
}
|
||||
#undef CleanupField
|
||||
|
||||
static void _XTIFFLocalDefaultDirectory(TIFF *tif)
|
||||
{
|
||||
xtiff *xt = XTIFFDIR(tif);
|
||||
XTIFFDirectory* xd = &xt->xtif_dir;
|
||||
xtiff *xt = XTIFFDIR(tif);
|
||||
XTIFFDirectory *xd = &xt->xtif_dir;
|
||||
|
||||
/* Install the extended Tag field info */
|
||||
_TIFFMergeFieldInfo(tif, xtiffFieldInfo, N(xtiffFieldInfo));
|
||||
/* Install the extended Tag field info */
|
||||
_TIFFMergeFieldInfo(tif, xtiffFieldInfo, N(xtiffFieldInfo));
|
||||
|
||||
/*
|
||||
* free up any dynamically allocated arrays
|
||||
* before the new directory is read in.
|
||||
*/
|
||||
|
||||
_XTIFFFreeDirectory(xt);
|
||||
_TIFFmemset(xt,0,sizeof(xtiff));
|
||||
/*
|
||||
* free up any dynamically allocated arrays
|
||||
* before the new directory is read in.
|
||||
*/
|
||||
|
||||
/* Override the tag access methods */
|
||||
_XTIFFFreeDirectory(xt);
|
||||
_TIFFmemset(xt, 0, sizeof(xtiff));
|
||||
|
||||
PARENT(xt,vsetfield) = TIFFMEMBER(tif,vsetfield);
|
||||
TIFFMEMBER(tif,vsetfield) = _XTIFFVSetField;
|
||||
PARENT(xt,vgetfield) = TIFFMEMBER(tif,vgetfield);
|
||||
TIFFMEMBER(tif,vgetfield) = _XTIFFVGetField;
|
||||
/* Override the tag access methods */
|
||||
|
||||
/*
|
||||
* XXX Set up any default values here.
|
||||
*/
|
||||
|
||||
xd->xd_example_single = 234;
|
||||
PARENT(xt, vsetfield) = TIFFMEMBER(tif, vsetfield);
|
||||
TIFFMEMBER(tif, vsetfield) = _XTIFFVSetField;
|
||||
PARENT(xt, vgetfield) = TIFFMEMBER(tif, vgetfield);
|
||||
TIFFMEMBER(tif, vgetfield) = _XTIFFVGetField;
|
||||
|
||||
/*
|
||||
* XXX Set up any default values here.
|
||||
*/
|
||||
|
||||
xd->xd_example_single = 234;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* Nothing below this line should need to be changed.
|
||||
**********************************************************************/
|
||||
@@ -250,39 +247,37 @@ static TIFFExtendProc _ParentExtender;
|
||||
* every time a new TIFF directory is opened.
|
||||
*/
|
||||
|
||||
static void
|
||||
_XTIFFDefaultDirectory(TIFF *tif)
|
||||
static void _XTIFFDefaultDirectory(TIFF *tif)
|
||||
{
|
||||
xtiff *xt;
|
||||
|
||||
/* Allocate Directory Structure if first time, and install it */
|
||||
if (!(tif->tif_flags & XTIFF_INITIALIZED))
|
||||
{
|
||||
xt = _TIFFmalloc(sizeof(xtiff));
|
||||
if (!xt)
|
||||
{
|
||||
/* handle memory allocation failure here ! */
|
||||
return;
|
||||
}
|
||||
_TIFFmemset(xt,0,sizeof(xtiff));
|
||||
/*
|
||||
* Install into TIFF structure.
|
||||
*/
|
||||
TIFFMEMBER(tif,clientdir) = (tidata_t)xt;
|
||||
tif->tif_flags |= XTIFF_INITIALIZED; /* don't do this again! */
|
||||
}
|
||||
|
||||
/* set up our own defaults */
|
||||
_XTIFFLocalDefaultDirectory(tif);
|
||||
xtiff *xt;
|
||||
|
||||
/* Since an XTIFF client module may have overridden
|
||||
* the default directory method, we call it now to
|
||||
* allow it to set up the rest of its own methods.
|
||||
/* Allocate Directory Structure if first time, and install it */
|
||||
if (!(tif->tif_flags & XTIFF_INITIALIZED))
|
||||
{
|
||||
xt = _TIFFmalloc(sizeof(xtiff));
|
||||
if (!xt)
|
||||
{
|
||||
/* handle memory allocation failure here ! */
|
||||
return;
|
||||
}
|
||||
_TIFFmemset(xt, 0, sizeof(xtiff));
|
||||
/*
|
||||
* Install into TIFF structure.
|
||||
*/
|
||||
TIFFMEMBER(tif, clientdir) = (tidata_t)xt;
|
||||
tif->tif_flags |= XTIFF_INITIALIZED; /* don't do this again! */
|
||||
}
|
||||
|
||||
if (_ParentExtender)
|
||||
(*_ParentExtender)(tif);
|
||||
/* set up our own defaults */
|
||||
_XTIFFLocalDefaultDirectory(tif);
|
||||
|
||||
/* Since an XTIFF client module may have overridden
|
||||
* the default directory method, we call it now to
|
||||
* allow it to set up the rest of its own methods.
|
||||
*/
|
||||
|
||||
if (_ParentExtender)
|
||||
(*_ParentExtender)(tif);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -290,61 +285,49 @@ _XTIFFDefaultDirectory(TIFF *tif)
|
||||
* procedure for the TIFF module.
|
||||
*/
|
||||
|
||||
static
|
||||
void _XTIFFInitialize(void)
|
||||
static void _XTIFFInitialize(void)
|
||||
{
|
||||
static first_time=1;
|
||||
|
||||
if (! first_time) return; /* Been there. Done that. */
|
||||
first_time = 0;
|
||||
|
||||
/* Grab the inherited method and install */
|
||||
_ParentExtender = TIFFSetTagExtender(_XTIFFDefaultDirectory);
|
||||
}
|
||||
static first_time = 1;
|
||||
|
||||
if (!first_time)
|
||||
return; /* Been there. Done that. */
|
||||
first_time = 0;
|
||||
|
||||
/* Grab the inherited method and install */
|
||||
_ParentExtender = TIFFSetTagExtender(_XTIFFDefaultDirectory);
|
||||
}
|
||||
|
||||
/*
|
||||
* Public File I/O Routines.
|
||||
*/
|
||||
TIFF*
|
||||
XTIFFOpen(const char* name, const char* mode)
|
||||
TIFF *XTIFFOpen(const char *name, const char *mode)
|
||||
{
|
||||
/* Set up the callback */
|
||||
_XTIFFInitialize();
|
||||
|
||||
/* Open the file; the callback will set everything up
|
||||
*/
|
||||
return TIFFOpen(name, mode);
|
||||
/* Set up the callback */
|
||||
_XTIFFInitialize();
|
||||
|
||||
/* Open the file; the callback will set everything up
|
||||
*/
|
||||
return TIFFOpen(name, mode);
|
||||
}
|
||||
|
||||
TIFF*
|
||||
XTIFFFdOpen(int fd, const char* name, const char* mode)
|
||||
TIFF *XTIFFFdOpen(int fd, const char *name, const char *mode)
|
||||
{
|
||||
/* Set up the callback */
|
||||
_XTIFFInitialize();
|
||||
/* Set up the callback */
|
||||
_XTIFFInitialize();
|
||||
|
||||
/* Open the file; the callback will set everything up
|
||||
*/
|
||||
return TIFFFdOpen(fd, name, mode);
|
||||
/* Open the file; the callback will set everything up
|
||||
*/
|
||||
return TIFFFdOpen(fd, name, mode);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
XTIFFClose(TIFF *tif)
|
||||
void XTIFFClose(TIFF *tif)
|
||||
{
|
||||
xtiff *xt = XTIFFDIR(tif);
|
||||
|
||||
/* call inherited function first */
|
||||
TIFFClose(tif);
|
||||
|
||||
/* Free up extended allocated memory */
|
||||
_XTIFFFreeDirectory(xt);
|
||||
_TIFFfree(xt);
|
||||
xtiff *xt = XTIFFDIR(tif);
|
||||
|
||||
/* call inherited function first */
|
||||
TIFFClose(tif);
|
||||
|
||||
/* Free up extended allocated memory */
|
||||
_XTIFFFreeDirectory(xt);
|
||||
_TIFFfree(xt);
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
+12
-19
@@ -14,46 +14,39 @@
|
||||
|
||||
#include "tiffio.h"
|
||||
|
||||
/*
|
||||
* XXX Define your private Tag names and values here
|
||||
/*
|
||||
* XXX Define your private Tag names and values here
|
||||
*/
|
||||
|
||||
/* These tags are not valid, but are provided for example */
|
||||
#define TIFFTAG_EXAMPLE_MULTI 61234
|
||||
#define TIFFTAG_EXAMPLE_SINGLE 61235
|
||||
#define TIFFTAG_EXAMPLE_ASCII 61236
|
||||
#define TIFFTAG_EXAMPLE_MULTI 61234
|
||||
#define TIFFTAG_EXAMPLE_SINGLE 61235
|
||||
#define TIFFTAG_EXAMPLE_ASCII 61236
|
||||
|
||||
/*
|
||||
/*
|
||||
* XXX Define Printing method flags. These
|
||||
* flags may be passed in to TIFFPrintDirectory() to
|
||||
* indicate that those particular field values should
|
||||
* be printed out in full, rather than just an indicator
|
||||
* of whether they are present or not.
|
||||
*/
|
||||
#define TIFFPRINT_MYMULTIDOUBLES 0x80000000
|
||||
#define TIFFPRINT_MYMULTIDOUBLES 0x80000000
|
||||
|
||||
/**********************************************************************
|
||||
* Nothing below this line should need to be changed by the user.
|
||||
**********************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern TIFF* XTIFFOpen(const char* name, const char* mode);
|
||||
extern TIFF* XTIFFFdOpen(int fd, const char* name, const char* mode);
|
||||
extern void XTIFFClose(TIFF *tif);
|
||||
extern TIFF *XTIFFOpen(const char *name, const char *mode);
|
||||
extern TIFF *XTIFFFdOpen(int fd, const char *name, const char *mode);
|
||||
extern void XTIFFClose(TIFF *tif);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __xtiffio_h */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
+23
-30
@@ -22,20 +22,20 @@
|
||||
|
||||
/* XXX - Define number of your extended tags here */
|
||||
#define NUM_XFIELD 3
|
||||
#define XFIELD_BASE (FIELD_LAST-NUM_XFIELD)
|
||||
#define XFIELD_BASE (FIELD_LAST - NUM_XFIELD)
|
||||
|
||||
/* XXX - Define your Tag Fields here */
|
||||
#define FIELD_EXAMPLE_MULTI (XFIELD_BASE+0)
|
||||
#define FIELD_EXAMPLE_SINGLE (XFIELD_BASE+1)
|
||||
#define FIELD_EXAMPLE_ASCII (XFIELD_BASE+2)
|
||||
|
||||
#define FIELD_EXAMPLE_MULTI (XFIELD_BASE + 0)
|
||||
#define FIELD_EXAMPLE_SINGLE (XFIELD_BASE + 1)
|
||||
#define FIELD_EXAMPLE_ASCII (XFIELD_BASE + 2)
|
||||
|
||||
/* XXX - Define Private directory tag structure here */
|
||||
struct XTIFFDirectory {
|
||||
uint16_t xd_num_multi; /* dir-count for the multi tag */
|
||||
double* xd_example_multi;
|
||||
uint32_t xd_example_single;
|
||||
char* xd_example_ascii;
|
||||
struct XTIFFDirectory
|
||||
{
|
||||
uint16_t xd_num_multi; /* dir-count for the multi tag */
|
||||
double *xd_example_multi;
|
||||
uint32_t xd_example_single;
|
||||
char *xd_example_ascii;
|
||||
};
|
||||
typedef struct XTIFFDirectory XTIFFDirectory;
|
||||
|
||||
@@ -43,30 +43,23 @@ typedef struct XTIFFDirectory XTIFFDirectory;
|
||||
* Nothing below this line should need to be changed by the user.
|
||||
**********************************************************************/
|
||||
|
||||
struct xtiff {
|
||||
TIFF *xtif_tif; /* parent TIFF pointer */
|
||||
uint32_t xtif_flags;
|
||||
#define XTIFFP_PRINT 0x00000001
|
||||
XTIFFDirectory xtif_dir; /* internal rep of current directory */
|
||||
TIFFVSetMethod xtif_vsetfield; /* inherited tag set routine */
|
||||
TIFFVGetMethod xtif_vgetfield; /* inherited tag get routine */
|
||||
TIFFPrintMethod xtif_printdir; /* inherited dir print method */
|
||||
struct xtiff
|
||||
{
|
||||
TIFF *xtif_tif; /* parent TIFF pointer */
|
||||
uint32_t xtif_flags;
|
||||
#define XTIFFP_PRINT 0x00000001
|
||||
XTIFFDirectory xtif_dir; /* internal rep of current directory */
|
||||
TIFFVSetMethod xtif_vsetfield; /* inherited tag set routine */
|
||||
TIFFVGetMethod xtif_vgetfield; /* inherited tag get routine */
|
||||
TIFFPrintMethod xtif_printdir; /* inherited dir print method */
|
||||
};
|
||||
typedef struct xtiff xtiff;
|
||||
|
||||
#define PARENT(xt, pmember) ((xt)->xtif_##pmember)
|
||||
#define TIFFMEMBER(tf, pmember) ((tf)->tif_##pmember)
|
||||
#define XTIFFDIR(tif) ((xtiff *)TIFFMEMBER(tif, clientdir))
|
||||
|
||||
#define PARENT(xt,pmember) ((xt)->xtif_ ## pmember)
|
||||
#define TIFFMEMBER(tf,pmember) ((tf)->tif_ ## pmember)
|
||||
#define XTIFFDIR(tif) ((xtiff *)TIFFMEMBER(tif,clientdir))
|
||||
|
||||
/* Extended TIFF flags */
|
||||
#define XTIFF_INITIALIZED 0x80000000
|
||||
|
||||
|
||||
#endif /* __xtiffiop_h */
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
+184
-187
@@ -1,11 +1,11 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
//#define STRICT
|
||||
// #define STRICT
|
||||
#include "diblib.h"
|
||||
#include <commdlg.h>
|
||||
#include <stdlib.h> // MAX_ constants
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <commdlg.h>
|
||||
#include <stdlib.h> // MAX_ constants
|
||||
#include "diblib.h"
|
||||
|
||||
/*--------------------------------------------------------------------
|
||||
READ TIFF
|
||||
@@ -31,44 +31,42 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
// piggyback some data on top of the RGBA Image
|
||||
struct TIFFDibImage {
|
||||
struct TIFFDibImage
|
||||
{
|
||||
TIFFRGBAImage tif;
|
||||
int dibinstalled;
|
||||
} ;
|
||||
|
||||
int dibinstalled;
|
||||
};
|
||||
|
||||
HANDLE LoadTIFFinDIB(LPCTSTR lpFileName);
|
||||
HANDLE TIFFRGBA2DIB(TIFFDibImage* dib, uint32_t* raster) ;
|
||||
HANDLE TIFFRGBA2DIB(TIFFDibImage *dib, uint32_t *raster);
|
||||
|
||||
static void
|
||||
MyWarningHandler(const char* module, const char* fmt, va_list ap)
|
||||
static void MyWarningHandler(const char *module, const char *fmt, va_list ap)
|
||||
{
|
||||
// ignore all warnings (unused tags, etc)
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
MyErrorHandler(const char* module, const char* fmt, va_list ap)
|
||||
static void MyErrorHandler(const char *module, const char *fmt, va_list ap)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Turn off the error and warning handlers to check if a valid file.
|
||||
// Necessary because of the way that the Doc loads images and restart files.
|
||||
int ChkTIFF ( LPCTSTR lpszPath )
|
||||
int ChkTIFF(LPCTSTR lpszPath)
|
||||
{
|
||||
int rtn = 0;
|
||||
|
||||
TIFFErrorHandler eh;
|
||||
TIFFErrorHandler wh;
|
||||
TIFFErrorHandler eh;
|
||||
TIFFErrorHandler wh;
|
||||
|
||||
eh = TIFFSetErrorHandler(NULL);
|
||||
wh = TIFFSetWarningHandler(NULL);
|
||||
|
||||
TIFF* tif = TIFFOpen(lpszPath, "r");
|
||||
if (tif) {
|
||||
TIFF *tif = TIFFOpen(lpszPath, "r");
|
||||
if (tif)
|
||||
{
|
||||
rtn = 1;
|
||||
TIFFClose(tif);
|
||||
}
|
||||
@@ -79,34 +77,42 @@ int ChkTIFF ( LPCTSTR lpszPath )
|
||||
return rtn;
|
||||
}
|
||||
|
||||
void DibInstallHack(TIFFDibImage* img) ;
|
||||
void DibInstallHack(TIFFDibImage *img);
|
||||
|
||||
PVOID ReadTIFF ( LPCTSTR lpszPath )
|
||||
PVOID ReadTIFF(LPCTSTR lpszPath)
|
||||
{
|
||||
void* pDIB = 0;
|
||||
TIFFErrorHandler wh;
|
||||
void *pDIB = 0;
|
||||
TIFFErrorHandler wh;
|
||||
|
||||
wh = TIFFSetWarningHandler(MyWarningHandler);
|
||||
|
||||
if (ChkTIFF(lpszPath)) {
|
||||
TIFF* tif = TIFFOpen(lpszPath, "r");
|
||||
if (tif) {
|
||||
if (ChkTIFF(lpszPath))
|
||||
{
|
||||
TIFF *tif = TIFFOpen(lpszPath, "r");
|
||||
if (tif)
|
||||
{
|
||||
char emsg[1024];
|
||||
|
||||
if (TIFFRGBAImageOK(tif, emsg)) {
|
||||
if (TIFFRGBAImageOK(tif, emsg))
|
||||
{
|
||||
TIFFDibImage img;
|
||||
char emsg[1024];
|
||||
|
||||
if (TIFFRGBAImageBegin(&img.tif, tif, -1, emsg)) {
|
||||
if (TIFFRGBAImageBegin(&img.tif, tif, -1, emsg))
|
||||
{
|
||||
size_t npixels;
|
||||
uint32_t* raster;
|
||||
uint32_t *raster;
|
||||
|
||||
DibInstallHack(&img);
|
||||
|
||||
npixels = img.tif.width * img.tif.height;
|
||||
raster = (uint32_t*) _TIFFmalloc(npixels * sizeof (uint32_t));
|
||||
if (raster != NULL) {
|
||||
if (TIFFRGBAImageGet(&img.tif, raster, img.tif.width, img.tif.height)) {
|
||||
raster =
|
||||
(uint32_t *)_TIFFmalloc(npixels * sizeof(uint32_t));
|
||||
if (raster != NULL)
|
||||
{
|
||||
if (TIFFRGBAImageGet(&img.tif, raster, img.tif.width,
|
||||
img.tif.height))
|
||||
{
|
||||
pDIB = TIFFRGBA2DIB(&img, raster);
|
||||
}
|
||||
}
|
||||
@@ -114,8 +120,9 @@ PVOID ReadTIFF ( LPCTSTR lpszPath )
|
||||
}
|
||||
TIFFRGBAImageEnd(&img.tif);
|
||||
}
|
||||
else {
|
||||
TRACE("Unable to open image(%s): %s\n", lpszPath, emsg );
|
||||
else
|
||||
{
|
||||
TRACE("Unable to open image(%s): %s\n", lpszPath, emsg);
|
||||
}
|
||||
TIFFClose(tif);
|
||||
}
|
||||
@@ -126,12 +133,10 @@ PVOID ReadTIFF ( LPCTSTR lpszPath )
|
||||
return pDIB;
|
||||
}
|
||||
|
||||
|
||||
|
||||
HANDLE TIFFRGBA2DIB(TIFFDibImage* dib, uint32_t* raster)
|
||||
HANDLE TIFFRGBA2DIB(TIFFDibImage *dib, uint32_t *raster)
|
||||
{
|
||||
void* pDIB = 0;
|
||||
TIFFRGBAImage* img = &dib->tif;
|
||||
void *pDIB = 0;
|
||||
TIFFRGBAImage *img = &dib->tif;
|
||||
|
||||
uint32_t imageLength;
|
||||
uint32_t imageWidth;
|
||||
@@ -140,8 +145,8 @@ HANDLE TIFFRGBA2DIB(TIFFDibImage* dib, uint32_t* raster)
|
||||
uint32_t RowsPerStrip;
|
||||
uint16_t PhotometricInterpretation;
|
||||
|
||||
BITMAPINFOHEADER bi;
|
||||
int dwDIBSize ;
|
||||
BITMAPINFOHEADER bi;
|
||||
int dwDIBSize;
|
||||
|
||||
TIFFGetField(img->tif, TIFFTAG_IMAGEWIDTH, &imageWidth);
|
||||
TIFFGetField(img->tif, TIFFTAG_IMAGELENGTH, &imageLength);
|
||||
@@ -150,91 +155,97 @@ HANDLE TIFFRGBA2DIB(TIFFDibImage* dib, uint32_t* raster)
|
||||
TIFFGetField(img->tif, TIFFTAG_SAMPLESPERPIXEL, &SamplePerPixel);
|
||||
TIFFGetField(img->tif, TIFFTAG_PHOTOMETRIC, &PhotometricInterpretation);
|
||||
|
||||
if ( BitsPerSample == 1 && SamplePerPixel == 1 && dib->dibinstalled ) { // bilevel
|
||||
bi.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bi.biWidth = imageWidth;
|
||||
bi.biHeight = imageLength;
|
||||
bi.biPlanes = 1; // always
|
||||
bi.biBitCount = 1;
|
||||
bi.biCompression = BI_RGB;
|
||||
bi.biSizeImage = WIDTHBYTES(bi.biWidth * bi.biBitCount) * bi.biHeight;
|
||||
bi.biXPelsPerMeter = 0;
|
||||
bi.biYPelsPerMeter = 0;
|
||||
bi.biClrUsed = 0; // must be zero for RGB compression (none)
|
||||
bi.biClrImportant = 0; // always
|
||||
if (BitsPerSample == 1 && SamplePerPixel == 1 && dib->dibinstalled)
|
||||
{ // bilevel
|
||||
bi.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bi.biWidth = imageWidth;
|
||||
bi.biHeight = imageLength;
|
||||
bi.biPlanes = 1; // always
|
||||
bi.biBitCount = 1;
|
||||
bi.biCompression = BI_RGB;
|
||||
bi.biSizeImage = WIDTHBYTES(bi.biWidth * bi.biBitCount) * bi.biHeight;
|
||||
bi.biXPelsPerMeter = 0;
|
||||
bi.biYPelsPerMeter = 0;
|
||||
bi.biClrUsed = 0; // must be zero for RGB compression (none)
|
||||
bi.biClrImportant = 0; // always
|
||||
|
||||
// Get the size of the DIB
|
||||
dwDIBSize = GetDIBSize( &bi );
|
||||
dwDIBSize = GetDIBSize(&bi);
|
||||
|
||||
// Allocate for the BITMAPINFO structure and the color table.
|
||||
pDIB = GlobalAllocPtr( GHND, dwDIBSize );
|
||||
if (pDIB == 0) {
|
||||
return( NULL );
|
||||
pDIB = GlobalAllocPtr(GHND, dwDIBSize);
|
||||
if (pDIB == 0)
|
||||
{
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
// Copy the header info
|
||||
*((BITMAPINFOHEADER*)pDIB) = bi;
|
||||
*((BITMAPINFOHEADER *)pDIB) = bi;
|
||||
|
||||
// Get a pointer to the color table
|
||||
RGBQUAD *pRgbq = (RGBQUAD *)((LPSTR)pDIB + sizeof(BITMAPINFOHEADER));
|
||||
RGBQUAD *pRgbq = (RGBQUAD *)((LPSTR)pDIB + sizeof(BITMAPINFOHEADER));
|
||||
|
||||
pRgbq[0].rgbRed = 0;
|
||||
pRgbq[0].rgbBlue = 0;
|
||||
pRgbq[0].rgbGreen = 0;
|
||||
pRgbq[0].rgbRed = 0;
|
||||
pRgbq[0].rgbBlue = 0;
|
||||
pRgbq[0].rgbGreen = 0;
|
||||
pRgbq[0].rgbReserved = 0;
|
||||
pRgbq[1].rgbRed = 255;
|
||||
pRgbq[1].rgbBlue = 255;
|
||||
pRgbq[1].rgbGreen = 255;
|
||||
pRgbq[1].rgbRed = 255;
|
||||
pRgbq[1].rgbBlue = 255;
|
||||
pRgbq[1].rgbGreen = 255;
|
||||
pRgbq[1].rgbReserved = 255;
|
||||
|
||||
// Pointers to the bits
|
||||
//PVOID pbiBits = (LPSTR)pRgbq + bi.biClrUsed * sizeof(RGBQUAD);
|
||||
// PVOID pbiBits = (LPSTR)pRgbq + bi.biClrUsed * sizeof(RGBQUAD);
|
||||
//
|
||||
// In the BITMAPINFOHEADER documentation, it appears that
|
||||
// there should be no color table for 32 bit images, but
|
||||
// experience shows that the image is off by 3 words if it
|
||||
// is not included. So here it is.
|
||||
PVOID pbiBits = GetDIBImagePtr((BITMAPINFOHEADER*)pDIB); //(LPSTR)pRgbq + 3 * sizeof(RGBQUAD);
|
||||
PVOID pbiBits = GetDIBImagePtr(
|
||||
(BITMAPINFOHEADER *)pDIB); //(LPSTR)pRgbq + 3 * sizeof(RGBQUAD);
|
||||
|
||||
int sizeWords = bi.biSizeImage/4;
|
||||
RGBQUAD* rgbDib = (RGBQUAD*)pbiBits;
|
||||
long* rgbTif = (long*)raster;
|
||||
int sizeWords = bi.biSizeImage / 4;
|
||||
RGBQUAD *rgbDib = (RGBQUAD *)pbiBits;
|
||||
long *rgbTif = (long *)raster;
|
||||
|
||||
_TIFFmemcpy(pbiBits, raster, bi.biSizeImage);
|
||||
}
|
||||
|
||||
// For now just always default to the RGB 32 bit form. // save as 32 bit for simplicity
|
||||
else if ( true /*BitsPerSample == 8 && SamplePerPixel == 3*/ ) { // 24 bit color
|
||||
// For now just always default to the RGB 32 bit form. // save as 32 bit
|
||||
// for simplicity
|
||||
else if (true /*BitsPerSample == 8 && SamplePerPixel == 3*/)
|
||||
{ // 24 bit color
|
||||
|
||||
bi.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bi.biWidth = imageWidth;
|
||||
bi.biHeight = imageLength;
|
||||
bi.biPlanes = 1; // always
|
||||
bi.biBitCount = 32;
|
||||
bi.biCompression = BI_RGB;
|
||||
bi.biSizeImage = WIDTHBYTES(bi.biWidth * bi.biBitCount) * bi.biHeight;
|
||||
bi.biXPelsPerMeter = 0;
|
||||
bi.biYPelsPerMeter = 0;
|
||||
bi.biClrUsed = 0; // must be zero for RGB compression (none)
|
||||
bi.biClrImportant = 0; // always
|
||||
bi.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bi.biWidth = imageWidth;
|
||||
bi.biHeight = imageLength;
|
||||
bi.biPlanes = 1; // always
|
||||
bi.biBitCount = 32;
|
||||
bi.biCompression = BI_RGB;
|
||||
bi.biSizeImage = WIDTHBYTES(bi.biWidth * bi.biBitCount) * bi.biHeight;
|
||||
bi.biXPelsPerMeter = 0;
|
||||
bi.biYPelsPerMeter = 0;
|
||||
bi.biClrUsed = 0; // must be zero for RGB compression (none)
|
||||
bi.biClrImportant = 0; // always
|
||||
|
||||
// Get the size of the DIB
|
||||
dwDIBSize = GetDIBSize( &bi );
|
||||
dwDIBSize = GetDIBSize(&bi);
|
||||
|
||||
// Allocate for the BITMAPINFO structure and the color table.
|
||||
pDIB = GlobalAllocPtr( GHND, dwDIBSize );
|
||||
if (pDIB == 0) {
|
||||
return( NULL );
|
||||
pDIB = GlobalAllocPtr(GHND, dwDIBSize);
|
||||
if (pDIB == 0)
|
||||
{
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
// Copy the header info
|
||||
*((BITMAPINFOHEADER*)pDIB) = bi;
|
||||
*((BITMAPINFOHEADER *)pDIB) = bi;
|
||||
|
||||
// Get a pointer to the color table
|
||||
RGBQUAD *pRgbq = (RGBQUAD *)((LPSTR)pDIB + sizeof(BITMAPINFOHEADER));
|
||||
RGBQUAD *pRgbq = (RGBQUAD *)((LPSTR)pDIB + sizeof(BITMAPINFOHEADER));
|
||||
|
||||
// Pointers to the bits
|
||||
//PVOID pbiBits = (LPSTR)pRgbq + bi.biClrUsed * sizeof(RGBQUAD);
|
||||
// PVOID pbiBits = (LPSTR)pRgbq + bi.biClrUsed * sizeof(RGBQUAD);
|
||||
//
|
||||
// In the BITMAPINFOHEADER documentation, it appears that
|
||||
// there should be no color table for 32 bit images, but
|
||||
@@ -242,15 +253,15 @@ HANDLE TIFFRGBA2DIB(TIFFDibImage* dib, uint32_t* raster)
|
||||
// is not included. So here it is.
|
||||
PVOID pbiBits = (LPSTR)pRgbq + 3 * sizeof(RGBQUAD);
|
||||
|
||||
int sizeWords = bi.biSizeImage/4;
|
||||
RGBQUAD* rgbDib = (RGBQUAD*)pbiBits;
|
||||
long* rgbTif = (long*)raster;
|
||||
int sizeWords = bi.biSizeImage / 4;
|
||||
RGBQUAD *rgbDib = (RGBQUAD *)pbiBits;
|
||||
long *rgbTif = (long *)raster;
|
||||
|
||||
// Swap the byte order while copying
|
||||
for ( int i = 0 ; i < sizeWords ; ++i )
|
||||
for (int i = 0; i < sizeWords; ++i)
|
||||
{
|
||||
rgbDib[i].rgbRed = TIFFGetR(rgbTif[i]);
|
||||
rgbDib[i].rgbBlue = TIFFGetB(rgbTif[i]);
|
||||
rgbDib[i].rgbRed = TIFFGetR(rgbTif[i]);
|
||||
rgbDib[i].rgbBlue = TIFFGetB(rgbTif[i]);
|
||||
rgbDib[i].rgbGreen = TIFFGetG(rgbTif[i]);
|
||||
rgbDib[i].rgbReserved = 0;
|
||||
}
|
||||
@@ -259,9 +270,6 @@ HANDLE TIFFRGBA2DIB(TIFFDibImage* dib, uint32_t* raster)
|
||||
return pDIB;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Hacked from tif_getimage.c in libtiff in v3.5.7
|
||||
@@ -269,49 +277,42 @@ HANDLE TIFFRGBA2DIB(TIFFDibImage* dib, uint32_t* raster)
|
||||
//
|
||||
typedef unsigned char u_char;
|
||||
|
||||
#define DECLAREContigPutFunc(name) \
|
||||
static void name(TIFFRGBAImage *img, uint32_t *cp, uint32_t x, uint32_t y, \
|
||||
uint32_t w, uint32_t h, int32_t fromskew, int32_t toskew, \
|
||||
u_char *pp)
|
||||
|
||||
#define DECLAREContigPutFunc(name) \
|
||||
static void name(\
|
||||
TIFFRGBAImage* img, \
|
||||
uint32_t* cp, \
|
||||
uint32_t x, uint32_t y, \
|
||||
uint32_t w, uint32_t h, \
|
||||
int32_t fromskew, int32_t toskew, \
|
||||
u_char* pp \
|
||||
)
|
||||
|
||||
#define DECLARESepPutFunc(name) \
|
||||
static void name(\
|
||||
TIFFRGBAImage* img,\
|
||||
uint32_t* cp,\
|
||||
uint32_t x, uint32_t y, \
|
||||
uint32_t w, uint32_t h,\
|
||||
int32_t fromskew, int32_t toskew,\
|
||||
u_char* r, u_char* g, u_char* b, u_char* a\
|
||||
)
|
||||
#define DECLARESepPutFunc(name) \
|
||||
static void name(TIFFRGBAImage *img, uint32_t *cp, uint32_t x, uint32_t y, \
|
||||
uint32_t w, uint32_t h, int32_t fromskew, int32_t toskew, \
|
||||
u_char *r, u_char *g, u_char *b, u_char *a)
|
||||
|
||||
DECLAREContigPutFunc(putContig1bitTile);
|
||||
static int getStripContig1Bit(TIFFRGBAImage* img, uint32_t* uraster, uint32_t w, uint32_t h);
|
||||
static int getStripContig1Bit(TIFFRGBAImage *img, uint32_t *uraster, uint32_t w,
|
||||
uint32_t h);
|
||||
|
||||
//typdef struct TIFFDibImage {
|
||||
// TIFFRGBAImage tif;
|
||||
// dibinstalled;
|
||||
//} TIFFDibImage ;
|
||||
// typdef struct TIFFDibImage {
|
||||
// TIFFRGBAImage tif;
|
||||
// dibinstalled;
|
||||
// } TIFFDibImage ;
|
||||
|
||||
void DibInstallHack(TIFFDibImage* dib) {
|
||||
TIFFRGBAImage* img = &dib->tif;
|
||||
void DibInstallHack(TIFFDibImage *dib)
|
||||
{
|
||||
TIFFRGBAImage *img = &dib->tif;
|
||||
dib->dibinstalled = false;
|
||||
switch (img->photometric) {
|
||||
switch (img->photometric)
|
||||
{
|
||||
case PHOTOMETRIC_MINISWHITE:
|
||||
case PHOTOMETRIC_MINISBLACK:
|
||||
switch (img->bitspersample) {
|
||||
case 1:
|
||||
img->put.contig = putContig1bitTile;
|
||||
img->get = getStripContig1Bit;
|
||||
dib->dibinstalled = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
switch (img->bitspersample)
|
||||
{
|
||||
case 1:
|
||||
img->put.contig = putContig1bitTile;
|
||||
img->get = getStripContig1Bit;
|
||||
dib->dibinstalled = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,15 +325,16 @@ DECLAREContigPutFunc(putContig1bitTile)
|
||||
{
|
||||
int samplesperpixel = img->samplesperpixel;
|
||||
|
||||
(void) y;
|
||||
(void)y;
|
||||
fromskew *= samplesperpixel;
|
||||
int wb = WIDTHBYTES(w);
|
||||
u_char* ucp = (u_char*)cp;
|
||||
u_char *ucp = (u_char *)cp;
|
||||
|
||||
/* Convert 'w' to bytes from pixels (rounded up) */
|
||||
w = (w+7)/8;
|
||||
w = (w + 7) / 8;
|
||||
|
||||
while (h-- > 0) {
|
||||
while (h-- > 0)
|
||||
{
|
||||
_TIFFmemcpy(ucp, pp, w);
|
||||
/*
|
||||
for (x = wb; x-- > 0;) {
|
||||
@@ -348,32 +350,32 @@ DECLAREContigPutFunc(putContig1bitTile)
|
||||
/*
|
||||
* Hacked from the tif_getimage.c file.
|
||||
*/
|
||||
static uint32_t
|
||||
setorientation(TIFFRGBAImage* img, uint32_t h)
|
||||
static uint32_t setorientation(TIFFRGBAImage *img, uint32_t h)
|
||||
{
|
||||
TIFF* tif = img->tif;
|
||||
TIFF *tif = img->tif;
|
||||
uint32_t y;
|
||||
|
||||
switch (img->orientation) {
|
||||
case ORIENTATION_BOTRIGHT:
|
||||
case ORIENTATION_RIGHTBOT: /* XXX */
|
||||
case ORIENTATION_LEFTBOT: /* XXX */
|
||||
TIFFWarning(TIFFFileName(tif), "using bottom-left orientation");
|
||||
img->orientation = ORIENTATION_BOTLEFT;
|
||||
/* fall through... */
|
||||
case ORIENTATION_BOTLEFT:
|
||||
y = 0;
|
||||
break;
|
||||
case ORIENTATION_TOPRIGHT:
|
||||
case ORIENTATION_RIGHTTOP: /* XXX */
|
||||
case ORIENTATION_LEFTTOP: /* XXX */
|
||||
default:
|
||||
TIFFWarning(TIFFFileName(tif), "using top-left orientation");
|
||||
img->orientation = ORIENTATION_TOPLEFT;
|
||||
/* fall through... */
|
||||
case ORIENTATION_TOPLEFT:
|
||||
y = h-1;
|
||||
break;
|
||||
switch (img->orientation)
|
||||
{
|
||||
case ORIENTATION_BOTRIGHT:
|
||||
case ORIENTATION_RIGHTBOT: /* XXX */
|
||||
case ORIENTATION_LEFTBOT: /* XXX */
|
||||
TIFFWarning(TIFFFileName(tif), "using bottom-left orientation");
|
||||
img->orientation = ORIENTATION_BOTLEFT;
|
||||
/* fall through... */
|
||||
case ORIENTATION_BOTLEFT:
|
||||
y = 0;
|
||||
break;
|
||||
case ORIENTATION_TOPRIGHT:
|
||||
case ORIENTATION_RIGHTTOP: /* XXX */
|
||||
case ORIENTATION_LEFTTOP: /* XXX */
|
||||
default:
|
||||
TIFFWarning(TIFFFileName(tif), "using top-left orientation");
|
||||
img->orientation = ORIENTATION_TOPLEFT;
|
||||
/* fall through... */
|
||||
case ORIENTATION_TOPLEFT:
|
||||
y = h - 1;
|
||||
break;
|
||||
}
|
||||
return (y);
|
||||
}
|
||||
@@ -389,61 +391,56 @@ setorientation(TIFFRGBAImage* img, uint32_t h)
|
||||
* This is set up to allow us to just copy the data to the raster
|
||||
* for 1-bit bitmaps
|
||||
*/
|
||||
static int
|
||||
getStripContig1Bit(TIFFRGBAImage* img, uint32_t* raster, uint32_t w, uint32_t h)
|
||||
static int getStripContig1Bit(TIFFRGBAImage *img, uint32_t *raster, uint32_t w,
|
||||
uint32_t h)
|
||||
{
|
||||
TIFF* tif = img->tif;
|
||||
TIFF *tif = img->tif;
|
||||
tileContigRoutine put = img->put.contig;
|
||||
uint16_t orientation;
|
||||
uint32_t row, y, nrow, rowstoread;
|
||||
uint32_t pos;
|
||||
u_char* buf;
|
||||
u_char *buf;
|
||||
uint32_t rowsperstrip;
|
||||
uint32_t imagewidth = img->width;
|
||||
tsize_t scanline;
|
||||
int32_t fromskew, toskew;
|
||||
tstrip_t strip;
|
||||
tsize_t stripsize;
|
||||
u_char* braster = (u_char*)raster; // byte wide raster
|
||||
uint32_t wb = WIDTHBYTES(w);
|
||||
tsize_t stripsize;
|
||||
u_char *braster = (u_char *)raster; // byte wide raster
|
||||
uint32_t wb = WIDTHBYTES(w);
|
||||
int ret = 1;
|
||||
|
||||
buf = (u_char*) _TIFFmalloc(TIFFStripSize(tif));
|
||||
if (buf == 0) {
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for strip buffer");
|
||||
buf = (u_char *)_TIFFmalloc(TIFFStripSize(tif));
|
||||
if (buf == 0)
|
||||
{
|
||||
TIFFErrorExtR(tif, TIFFFileName(tif), "No space for strip buffer");
|
||||
return (0);
|
||||
}
|
||||
y = setorientation(img, h);
|
||||
orientation = img->orientation;
|
||||
toskew = -(int32_t) (orientation == ORIENTATION_TOPLEFT ? wb+wb : wb-wb);
|
||||
toskew = -(int32_t)(orientation == ORIENTATION_TOPLEFT ? wb + wb : wb - wb);
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
|
||||
scanline = TIFFScanlineSize(tif);
|
||||
fromskew = (w < imagewidth ? imagewidth - w : 0)/8;
|
||||
fromskew = (w < imagewidth ? imagewidth - w : 0) / 8;
|
||||
for (row = 0; row < h; row += nrow)
|
||||
{
|
||||
rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip;
|
||||
nrow = (row + rowstoread > h ? h - row : rowstoread);
|
||||
strip = TIFFComputeStrip(tif,row+img->row_offset, 0);
|
||||
stripsize = ((row + img->row_offset)%rowsperstrip + nrow) * scanline;
|
||||
if (TIFFReadEncodedStrip(tif, strip, buf, stripsize ) < 0
|
||||
&& img->stoponerr)
|
||||
strip = TIFFComputeStrip(tif, row + img->row_offset, 0);
|
||||
stripsize = ((row + img->row_offset) % rowsperstrip + nrow) * scanline;
|
||||
if (TIFFReadEncodedStrip(tif, strip, buf, stripsize) < 0 &&
|
||||
img->stoponerr)
|
||||
{
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
pos = ((row + img->row_offset) % rowsperstrip) * scanline;
|
||||
(*put)(img, (uint32_t*)(braster+y*wb), 0, y, w, nrow, fromskew, toskew, buf + pos);
|
||||
y += (orientation == ORIENTATION_TOPLEFT ?-(int32_t) nrow : (int32_t) nrow);
|
||||
(*put)(img, (uint32_t *)(braster + y * wb), 0, y, w, nrow, fromskew,
|
||||
toskew, buf + pos);
|
||||
y += (orientation == ORIENTATION_TOPLEFT ? -(int32_t)nrow
|
||||
: (int32_t)nrow);
|
||||
}
|
||||
_TIFFfree(buf);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c++
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
+234
-256
@@ -1,42 +1,39 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* Source file for Windows 95/Win32.
|
||||
* Source file for Windows 95/Win32.
|
||||
*
|
||||
* The function LoadTIFFinDIB in this source file let you load
|
||||
* a TIFF file and build a memory DIB with it and return the
|
||||
* The function LoadTIFFinDIB in this source file let you load
|
||||
* a TIFF file and build a memory DIB with it and return the
|
||||
* HANDLE (HDIB) of the memory block containing the DIB.
|
||||
*
|
||||
* Example :
|
||||
*
|
||||
* Example :
|
||||
*
|
||||
* HDIB hDIB;
|
||||
* hDIB = LoadTIFFinDIB("sample.tif");
|
||||
*
|
||||
*
|
||||
* To build this source file you must include the TIFF library
|
||||
* To build this source file you must include the TIFF library
|
||||
* in your project.
|
||||
*
|
||||
* 4/12/95 Philippe Tenenhaus 100423.3705@compuserve.com
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
|
||||
#include "tiffio.h"
|
||||
#include "tiffio.h"
|
||||
|
||||
#define HDIB HANDLE
|
||||
#define IS_WIN30_DIB(lpbi) ((*(LPDWORD)(lpbi)) == sizeof(BITMAPINFOHEADER))
|
||||
#define CVT(x) (((x) * 255L) / ((1L<<16)-1))
|
||||
#define IS_WIN30_DIB(lpbi) ((*(LPDWORD)(lpbi)) == sizeof(BITMAPINFOHEADER))
|
||||
#define CVT(x) (((x)*255L) / ((1L << 16) - 1))
|
||||
|
||||
static HDIB CreateDIB(DWORD dwWidth, DWORD dwHeight, WORD wBitCount);
|
||||
static LPSTR FindDIBBits(LPSTR lpDIB);
|
||||
static WORD PaletteSize(LPSTR lpDIB);
|
||||
static WORD DIBNumColors(LPSTR lpDIB);
|
||||
static int checkcmap(int n, uint16_t* r, uint16_t* g, uint16_t* b);
|
||||
|
||||
|
||||
static int checkcmap(int n, uint16_t *r, uint16_t *g, uint16_t *b);
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* HDIB LoadTIFFinDIB(LPSTR lpFileName)
|
||||
* HDIB LoadTIFFinDIB(LPSTR lpFileName)
|
||||
*
|
||||
* Parameter:
|
||||
*
|
||||
@@ -56,181 +53,173 @@ static int checkcmap(int n, uint16_t* r, uint16_t* g, uint16_t* b);
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
HDIB LoadTIFFinDIB(LPSTR lpFileName)
|
||||
HDIB LoadTIFFinDIB(LPSTR lpFileName)
|
||||
{
|
||||
TIFF *tif;
|
||||
unsigned long imageLength;
|
||||
unsigned long imageWidth;
|
||||
unsigned int BitsPerSample;
|
||||
TIFF *tif;
|
||||
unsigned long imageLength;
|
||||
unsigned long imageWidth;
|
||||
unsigned int BitsPerSample;
|
||||
unsigned long LineSize;
|
||||
unsigned int SamplePerPixel;
|
||||
unsigned long RowsPerStrip;
|
||||
int PhotometricInterpretation;
|
||||
long nrow;
|
||||
unsigned long row;
|
||||
char *buf;
|
||||
LPBITMAPINFOHEADER lpDIB;
|
||||
HDIB hDIB;
|
||||
char *lpBits;
|
||||
HGLOBAL hStrip;
|
||||
int i,l;
|
||||
int Align;
|
||||
|
||||
unsigned int SamplePerPixel;
|
||||
unsigned long RowsPerStrip;
|
||||
int PhotometricInterpretation;
|
||||
long nrow;
|
||||
unsigned long row;
|
||||
char *buf;
|
||||
LPBITMAPINFOHEADER lpDIB;
|
||||
HDIB hDIB;
|
||||
char *lpBits;
|
||||
HGLOBAL hStrip;
|
||||
int i, l;
|
||||
int Align;
|
||||
|
||||
tif = TIFFOpen(lpFileName, "r");
|
||||
|
||||
|
||||
if (!tif)
|
||||
goto TiffOpenError;
|
||||
|
||||
|
||||
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imageWidth);
|
||||
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imageLength);
|
||||
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imageLength);
|
||||
TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &BitsPerSample);
|
||||
TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &RowsPerStrip);
|
||||
TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &RowsPerStrip);
|
||||
TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &RowsPerStrip);
|
||||
TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &RowsPerStrip);
|
||||
TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &PhotometricInterpretation);
|
||||
|
||||
LineSize = TIFFScanlineSize(tif); //Number of byte in ine line
|
||||
|
||||
SamplePerPixel = (int) (LineSize/imageWidth);
|
||||
LineSize = TIFFScanlineSize(tif); // Number of byte in ine line
|
||||
|
||||
//Align = Number of byte to add at the end of each line of the DIB
|
||||
SamplePerPixel = (int)(LineSize / imageWidth);
|
||||
|
||||
// Align = Number of byte to add at the end of each line of the DIB
|
||||
Align = 4 - (LineSize % 4);
|
||||
if (Align == 4) Align = 0;
|
||||
if (Align == 4)
|
||||
Align = 0;
|
||||
|
||||
|
||||
//Create a new DIB
|
||||
hDIB = CreateDIB((DWORD) imageWidth, (DWORD) imageLength, (WORD)
|
||||
(BitsPerSample*SamplePerPixel));
|
||||
lpDIB = (LPBITMAPINFOHEADER) GlobalLock(hDIB);
|
||||
// Create a new DIB
|
||||
hDIB = CreateDIB((DWORD)imageWidth, (DWORD)imageLength,
|
||||
(WORD)(BitsPerSample * SamplePerPixel));
|
||||
lpDIB = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
|
||||
if (!lpDIB)
|
||||
goto OutOfDIBMemory;
|
||||
|
||||
if (lpDIB)
|
||||
lpBits = FindDIBBits((LPSTR) lpDIB);
|
||||
else
|
||||
lpBits = NULL;
|
||||
goto OutOfDIBMemory;
|
||||
|
||||
//In the tiff file the lines are save from up to down
|
||||
//In a DIB the lines must be save from down to up
|
||||
if (lpDIB)
|
||||
lpBits = FindDIBBits((LPSTR)lpDIB);
|
||||
else
|
||||
lpBits = NULL;
|
||||
|
||||
// In the tiff file the lines are save from up to down
|
||||
// In a DIB the lines must be save from down to up
|
||||
if (lpBits)
|
||||
{
|
||||
lpBits = FindDIBBits((LPSTR) lpDIB);
|
||||
lpBits+=((imageWidth*SamplePerPixel)+Align)*(imageLength-1);
|
||||
//now lpBits pointe on the bottom line
|
||||
|
||||
hStrip = GlobalAlloc(GHND,TIFFStripSize(tif));
|
||||
buf = GlobalLock(hStrip);
|
||||
|
||||
{
|
||||
lpBits = FindDIBBits((LPSTR)lpDIB);
|
||||
lpBits += ((imageWidth * SamplePerPixel) + Align) * (imageLength - 1);
|
||||
// now lpBits pointe on the bottom line
|
||||
|
||||
hStrip = GlobalAlloc(GHND, TIFFStripSize(tif));
|
||||
buf = GlobalLock(hStrip);
|
||||
|
||||
if (!buf)
|
||||
goto OutOfBufMemory;
|
||||
|
||||
//PhotometricInterpretation = 2 image is RGB
|
||||
//PhotometricInterpretation = 3 image have a color palette
|
||||
goto OutOfBufMemory;
|
||||
|
||||
// PhotometricInterpretation = 2 image is RGB
|
||||
// PhotometricInterpretation = 3 image have a color palette
|
||||
if (PhotometricInterpretation == 3)
|
||||
{
|
||||
uint16_t* red;
|
||||
uint16_t* green;
|
||||
uint16_t* blue;
|
||||
int16_t i;
|
||||
LPBITMAPINFO lpbmi;
|
||||
int Palette16Bits;
|
||||
|
||||
TIFFGetField(tif, TIFFTAG_COLORMAP, &red, &green, &blue);
|
||||
uint16_t *red;
|
||||
uint16_t *green;
|
||||
uint16_t *blue;
|
||||
int16_t i;
|
||||
LPBITMAPINFO lpbmi;
|
||||
int Palette16Bits;
|
||||
|
||||
//Is the palette 16 or 8 bits ?
|
||||
if (checkcmap(1<<BitsPerSample, red, green, blue) == 16)
|
||||
Palette16Bits = TRUE;
|
||||
else
|
||||
Palette16Bits = FALSE;
|
||||
|
||||
lpbmi = (LPBITMAPINFO)lpDIB;
|
||||
|
||||
//load the palette in the DIB
|
||||
for (i = (1<<BitsPerSample)-1; i >= 0; i--)
|
||||
{
|
||||
if (Palette16Bits)
|
||||
{
|
||||
lpbmi->bmiColors[i].rgbRed =(BYTE) CVT(red[i]);
|
||||
lpbmi->bmiColors[i].rgbGreen = (BYTE) CVT(green[i]);
|
||||
lpbmi->bmiColors[i].rgbBlue = (BYTE) CVT(blue[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
lpbmi->bmiColors[i].rgbRed = (BYTE) red[i];
|
||||
lpbmi->bmiColors[i].rgbGreen = (BYTE) green[i];
|
||||
lpbmi->bmiColors[i].rgbBlue = (BYTE) blue[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//read the tiff lines and save them in the DIB
|
||||
//with RGB mode, we have to change the order of the 3 samples RGB
|
||||
<=> BGR
|
||||
for (row = 0; row < imageLength; row += RowsPerStrip)
|
||||
{
|
||||
nrow = (row + RowsPerStrip > imageLength ? imageLength - row :
|
||||
RowsPerStrip);
|
||||
if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0),
|
||||
buf, nrow*LineSize)==-1)
|
||||
{
|
||||
goto TiffReadError;
|
||||
}
|
||||
TIFFGetField(tif, TIFFTAG_COLORMAP, &red, &green, &blue);
|
||||
|
||||
// Is the palette 16 or 8 bits ?
|
||||
if (checkcmap(1 << BitsPerSample, red, green, blue) == 16)
|
||||
Palette16Bits = TRUE;
|
||||
else
|
||||
{
|
||||
for (l = 0; l < nrow; l++)
|
||||
{
|
||||
if (SamplePerPixel == 3)
|
||||
for (i=0;i< (int) (imageWidth);i++)
|
||||
{
|
||||
lpBits[i*SamplePerPixel+0]=buf[l*LineSize+i*Sample
|
||||
PerPixel+2];
|
||||
lpBits[i*SamplePerPixel+1]=buf[l*LineSize+i*Sample
|
||||
PerPixel+1];
|
||||
lpBits[i*SamplePerPixel+2]=buf[l*LineSize+i*Sample
|
||||
PerPixel+0];
|
||||
}
|
||||
else
|
||||
memcpy(lpBits, &buf[(int) (l*LineSize)], (int)
|
||||
imageWidth*SamplePerPixel);
|
||||
|
||||
lpBits-=imageWidth*SamplePerPixel+Align;
|
||||
Palette16Bits = FALSE;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
lpbmi = (LPBITMAPINFO)lpDIB;
|
||||
|
||||
// load the palette in the DIB
|
||||
for (i = (1 << BitsPerSample) - 1; i >= 0; i--)
|
||||
{
|
||||
if (Palette16Bits)
|
||||
{
|
||||
lpbmi->bmiColors[i].rgbRed = (BYTE)CVT(red[i]);
|
||||
lpbmi->bmiColors[i].rgbGreen = (BYTE)CVT(green[i]);
|
||||
lpbmi->bmiColors[i].rgbBlue = (BYTE)CVT(blue[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
lpbmi->bmiColors[i].rgbRed = (BYTE)red[i];
|
||||
lpbmi->bmiColors[i].rgbGreen = (BYTE)green[i];
|
||||
lpbmi->bmiColors[i].rgbBlue = (BYTE)blue[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// read the tiff lines and save them in the DIB
|
||||
// with RGB mode, we have to change the order of the 3 samples RGB
|
||||
<=> BGR for (row = 0; row < imageLength; row += RowsPerStrip)
|
||||
{
|
||||
nrow = (row + RowsPerStrip > imageLength ? imageLength - row
|
||||
: RowsPerStrip);
|
||||
if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0), buf,
|
||||
nrow * LineSize) == -1)
|
||||
{
|
||||
goto TiffReadError;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (l = 0; l < nrow; l++)
|
||||
{
|
||||
if (SamplePerPixel == 3)
|
||||
for (i = 0; i < (int)(imageWidth); i++)
|
||||
{
|
||||
lpBits[i * SamplePerPixel + 0] =
|
||||
buf[l * LineSize + i * Sample PerPixel + 2];
|
||||
lpBits[i * SamplePerPixel + 1] =
|
||||
buf[l * LineSize + i * Sample PerPixel + 1];
|
||||
lpBits[i * SamplePerPixel + 2] =
|
||||
buf[l * LineSize + i * Sample PerPixel + 0];
|
||||
}
|
||||
else
|
||||
memcpy(lpBits, &buf[(int)(l * LineSize)],
|
||||
(int)imageWidth * SamplePerPixel);
|
||||
|
||||
lpBits -= imageWidth * SamplePerPixel + Align;
|
||||
}
|
||||
}
|
||||
}
|
||||
GlobalUnlock(hStrip);
|
||||
GlobalFree(hStrip);
|
||||
GlobalUnlock(hDIB);
|
||||
GlobalUnlock(hDIB);
|
||||
TIFFClose(tif);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return hDIB;
|
||||
|
||||
OutOfBufMemory:
|
||||
|
||||
TiffReadError:
|
||||
GlobalUnlock(hDIB);
|
||||
GlobalFree(hStrip);
|
||||
OutOfDIBMemory:
|
||||
TIFFClose(tif);
|
||||
TiffOpenError:
|
||||
return (HANDLE) 0;
|
||||
|
||||
|
||||
|
||||
OutOfBufMemory:
|
||||
|
||||
TiffReadError:
|
||||
GlobalUnlock(hDIB);
|
||||
GlobalFree(hStrip);
|
||||
OutOfDIBMemory:
|
||||
TIFFClose(tif);
|
||||
TiffOpenError:
|
||||
return (HANDLE)0;
|
||||
}
|
||||
|
||||
|
||||
static int checkcmap(int n, uint16_t* r, uint16_t* g, uint16_t* b)
|
||||
static int checkcmap(int n, uint16_t *r, uint16_t *g, uint16_t *b)
|
||||
{
|
||||
while (n-- > 0)
|
||||
if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256)
|
||||
return (16);
|
||||
|
||||
return (16);
|
||||
|
||||
return (8);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* All the following functions were created by microsoft, they are
|
||||
* parts of the sample project "wincap" given with the SDK Win32.
|
||||
@@ -247,135 +236,124 @@ static int checkcmap(int n, uint16_t* r, uint16_t* g, uint16_t* b)
|
||||
|
||||
HDIB CreateDIB(DWORD dwWidth, DWORD dwHeight, WORD wBitCount)
|
||||
{
|
||||
BITMAPINFOHEADER bi; // bitmap header
|
||||
LPBITMAPINFOHEADER lpbi; // pointer to BITMAPINFOHEADER
|
||||
DWORD dwLen; // size of memory block
|
||||
HDIB hDIB;
|
||||
DWORD dwBytesPerLine; // Number of bytes per scanline
|
||||
BITMAPINFOHEADER bi; // bitmap header
|
||||
LPBITMAPINFOHEADER lpbi; // pointer to BITMAPINFOHEADER
|
||||
DWORD dwLen; // size of memory block
|
||||
HDIB hDIB;
|
||||
DWORD dwBytesPerLine; // Number of bytes per scanline
|
||||
|
||||
// Make sure bits per pixel is valid
|
||||
if (wBitCount <= 1)
|
||||
wBitCount = 1;
|
||||
else if (wBitCount <= 4)
|
||||
wBitCount = 4;
|
||||
else if (wBitCount <= 8)
|
||||
wBitCount = 8;
|
||||
else if (wBitCount <= 24)
|
||||
wBitCount = 24;
|
||||
else
|
||||
wBitCount = 4; // set default value to 4 if parameter is bogus
|
||||
|
||||
// Make sure bits per pixel is valid
|
||||
if (wBitCount <= 1)
|
||||
wBitCount = 1;
|
||||
else if (wBitCount <= 4)
|
||||
wBitCount = 4;
|
||||
else if (wBitCount <= 8)
|
||||
wBitCount = 8;
|
||||
else if (wBitCount <= 24)
|
||||
wBitCount = 24;
|
||||
else
|
||||
wBitCount = 4; // set default value to 4 if parameter is bogus
|
||||
// initialize BITMAPINFOHEADER
|
||||
bi.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bi.biWidth = dwWidth; // fill in width from parameter
|
||||
bi.biHeight = dwHeight; // fill in height from parameter
|
||||
bi.biPlanes = 1; // must be 1
|
||||
bi.biBitCount = wBitCount; // from parameter
|
||||
bi.biCompression = BI_RGB;
|
||||
bi.biSizeImage =
|
||||
(dwWidth * dwHeight * wBitCount) / 8; // 0; // 0's here
|
||||
mean "default" bi.biXPelsPerMeter = 2834; // 0;
|
||||
bi.biYPelsPerMeter = 2834; // 0;
|
||||
bi.biClrUsed = 0;
|
||||
bi.biClrImportant = 0;
|
||||
|
||||
// initialize BITMAPINFOHEADER
|
||||
bi.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bi.biWidth = dwWidth; // fill in width from parameter
|
||||
bi.biHeight = dwHeight; // fill in height from parameter
|
||||
bi.biPlanes = 1; // must be 1
|
||||
bi.biBitCount = wBitCount; // from parameter
|
||||
bi.biCompression = BI_RGB;
|
||||
bi.biSizeImage = (dwWidth*dwHeight*wBitCount)/8; //0; // 0's here
|
||||
mean "default"
|
||||
bi.biXPelsPerMeter = 2834; //0;
|
||||
bi.biYPelsPerMeter = 2834; //0;
|
||||
bi.biClrUsed = 0;
|
||||
bi.biClrImportant = 0;
|
||||
// calculate size of memory block required to store the DIB. This
|
||||
// block should be big enough to hold the BITMAPINFOHEADER, the color
|
||||
// table, and the bits
|
||||
|
||||
// calculate size of memory block required to store the DIB. This
|
||||
// block should be big enough to hold the BITMAPINFOHEADER, the color
|
||||
// table, and the bits
|
||||
dwBytesPerLine = (((wBitCount * dwWidth) + 31) / 32 * 4);
|
||||
dwLen = bi.biSize + PaletteSize((LPSTR)&bi) + (dwBytesPerLine * dwHeight);
|
||||
|
||||
dwBytesPerLine = (((wBitCount * dwWidth) + 31) / 32 * 4);
|
||||
dwLen = bi.biSize + PaletteSize((LPSTR)&bi) + (dwBytesPerLine * dwHeight);
|
||||
// alloc memory block to store our bitmap
|
||||
hDIB = GlobalAlloc(GHND, dwLen);
|
||||
|
||||
// alloc memory block to store our bitmap
|
||||
hDIB = GlobalAlloc(GHND, dwLen);
|
||||
// major bummer if we couldn't get memory block
|
||||
if (!hDIB)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// major bummer if we couldn't get memory block
|
||||
if (!hDIB)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
// lock memory and get pointer to it
|
||||
lpbi = (VOID FAR *)GlobalLock(hDIB);
|
||||
|
||||
// lock memory and get pointer to it
|
||||
lpbi = (VOID FAR *)GlobalLock(hDIB);
|
||||
// use our bitmap info structure to fill in first part of
|
||||
// our DIB with the BITMAPINFOHEADER
|
||||
*lpbi = bi;
|
||||
|
||||
// use our bitmap info structure to fill in first part of
|
||||
// our DIB with the BITMAPINFOHEADER
|
||||
*lpbi = bi;
|
||||
// Since we don't know what the colortable and bits should contain,
|
||||
// just leave these blank. Unlock the DIB and return the HDIB.
|
||||
|
||||
// Since we don't know what the colortable and bits should contain,
|
||||
// just leave these blank. Unlock the DIB and return the HDIB.
|
||||
GlobalUnlock(hDIB);
|
||||
|
||||
GlobalUnlock(hDIB);
|
||||
|
||||
/* return handle to the DIB */
|
||||
return hDIB;
|
||||
/* return handle to the DIB */
|
||||
return hDIB;
|
||||
}
|
||||
|
||||
|
||||
LPSTR FAR FindDIBBits(LPSTR lpDIB)
|
||||
{
|
||||
return (lpDIB + *(LPDWORD)lpDIB + PaletteSize(lpDIB));
|
||||
return (lpDIB + *(LPDWORD)lpDIB + PaletteSize(lpDIB));
|
||||
}
|
||||
|
||||
|
||||
WORD FAR PaletteSize(LPSTR lpDIB)
|
||||
{
|
||||
/* calculate the size required by the palette */
|
||||
if (IS_WIN30_DIB (lpDIB))
|
||||
return (DIBNumColors(lpDIB) * sizeof(RGBQUAD));
|
||||
else
|
||||
return (DIBNumColors(lpDIB) * sizeof(RGBTRIPLE));
|
||||
/* calculate the size required by the palette */
|
||||
if (IS_WIN30_DIB(lpDIB))
|
||||
return (DIBNumColors(lpDIB) * sizeof(RGBQUAD));
|
||||
else
|
||||
return (DIBNumColors(lpDIB) * sizeof(RGBTRIPLE));
|
||||
}
|
||||
|
||||
|
||||
WORD DIBNumColors(LPSTR lpDIB)
|
||||
{
|
||||
WORD wBitCount; // DIB bit count
|
||||
WORD wBitCount; // DIB bit count
|
||||
|
||||
/* If this is a Windows-style DIB, the number of colors in the
|
||||
* color table can be less than the number of bits per pixel
|
||||
* allows for (i.e. lpbi->biClrUsed can be set to some value).
|
||||
* If this is the case, return the appropriate value.
|
||||
*/
|
||||
/* If this is a Windows-style DIB, the number of colors in the
|
||||
* color table can be less than the number of bits per pixel
|
||||
* allows for (i.e. lpbi->biClrUsed can be set to some value).
|
||||
* If this is the case, return the appropriate value.
|
||||
*/
|
||||
|
||||
if (IS_WIN30_DIB(lpDIB))
|
||||
{
|
||||
DWORD dwClrUsed;
|
||||
if (IS_WIN30_DIB(lpDIB))
|
||||
{
|
||||
DWORD dwClrUsed;
|
||||
|
||||
dwClrUsed = ((LPBITMAPINFOHEADER)lpDIB)->biClrUsed;
|
||||
if (dwClrUsed)
|
||||
return (WORD)dwClrUsed;
|
||||
}
|
||||
dwClrUsed = ((LPBITMAPINFOHEADER)lpDIB)->biClrUsed;
|
||||
if (dwClrUsed)
|
||||
return (WORD)dwClrUsed;
|
||||
}
|
||||
|
||||
/* Calculate the number of colors in the color table based on
|
||||
* the number of bits per pixel for the DIB.
|
||||
*/
|
||||
if (IS_WIN30_DIB(lpDIB))
|
||||
wBitCount = ((LPBITMAPINFOHEADER)lpDIB)->biBitCount;
|
||||
else
|
||||
wBitCount = ((LPBITMAPCOREHEADER)lpDIB)->bcBitCount;
|
||||
/* Calculate the number of colors in the color table based on
|
||||
* the number of bits per pixel for the DIB.
|
||||
*/
|
||||
if (IS_WIN30_DIB(lpDIB))
|
||||
wBitCount = ((LPBITMAPINFOHEADER)lpDIB)->biBitCount;
|
||||
else
|
||||
wBitCount = ((LPBITMAPCOREHEADER)lpDIB)->bcBitCount;
|
||||
|
||||
/* return number of colors based on bits per pixel */
|
||||
switch (wBitCount)
|
||||
{
|
||||
case 1:
|
||||
return 2;
|
||||
/* return number of colors based on bits per pixel */
|
||||
switch (wBitCount)
|
||||
{
|
||||
case 1:
|
||||
return 2;
|
||||
|
||||
case 4:
|
||||
return 16;
|
||||
case 4:
|
||||
return 16;
|
||||
|
||||
case 8:
|
||||
return 256;
|
||||
case 8:
|
||||
return 256;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 8
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
# CMake build for libtiff
|
||||
# Run "cmake" to generate the build files for your platform
|
||||
#
|
||||
# Copyright © 2015 Open Microscopy Environment / University of Dundee
|
||||
# Copyright © 2021-2022 Roger Leigh <rleigh@codelibre.net>
|
||||
# Written by Roger Leigh <rleigh@codelibre.net>
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and
|
||||
# its documentation for any purpose is hereby granted without fee, provided
|
||||
# that (i) the above copyright notices and this permission notice appear in
|
||||
# all copies of the software and related documentation, and (ii) the names of
|
||||
# Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
# publicity relating to the software without the specific, prior written
|
||||
# permission of Sam Leffler and Silicon Graphics.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
# OF THIS SOFTWARE.
|
||||
|
||||
cmake_minimum_required(VERSION 3.2.0)
|
||||
|
||||
include(Sphinx)
|
||||
|
||||
if (BUILD_SPHINX AND SPHINX_BUILD)
|
||||
# Re-run CMake when the Sphinx configuration is updated
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/conf.py")
|
||||
|
||||
message(STATUS "Checking manual page dependencies")
|
||||
|
||||
# Create build directory and conf.py
|
||||
set(sphinx_srcdir "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set(sphinx_builddir "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
file(MAKE_DIRECTORY "${sphinx_builddir}")
|
||||
|
||||
sphinx_manpages("${sphinx_srcdir}" "${sphinx_builddir}/man" MAN_PAGES)
|
||||
sphinx_manpage_dependencies("${sphinx_srcdir}" MAN_PAGE_DEPENDENCIES)
|
||||
sphinx_dependencies("${sphinx_srcdir}" SPHINX_DEPENDENCIES)
|
||||
|
||||
# Generate and install man pages
|
||||
|
||||
unset(man_target)
|
||||
if(MAN_PAGES)
|
||||
add_custom_command(OUTPUT ${MAN_PAGES}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${sphinx_builddir}/cache"
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BINARY_DIR}/man"
|
||||
COMMAND ${SPHINX_BUILD}
|
||||
-D "release=${LIBTIFF_VERSION_FULL}"
|
||||
-D "version=${tiff_VERSION_MAJOR}.${tiff_VERSION_MINOR}"
|
||||
-d "${sphinx_builddir}/cache"
|
||||
-b man
|
||||
"${sphinx_srcdir}" "${sphinx_builddir}/man"
|
||||
WORKING_DIRECTORY "${sphinx_srcdir}"
|
||||
DEPENDS ${MAN_PAGE_DEPENDENCIES})
|
||||
|
||||
if(NOT TARGET doc-man)
|
||||
add_custom_target(doc-man ALL)
|
||||
endif()
|
||||
add_custom_target(${PROJECT_NAME}-doc-man DEPENDS ${MAN_PAGES})
|
||||
add_dependencies(doc-man ${PROJECT_NAME}-doc-man)
|
||||
set(man_target ${PROJECT_NAME}-doc-man)
|
||||
|
||||
foreach (man ${MAN_PAGES})
|
||||
string(REGEX REPLACE ".*\\.([0-9])[a-z]*\$" "\\1" man_section "${man}")
|
||||
install(FILES "${man}"
|
||||
DESTINATION "${CMAKE_INSTALL_MANDIR}/man${man_section}"
|
||||
COMPONENT "runtime")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Generate and install HTML manual
|
||||
# Depends on man to allow sharing of cache with parallel build.
|
||||
|
||||
add_custom_command(OUTPUT "${sphinx_builddir}/html/index.html"
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${sphinx_builddir}/cache"
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${sphinx_builddir}/html"
|
||||
COMMAND ${SPHINX_BUILD}
|
||||
-D "release=${tiff_VERSION}"
|
||||
-D "version=${tiff_VERSION_MAJOR}.${tiff_VERSION_MINOR}"
|
||||
-d "${sphinx_builddir}/cache"
|
||||
-b html
|
||||
"${sphinx_srcdir}" "${sphinx_builddir}/html"
|
||||
WORKING_DIRECTORY "${sphinx_srcdir}"
|
||||
DEPENDS ${man_target} ${SPHINX_DEPENDENCIES})
|
||||
|
||||
if(NOT TARGET doc-html)
|
||||
add_custom_target(doc-html ALL)
|
||||
endif()
|
||||
add_custom_target(${PROJECT_NAME}-doc-html DEPENDS "${sphinx_builddir}/html/index.html")
|
||||
add_dependencies(doc-html ${PROJECT_NAME}-doc-html)
|
||||
|
||||
install(DIRECTORY "${sphinx_builddir}/html"
|
||||
DESTINATION "${CMAKE_INSTALL_DOCDIR}/manual"
|
||||
COMPONENT "runtime")
|
||||
|
||||
if(sphinx-linkcheck)
|
||||
set(sphinx_linkcheck_all ALL)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET doc-linkcheck)
|
||||
add_custom_target(doc-linkcheck)
|
||||
endif()
|
||||
add_custom_target(${PROJECT_NAME}-doc-linkcheck ${sphinx_linkcheck_all}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${sphinx_builddir}/cache"
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${sphinx_builddir}/linkcheck"
|
||||
COMMAND ${SPHINX_BUILD}
|
||||
-D "release=${tiff_VERSION}"
|
||||
-D "version=${tiff_VERSION_MAJOR}.${tiff_VERSION_MINOR}"
|
||||
-c "${sphinx_builddir}"
|
||||
-d "${sphinx_builddir}/cache"
|
||||
-b linkcheck
|
||||
"${sphinx_srcdir}" "${sphinx_builddir}/linkcheck"
|
||||
COMMENT "Checking remote links in sphinx documentation"
|
||||
WORKING_DIRECTORY "${sphinx_srcdir}"
|
||||
DEPENDS ${man_target} ${SPHINX_DEPENDENCIES})
|
||||
add_dependencies(doc-linkcheck ${PROJECT_NAME}-doc-linkcheck)
|
||||
|
||||
if(NOT TARGET doc-locallinkcheck)
|
||||
add_custom_target(doc-locallinkcheck)
|
||||
endif()
|
||||
add_custom_target(${PROJECT_NAME}-doc-locallinkcheck ${sphinx_linkcheck_all}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
"-DOUTPUT=${sphinx_builddir}/linkcheck/output.txt"
|
||||
"-DSPHINX_INSTALL_PATH=${PROJECT_NAME}/manual/html"
|
||||
"-DINTERNAL_REFERENCE=${sphinx_builddir}/html"
|
||||
"-DEXTERNAL_REFERENCE=${CMAKE_INSTALL_FULL_DATAROOTDIR}/doc"
|
||||
"-DDOXYGEN_REFERENCE=${PROJECT_BINARY_DIR}/docs/doxygen/api"
|
||||
"-DDOXYGEN_INSTALL_PATH=${PROJECT_NAME}/api"
|
||||
-P "${PROJECT_SOURCE_DIR}/cmake/SphinxCheckInternalLinks.cmake"
|
||||
COMMENT "Checking local links in sphinx documentation"
|
||||
WORKING_DIRECTORY "${sphinx_srcdir}"
|
||||
DEPENDS doc-linkcheck)
|
||||
add_dependencies(doc-locallinkcheck ${PROJECT_NAME}-doc-locallinkcheck)
|
||||
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/html-prebuilt/")
|
||||
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/html-prebuilt/"
|
||||
DESTINATION "${CMAKE_INSTALL_DOCDIR}/manual/html"
|
||||
COMPONENT "runtime")
|
||||
else()
|
||||
message(WARNING "Manual pages and HTML manual will not be generated or installed")
|
||||
endif()
|
||||
+288
@@ -0,0 +1,288 @@
|
||||
#
|
||||
# Tag Image File Format (TIFF) Software
|
||||
#
|
||||
# Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu>
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and
|
||||
# its documentation for any purpose is hereby granted without fee, provided
|
||||
# that (i) the above copyright notices and this permission notice appear in
|
||||
# all copies of the software and related documentation, and (ii) the names of
|
||||
# Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
# publicity relating to the software without the specific, prior written
|
||||
# permission of Sam Leffler and Silicon Graphics.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
# OF THIS SOFTWARE.
|
||||
|
||||
# Process this file with automake to produce Makefile.in.
|
||||
|
||||
docdir = $(LIBTIFF_DOCDIR)/manual
|
||||
|
||||
rst_sources = \
|
||||
index.rst \
|
||||
build.rst \
|
||||
internals.rst \
|
||||
tools/tiffgt.rst \
|
||||
tools/tiffdither.rst \
|
||||
tools/tiff2pdf.rst \
|
||||
tools/tiff2ps.rst \
|
||||
tools/ppm2tiff.rst \
|
||||
tools/raw2tiff.rst \
|
||||
tools/fax2tiff.rst \
|
||||
tools/tiffcrop.rst \
|
||||
tools/tiff2bw.rst \
|
||||
tools/fax2ps.rst \
|
||||
tools/thumbnail.rst \
|
||||
tools/tiffcmp.rst \
|
||||
tools/tiffdump.rst \
|
||||
tools/tiff2rgba.rst \
|
||||
tools/tiffinfo.rst \
|
||||
tools/rgb2ycbcr.rst \
|
||||
tools/tiffset.rst \
|
||||
tools/tiffsplit.rst \
|
||||
tools/tiffmedian.rst \
|
||||
tools/pal2rgb.rst \
|
||||
tools/tiffcp.rst \
|
||||
project/license.rst \
|
||||
project/index.rst \
|
||||
project/acknowledgements.rst \
|
||||
project/bugs.rst \
|
||||
project/mailinglist.rst \
|
||||
project/psc.rst \
|
||||
addingtags.rst \
|
||||
specification/index.rst \
|
||||
specification/bigtiff.rst \
|
||||
specification/coverage.rst \
|
||||
specification/technote2.rst \
|
||||
specification/coverage-bigtiff.rst \
|
||||
releases/v3.4beta028.rst \
|
||||
releases/v4.0.9.rst \
|
||||
releases/v3.9.0.rst \
|
||||
releases/v4.0.7.rst \
|
||||
releases/v3.5.7.rst \
|
||||
releases/v4.0.0.rst \
|
||||
releases/v3.7.0beta2.rst \
|
||||
releases/v3.7.1.rst \
|
||||
releases/index.rst \
|
||||
releases/v3.8.0.rst \
|
||||
releases/v4.1.0.rst \
|
||||
releases/historical.rst \
|
||||
releases/v3.5.6beta.rst \
|
||||
releases/v3.6.1.rst \
|
||||
releases/v4.2.0.rst \
|
||||
releases/v3.7.0.rst \
|
||||
releases/v4.0.1.rst \
|
||||
releases/v3.5.1.rst \
|
||||
releases/v4.0.10.rst \
|
||||
releases/v4.0.6.rst \
|
||||
releases/v4.0.8.rst \
|
||||
releases/v3.9.1.rst \
|
||||
releases/v3.4beta029.rst \
|
||||
releases/v4.3.0.rst \
|
||||
releases/v3.4beta031.rst \
|
||||
releases/v3.7.0alpha.rst \
|
||||
releases/v3.6.0.rst \
|
||||
releases/v3.4beta036.rst \
|
||||
releases/v4.0.4beta.rst \
|
||||
releases/v3.8.1.rst \
|
||||
releases/v4.4.0.rst \
|
||||
releases/v3.4beta035.rst \
|
||||
releases/v3.4beta032.rst \
|
||||
releases/v3.4beta007.rst \
|
||||
releases/v3.9.0beta.rst \
|
||||
releases/v3.8.2.rst \
|
||||
releases/v3.4beta018.rst \
|
||||
releases/v3.7.3.rst \
|
||||
releases/v3.4beta016.rst \
|
||||
releases/v3.7.4.rst \
|
||||
releases/v3.5.2.rst \
|
||||
releases/v4.0.5.rst \
|
||||
releases/v3.4beta024.rst \
|
||||
releases/v3.5.5.rst \
|
||||
releases/v4.0.2.rst \
|
||||
releases/v3.9.5.rst \
|
||||
releases/v3.9.2.rst \
|
||||
releases/v3.4beta033.rst \
|
||||
releases/v3.4beta034.rst \
|
||||
releases/v3.9.3.rst \
|
||||
releases/v3.9.4.rst \
|
||||
releases/v3.7.0beta.rst \
|
||||
releases/v3.5.4.rst \
|
||||
releases/v4.0.3.rst \
|
||||
releases/v3.5.3.rst \
|
||||
releases/v4.0.4.rst \
|
||||
releases/v3.7.2.rst \
|
||||
releases/v4.5.0.rst \
|
||||
releases/v4.5.1.rst \
|
||||
releases/v4.6.0.rst \
|
||||
releases/v4.7.0.rst \
|
||||
rfcs/index.rst \
|
||||
rfcs/rfc1_psc.rst \
|
||||
rfcs/rfc2_restoring_needed_tools.rst \
|
||||
functions.rst \
|
||||
tools.rst \
|
||||
terms.rst \
|
||||
contrib.rst \
|
||||
functions/TIFFRGBAImage.rst \
|
||||
functions/TIFFGetField.rst \
|
||||
functions/TIFFSetDirectory.rst \
|
||||
functions/TIFFWriteRawStrip.rst \
|
||||
functions/TIFFcolor.rst \
|
||||
functions/TIFFstrip.rst \
|
||||
functions/TIFFReadDirectory.rst \
|
||||
functions/TIFFReadRawTile.rst \
|
||||
functions/libtiff.rst \
|
||||
functions/TIFFPrintDirectory.rst \
|
||||
functions/TIFFsize.rst \
|
||||
functions/TIFFReadRGBATile.rst \
|
||||
functions/TIFFswab.rst \
|
||||
functions/TIFFmemory.rst \
|
||||
functions/TIFFtile.rst \
|
||||
functions/TIFFReadEncodedTile.rst \
|
||||
functions/TIFFWriteDirectory.rst \
|
||||
functions/TIFFSetField.rst \
|
||||
functions/TIFFWriteScanline.rst \
|
||||
functions/TIFFClose.rst \
|
||||
functions/TIFFFieldName.rst \
|
||||
functions/TIFFFieldReadCount.rst \
|
||||
functions/TIFFError.rst \
|
||||
functions/TIFFOpen.rst \
|
||||
functions/TIFFOpenOptions.rst \
|
||||
functions/TIFFcodec.rst \
|
||||
functions/TIFFFlush.rst \
|
||||
functions/TIFFDataWidth.rst \
|
||||
functions/TIFFReadRawStrip.rst \
|
||||
functions/TIFFReadTile.rst \
|
||||
functions/TIFFFieldWriteCount.rst \
|
||||
functions/TIFFbuffer.rst \
|
||||
functions/TIFFWriteRawTile.rst \
|
||||
functions/TIFFWarning.rst \
|
||||
functions/TIFFFieldDataType.rst \
|
||||
functions/TIFFWriteEncodedStrip.rst \
|
||||
functions/TIFFFieldPassCount.rst \
|
||||
functions/TIFFReadRGBAImage.rst \
|
||||
functions/TIFFReadScanline.rst \
|
||||
functions/TIFFReadEncodedStrip.rst \
|
||||
functions/TIFFFieldTag.rst \
|
||||
functions/TIFFWriteTile.rst \
|
||||
functions/TIFFReadRGBAStrip.rst \
|
||||
functions/TIFFquery.rst \
|
||||
functions/TIFFWriteEncodedTile.rst \
|
||||
functions/_TIFFauxiliary.rst \
|
||||
functions/_TIFFRewriteField.rst \
|
||||
functions/TIFFAccessTagMethods.rst \
|
||||
functions/TIFFClientInfo.rst \
|
||||
functions/TIFFCreateDirectory.rst \
|
||||
functions/TIFFCustomDirectory.rst \
|
||||
functions/TIFFCustomTagList.rst \
|
||||
functions/TIFFDeferStrileArrayWriting.rst \
|
||||
functions/TIFFFieldQuery.rst \
|
||||
functions/TIFFMergeFieldInfo.rst \
|
||||
functions/TIFFProcFunctions.rst \
|
||||
functions/TIFFReadFromUserBuffer.rst \
|
||||
functions/TIFFSetTagExtender.rst \
|
||||
functions/TIFFStrileQuery.rst \
|
||||
libtiff.rst \
|
||||
multi_page.rst \
|
||||
images.rst
|
||||
|
||||
EXTRA_DIST = \
|
||||
CMakeLists.txt \
|
||||
conf.py \
|
||||
specification/bigtiffpr_images \
|
||||
images \
|
||||
$(rst_sources)
|
||||
|
||||
if TIFF_DOCS
|
||||
if SPHINX
|
||||
doc-html: $(EXTRA_DIST) ../configure.ac
|
||||
$(SPHINX_BUILD) \
|
||||
-D "release=$(LIBTIFF_VERSION)" \
|
||||
-D "version=$(LIBTIFF_MAJOR_VERSION).$(LIBTIFF_MINOR_VERSION)" \
|
||||
-d "$(builddir)/cache" \
|
||||
-b html \
|
||||
"$(srcdir)" "$(builddir)/html"
|
||||
touch doc-html
|
||||
|
||||
doc-man: $(EXTRA_DIST) ../configure.ac
|
||||
$(SPHINX_BUILD) \
|
||||
-D "release=$(LIBTIFF_VERSION)" \
|
||||
-D "version=$(LIBTIFF_MAJOR_VERSION).$(LIBTIFF_MINOR_VERSION)" \
|
||||
-d "$(builddir)/cache" \
|
||||
-b man \
|
||||
"$(srcdir)" "$(builddir)/man"
|
||||
touch doc-man
|
||||
|
||||
man1_MANS = $(TIFF_MAN1_GEN)
|
||||
man3_MANS = $(TIFF_MAN3_GEN)
|
||||
|
||||
@TIFF_MAN_RULES@
|
||||
|
||||
all-local: doc-html doc-man
|
||||
|
||||
clean-local:
|
||||
rm -rf html
|
||||
rm -rf man
|
||||
rm -rf cache
|
||||
rm -f doc-html
|
||||
rm -f doc-man
|
||||
|
||||
html_installdir = html
|
||||
else
|
||||
# Sphinx not available
|
||||
doc-html:
|
||||
echo "HTML documentation generation not configured (sphinx not available)"
|
||||
exit 1
|
||||
|
||||
doc-man:
|
||||
echo "Manual page documentation generation not configured (sphinx not available)"
|
||||
exit 1
|
||||
|
||||
.PHONY: doc-html doc-man
|
||||
|
||||
man1_MANS = $(TIFF_MAN1_PREBUILT)
|
||||
man3_MANS = $(TIFF_MAN3_PREBUILT)
|
||||
|
||||
html_installdir = $(srcdir)/html-prebuilt
|
||||
endif
|
||||
|
||||
|
||||
install-data-local: all-local
|
||||
find $(html_installdir) -type d | sed -e 's;^$(html_installdir);;' | while read dir; do \
|
||||
echo " $(MKDIR_P) '$(DESTDIR)$(docdir)$$dir'"; \
|
||||
$(MKDIR_P) "$(DESTDIR)$(docdir)$$dir" || exit 1; \
|
||||
done
|
||||
find $(html_installdir) -type f | sed -e 's;^$(html_installdir);;' | while read docfile; do \
|
||||
docsubdir=$$(dirname $$docfile); \
|
||||
echo "$(INSTALL_DATA) '$(html_installdir)$$docfile' '$(DESTDIR)$(docdir)$$docsubdir'"; \
|
||||
$(INSTALL_DATA) "$(html_installdir)$$docfile" "$(DESTDIR)$(docdir)$$docsubdir"; \
|
||||
done
|
||||
|
||||
uninstall-local:
|
||||
echo "rm -r $(DESTDIR)$(docdir)"
|
||||
rm -r $(DESTDIR)$(docdir)
|
||||
else
|
||||
# Documentation generation disabled
|
||||
doc-html:
|
||||
echo "HTML documentation generation not configured"
|
||||
exit 1
|
||||
|
||||
doc-man:
|
||||
echo "Manual page documentation generation not configured"
|
||||
exit 1
|
||||
|
||||
.PHONY: doc-html doc-man
|
||||
|
||||
endif
|
||||
|
||||
dist-hook: doc-html doc-man
|
||||
cp -r html $(distdir)/html-prebuilt
|
||||
cp -r man $(distdir)/man-prebuilt
|
||||
@@ -0,0 +1,316 @@
|
||||
Defining New TIFF Tags
|
||||
======================
|
||||
|
||||
Libtiff has built-in knowledge of all the standard TIFF tags, as
|
||||
well as extensions. The following describes how to add knowledge of
|
||||
new tags as builtins to libtiff, or how to application specific tags can
|
||||
be used by applications without modifying libtiff.
|
||||
|
||||
.. _TIFFFieldInfo_Definition:
|
||||
|
||||
TIFFFieldInfo
|
||||
-------------
|
||||
|
||||
How libtiff manages specific tags is primarily controlled by the
|
||||
definition for that tag value stored internally as a TIFFFieldInfo structure.
|
||||
This structure looks like this:
|
||||
|
||||
.. highlight:: c
|
||||
|
||||
::
|
||||
|
||||
typedef struct {
|
||||
ttag_t field_tag; /* field's tag */
|
||||
short field_readcount; /* read count / TIFF_VARIABLE / TIFF_VARIABLE2 / TIFF_SPP */
|
||||
short field_writecount; /* write count / TIFF_VARIABLE / TIFF_VARIABLE2 */
|
||||
TIFFDataType field_type; /* type of associated data */
|
||||
unsigned short field_bit; /* bit in fieldsset bit vector */
|
||||
unsigned char field_oktochange; /* if true, can change while writing */
|
||||
unsigned char field_passcount; /* if true, pass dir count on set */
|
||||
char *field_name; /* ASCII name */
|
||||
} TIFFFieldInfo;
|
||||
|
||||
|
||||
.. c:member:: ttag_t TIFFFieldInfo.field_tag
|
||||
|
||||
The tag number. For instance 277 for the
|
||||
SamplesPerPixel tag. Builtin tags will generally have a ``#define`` in
|
||||
:file:`tiff.h` for each known tag.
|
||||
|
||||
.. c:member:: short TIFFFieldInfo.field_readcount
|
||||
|
||||
The number of values which should be read.
|
||||
The special value :c:macro:`TIFF_VARIABLE` (-1) indicates that a variable number of
|
||||
values may be read. The special value :c:macro:`TIFFTAG_SPP` (-2) indicates that there
|
||||
should be one value for each sample as defined by :c:macro:`TIFFTAG_SAMPLESPERPIXEL`.
|
||||
The special value :c:macro:`TIFF_VARIABLE2` (-3) is similar to :c:macro:`TIFF_VARIABLE`
|
||||
but the required TIFFGetField() count value must be uint32_t* instead of uint16_t* as
|
||||
for :c:macro:`TIFF_VARIABLE` (-1).
|
||||
For ASCII fields with variable length, this field is :c:macro:`TIFF_VARIABLE`.
|
||||
|
||||
.. c:member:: short TIFFFieldInfo.field_writecount
|
||||
|
||||
The number of values which should be written.
|
||||
Generally the same as field_readcount. A few built-in exceptions exist, but
|
||||
I haven't analysed why they differ.
|
||||
|
||||
.. c:member:: TIFFDataType TIFFFieldInfo.field_type
|
||||
|
||||
Type of the field. One of :c:enumerator:`TIFF_BYTE`, :c:enumerator:`TIFF_ASCII`,
|
||||
:c:enumerator:`TIFF_SHORT`, :c:enumerator:`TIFF_LONG`,
|
||||
:c:enumerator:`TIFF_RATIONAL`, :c:enumerator:`TIFF_SBYTE`,
|
||||
:c:enumerator:`TIFF_UNDEFINED`, :c:enumerator:`TIFF_SSHORT`,
|
||||
:c:enumerator:`TIFF_SLONG`, :c:enumerator:`TIFF_SRATIONAL`,
|
||||
:c:enumerator:`TIFF_FLOAT`, :c:enumerator:`TIFF_DOUBLE` or
|
||||
:c:enumerator:`TIFF_IFD`.
|
||||
And for BigTIFF :c:enumerator:`TIFF_LONG8`,
|
||||
:c:enumerator:`TIFF_SLONG8` and :c:enumerator:`TIFF_IFD8`,
|
||||
which are automatically reverted to 4 byte fields in
|
||||
ClassicTIFF.
|
||||
|
||||
.. c:member:: unsigned short TIFFFieldInfo.field_bit
|
||||
|
||||
Built-in tags stored in special fields in the
|
||||
TIFF structure have assigned field numbers to distinguish them (e.g.
|
||||
:c:macro:`FIELD_SAMPLESPERPIXEL`). New tags should generally just use
|
||||
:c:macro:`FIELD_CUSTOM` indicating they are stored in the generic tag list.
|
||||
|
||||
.. c:member:: unsigned char TIFFFieldInfo.field_oktochange
|
||||
|
||||
TRUE if it is OK to change this tag value
|
||||
while an image is being written. FALSE for stuff that must be set once
|
||||
and then left unchanged (like ImageWidth, or PhotometricInterpretation for
|
||||
instance).
|
||||
|
||||
.. c:member:: unsigned char TIFFFieldInfo.field_passcount
|
||||
|
||||
If TRUE, then the count value must be passed
|
||||
in :c:func:`TIFFSetField`, and :c:func:`TIFFGetField`, otherwise the count is not required.
|
||||
This should generally be TRUE for non-ascii variable count tags unless
|
||||
the count is implicit (such as with the colormap).
|
||||
|
||||
.. c:member:: char * TIFFFieldInfo.field_name
|
||||
|
||||
A name for the tag. Normally mixed case (studly caps)
|
||||
like ``StripByteCounts``, and relatively short.
|
||||
|
||||
Within :file:`tif_dirinfo.c` file, the built-in TIFF tags are defined with
|
||||
:c:struct:`TIFFField` structure that has additional parameters defining the var_arg
|
||||
interface of :c:func:`TIFFSetField` and :c:func:`TIFFGetField`.
|
||||
|
||||
Various functions exist for getting the internal :c:struct:`TIFFFieldInfo`
|
||||
definitions, including :c:func:`_TIFFFindFieldInfo`, and
|
||||
:c:func:`_TIFFFindFieldInfoByName`. See
|
||||
:file:`tif_dirinfo.c` for details.
|
||||
|
||||
.. _Tag_Auto_registration:
|
||||
|
||||
Default Tag Auto-registration
|
||||
-----------------------------
|
||||
|
||||
In libtiff 3.6.0 a new mechanism was introduced allowing libtiff to
|
||||
read unrecognised tags automatically. When an unknown tags is encountered,
|
||||
it is automatically internally defined with a default name and a type
|
||||
derived from the tag value in the file. Applications only need to predefine
|
||||
application specific tags if they need to be able to set them in a file, or
|
||||
if particular calling conventions are desired for :c:func:`TIFFSetField` and
|
||||
:c:func:`TIFFGetField`.
|
||||
|
||||
When tags are autodefined like this the :c:member:`field_readcount` and
|
||||
:c:member:`field_writecount` values are always :c:macro:`TIFF_VARIABLE2` (-3). The
|
||||
:c:member:`field_passcount` is always TRUE, and the :c:member:`field_bit` is
|
||||
:c:macro:`FIELD_CUSTOM`. The field name will be ``Tag %d`` where the ``%d``
|
||||
is the tag number.
|
||||
|
||||
Thus, to read anonymous auto-registered tags use the following:
|
||||
|
||||
::
|
||||
|
||||
uint32_t count;
|
||||
void* value; //has to be a pointer to the expected value type.
|
||||
TIFFGetField(tif, TIFFTAG_UNKNOWN_TO_LIBTIFF, &count, &value);
|
||||
|
||||
|
||||
.. _Define_Application_Tags:
|
||||
|
||||
Defining Application Tags
|
||||
-------------------------
|
||||
|
||||
For various reasons, it is common for applications to want to define
|
||||
their own tags to store information outside the core TIFF specification.
|
||||
This is done by calling :c:func:`TIFFMergeFieldInfo` with one or more
|
||||
:c:struct:`TIFFFieldInfo`.
|
||||
|
||||
The libgeotiff library provides geospatial information extensions within
|
||||
a TIFF file. First, an array of :c:struct:`TIFFFieldInfo` is prepared with
|
||||
information on the new tags:
|
||||
|
||||
::
|
||||
|
||||
static const TIFFFieldInfo xtiffFieldInfo[] = {
|
||||
|
||||
/* XXX Insert Your tags here */
|
||||
{ TIFFTAG_GEOPIXELSCALE, -1,-1, TIFF_DOUBLE, FIELD_CUSTOM,
|
||||
TRUE, TRUE, "GeoPixelScale" },
|
||||
{ TIFFTAG_GEOTRANSMATRIX, -1,-1, TIFF_DOUBLE, FIELD_CUSTOM,
|
||||
TRUE, TRUE, "GeoTransformationMatrix" },
|
||||
{ TIFFTAG_GEOTIEPOINTS, -1,-1, TIFF_DOUBLE, FIELD_CUSTOM,
|
||||
TRUE, TRUE, "GeoTiePoints" },
|
||||
{ TIFFTAG_GEOKEYDIRECTORY, -1,-1, TIFF_SHORT, FIELD_CUSTOM,
|
||||
TRUE, TRUE, "GeoKeyDirectory" },
|
||||
{ TIFFTAG_GEODOUBLEPARAMS, -1,-1, TIFF_DOUBLE, FIELD_CUSTOM,
|
||||
TRUE, TRUE, "GeoDoubleParams" },
|
||||
{ TIFFTAG_GEOASCIIPARAMS, -1,-1, TIFF_ASCII, FIELD_CUSTOM,
|
||||
TRUE, FALSE, "GeoASCIIParams" }
|
||||
};
|
||||
|
||||
In order to define the tags, we call :c:func:`TIFFMergeFieldInfo` on the
|
||||
desired TIFF handle with the list of :c:struct:`TIFFFieldInfo`.
|
||||
|
||||
::
|
||||
|
||||
#define N(a) (sizeof (a) / sizeof (a[0]))
|
||||
|
||||
/* Install the extended Tag field info */
|
||||
TIFFMergeFieldInfo(tif, xtiffFieldInfo, N(xtiffFieldInfo));
|
||||
|
||||
The tags need to be defined for each TIFF file opened - and when reading
|
||||
they should be defined before the tags of the file are read, yet a valid
|
||||
:c:expr:`TIFF *` is needed to merge the tags against. In order to get them
|
||||
registered at the appropriate part of the setup process, it is necessary
|
||||
to register our merge function as an extender callback with libtiff.
|
||||
This is done with :c:func:`TIFFSetTagExtender`. We also keep track of the
|
||||
previous tag extender (if any) so that we can call it from our extender
|
||||
allowing a chain of customizations to take effect.
|
||||
|
||||
::
|
||||
|
||||
static TIFFExtendProc _ParentExtender = NULL;
|
||||
|
||||
static
|
||||
void _XTIFFInitialize(void)
|
||||
{
|
||||
static int first_time=1;
|
||||
|
||||
if (! first_time) return; /* Been there. Done that. */
|
||||
first_time = 0;
|
||||
|
||||
/* Grab the inherited method and install */
|
||||
_ParentExtender = TIFFSetTagExtender(_XTIFFDefaultDirectory);
|
||||
}
|
||||
|
||||
The extender callback is looks like this. It merges in our new fields
|
||||
and then calls the next extender if there is one in effect.
|
||||
|
||||
::
|
||||
|
||||
static void
|
||||
_XTIFFDefaultDirectory(TIFF *tif)
|
||||
{
|
||||
/* Install the extended Tag field info */
|
||||
TIFFMergeFieldInfo(tif, xtiffFieldInfo, N(xtiffFieldInfo));
|
||||
|
||||
/* Since an XTIFF client module may have overridden
|
||||
* the default directory method, we call it now to
|
||||
* allow it to set up the rest of its own methods.
|
||||
*/
|
||||
|
||||
if (_ParentExtender)
|
||||
(*_ParentExtender)(tif);
|
||||
}
|
||||
|
||||
The above approach ensures that our new definitions are used when reading
|
||||
or writing any TIFF file. However, since on reading we already have
|
||||
default definitions for tags, it is usually not critical to pre-define them.
|
||||
If tag definitions are only required for writing custom tags, you can just
|
||||
call :c:func:`TIFFMergeFieldInfo` before setting new tags. The whole extender
|
||||
architecture can then be avoided.
|
||||
|
||||
Adding New Builtin Tags
|
||||
-----------------------
|
||||
|
||||
A similar approach is taken to the above. However, the :c:struct:`TIFFFieldInfo`
|
||||
should be added to the :c:expr:`tiffFieldInfo[]` list in :file:`tif_dirinfo.c`.
|
||||
Ensure that new tags are added in sorted order by the tag number.
|
||||
|
||||
Normally new built-in tags should be defined with :c:macro:`FIELD_CUSTOM`; however, if
|
||||
it is desirable for the tag value to have it's own field in the :c:struct:`TIFFDirectory`
|
||||
structure, then you will need to ``#define`` a new :c:macro:`FIELD_` value for it, and
|
||||
add appropriate handling as follows:
|
||||
|
||||
#. Define the tag in :file:`tiff.h`.
|
||||
#. Add a field to the directory structure in :file:`tif_dir.h`
|
||||
and define a ``FIELD_*`` bit (also update the definition of
|
||||
:c:macro:`FIELD_CODEC` to reflect your addition).
|
||||
#. Add an entry in the :c:struct:`TIFFFieldInfo` array defined at the top of
|
||||
:file:`tif_dirinfo.c`.
|
||||
|
||||
.. note::
|
||||
|
||||
Note that you must keep this array sorted by tag
|
||||
number and that the widest variant entry for a tag should come
|
||||
first (e.g. :c:macro:`LONG` before :c:macro:`SHORT`).
|
||||
#. Add entries in :c:func:`_TIFFVSetField` and :c:func:`_TIFFVGetField`
|
||||
for the new tag.
|
||||
#. (*optional*) If the value associated with the tag is not a scalar value
|
||||
(e.g. the array for ``TransferFunction``) and requires
|
||||
special processing,
|
||||
then add the appropriate code to :c:func:`TIFFReadDirectory` and
|
||||
:c:func:`TIFFWriteDirectory`. You're best off finding a similar tag and
|
||||
cribbing code.
|
||||
#. Add support to :c:func:`TIFFPrintDirectory` in :file:`tif_print.c`
|
||||
to print the tag's value.
|
||||
|
||||
If you want to maintain portability, beware of making assumptions
|
||||
about data types. Use the typedefs (:c:type:`uint16_t`, etc. when dealing with
|
||||
data on disk and ``t*_t`` when stuff is in memory) and be careful about
|
||||
passing items through printf or similar vararg interfaces.
|
||||
|
||||
Adding New Codec-private Tags
|
||||
-----------------------------
|
||||
|
||||
To add tags that are meaningful *only when a particular compression
|
||||
algorithm is used* follow these steps:
|
||||
|
||||
#. Define the tag in :file:`tiff.h`.
|
||||
#. Allocate storage for the tag values in the private state block of
|
||||
the codec.
|
||||
#. Insure the state block is created when the codec is initialized.
|
||||
#. At :c:func:`TIFFInitfoo` time override the method pointers in the
|
||||
:c:struct:`TIFF` structure for getting, setting and printing tag values.
|
||||
For example,
|
||||
|
||||
::
|
||||
|
||||
sp->vgetparent = tif->tif_vgetfield;
|
||||
tif->tif_vgetfield = fooVGetField; /* hook for codec tags */
|
||||
sp->vsetparent = tif->tif_vsetfield;
|
||||
tif->tif_vsetfield = fooVSetField; /* hook for codec tags */
|
||||
tif->tif_printdir = fooPrintDir; /* hook for codec tags */
|
||||
|
||||
(Actually you may decide not to override the
|
||||
:c:member:`tif_printdir` method, but rather just specify it).
|
||||
#. Create a private :c:struct:`TIFFFieldInfo` array for your tags and
|
||||
merge them into the core tags at initialization time using
|
||||
:c:func:`_TIFFMergeFieldInfo`; e.g.
|
||||
|
||||
::
|
||||
|
||||
_TIFFMergeFieldInfo(tif, fooFieldInfo, N(fooFieldInfo));
|
||||
|
||||
(where :c:macro:`N` is a macro used liberaly throughout the distributed code).
|
||||
|
||||
#. Fill in the get and set routines. Be sure to call the parent method
|
||||
for tags that you are not handled directly. Also be sure to set the
|
||||
``FIELD_*`` bits for tags that are to be written to the file. Note that
|
||||
you can create "pseudo-tags" by defining tags that are processed
|
||||
exclusively in the get/set routines and never written to file (see
|
||||
the handling of :c:macro:`TIFFTAG_FAXMODE` in :file:`tif_fax3.c`
|
||||
for an example of this).
|
||||
#. Fill in the print routine, if appropriate.
|
||||
|
||||
Note that space has been allocated in the ``FIELD_*`` bit space for
|
||||
codec-private tags. Define your bits as ``FIELD_CODEC+<offset>`` to
|
||||
keep them away from the core tags. If you need more tags than there
|
||||
is room for, just increase :c:macro:`FIELD_SETLONGS` at the top of
|
||||
:file:`tiffiop.h`.
|
||||
+754
@@ -0,0 +1,754 @@
|
||||
Building the TIFF Software Distribution
|
||||
=======================================
|
||||
|
||||
.. image:: images/cramps.gif
|
||||
:width: 159
|
||||
:alt: cramps
|
||||
|
||||
This chapter contains step-by-step instructions on how to configure
|
||||
and build the TIFF software distribution. The software is most
|
||||
easily built on a UNIX system, but with a little bit of work it can
|
||||
easily be built and used on other non-UNIX platforms.
|
||||
|
||||
|
||||
Building on all systems with CMake
|
||||
----------------------------------
|
||||
|
||||
CMake may be used to
|
||||
generate build files for most common build systems and IDEs, and
|
||||
supports all UNIX-like systems as well as Windows. See
|
||||
the `CMake website <http://www.cmake.org/>`_ for further
|
||||
details. To build the software on you need to first run
|
||||
:command:`cmake` to configure the build and generate the system-specific
|
||||
build files. This reads the top-level :file:`CMakeLists.txt` file,
|
||||
which probes the target system for necessary tools and functions,
|
||||
checks any options you specified to configure the build, and then
|
||||
outputs build files configured for your system. If using ``Unix
|
||||
Makefiles``, once configuration is done, you simply
|
||||
run :command:`make` (or :command:`gmake`) to build the software and
|
||||
then :command:`make install` to do the installation. For other build
|
||||
systems, you do the equivalent steps with the tool for that system.
|
||||
For example, on any UNIX system:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
$ cd ./tiff-4.0.5
|
||||
$ cmake
|
||||
...lots of messages...
|
||||
$ make
|
||||
...lots of messages...
|
||||
$ make test
|
||||
...lots of messages...
|
||||
# make install
|
||||
|
||||
Building is dependent on a :program:`make` utility and a C
|
||||
(and optionally a C++) compiler, so you will need these tools.
|
||||
|
||||
In general, the software is designed such that the following
|
||||
targets will always be available:
|
||||
|
||||
::
|
||||
|
||||
make [all] build stuff
|
||||
make test run the test suite
|
||||
make install build and install stuff
|
||||
make clean remove object files, executables and cruft
|
||||
|
||||
Build Trees
|
||||
^^^^^^^^^^^
|
||||
|
||||
There are two schemes for configuring and building the software. If
|
||||
you intend to build the software for only one target system, you
|
||||
can configure the software so that it is built in the same
|
||||
directories as the source code.
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
$ gzip -dc tiff-4.0.5.tar.gz | tar -xf -
|
||||
$ cd ./tiff-4.0.5
|
||||
$ cmake
|
||||
$ make
|
||||
$ make test
|
||||
$ make install
|
||||
|
||||
Otherwise, you can configure a build tree that is parallel to
|
||||
the source tree hierarchy (or in some completely different place)
|
||||
but which contains only configured files and files created during
|
||||
the build procedure.
|
||||
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
$ gzip -dc tiff-4.0.5.tar.gz | tar -xf -
|
||||
$ mkdir tiff-4.0.5-build
|
||||
$ cd ./tiff-4.0.5-build
|
||||
$ cmake ../tiff-4.0.5
|
||||
$ make
|
||||
$ make test
|
||||
$ make install
|
||||
|
||||
This second scheme is useful for:
|
||||
|
||||
* building multiple targets from a single source tree
|
||||
* building from a read-only source tree
|
||||
* sharing the source files via a network, but building on
|
||||
multiple systems
|
||||
* keeping the source tree clean
|
||||
(unlike :program:`autoconf`, :program:`cmake` does not provide
|
||||
a ``distclean`` target, so out of source builds are
|
||||
recommended)
|
||||
|
||||
Generators
|
||||
^^^^^^^^^^
|
||||
|
||||
The default generator for UNIX is ``Unix Makefiles``, and on Windows is
|
||||
``NMake Makefiles`` or ``MSBuild`` depending upon the setup.
|
||||
Run :command:`cmake --help` to list all the
|
||||
generators available for your platform. For example, to use the Ninja
|
||||
`build system <https://martine.github.io/ninja/>`_ on UNIX or
|
||||
Windows:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
cmake -G Ninja
|
||||
cmake --build .
|
||||
ctest -V
|
||||
cmake --build . --target install
|
||||
|
||||
Note that :command:`cmake --build .` is a build-system-independent way
|
||||
of building a target; you can always use the build system directly.
|
||||
|
||||
Alternatively, using the MSBuild system on Windows (64-bit Release
|
||||
build with VS2013):
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
cmake -G "Visual Studio 12 2013 Win64"
|
||||
cmake --build . --config Release
|
||||
ctest -V -C Release
|
||||
cmake --build . --config Release --target install
|
||||
|
||||
With the above configuration, it's also possible to open the generated
|
||||
solution file with the Visual Studio IDE as well as building on the
|
||||
command-line.
|
||||
|
||||
Configuration Options
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The configuration process is critical to the proper compilation,
|
||||
installation, and operation of the
|
||||
software. The :file:`CMakeLists.txt` script runs a series of tests to
|
||||
decide whether or not the target system supports required
|
||||
functionality and, if it does not, whether it can emulate or
|
||||
workaround the missing functions. After running :command:`cmake`, check
|
||||
the :file:`CMakeCache.txt` file; this contains all the results of the
|
||||
checks performed and the options set by the user. If :program:`cmake`
|
||||
failed to run, check :file:`CMakeFiles/CMakeOutput.log`
|
||||
and :file:`CMakeFiles/CMakeError.log`; these should record the error
|
||||
which caused the failure.
|
||||
|
||||
A second function of the configure script is to set the default
|
||||
configuration parameters for the software. Of particular note are the
|
||||
directories where the software is to be installed. By default the
|
||||
software is installed in the :file:`/usr/local` hierarchy. To change
|
||||
this behaviour the appropriate parameters can be specified on the
|
||||
command line. Run :command:`cmake --help` to get a full list of possible
|
||||
options, and :command:`cmake -LH` to list all the configurable options for
|
||||
this software package, or :command:`cmake -LAH` to show all advanced
|
||||
options in addition. Standard installation related options are shown
|
||||
below.
|
||||
|
||||
.. list-table:: Installation options
|
||||
:widths: 10 15
|
||||
:header-rows: 1
|
||||
|
||||
* - Option
|
||||
- Description
|
||||
|
||||
* - ``CMAKE_INSTALL_PREFIX``
|
||||
- Installation root directory. The options below may be used to override
|
||||
individual installation locations.
|
||||
* - ``CMAKE_INSTALL_BINDIR``
|
||||
- user executables [:file:`PREFIX/bin`]
|
||||
* - ``CMAKE_INSTALL_SBINDIR``
|
||||
- system admin executables [:file:`PREFIX/sbin`]
|
||||
* - ``CMAKE_INSTALL_LIBEXECDIR``
|
||||
- program executables [:file:`PREFIX/libexec`]
|
||||
* - ``CMAKE_INSTALL_SYSCONFDIR``
|
||||
- read-only single-machine data [:file:`PREFIX/etc`]
|
||||
* - ``CMAKE_INSTALL_SHAREDSTATEDIR``
|
||||
- modifiable architecture-independent data [:file:`PREFIX/com`]
|
||||
* - ``CMAKE_INSTALL_LOCALSTATEDIR``
|
||||
- modifiable single-machine data [:file:`PREFIX/var`]
|
||||
* - ``CMAKE_INSTALL_LIBDIR``
|
||||
- object code libraries [:file:`PREFIX/lib`]
|
||||
* - ``CMAKE_INSTALL_INCLUDEDIR``
|
||||
- C header files [:file:`PREFIX/include`]
|
||||
* - ``CMAKE_INSTALL_OLDINCLUDEDIR``
|
||||
- C header files for non-gcc [:file:`/usr/include`]
|
||||
* - ``CMAKE_INSTALL_DATAROOTDIR``
|
||||
- read-only architecture-independent data root [:file:`PREFIX/share`]
|
||||
* - ``CMAKE_INSTALL_DATADIR``
|
||||
- read-only architecture-independent data [:file:`DATAROOTDIR`]
|
||||
* - ``CMAKE_INSTALL_LOCALEDIR``
|
||||
- locale-dependent data [:file:`DATAROOTDIR/locale`]
|
||||
* - ``CMAKE_INSTALL_MANDIR``
|
||||
- man documentation [:file:`DATAROOTDIR/man`]
|
||||
* - ``CMAKE_INSTALL_DOCDIR``
|
||||
- documentation root [:file:`DATAROOTDIR/doc/tiff`]
|
||||
|
||||
Also see the
|
||||
CMake `documentation <http://www.cmake.org/cmake/help/latest/>`_
|
||||
for `additional variables <http://www.cmake.org/cmake/help/latest/manual/cmake-variables.7.html>`_
|
||||
which may be set.
|
||||
|
||||
Configuring Optional Packages/Support
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The TIFF software comes with several packages that are installed
|
||||
only as needed, or only if specifically configured at the time the
|
||||
configure script is run. Packages can be configured via the
|
||||
:program:`cmake` commandline parameters.
|
||||
|
||||
Static/Shared Objects Support
|
||||
.............................
|
||||
|
||||
``BUILD_SHARED_LIBS[=ON|OFF]``:
|
||||
|
||||
Build shared libraries (default is ``ON``)
|
||||
|
||||
This option controls whether or not to configure the software
|
||||
to build a shared and static binaries for the TIFF library. Use of
|
||||
shared libraries can significantly reduce the disk space needed for
|
||||
users of the TIFF software. If shared libraries are not used then
|
||||
the code is statically linked into each application that uses it.
|
||||
|
||||
``ld-version-script[=ON|OFF]``
|
||||
|
||||
Enable linker version script (default is ``ON``)
|
||||
|
||||
Add shared library symbol versioning on ELF-based systems (e.g.
|
||||
Linux and FreeBSD) which use the GNU linker. This is needed if
|
||||
several major versions of libtiff might be loaded at once into the
|
||||
same program.
|
||||
|
||||
JPEG Support
|
||||
............
|
||||
|
||||
``jpeg[=ON|OFF]``
|
||||
|
||||
Enable IJG JPEG library usage (required for JPEG compression, enabled by default)
|
||||
|
||||
``JPEG_INCLUDE_DIR=DIR``:
|
||||
|
||||
Location of IJG JPEG library headers
|
||||
|
||||
``JPEG_LIBRARY=DIR``
|
||||
|
||||
Location of IJG JPEG library binary
|
||||
|
||||
The ``JPEG`` package enables support for the handling of
|
||||
TIFF images with JPEG-encoded data. Support for JPEG-encoded data
|
||||
requires the Independent JPEG Group (IJG) ``libjpeg``
|
||||
distribution; this software is available at `<http://www.ijg.org/>`_.
|
||||
The CMake script automatically tries to search for a working IJG JPEG
|
||||
installation. If it fails to find library, JPEG support will be
|
||||
automatically disabled. If you want specify the exact paths to
|
||||
library binary and headers, use above options for that.
|
||||
|
||||
ZIP Support
|
||||
...........
|
||||
|
||||
The ``ZIP`` support enables support for the handling of TIFF
|
||||
images with deflate-encoded data (enabled by default if
|
||||
available). Support for deflate-encoded data requires the freely
|
||||
available ``zlib`` distribution written by Jean-loup Gailly and
|
||||
Mark Adler; this software is available at `<http://www.zlib.org/>`_.
|
||||
|
||||
|
||||
Building on a UNIX System with Autoconf
|
||||
---------------------------------------
|
||||
|
||||
.. program:: configure
|
||||
|
||||
To build the software on a UNIX system you need to first run the
|
||||
:program:`configure` shell script that is located in the top level of the
|
||||
source directory. This script probes the target system for
|
||||
necessary tools and functions and constructs a build environment in
|
||||
which the software may be compiled. Once configuration is done, you
|
||||
simply run :command:`make` (or :command:`gmake`) to build the software
|
||||
and then :command:`make install` to do the installation; for example:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
% cd ./tiff-4.0.5
|
||||
% ./configure
|
||||
...lots of messages...
|
||||
% make
|
||||
...lots of messages...
|
||||
% make check
|
||||
...lots of messages...
|
||||
# make install
|
||||
|
||||
Supplied Makefiles are dependent on a :program:`make` utility and a C
|
||||
(and optionally a C++ compiler), so you will need these tools.
|
||||
|
||||
In general, the software is designed such that the following
|
||||
should be "make-able" in each directory:
|
||||
|
||||
.. list-table:: Make targets
|
||||
:widths: 10 15
|
||||
:header-rows: 1
|
||||
|
||||
* - Target
|
||||
- Description
|
||||
* - :command:`make [all]`
|
||||
- build everything
|
||||
* - :command:`make check`
|
||||
- run the test suite
|
||||
* - :command:`make install`
|
||||
- build and install everything
|
||||
* - :command:`make clean`
|
||||
- remove object files, executables and cruft
|
||||
* - :command:`make distclean`
|
||||
- remove everything that can be recreated
|
||||
|
||||
Note that after running :command:`make distclean` the
|
||||
:program:`configure` script must be run again to create the :file:`Makefile`
|
||||
and other make-related files.
|
||||
|
||||
Build Trees
|
||||
^^^^^^^^^^^
|
||||
|
||||
There are two schemes for configuring and building the software. If
|
||||
you intend to build the software for only one target system, you
|
||||
can configure the software so that it is built in the same
|
||||
directories as the source code.
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
% gzip -dc tiff-4.0.5.tar.gz | tar -xf -
|
||||
% cd ./tiff-4.0.5
|
||||
% ./configure
|
||||
% make
|
||||
% make check
|
||||
% make install
|
||||
|
||||
Otherwise, you can configure a build tree that is parallel to
|
||||
the source tree hierarchy (or in some completely different place)
|
||||
but which contains only configured files and files created during
|
||||
the build procedure.
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
% gzip -dc tiff-4.0.5.tar.gz | tar -xf -
|
||||
% mkdir tiff-4.0.5-build
|
||||
% cd ./tiff-4.0.5-build
|
||||
% ../tiff-4.0.5/configure
|
||||
% make
|
||||
% make check
|
||||
% make install
|
||||
|
||||
This second scheme is useful for:
|
||||
|
||||
* building multiple targets from a single source tree
|
||||
* building from a read-only source tree
|
||||
* sharing the source files via a network, but building on
|
||||
multiple systems
|
||||
|
||||
Configuration Options
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The configuration process is critical to the proper compilation,
|
||||
installation, and operation of the software. The configure script
|
||||
runs a series of tests to decide whether or not the target system
|
||||
supports required functionality and, if it does not, whether it can
|
||||
emulate or workaround the missing functions. This procedure is
|
||||
fairly complicated and, due to the nonstandard nature of most UNIX
|
||||
systems, prone to error. The first time that you configure the
|
||||
software for use you should check the output from the configure
|
||||
script and look for anything that does not make sense for your
|
||||
system.
|
||||
|
||||
A second function of the configure script is to set the default
|
||||
configuration parameters for the software. Of particular note are
|
||||
the directories where the software is to be installed. By default
|
||||
the software is installed in the :file:`/usr/local` hierarchy. To
|
||||
change this behaviour the appropriate parameters can be specified
|
||||
on the command line to configure. Run :command:`./configure --help` to
|
||||
get a full list of possible options. Standard installation related
|
||||
options are shown below.
|
||||
|
||||
Installation directories:
|
||||
|
||||
.. option:: --prefix=PREFIX
|
||||
|
||||
install architecture-independent files in *PREFIX* [:file:`/usr/local`]
|
||||
|
||||
.. option:: --exec-prefix=EPREFIX
|
||||
|
||||
install architecture-dependent files in *EPREFIX* [:file:`PREFIX`]
|
||||
|
||||
By default, :command:`make install` will install all the files in
|
||||
:file:`/usr/local/bin`, :file:`/usr/local/lib` etc. You can specify
|
||||
an installation prefix other than :file:`/usr/local` using :option:`--prefix`,
|
||||
for instance ``--prefix=$HOME``. For better control, use the options below.
|
||||
|
||||
Fine tuning of the installation directories:
|
||||
|
||||
.. option:: --bindir=DIR
|
||||
|
||||
user executables [:file:`EPREFIX/bin`]
|
||||
|
||||
.. option:: --sbindir=DIR
|
||||
|
||||
system admin executables [:file:`EPREFIX/sbin`]
|
||||
|
||||
.. option:: --libexecdir=DIR
|
||||
|
||||
program executables [:file:`EPREFIX/libexec`]
|
||||
|
||||
.. option:: --sysconfdir=DIR
|
||||
|
||||
read-only single-machine data [:file:`PREFIX/etc`]
|
||||
|
||||
.. option:: --sharedstatedir=DIR
|
||||
|
||||
modifiable architecture-independent data [:file:`PREFIX/com`]
|
||||
|
||||
.. option:: --localstatedir=DIR
|
||||
|
||||
modifiable single-machine data [:file:`PREFIX/var`]
|
||||
|
||||
.. option:: --libdir=DIR
|
||||
|
||||
object code libraries [:file:`EPREFIX/lib`]
|
||||
|
||||
.. option:: --includedir=DIR
|
||||
|
||||
C header files [:file:`PREFIX/include`]
|
||||
|
||||
.. option:: --oldincludedir=DIR
|
||||
|
||||
C header files for non-gcc [:file:`/usr/include`]
|
||||
|
||||
.. option:: --datarootdir=DIR
|
||||
|
||||
read-only architecture-independent data root [:file:`PREFIX/share`]
|
||||
|
||||
.. option:: --datadir=DIR
|
||||
|
||||
read-only architecture-independent data [:file:`DATAROOTDIR`]
|
||||
|
||||
.. option:: --localedir=DIR
|
||||
|
||||
locale-dependent data [:file:`DATAROOTDIR/locale`]
|
||||
|
||||
.. option:: --mandir=DIR
|
||||
|
||||
man documentation [:file:`DATAROOTDIR/man`]
|
||||
|
||||
.. option:: --docdir=DIR
|
||||
|
||||
documentation root [:file:`DATAROOTDIR/doc/tiff`]
|
||||
|
||||
.. option:: --htmldir=DIR
|
||||
|
||||
html documentation [:file:`DOCDIR`]
|
||||
|
||||
|
||||
Program names:
|
||||
|
||||
.. option:: --program-prefix=PREFIX
|
||||
|
||||
prepend *PREFIX* to installed program names
|
||||
|
||||
.. option:: --program-suffix=SUFFIX
|
||||
|
||||
append *SUFFIX* to installed program names
|
||||
|
||||
.. option:: --program-transform-name=PROGRAM
|
||||
|
||||
run :command:`sed` *PROGRAM* on installed program names
|
||||
|
||||
Configuring Optional Packages/Support
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The TIFF software comes with several packages that are installed
|
||||
only as needed, or only if specifically configured at the time the
|
||||
configure script is run. Packages can be configured via the
|
||||
:program:`configure` script commandline parameters.
|
||||
|
||||
Static/Shared Objects Support
|
||||
.............................
|
||||
|
||||
.. option:: --enable-shared[=PKGS]
|
||||
|
||||
Build shared libraries [enabled]
|
||||
|
||||
.. option:: --enable-static[=PKGS]
|
||||
|
||||
Build static libraries [enabled]
|
||||
|
||||
These options control whether or not to configure the software
|
||||
to build a shared and static binaries for the TIFF library. Use of
|
||||
shared libraries can significantly reduce the disk space needed for
|
||||
users of the TIFF software. If shared libraries are not used then
|
||||
the code is statically linked into each application that uses it.
|
||||
By default both types of binaries are configured.
|
||||
|
||||
.. option:: --enable-rpath
|
||||
|
||||
Enable runtime linker paths (``-R`` libtool option)
|
||||
|
||||
Add library directories (see other options below) to the TIFF
|
||||
library run-time linker path.
|
||||
|
||||
.. option:: --enable-ld-version-script
|
||||
|
||||
Enable linker version script [yes]
|
||||
|
||||
Add shared library symbol versioning on ELF-based systems (e.g.
|
||||
Linux and FreeBSD) which use the GNU linker. This is needed if
|
||||
several major versions of libtiff might be loaded at once into the
|
||||
same program.
|
||||
|
||||
JPEG Support
|
||||
............
|
||||
|
||||
.. option:: --disable-jpeg
|
||||
|
||||
Disable IJG JPEG library usage (required for JPEG compression, enabled by default)
|
||||
|
||||
.. option:: --with-jpeg-include-dir=DIR
|
||||
|
||||
Location of IJG JPEG library headers
|
||||
|
||||
.. option:: --with-jpeg-lib-dir=DIR
|
||||
|
||||
Location of IJG JPEG library binary)
|
||||
|
||||
The ``JPEG`` package enables support for the handling of
|
||||
TIFF images with JPEG-encoded data. Support for JPEG-encoded data
|
||||
requires the Independent JPEG Group (IJG) ``libjpeg``
|
||||
distribution; this software is available at
|
||||
`<http://www.ijg.org/>`_. The :program:`configure`
|
||||
script automatically tries to search for a working IJG JPEG
|
||||
installation. If it fails to find library, JPEG support will be
|
||||
automatically disabled. If you want specify the exact paths to
|
||||
library binary and headers, use above switches for that.
|
||||
|
||||
ZIP Support
|
||||
...........
|
||||
|
||||
The ``ZIP`` support enables support for the handling of
|
||||
TIFF images with deflate-encoded data. Support for deflate-encoded
|
||||
data requires the freely available ``zlib`` distribution
|
||||
written by Jean-loup Gailly and Mark Adler; this software is
|
||||
available at `<http://www.zlib.org/>`_. Support will be
|
||||
enabled automatically if ``zlib`` is found.
|
||||
|
||||
|
||||
Building the Software on Other Systems
|
||||
--------------------------------------
|
||||
|
||||
This section contains information that might be useful if you are
|
||||
working on a non-UNIX system that is not directly supported. All
|
||||
library-related files described below are located in the
|
||||
:file:`libtiff` directory.
|
||||
|
||||
The library requires two files that are generated
|
||||
*on-the-fly*. The file :file:`tif_fax3sm.c` has the state
|
||||
tables for the Group 3 and Group 4 decoders. This file is generated
|
||||
by the :program:`mkg3states` program on a UNIX system; for
|
||||
example:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
cd libtiff
|
||||
cc -o mkg3states mkg3states.c
|
||||
rm -f tif_fax3sm.c
|
||||
./mkg3states -c const tif_fax3sm.c
|
||||
|
||||
The ``-c`` option can be used to control whether or not the
|
||||
resulting tables are generated with a ``const`` declaration.
|
||||
The ``-s`` option can be used to specify a C storage class for
|
||||
the table declarations. The ``-b`` option can be used to force
|
||||
data values to be explicitly bracketed with ``{}`` (apparently
|
||||
needed for some MS-Windows compilers); otherwise the structures are
|
||||
emitted in as compact a format as possible. Consult the source code
|
||||
for this program if you have questions.
|
||||
|
||||
The second file required to build the library, :file:`version.h`,
|
||||
contains the version information returned by the
|
||||
:c:func:`TIFFGetVersion` routine. This file is built on most systems
|
||||
using the :file:`mkversion` program and the contents of the
|
||||
:file:`VERSION` and :file:`tiff.alpha` files; for example,
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
cd libtiff
|
||||
cc -o mkversion mkversion.c
|
||||
rm -f version.h
|
||||
./mkversion -v ../VERSION -a ../dist/tiff.alpha version.h
|
||||
|
||||
Otherwise, when building the library on a non-UNIX system be
|
||||
sure to consult the files :file:`tiffcomp.h` and :file:`tiffconf.h`.
|
||||
The former contains system compatibility definitions while the
|
||||
latter is provided so that the software configuration can be
|
||||
controlled on systems that do not support the make facility for
|
||||
building the software.
|
||||
|
||||
Systems without a 32-bit compiler may not be able to handle some
|
||||
of the codecs in the library; especially the Group 3 and 4 decoder.
|
||||
If you encounter problems try disabling support for a particular
|
||||
codec; consult the :doc:`internals`.
|
||||
|
||||
Programs in the tools directory are written to assume an ANSI C
|
||||
compilation environment. There may be a few POSIX'isms as well. The
|
||||
code in the :file:`port` directory is provided to emulate routines
|
||||
that may be missing on some systems. On UNIX systems the
|
||||
:program:`configure` script automatically figures out which routines
|
||||
are not present on a system and enables the use of the equivalent
|
||||
emulation routines from the :file:`port` directory. It may be
|
||||
necessary to manually do this work on a non-UNIX system.
|
||||
|
||||
|
||||
Testing the software
|
||||
--------------------
|
||||
|
||||
Assuming you have working versions of :doc:`/tools/tiffgt`, you can now use
|
||||
it to view any of the sample images available for testing, or try
|
||||
:doc:`/tools/tiffinfo` to display the file metadata. See the
|
||||
:doc:`images` section on obtaining the test images. Otherwise, you can
|
||||
do a cursory check of the library with the :doc:`/tools/tiffcp` and
|
||||
:doc:`/tools/tiffcmp` programs. For example,
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
tiffcp -lzw cramps.tif x.tif
|
||||
tiffcmp cramps.tif x.tif
|
||||
|
||||
(:program:`tiffcmp` should be silent if the files compare
|
||||
correctly).
|
||||
|
||||
|
||||
LibTIFF source files
|
||||
--------------------
|
||||
|
||||
The following files make up the core library:
|
||||
|
||||
.. list-table:: Core library source files
|
||||
:widths: 5 15
|
||||
:header-rows: 1
|
||||
|
||||
* - File
|
||||
- Description
|
||||
|
||||
* - :file:`libtiff/tiff.h`
|
||||
- TIFF spec definitions
|
||||
* - :file:`libtiff/tiffconf.h`
|
||||
- non-UNIX configuration definitions
|
||||
* - :file:`libtiff/tiffio.h`
|
||||
- public TIFF library definitions
|
||||
* - :file:`libtiff/tiffiop.h`
|
||||
- private TIFF library definitions
|
||||
* - :file:`libtiff/t4.h`
|
||||
- CCITT Group 3/4 code tables+definitions
|
||||
* - :file:`libtiff/tif_dir.h`
|
||||
- private defs for TIFF directory handling
|
||||
* - :file:`libtiff/tif_fax3.h`
|
||||
- CCITT Group 3/4-related definitions
|
||||
* - :file:`libtiff/tif_predict.h`
|
||||
- private defs for Predictor tag support
|
||||
* - :file:`libtiff/tiffvers.h`
|
||||
- version string
|
||||
* - :file:`libtiff/uvcode.h`
|
||||
- LogL/LogLuv codec-specific definitions
|
||||
* - :file:`libtiff/tif_aux.c`
|
||||
- auxiliary directory-related functions
|
||||
* - :file:`libtiff/tif_close.c`
|
||||
- close an open TIFF file
|
||||
* - :file:`libtiff/tif_codec.c`
|
||||
- configuration table of builtin codecs
|
||||
* - :file:`libtiff/tif_color.c`
|
||||
- colorspace transforms
|
||||
* - :file:`libtiff/tif_compress.c`
|
||||
- compression scheme support
|
||||
* - :file:`libtiff/tif_dir.c`
|
||||
- directory tag interface code
|
||||
* - :file:`libtiff/tif_dirinfo.c`
|
||||
- directory known tag support code
|
||||
* - :file:`libtiff/tif_dirread.c`
|
||||
- directory reading code
|
||||
* - :file:`libtiff/tif_dirwrite.c`
|
||||
- directory writing code
|
||||
* - :file:`libtiff/tif_dumpmode.c`
|
||||
- "no" compression codec
|
||||
* - :file:`libtiff/tif_error.c`
|
||||
- library error handler
|
||||
* - :file:`libtiff/tif_fax3.c`
|
||||
- CCITT Group 3 and 4 codec
|
||||
* - :file:`libtiff/tif_fax3sm.c`
|
||||
- G3/G4 state tables (generated by mkg3states)
|
||||
* - :file:`libtiff/tif_flush.c`
|
||||
- i/o and directory state flushing
|
||||
* - :file:`libtiff/tif_getimage.c`
|
||||
- :doc:`/functions/TIFFRGBAImage` support
|
||||
* - :file:`libtiff/tif_jbig.c`
|
||||
- JBIG codec
|
||||
* - :file:`libtiff/tif_jpeg.c`
|
||||
- JPEG codec (interface to the IJG distribution)
|
||||
* - :file:`libtiff/tif_jpeg_12.c`
|
||||
- 12-bit JPEG codec (interface to the IJG distribution)
|
||||
* - :file:`libtiff/tif_lerc.c`
|
||||
- LERC codec
|
||||
* - :file:`libtiff/tif_luv.c`
|
||||
- SGI LogL/LogLuv codec
|
||||
* - :file:`libtiff/tif_lzma.c`
|
||||
- LZMA codec
|
||||
* - :file:`libtiff/tif_lzw.c`
|
||||
- LZW codec
|
||||
* - :file:`libtiff/tif_next.c`
|
||||
- NeXT 2-bit scheme codec (decoding only)
|
||||
* - :file:`libtiff/tif_ojpeg.c`
|
||||
- Old JPEG codec (obsolete, decoding only)
|
||||
* - :file:`libtiff/tif_open.c`
|
||||
- open and simply query code
|
||||
* - :file:`libtiff/tif_packbits.c`
|
||||
- Packbits codec
|
||||
* - :file:`libtiff/tif_pixarlog.c`
|
||||
- Pixar codec
|
||||
* - :file:`libtiff/tif_predict.c`
|
||||
- Predictor tag support
|
||||
* - :file:`libtiff/tif_print.c`
|
||||
- directory printing support
|
||||
* - :file:`libtiff/tif_read.c`
|
||||
- image data reading support
|
||||
* - :file:`libtiff/tif_strip.c`
|
||||
- some strip-related code
|
||||
* - :file:`libtiff/tif_swab.c`
|
||||
- byte and bit swapping support
|
||||
* - :file:`libtiff/tif_thunder.c`
|
||||
- Thunderscan codec (decoding only)
|
||||
* - :file:`libtiff/tif_tile.c`
|
||||
- some tile-related code
|
||||
* - :file:`libtiff/tif_unix.c`
|
||||
- UNIX-related OS support
|
||||
* - :file:`libtiff/tif_version.c`
|
||||
- library version support
|
||||
* - :file:`libtiff/tif_warning.c`
|
||||
- library warning handler
|
||||
* - :file:`libtiff/tif_win32.c`
|
||||
- Win32 (Windows)-related OS support
|
||||
* - :file:`libtiff/tif_write.c`
|
||||
- image data writing support
|
||||
* - :file:`libtiff/tif_zip.c`
|
||||
- Deflate codec
|
||||
* - :file:`libtiff/tif_zstd.c`
|
||||
- ZSTD codec
|
||||
|
||||
* - :file:`libtiff/mkg3states.c`
|
||||
- program to generate G3/G4 decoder state tables
|
||||
* - :file:`libtiff/mkspans.c`
|
||||
- program to generate black-white span tables
|
||||
+179
@@ -0,0 +1,179 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Configuration file for the Sphinx documentation builder.
|
||||
#
|
||||
# This file only contains a selection of the most common options. For a full
|
||||
# list see the documentation:
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
||||
|
||||
# -- Path setup --------------------------------------------------------------
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#
|
||||
# import os
|
||||
# import sys
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# Substitutions from external build system.
|
||||
srcdir = None
|
||||
builddir = None
|
||||
ext_source_branch = None
|
||||
ext_source_user = None
|
||||
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = 'LibTIFF'
|
||||
copyright = '1988-2022, LibTIFF contributors'
|
||||
author = 'LibTIFF contributors'
|
||||
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = 'UNDEFINED'
|
||||
version = 'UNDEFINED'
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.extlinks'
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This pattern also affects html_static_path and html_extra_path.
|
||||
exclude_patterns = []
|
||||
|
||||
extlinks = {
|
||||
# GitLab links
|
||||
'issue' : ('https://gitlab.com/libtiff/libtiff/-/issues/%s', 'issue #%s'),
|
||||
'merge' : ('https://gitlab.com/libtiff/libtiff/-/merge_requests/%s', 'merge request #%s'),
|
||||
'commit' : ('https://gitlab.com/libtiff/libtiff/-/commit/%s', 'commit %s'),
|
||||
'branch' : ('https://gitlab.com/libtiff/libtiff/-/tree/%s', 'branch %s'),
|
||||
'tag' : ('https://gitlab.com/libtiff/libtiff/-/tags/%s', 'tag %s'),
|
||||
|
||||
# Old Bugzilla
|
||||
'bugzilla' : ('http://bugzilla.maptools.org/show_bug.cgi?id=%s', 'MapTools bugzilla #%s'),
|
||||
'bugzilla-rs' : ('http://bugzilla.remotesensing.org/show_bug.cgi?id=%s', 'Remote Sensing bugzilla #%s [no longer available]'),
|
||||
|
||||
# GDAL
|
||||
'gdal-trac' : ('http://trac.osgeo.org/gdal/ticket/%s', 'GDAL trac #%s'),
|
||||
'oss-fuzz' : ('https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=%s', 'OSS-Fuzz #%s'),
|
||||
|
||||
# Security
|
||||
'cve' : ('https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-%s', 'CVE-%s'),
|
||||
}
|
||||
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
html_theme = 'sphinxdoc'
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
html_extra_path = []
|
||||
|
||||
# -- Options for manual page output --------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('functions/libtiff', 'libtiff', 'introduction to libtiff, a library for reading and writing TIFF files', author, '3tiff'),
|
||||
|
||||
('tools/fax2ps', 'fax2ps', 'convert a TIFF facsimile to compressed PostScript™', author, 1),
|
||||
('tools/fax2tiff', 'fax2tiff', 'create a TIFF Class F fax file from raw fax data', author, 1),
|
||||
('tools/pal2rgb', 'pal2rgb', 'convert a palette color TIFF image to a full color image', author, 1),
|
||||
('tools/ppm2tiff', 'ppm2tiff', 'create a TIFF file from PPM, PGM and PBM image files', author, 1),
|
||||
('tools/raw2tiff', 'raw2tiff', 'create a TIFF file from a raw data file', author, 1),
|
||||
('tools/rgb2ycbcr', 'rgb2ycbcr', 'convert non-YCbCr TIFF images to a YCbCr TIFF image', author, 1),
|
||||
('tools/thumbnail', 'thumbnail', 'create a TIFF file with thumbnail images', author, 1),
|
||||
('tools/tiff2bw', 'tiff2bw', 'convert a color TIFF image to greyscale', author, 1),
|
||||
('tools/tiff2pdf', 'tiff2pdf', 'convert a TIFF image to a PDF document', author, 1),
|
||||
('tools/tiff2ps', 'tiff2ps', 'convert TIFF image to PostScript™', author, 1),
|
||||
('tools/tiff2rgba', 'tiff2rgba', 'convert a TIFF image to RGBA color space', author, 1),
|
||||
('tools/tiffcmp', 'tiffcmp', 'compare two TIFF files', author, 1),
|
||||
('tools/tiffcp', 'tiffcp', 'copy (and possibly convert) a TIFF file', author, 1),
|
||||
('tools/tiffcrop', 'tiffcrop', 'select, copy, crop, convert, extract, and/or process one or more TIFF files', author, 1),
|
||||
('tools/tiffdither', 'tiffdither', 'convert a greyscale TIFF image to bilevel using dithering', author, 1),
|
||||
('tools/tiffdump', 'tiffdump', 'print verbatim information about TIFF files', author, 1),
|
||||
('tools/tiffgt', 'tiffgt', 'display an image stored in a TIFF file (Silicon Graphics version)', author, 1),
|
||||
('tools/tiffinfo', 'tiffinfo', 'print information about TIFF files', author, 1),
|
||||
('tools/tiffmedian', 'tiffmedian', 'apply the median cut algorithm to data in a TIFF file', author, 1),
|
||||
('tools/tiffset', 'tiffset', 'set or unset a field in a TIFF header', author, 1),
|
||||
('tools/tiffsplit', 'tiffsplit', 'split a multi-image TIFF into single-image TIFF files', author, 1),
|
||||
|
||||
('functions/_TIFFauxiliary', '_TIFFauxiliary', 'auxiliary functions', author, '3tiff'),
|
||||
('functions/_TIFFRewriteField', '_TIFFRewriteField', 'rewrite a field in the directory on disk', author, '3tiff'),
|
||||
('functions/TIFFAccessTagMethods', 'TIFFAccessTagMethods', 'provides read/write access to the TIFFTagMethods', author, '3tiff'),
|
||||
('functions/TIFFbuffer', 'TIFFbuffer', 'I/O buffering control routines', author, '3tiff'),
|
||||
('functions/TIFFClientInfo', 'TIFFClientInfo', 'provides a method to hand over user defined data from one routine to another', author, '3tiff'),
|
||||
('functions/TIFFClose', 'TIFFClose', 'close a previously opened TIFF file', author, '3tiff'),
|
||||
('functions/TIFFcodec', 'TIFFcodec', 'codec-related utility routines', author, '3tiff'),
|
||||
('functions/TIFFcolor', 'TIFFcolor', 'color conversion routines', author, '3tiff'),
|
||||
('functions/TIFFCreateDirectory', 'TIFFCreateDirectory', 'routines to create a directory and retrieve information about directories', author, '3tiff'),
|
||||
('functions/TIFFCustomDirectory', 'TIFFCustomDirectory', 'routines to create a custom directory', author, '3tiff'),
|
||||
('functions/TIFFCustomTagList', 'TIFFCustomTagList', 'returns information about the custom tag list', author, '3tiff'),
|
||||
('functions/TIFFDataWidth', 'TIFFDataWidth', 'get the size of TIFF data types', author, '3tiff'),
|
||||
('functions/TIFFDeferStrileArrayWriting', 'TIFFDeferStrileArrayWriting', 'defer strile array writing', author, '3tiff'),
|
||||
('functions/TIFFError', 'TIFFError', 'library error handling interface', author, '3tiff'),
|
||||
('functions/TIFFFieldDataType', 'TIFFFieldDataType', 'get TIFF data type from field information', author, '3tiff'),
|
||||
('functions/TIFFFieldName', 'TIFFFieldName', 'get TIFF field name from field information', author, '3tiff'),
|
||||
('functions/TIFFFieldPassCount', 'TIFFFieldPassCount', 'get whether to pass a count to TIFFGetField/TIFFSetField', author, '3tiff'),
|
||||
('functions/TIFFFieldQuery', 'TIFFFieldQuery', 'routines to query TIFF field information', author, '3tiff'),
|
||||
('functions/TIFFFieldReadCount', 'TIFFFieldReadCount', 'get number of values to be read from field', author, '3tiff'),
|
||||
('functions/TIFFFieldTag', 'TIFFFieldTag', 'get TIFF field tag value from field information', author, '3tiff'),
|
||||
('functions/TIFFFieldWriteCount', 'TIFFFieldWriteCount', 'get number of values to be written to field', author, '3tiff'),
|
||||
('functions/TIFFFlush', 'TIFFFlush', 'flush pending writes to an open TIFF file', author, '3tiff'),
|
||||
('functions/TIFFGetField', 'TIFFGetField', 'get the value(s) of a tag in an open TIFF file', author, '3tiff'),
|
||||
('functions/TIFFmemory', 'TIFFmemory', 'memory management-related functions for use with TIFF files', author, '3tiff'),
|
||||
('functions/TIFFMergeFieldInfo', 'TIFFMergeFieldInfo', 'add application-defined TIFF tags to the list of known libtiff tags', author, '3tiff'),
|
||||
('functions/TIFFOpen', 'TIFFOpen', 'open a TIFF file for reading or writing', author, '3tiff'),
|
||||
('functions/TIFFPrintDirectory', 'TIFFPrintDirectory', 'print a description of a TIFF directory', author, '3tiff'),
|
||||
('functions/TIFFProcFunctions', 'TIFFProcFunctions', 'set TIFF processing functions', author, '3tiff'),
|
||||
('functions/TIFFquery', 'TIFFquery', 'query routines', author, '3tiff'),
|
||||
('functions/TIFFReadDirectory', 'TIFFReadDirectory', 'get the contents of the next directory in an open TIFF file', author, '3tiff'),
|
||||
('functions/TIFFReadEncodedStrip', 'TIFFReadEncodedStrip', 'read and decode a strip of data from an open TIFF file', author, '3tiff'),
|
||||
('functions/TIFFReadEncodedTile', 'TIFFReadEncodedTile', 'read and decode a tile of data from an open TIFF file', author, '3tiff'),
|
||||
('functions/TIFFReadFromUserBuffer', 'TIFFReadFromUserBuffer', 'decode data using an user defined buffer', author, '3tiff'),
|
||||
('functions/TIFFReadRawStrip', 'TIFFReadRawStrip', 'return the undecoded contents of a strip of data from an open TIFF file', author, '3tiff'),
|
||||
('functions/TIFFReadRawTile', 'TIFFReadRawTile', 'return an undecoded tile of data from an open TIFF file', author, '3tiff'),
|
||||
('functions/TIFFReadRGBAImage', 'TIFFReadRGBAImage', 'read and decode an image into a fixed-format raster', author, '3tiff'),
|
||||
('functions/TIFFReadRGBAStrip', 'TIFFReadRGBAStrip', 'read and decode an image strip into a fixed-format raster', author, '3tiff'),
|
||||
('functions/TIFFReadRGBATile', 'TIFFReadRGBATile', 'read and decode an image tile into a fixed-format raster', author, '3tiff'),
|
||||
('functions/TIFFReadScanline', 'TIFFReadScanline', 'read and decode a scanline of data from an open TIFF file', author, '3tiff'),
|
||||
('functions/TIFFReadTile', 'TIFFReadTile', 'read and decode a tile of data from an open TIFF file', author, '3tiff'),
|
||||
('functions/TIFFRGBAImage', 'TIFFRGBAImage', 'read and decode an image into a raster', author, '3tiff'),
|
||||
('functions/TIFFSetDirectory', 'TIFFSetDirectory', 'set the current directory for an open TIFF file', author, '3tiff'),
|
||||
('functions/TIFFSetField', 'TIFFSetField', 'set the value(s) of a tag in a TIFF file open for writing', author, '3tiff'),
|
||||
('functions/TIFFSetTagExtender', 'TIFFSetTagExtender', 'register the merge function for user defined tags as an extender callback with libtiff', author, '3tiff'),
|
||||
('functions/TIFFsize', 'TIFFsize', 'return the size of various items associated with an open TIFF file', author, '3tiff'),
|
||||
('functions/TIFFStrileQuery', 'TIFFStrileQuery', 'get strile byte count and offset', author, '3tiff'),
|
||||
('functions/TIFFstrip', 'TIFFstrip', 'strip-related utility routines', author, '3tiff'),
|
||||
('functions/TIFFswab', 'TIFFswab', 'byte- and bit-swapping routines', author, '3tiff'),
|
||||
('functions/TIFFtile', 'TIFFtile', 'tile-related utility routines', author, '3tiff'),
|
||||
('functions/TIFFWarning', 'TIFFWarning', 'library warning interface', author, '3tiff'),
|
||||
('functions/TIFFWriteDirectory', 'TIFFWriteDirectory', 'write the current directory in an open TIFF file', author, '3tiff'),
|
||||
('functions/TIFFWriteEncodedStrip', 'TIFFWriteEncodedStrip', 'compress and write a strip of data to an open TIFF file', author, '3tiff'),
|
||||
('functions/TIFFWriteEncodedTile', 'TIFFWriteEncodedTile', 'compress and write a tile of data to an open TIFF file', author, '3tiff'),
|
||||
('functions/TIFFWriteRawStrip', 'TIFFWriteRawStrip', 'write a strip of raw data to an open TIFF file', author, '3tiff'),
|
||||
('functions/TIFFWriteRawTile', 'TIFFWriteRawTile', 'write a tile of raw data to an open TIFF file', author, '3tiff'),
|
||||
('functions/TIFFWriteScanline', 'TIFFWriteScanline', 'write a scanline to an open TIFF file', author, '3tiff'),
|
||||
('functions/TIFFWriteTile', 'TIFFWriteTile', 'encode and write a tile of data to an open TIFF file', author, '3tiff'),
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
man_show_urls = True
|
||||
|
||||
smartquotes = False
|
||||
@@ -0,0 +1,88 @@
|
||||
Contributed TIFF Software
|
||||
=========================
|
||||
|
||||
.. image:: images/smallliz.jpg
|
||||
:width: 108
|
||||
:alt: smallliz
|
||||
|
||||
The :file:`contrib` directory has contributed software that
|
||||
uses the TIFF library or which is associated with the library
|
||||
(typically glue and guidance for ports to non-UNIX platforms, or tools that
|
||||
aren't directly TIFF related).
|
||||
|
||||
.. list-table:: Contributed software
|
||||
:widths: 5 20
|
||||
:header-rows: 1
|
||||
|
||||
* - Location
|
||||
- Description
|
||||
|
||||
* - :file:`contrib/dbs`
|
||||
- various tools from Dan & Chris Sears, including a simple X-based viewer
|
||||
|
||||
* - :file:`contrib/ras`
|
||||
- two programs by Patrick Naughton for converting
|
||||
between Sun rasterfile format and TIFF (these
|
||||
require :file:`libpixrect.a`, as opposed to the one in
|
||||
tools that doesn't)
|
||||
|
||||
* - :file:`contrib/mac-mpw`
|
||||
|
||||
:file:`contrib/mac-cw`
|
||||
- scripts and files from Niles Ritter for building
|
||||
the library and tools under Macintosh/MPW C and
|
||||
code warrior.
|
||||
|
||||
* - :file:`contrib/acorn`
|
||||
- scripts and files from Peter Greenham for building
|
||||
the library and tools on an Acorn RISC OS system.
|
||||
|
||||
* - :file:`contrib/win32`
|
||||
- scripts and files from Scott Wagner for building
|
||||
the library under Windows NT and Windows 95. (The makefile.vc in the
|
||||
libtiff/libtiff directory may be sufficient for most users.)
|
||||
|
||||
* - :file:`contrib/win_dib`
|
||||
- two separate implementations of TIFF to DIB code suitable for any Win32
|
||||
platform. Contributed by Mark James, and Philippe Tenenhaus.
|
||||
|
||||
* - :file:`contrib/ojpeg`
|
||||
- Patch for IJG JPEG library related to support for some Old JPEG in TIFF files.
|
||||
Contributed by Scott Marovich.
|
||||
|
||||
* - :file:`contrib/dosdjgpp`
|
||||
- scripts and files from Alexander Lehmann for building
|
||||
the library under MSDOS with the DJGPP v2 compiler.
|
||||
|
||||
* - :file:`contrib/tags`
|
||||
- scripts and files from Niles Ritter for adding private
|
||||
tag support at runtime, without changing libtiff.
|
||||
|
||||
* - :file:`contrib/mfs`
|
||||
- code from Mike Johnson to read+write images in memory
|
||||
without modifying the library
|
||||
|
||||
* - :file:`contrib/pds`
|
||||
- various routines from Conrad Poelman; a TIFF image iterator and
|
||||
code to support "private sub-directories"
|
||||
|
||||
* - :file:`contrib/iptcutil`
|
||||
- A utility by `Bill Radcliffe <billr@corbis.com>`_ to
|
||||
convert an extracted IPTC Newsphoto caption from a binary blob to
|
||||
ASCII text, and vice versa. IPTC binary blobs can be extracted from
|
||||
images via the `ImageMagick <http://www.ImageMagick.org/>`_ convert(1)
|
||||
utility.
|
||||
|
||||
* - :file:`contrib/addtiffo`
|
||||
- A utility (and supporting subroutine) for building
|
||||
one or more reduce resolution
|
||||
overviews to an existing TIFF file. Supplied by
|
||||
`Frank Warmerdam <http://pobox.com/~warmerdam>`_.
|
||||
|
||||
* - :file:`contrib/stream`
|
||||
- A class (TiffStream) for accessing TIFF files through a C++ stream
|
||||
interface. Supplied by `Avi Bleiweiss <avi@shutterfly.com>`_.
|
||||
|
||||
|
||||
Questions regarding these packages are usually best directed toward
|
||||
their authors.
|
||||
@@ -0,0 +1,66 @@
|
||||
TIFF Functions Overview
|
||||
=======================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:titlesonly:
|
||||
|
||||
functions/libtiff
|
||||
functions/TIFFAccessTagMethods
|
||||
functions/TIFFbuffer
|
||||
functions/TIFFClientInfo
|
||||
functions/TIFFClose
|
||||
functions/TIFFcodec
|
||||
functions/TIFFcolor
|
||||
functions/TIFFCreateDirectory
|
||||
functions/TIFFCustomDirectory
|
||||
functions/TIFFCustomTagList
|
||||
functions/TIFFDataWidth
|
||||
functions/TIFFDeferStrileArrayWriting
|
||||
functions/TIFFError
|
||||
functions/TIFFFieldDataType
|
||||
functions/TIFFFieldName
|
||||
functions/TIFFFieldPassCount
|
||||
functions/TIFFFieldQuery
|
||||
functions/TIFFFieldReadCount
|
||||
functions/TIFFFieldTag
|
||||
functions/TIFFFieldWriteCount
|
||||
functions/TIFFFlush
|
||||
functions/TIFFGetField
|
||||
functions/TIFFmemory
|
||||
functions/TIFFMergeFieldInfo
|
||||
functions/TIFFOpen
|
||||
functions/TIFFOpenOptions
|
||||
functions/TIFFPrintDirectory
|
||||
functions/TIFFProcFunctions
|
||||
functions/TIFFquery
|
||||
functions/TIFFReadDirectory
|
||||
functions/TIFFReadEncodedStrip
|
||||
functions/TIFFReadEncodedTile
|
||||
functions/TIFFReadFromUserBuffer
|
||||
functions/TIFFReadRawStrip
|
||||
functions/TIFFReadRawTile
|
||||
functions/TIFFReadRGBAImage
|
||||
functions/TIFFReadRGBAStrip
|
||||
functions/TIFFReadRGBATile
|
||||
functions/TIFFReadScanline
|
||||
functions/TIFFReadTile
|
||||
functions/TIFFRGBAImage
|
||||
functions/TIFFSetDirectory
|
||||
functions/TIFFSetField
|
||||
functions/TIFFSetTagExtender
|
||||
functions/TIFFsize
|
||||
functions/TIFFStrileQuery
|
||||
functions/TIFFstrip
|
||||
functions/TIFFswab
|
||||
functions/TIFFtile
|
||||
functions/TIFFWarning
|
||||
functions/TIFFWriteDirectory
|
||||
functions/TIFFWriteEncodedStrip
|
||||
functions/TIFFWriteEncodedTile
|
||||
functions/TIFFWriteRawStrip
|
||||
functions/TIFFWriteRawTile
|
||||
functions/TIFFWriteScanline
|
||||
functions/TIFFWriteTile
|
||||
functions/_TIFFauxiliary
|
||||
functions/_TIFFRewriteField
|
||||
@@ -0,0 +1,30 @@
|
||||
TIFFAccessTagMethods
|
||||
====================
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. highlight:: c
|
||||
|
||||
::
|
||||
|
||||
#include <tiffio.h>
|
||||
|
||||
.. c:function:: TIFFTagMethods *TIFFAccessTagMethods(TIFF* tif)
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
This provides read/write access to the TIFFTagMethods within the TIFF
|
||||
structure to application code without giving access to the private TIFF
|
||||
structure.
|
||||
|
||||
Diagnostics
|
||||
-----------
|
||||
|
||||
None
|
||||
|
||||
See also
|
||||
--------
|
||||
|
||||
:doc:`libtiff` (3tiff)
|
||||
@@ -0,0 +1,40 @@
|
||||
TIFFClientInfo
|
||||
==============
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. highlight:: c
|
||||
|
||||
::
|
||||
|
||||
#include <tiffio.h>
|
||||
|
||||
.. c:function:: void *TIFFGetClientInfo(TIFF* tif, const char *name)
|
||||
|
||||
.. c:function:: void TIFFSetClientInfo(TIFF* tif, void *data, const char *name)
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
.. TODO: Check explanation of clientinfo linked list intention and usage.
|
||||
|
||||
The *clientinfo* linked list provides a method to hand over user defined
|
||||
data from one routine to another via the internal ``tif`` storage of the
|
||||
``libtiff`` library.
|
||||
|
||||
:c:func:`TIFFGetClientInfo` returns a pointer to the data of the named entry
|
||||
in the clientinfo-list. If the *name* is not found ``NULL`` is returned.
|
||||
|
||||
:c:func:`TIFFSetClientInfo` adds or replaces an entry in the clientinfo-list
|
||||
with the *name* and the pointer to the *data* provided by the caller.
|
||||
|
||||
Diagnostics
|
||||
-----------
|
||||
|
||||
None.
|
||||
|
||||
See also
|
||||
--------
|
||||
|
||||
:doc:`libtiff` (3tiff),
|
||||
@@ -0,0 +1,51 @@
|
||||
TIFFClose
|
||||
==========
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. highlight:: c
|
||||
|
||||
::
|
||||
|
||||
#include <tiffio.h>
|
||||
|
||||
.. c:function:: void TIFFClose(TIFF* tif)
|
||||
|
||||
.. c:function:: void TIFFCleanup(TIFF* tif)
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
:c:func:`TIFFClose` closes a file that was previously opened with
|
||||
:c:func:`TIFFOpen`. Any buffered data are flushed to the file, including
|
||||
the contents of the current directory (if modified); and all resources
|
||||
are reclaimed. :c:func:`TIFFClose` calls :c:func:`TIFFCleanup` and then
|
||||
the associated function to close the file handle.
|
||||
|
||||
:c:func:`TIFFCleanup` is an auxiliary function to free the TIFF structure.
|
||||
The given structure will be completely freed, so you should save opened file
|
||||
handle and pointer to the close procedure in external variables before
|
||||
calling :c:func:`TIFFCleanup`, if you will need these ones to close the file.
|
||||
:c:func:`TIFFCleanup` calls :c:func:`TIFFFlush`, which stores all pending data
|
||||
in the file.
|
||||
|
||||
.. note::
|
||||
Both functions have no return value.
|
||||
If you want to check whether the data has been successfully written
|
||||
to the file, you can call :c:func:`TIFFFlush`, which has a return value,
|
||||
before :c:func:`TIFFClose`.
|
||||
|
||||
|
||||
Diagnostics
|
||||
-----------
|
||||
|
||||
All error messages are directed to the :c:func:`TIFFErrorExtR` routine.
|
||||
Likewise, warning messages are directed to the :c:func:`TIFFWarningExtR` routine.
|
||||
|
||||
See also
|
||||
--------
|
||||
|
||||
:doc:`libtiff` (3tiff),
|
||||
:doc:`TIFFOpen` (3tiff),
|
||||
:doc:`TIFFError` (3tiff)
|
||||
@@ -0,0 +1,83 @@
|
||||
TIFFCreateDirectory
|
||||
===================
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. highlight:: c
|
||||
|
||||
::
|
||||
|
||||
#include <tiffio.h>
|
||||
|
||||
.. c:function:: int TIFFCreateDirectory(TIFF* tif)
|
||||
|
||||
.. c:function:: int TIFFFreeDirectory(TIFF* tif)
|
||||
|
||||
.. c:function:: int TIFFUnlinkDirectory(TIFF* tif, tdir_t dirn)
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
The following routines create or release a directory.
|
||||
|
||||
:c:func:`TIFFCreateDirectory` setup for a directory in a open TIFF file.
|
||||
The newly created directory will not exist on the file till
|
||||
:c:func:`TIFFWriteDirectory`, :c:func:`TIFFCheckpointDirectory`,
|
||||
:c:func:`TIFFFlush` or :c:func:`TIFFClose` is called.
|
||||
:c:func:`TIFFWriteDirectory` also creates a new directory,
|
||||
frees the ``*tif`` structure and sets up a new one.
|
||||
|
||||
:c:func:`TIFFFreeDirectory` releases allocated storage associated with a
|
||||
directory, especially custom-fields.
|
||||
However, the main part of the directory is not touched. Routine
|
||||
:c:func:`TIFFCleanup` calls :c:func:`TIFFFreeDirectory` to release
|
||||
the directory part of the `tif` structure.
|
||||
|
||||
:c:func:`TIFFUnlinkDirectory` unlink the specified directory from the
|
||||
directory chain.
|
||||
The parameter *dirn* specifies the subfile/directory
|
||||
as an integer number, with the first directory numbered one (1).
|
||||
This is different to :c:func:`TIFFSetDirectory` or :c:func:`TIFFCurrentDirectory` where the first
|
||||
directory starts with zero (0).
|
||||
|
||||
Directory query functions :c:func:`TIFFCurrentDirectory`,
|
||||
:c:func:`TIFFCurrentDirOffset`, :c:func:`TIFFLastDirectory` and
|
||||
:c:func:`TIFFNumberOfDirectories` retrieve information about directories
|
||||
in an open TIFF file. Be aware that until a directory is
|
||||
not written to file AND read back, the query functions won't retrieve
|
||||
the correct information!
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
Be aware:
|
||||
|
||||
- that until a directory is not written to file AND read back, the
|
||||
query functions won't retrieve the correct information!
|
||||
- that the newly created directory will not exist on the file till
|
||||
:c:func:`TIFFWriteDirectory`, :c:func:`TIFFCheckpointDirectory`,
|
||||
:c:func:`TIFFFlush` or :c:func:`TIFFClose` has been called.
|
||||
- that :c:func:`TIFFCreateDirectory` and :c:func:`TIFFWriteDirectory`
|
||||
create a new directory, free the ``*tif`` structure and set up a new one.
|
||||
- that unlike :c:func:`TIFFWriteDirectory`, :c:func:`TIFFCheckpointDirectory`
|
||||
does not free up the directory data structures in memory.
|
||||
|
||||
After ``libtiff`` version 4.6.0 :c:func:`TIFFCreateDirectory` also releases
|
||||
the directory part of the `tif` structure by calling :c:func:`TIFFFreeDirectory`,
|
||||
which should have been called by the user application before creating a new directory.
|
||||
|
||||
Diagnostics
|
||||
-----------
|
||||
|
||||
All error messages are directed to the :c:func:`TIFFErrorExtR` routine.
|
||||
Likewise, warning messages are directed to the :c:func:`TIFFWarningExtR` routine.
|
||||
|
||||
See also
|
||||
--------
|
||||
|
||||
:doc:`libtiff` (3tiff),
|
||||
:doc:`TIFFCustomDirectory` (3tiff),
|
||||
:doc:`TIFFquery` (3tiff),
|
||||
:doc:`TIFFSetDirectory` (3tiff),
|
||||
:doc:`TIFFWriteDirectory` (3tiff)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user