author | Claus Gittinger <cg@exept.de> |
Fri, 25 Aug 2017 00:53:54 +0200 | |
changeset 3975 | 1315fd14851b |
parent 3974 | b4f7c8442dd8 |
child 3976 | 5eda7dd4846b |
permissions | -rw-r--r-- |
0 | 1 |
" |
6 | 2 |
COPYRIGHT (c) 1991 by Claus Gittinger |
28 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
1571 | 12 |
"{ Package: 'stx:libview2' }" |
13 |
||
3552 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
0 | 16 |
ImageReader subclass:#TIFFReader |
192 | 17 |
instanceVariableNames:'planarConfiguration subFileType stripOffsets rowsPerStrip |
159
327da5085900
fixed saving of 24bit RGB images (forgot samplesPerPixel-TAG)
Claus Gittinger <cg@exept.de>
parents:
135
diff
changeset
|
18 |
fillOrder compression group3options predictor stripByteCounts |
327da5085900
fixed saving of 24bit RGB images (forgot samplesPerPixel-TAG)
Claus Gittinger <cg@exept.de>
parents:
135
diff
changeset
|
19 |
currentOffset stripOffsetsPos stripByteCountsPos bitsPerSamplePos |
3975 | 20 |
colorMapPos orientation isBigTiff' |
192 | 21 |
classVariableNames:'' |
22 |
poolDictionaries:'' |
|
1745
4fa0fad2a463
code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
23 |
category:'Graphics-Images-Readers' |
0 | 24 |
! |
25 |
||
3693 | 26 |
Dictionary subclass:#TIFFMetaData |
27 |
instanceVariableNames:'' |
|
28 |
classVariableNames:'' |
|
29 |
poolDictionaries:'' |
|
30 |
privateIn:TIFFReader |
|
31 |
! |
|
32 |
||
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
33 |
!TIFFReader class methodsFor:'documentation'! |
0 | 34 |
|
21 | 35 |
copyright |
36 |
" |
|
37 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
28 | 38 |
All Rights Reserved |
21 | 39 |
|
40 |
This software is furnished under a license and may be used |
|
41 |
only in accordance with the terms of that license and with the |
|
42 |
inclusion of the above copyright notice. This software may not |
|
43 |
be provided or otherwise made available to, or used by, any |
|
44 |
other person. No title to or ownership of the software is |
|
45 |
hereby transferred. |
|
46 |
" |
|
47 |
! |
|
48 |
||
0 | 49 |
documentation |
50 |
" |
|
21 | 51 |
This class knows how to read TIFF files and how to |
52 |
write uncompressed TIFF files. |
|
14 | 53 |
|
1826 | 54 |
Implemented & Missing Features: |
14 | 55 |
|
1826 | 56 |
- Only single image files are supported. |
57 |
- Not all formats are implemented, and of those that are, not all are tested. |
|
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
58 |
It should read with most rgb, palette, mono and greyscale images, |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
59 |
although the alpha channel is currently not supported and ignored. |
1826 | 60 |
It supports reading of uncompressed, LZW, packbits and CCITT-G3 compressed images |
61 |
JPEG and many other formats are currently not implemented. |
|
30 | 62 |
|
1826 | 63 |
- Only writing of uncompressed images is currently implemented. |
64 |
It should write (at least) mono, 8-bit palette and 24 bit rgb formats. |
|
65 |
||
66 |
More formats will come... (will they ever be needed ?) |
|
67 |
||
3777 | 68 |
TODO (?): since I don't want to spend all of my life adding more formats here and |
30 | 69 |
reinventing the wheel, this code should be changed to use the tiff library. |
70 |
That would give us most formats and also writing capabilities for free. |
|
1826 | 71 |
Late note: |
72 |
I hate C and interfacing to C libraries: it almost always leads to trouble |
|
73 |
w.r.t. memory leaks, non-reentrancy, non-interruptability etc. |
|
74 |
(we recently fixed a malloc-non-reentrant bug for some architecture...) |
|
75 |
So its robably better to do it all in a real programming language ;-) |
|
195 | 76 |
|
220 | 77 |
[author:] |
78 |
Claus Gittinger |
|
79 |
||
195 | 80 |
[See also:] |
234 | 81 |
Image Form Icon |
197 | 82 |
BlitImageReader FaceReader GIFReader JPEGReader PBMReader PCXReader |
210 | 83 |
ST80FormReader SunRasterReader TargaReader WindowsIconReader |
209 | 84 |
XBMReader XPMReader XWDReader |
0 | 85 |
" |
86 |
! ! |
|
87 |
||
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
88 |
!TIFFReader class methodsFor:'initialization'! |
28 | 89 |
|
90 |
initialize |
|
198 | 91 |
"install myself in the Image classes fileFormat table |
398 | 92 |
for the `.tiff' and `.tif' extensions." |
198 | 93 |
|
647 | 94 |
MIMETypes defineImageType:'image/tiff' suffix:'tif' reader:self. |
95 |
MIMETypes defineImageType:nil suffix:'tiff' reader:self. |
|
198 | 96 |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
97 |
" |
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
98 |
self initialize |
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
99 |
" |
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
100 |
|
398 | 101 |
"Modified: 1.2.1997 / 15:00:01 / cg" |
28 | 102 |
! ! |
103 |
||
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
104 |
!TIFFReader class methodsFor:'testing'! |
3 | 105 |
|
135 | 106 |
canRepresent:anImage |
107 |
"return true, if anImage can be represented in my file format. |
|
108 |
Any image is supported." |
|
109 |
||
110 |
^ true |
|
111 |
! |
|
112 |
||
3 | 113 |
isValidImageFile:aFileName |
114 |
"return true, if aFileName contains a GIF image" |
|
115 |
||
116 |
|inStream char1 char2 version| |
|
117 |
||
11 | 118 |
inStream := self streamReadingFile:aFileName. |
3 | 119 |
inStream isNil ifTrue:[^ false]. |
120 |
||
121 |
char1 := inStream next. |
|
122 |
char2 := inStream next. |
|
123 |
||
124 |
((char1 ~~ char2) or:[(char1 ~~ $I) and:[char1 ~~ $M]]) ifTrue:[ |
|
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
125 |
inStream close. |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
126 |
^ false |
3 | 127 |
]. |
128 |
||
129 |
inStream binary. |
|
3552 | 130 |
version := inStream nextInt16MSB:(char1 == $M). |
3 | 131 |
inStream close. |
132 |
||
133 |
(version ~~ 42) ifTrue:[^ false]. |
|
134 |
^ true |
|
0 | 135 |
! ! |
136 |
||
137 |
!TIFFReader methodsFor:'private'! |
|
138 |
||
139 |
decodeTiffTag:tagType numberType:numberType length:length |
|
140 |
|offset value valueArray |
|
40 | 141 |
val scaleFactor rV gV bV |
142 |
n "{ Class: SmallInteger }" |
|
35 | 143 |
i2 "{ Class: SmallInteger }" |
144 |
i3 "{ Class: SmallInteger }" | |
|
0 | 145 |
|
3975 | 146 |
"/ 'tiffTag: ' print. tagType printCR. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
147 |
|
516 | 148 |
(numberType == 3 "TIFF_SHORT") ifTrue:[ |
149 |
"16 bit ushort" |
|
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
150 |
valueArray := self readShorts:length signed:false. |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
151 |
value := valueArray at:1 |
516 | 152 |
] ifFalse:[(numberType == 4 "TIFF_LONG") ifTrue:[ |
153 |
"32 bit uinteger" |
|
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
154 |
valueArray := self readLongs:length signed:false. |
516 | 155 |
value := valueArray at:1 |
156 |
] ifFalse:[(numberType == 2 "TIFF_ASCII") ifTrue:[ |
|
157 |
"ascii characters" |
|
158 |
value := self readChars:length |
|
159 |
] ifFalse:[(numberType == 5 "TIFF_RATIONAL") ifTrue:[ |
|
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
160 |
"64 (32+32) bit ufraction" |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
161 |
valueArray := self readFracts:length signed:false. |
516 | 162 |
value := valueArray at:1 |
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
163 |
] ifFalse:[(numberType == 1 "TIFF_BYTE") ifTrue:[ |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
164 |
"8bit uinteger" |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
165 |
value := self readBytes:length signed:false |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
166 |
] ifFalse:[(numberType == 6 "TIFF_SBYTE") ifTrue:[ |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
167 |
"TIFF6: 8bit signed integer" |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
168 |
value := self readBytes:length signed:true |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
169 |
] ifFalse:[(numberType == 8 "TIFF_SSHORT") ifTrue:[ |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
170 |
"TIFF6: 16bit signed integer" |
3975 | 171 |
valueArray := self readShorts:length signed:true. |
172 |
value := valueArray at:1 |
|
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
173 |
] ifFalse:[(numberType == 9 "TIFF_SLONG") ifTrue:[ |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
174 |
"TIFF6: 32bit signed integer" |
3975 | 175 |
valueArray := self readLongs:length signed:true. |
176 |
value := valueArray at:1 |
|
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
177 |
] ifFalse:[(numberType == 10 "TIFF_SRATIONAL") ifTrue:[ |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
178 |
"TIFF6: 64 (32+32) bit signed fraction" |
3975 | 179 |
valueArray := self readFracts:length signed:true. |
180 |
value := valueArray at:1 |
|
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
181 |
] ifFalse:[(numberType == 11 "TIFF_FLOAT") ifTrue:[ |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
182 |
"TIFF6: 32 bit IEEE float" |
3975 | 183 |
valueArray := self readFloats:length. |
184 |
value := valueArray at:1 |
|
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
185 |
] ifFalse:[(numberType == 12 "TIFF_DOUBLE") ifTrue:[ |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
186 |
"TIFF6: 64 bit IEEE double" |
3975 | 187 |
valueArray := self readDoubles:length. |
188 |
value := valueArray at:1 |
|
3974 | 189 |
|
3975 | 190 |
] ifFalse:[(numberType == 7 "TIFF_UNDEFINED") ifTrue:[ |
191 |
"8bit anything" |
|
192 |
value := self readBytes:length signed:false |
|
193 |
||
3974 | 194 |
"/ the following are preps for the propsed bigTiff format |
195 |
] ifFalse:[(numberType == 16 "TIFF_LONG8") ifTrue:[ |
|
196 |
"BIGTIFF: 8-byte unsigned integer" |
|
3975 | 197 |
valueArray := self readLong8s:length signed:false. |
198 |
value := valueArray at:1. |
|
3974 | 199 |
] ifFalse:[(numberType == 17 "TIFF_SLONG8") ifTrue:[ |
200 |
"BIGTIFF: 8-byte signed integer" |
|
3975 | 201 |
valueArray := self readLong8s:length signed:true. |
202 |
value := valueArray at:1. |
|
3974 | 203 |
] ifFalse:[(numberType == 18 "TIFF_IFD8") ifTrue:[ |
204 |
"BIGTIFF: 8-byte unsigned IFD offset" |
|
3975 | 205 |
valueArray := self readLong8s:length signed:false. |
206 |
value := valueArray at:1. |
|
0 | 207 |
] ifFalse:[ |
3975 | 208 |
isBigTiff ifTrue:[ |
209 |
offset := (inStream nextInt64MSB:(byteOrder ~~ #lsb)) |
|
210 |
] ifFalse:[ |
|
211 |
offset := (inStream nextInt32MSB:(byteOrder ~~ #lsb)) |
|
212 |
] |
|
213 |
]]]]]]]]]]]]]]]. |
|
516 | 214 |
|
3974 | 215 |
(tagType between:200 and:299) ifTrue:[ |
516 | 216 |
(tagType == 254) ifTrue:[ |
217 |
"/ New SubfileType |
|
218 |
"/ REDUCEDIMAGE -> 1 |
|
219 |
"/ PAGE -> 2 |
|
220 |
"/ MASK -> 4 |
|
221 |
"newSubFileType := value." |
|
0 | 222 |
|
3693 | 223 |
"/ 'newSubfiletype ' print. value printNewline. |
516 | 224 |
|
225 |
^ self |
|
226 |
]. |
|
227 |
(tagType == 255) ifTrue:[ |
|
228 |
"/ Old SubfileType |
|
229 |
"/ IMAGE -> 1 |
|
230 |
"/ REDUCEDIMAGE -> 2 |
|
231 |
"/ PAGE -> 3 |
|
232 |
subFileType := value. |
|
233 |
||
3693 | 234 |
"/ 'subfiletype ' print. value printNewline. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
235 |
|
516 | 236 |
^ self |
237 |
]. |
|
238 |
(tagType == 256) ifTrue:[ |
|
239 |
"ImageWidth" |
|
240 |
width := value. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
241 |
|
3693 | 242 |
"/ 'width ' print. width printNewline. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
243 |
|
516 | 244 |
^ self |
245 |
]. |
|
246 |
(tagType == 257) ifTrue:[ |
|
247 |
"ImageHeight" |
|
248 |
height := value. |
|
249 |
||
3693 | 250 |
"/ 'height ' print. height printNewline. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
251 |
|
516 | 252 |
^ self |
253 |
]. |
|
254 |
(tagType == 258) ifTrue:[ |
|
1785
16917d309b46
oops - position incompatibility fixed
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
255 |
"bitspersample" |
516 | 256 |
bitsPerSample := valueArray. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
257 |
|
3693 | 258 |
"/ 'bitspersample ' print. bitsPerSample printNewline. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
259 |
|
516 | 260 |
^ self |
261 |
]. |
|
262 |
(tagType == 259) ifTrue:[ |
|
263 |
"/ compression |
|
264 |
"/ NONE -> 1 |
|
265 |
"/ CCITTRLE -> 2 |
|
266 |
"/ CCITTFAX3 -> 3 |
|
267 |
"/ CCITTFAX4 -> 4 |
|
268 |
"/ LZW -> 5 |
|
269 |
"/ OJPEG -> 6 |
|
270 |
"/ JPEG -> 7 |
|
271 |
"/ NEXT -> 32766 |
|
272 |
"/ CCITTRLEW -> 32771 |
|
520 | 273 |
"/ PACKBITS -> 32773 |
274 |
"/ THUNDERSCAN -> 32809 |
|
516 | 275 |
"/ PIXARFILM -> 32908 |
276 |
"/ PIXARLOG -> 32909 |
|
277 |
"/ DEFLATE -> 32946 |
|
278 |
"/ DCS -> 32947 |
|
279 |
"/ JBIG -> 34661 |
|
280 |
||
281 |
compression := value. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
282 |
|
3693 | 283 |
"/ 'compression ' print. compression printNewline. |
30 | 284 |
|
516 | 285 |
^ self |
286 |
]. |
|
287 |
(tagType == 262) ifTrue:[ |
|
288 |
"photometric" |
|
289 |
||
290 |
(value == 0) ifTrue:[ |
|
291 |
photometric := #whiteIs0 |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
292 |
] ifFalse:[ |
516 | 293 |
(value == 1) ifTrue:[ |
294 |
photometric := #blackIs0 |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
295 |
] ifFalse:[ |
516 | 296 |
(value == 2) ifTrue:[ |
297 |
photometric := #rgb |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
298 |
] ifFalse:[ |
516 | 299 |
(value == 3) ifTrue:[ |
300 |
photometric := #palette |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
301 |
] ifFalse:[ |
516 | 302 |
(value == 4) ifTrue:[ |
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
303 |
photometric := #transparencyMask |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
304 |
] ifFalse:[ |
516 | 305 |
(value == 5) ifTrue:[ |
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
306 |
photometric := #cmyk "/ color separations |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
307 |
] ifFalse:[ |
516 | 308 |
(value == 6) ifTrue:[ |
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
309 |
photometric := #ycbcr "/ CCIR 601 |
516 | 310 |
] ifFalse:[ |
311 |
(value == 8) ifTrue:[ |
|
312 |
photometric := #cielab "/ 1976 CIE L*a*b* |
|
313 |
] ifFalse:[ |
|
314 |
photometric := nil |
|
315 |
] |
|
316 |
] |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
317 |
] |
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
318 |
] |
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
319 |
] |
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
320 |
] |
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
321 |
] |
516 | 322 |
]. |
323 |
||
3693 | 324 |
"/ 'photometric ' print. photometric printNewline. |
516 | 325 |
|
326 |
^ self |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
327 |
]. |
516 | 328 |
(tagType == 263) ifTrue:[ |
3957 | 329 |
"/ Thresholding |
516 | 330 |
"/ BILEVEL -> 1 |
331 |
"/ HALFTONE -> 2 |
|
332 |
"/ ERRORDIFFUSE -> 3 |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
333 |
|
3957 | 334 |
"thresholding := value." |
516 | 335 |
|
3957 | 336 |
"/ 'thresholding ' print. value printNewline. |
516 | 337 |
|
338 |
^ self |
|
339 |
]. |
|
340 |
(tagType == 264) ifTrue:[ |
|
341 |
"CellWidth" |
|
3693 | 342 |
"/ 'cellWidth ' print. value printNewline. |
343 |
metaData at:#CellWidth put:value. |
|
516 | 344 |
|
345 |
^ self |
|
346 |
]. |
|
347 |
(tagType == 265) ifTrue:[ |
|
348 |
"CellLength" |
|
3693 | 349 |
"/ 'cellLength ' print. value printNewline. |
350 |
metaData at:#CellLength put:value. |
|
516 | 351 |
^ self |
352 |
]. |
|
353 |
(tagType == 266) ifTrue:[ |
|
354 |
"fillOrder" |
|
355 |
(value == 1) ifTrue:[ |
|
356 |
fillOrder := #msb |
|
357 |
] ifFalse:[ |
|
358 |
(value == 2) ifTrue:[ |
|
359 |
fillOrder := #lsb |
|
360 |
] ifFalse:[ |
|
361 |
fillOrder := nil |
|
362 |
] |
|
363 |
]. |
|
3693 | 364 |
"/ 'fillorder ' print. fillOrder printNewline. |
516 | 365 |
^ self |
366 |
]. |
|
367 |
(tagType == 269) ifTrue:[ |
|
368 |
"documentName - info only" |
|
3693 | 369 |
"/ 'documentName ' print. value printNewline. |
370 |
metaData at:#DocumentName put:value. |
|
516 | 371 |
^ self |
372 |
]. |
|
373 |
(tagType == 270) ifTrue:[ |
|
374 |
"imageDescription - info only" |
|
3693 | 375 |
"/ 'imageDescription ' print. value printNewline. |
376 |
metaData at:#ImageDescription put:value. |
|
516 | 377 |
^ self |
378 |
]. |
|
379 |
(tagType == 271) ifTrue:[ |
|
380 |
"make - info only" |
|
3693 | 381 |
"/ 'make ' print. value printNewline. |
382 |
metaData at:#Make put:value. |
|
516 | 383 |
^ self |
384 |
]. |
|
385 |
(tagType == 272) ifTrue:[ |
|
386 |
"model - info only" |
|
3693 | 387 |
"/ 'model ' print. value printNewline. |
388 |
metaData at:#Model put:value. |
|
516 | 389 |
^ self |
390 |
]. |
|
391 |
(tagType == 273) ifTrue:[ |
|
392 |
stripOffsets := valueArray. |
|
3693 | 393 |
"/ 'stripOffsets Array(' print. stripOffsets size print. ')' printNewline. |
516 | 394 |
^ self |
395 |
]. |
|
396 |
(tagType == 274) ifTrue:[ |
|
397 |
"Orientation" |
|
398 |
||
399 |
orientation := |
|
400 |
#( nil "/ 1 normal (topLeft) |
|
401 |
unsupported "/ 2 horizontal flip |
|
402 |
unsupported "/ 3 horizontal & vertical flip |
|
403 |
vFlip "/ 4 vertical flip |
|
404 |
unsupported "/ 5 rot 90' counter clock-wise |
|
405 |
unsupported "/ 6 rot 90' clock-wise |
|
406 |
unsupported "/ 7 rot 90' & flip |
|
407 |
unsupported "/ 8 rot 90' ccw & flip |
|
408 |
) at:value ifAbsent:#unsupported. |
|
3693 | 409 |
metaData at:#Orientation put:value. |
410 |
"/ 'orientation ' print. value printNewline. |
|
516 | 411 |
^ self |
412 |
]. |
|
413 |
(tagType == 277) ifTrue:[ |
|
414 |
samplesPerPixel := value. |
|
3693 | 415 |
"/ 'samplesperpixel ' print. samplesPerPixel printNewline. |
516 | 416 |
^ self |
417 |
]. |
|
418 |
(tagType == 278) ifTrue:[ |
|
419 |
rowsPerStrip := value. |
|
3693 | 420 |
"/ 'rowsperstrip ' print. rowsPerStrip printNewline. |
516 | 421 |
^ self |
422 |
]. |
|
423 |
(tagType == 279) ifTrue:[ |
|
424 |
"stripbytecount" |
|
425 |
stripByteCounts := valueArray. |
|
3693 | 426 |
"/ 'stripByteCounts Array(' print. |
427 |
"/ stripByteCounts size print. |
|
428 |
"/ ')' printNewline. |
|
516 | 429 |
^ self |
430 |
]. |
|
431 |
(tagType == 280) ifTrue:[ |
|
3693 | 432 |
"/ 'minSampleValue ' print. value printNewline. |
433 |
metaData at:#MinSampleValue put:value. |
|
516 | 434 |
^ self |
435 |
]. |
|
436 |
(tagType == 281) ifTrue:[ |
|
3693 | 437 |
"/ 'maxSampleValue ' print. value printNewline. |
438 |
metaData at:#MaxSampleValue put:value. |
|
516 | 439 |
^ self |
440 |
]. |
|
441 |
(tagType == 282) ifTrue:[ |
|
3974 | 442 |
"/ 'xResolution ' print. value printNewline. |
3693 | 443 |
metaData at:#ResolutionX put:value. |
516 | 444 |
^ self |
445 |
]. |
|
446 |
(tagType == 283) ifTrue:[ |
|
3974 | 447 |
"/ 'yResolution ' print. value printNewline. |
3693 | 448 |
metaData at:#ResolutionY put:value. |
516 | 449 |
^ self |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
450 |
]. |
516 | 451 |
(tagType == 284) ifTrue:[ |
452 |
(value == 1) ifTrue:[ |
|
453 |
planarConfiguration := 1 |
|
454 |
] ifFalse:[ |
|
455 |
(value == 2) ifTrue:[ |
|
456 |
planarConfiguration := 2 |
|
457 |
] ifFalse:[ |
|
458 |
planarConfiguration := nil |
|
459 |
] |
|
460 |
]. |
|
3693 | 461 |
"/ 'planarconfig ' print. planarConfiguration printNewline. |
516 | 462 |
^ self |
463 |
]. |
|
464 |
(tagType == 285) ifTrue:[ |
|
3693 | 465 |
"/ 'pageName ' print. value printNewline. |
466 |
metaData at:#PageName put:value. |
|
516 | 467 |
^ self |
468 |
]. |
|
469 |
(tagType == 286) ifTrue:[ |
|
3974 | 470 |
"/ 'xPosition ' print. value printNewline. |
3693 | 471 |
metaData at:#PositionX put:value. |
516 | 472 |
^ self |
473 |
]. |
|
474 |
(tagType == 287) ifTrue:[ |
|
3974 | 475 |
"/ 'yPosition ' print. value printNewline. |
3693 | 476 |
metaData at:#PositionY put:value. |
516 | 477 |
^ self |
478 |
]. |
|
479 |
(tagType == 288) ifTrue:[ |
|
3693 | 480 |
"/ 'freeOffsets ' print. value printNewline. |
516 | 481 |
^ self |
482 |
]. |
|
483 |
(tagType == 289) ifTrue:[ |
|
3693 | 484 |
"/ 'freeByteCounts ' print. value printNewline. |
516 | 485 |
^ self |
486 |
]. |
|
487 |
(tagType == 290) ifTrue:[ |
|
3693 | 488 |
"/ 'grayResponceUnit' print. value printNewline. |
489 |
metaData at:#GrayResponceUnit put:value. |
|
516 | 490 |
^ self |
491 |
]. |
|
492 |
(tagType == 291) ifTrue:[ |
|
3693 | 493 |
"/ 'grayResponceCurve' print. value printNewline. |
494 |
metaData at:#GrayResponceCurve put:value. |
|
516 | 495 |
^ self |
496 |
]. |
|
497 |
(tagType == 292) ifTrue:[ |
|
498 |
"/ group3options |
|
499 |
"/ 2DENCODING -> 1 |
|
500 |
"/ UNCOMPRESSED -> 2 |
|
501 |
"/ FILLBITS -> 4 |
|
502 |
||
503 |
group3options := value. |
|
3693 | 504 |
"/ 'group3options ' print. group3options printNewline. |
516 | 505 |
^ self |
506 |
]. |
|
507 |
(tagType == 293) ifTrue:[ |
|
508 |
"/ group4options |
|
509 |
"/ UNCOMPRESSED -> 2 |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
510 |
|
516 | 511 |
"group4options := value." |
3693 | 512 |
"/ 'group4options ' print. value printNewline. |
516 | 513 |
^ self |
514 |
]. |
|
515 |
(tagType == 296) ifTrue:[ |
|
516 |
"resolutionunit" |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
517 |
|
516 | 518 |
"/ (value == 1) ifTrue:[ |
519 |
"/ 'res-unit pixel' printNewline |
|
520 |
"/ ] ifFalse:[ |
|
521 |
"/ (value == 2) ifTrue:[ |
|
522 |
"/ 'res-unit inch' printNewline |
|
523 |
"/ ] ifFalse:[ |
|
524 |
"/ (value == 3) ifTrue:[ |
|
525 |
"/ 'res-unit mm' printNewline |
|
526 |
"/ ] ifFalse:[ |
|
527 |
"/ 'res-unit invalid' printNewline |
|
528 |
"/ ] |
|
529 |
"/ ] |
|
530 |
"/ ]. |
|
3693 | 531 |
metaData at:#ResolutionUnit put:value. |
516 | 532 |
^ self |
533 |
]. |
|
534 |
(tagType == 297) ifTrue:[ |
|
3693 | 535 |
"/ 'pageNumber ' print. value printNewline. |
536 |
metaData at:#PageNumber put:value. |
|
516 | 537 |
^ self |
538 |
]. |
|
0 | 539 |
]. |
3974 | 540 |
|
541 |
(tagType between:300 and:399) ifTrue:[ |
|
516 | 542 |
(tagType == 300) ifTrue:[ |
3693 | 543 |
"/ 'colorResponceUnit' print. value printNewline. |
544 |
metaData at:#ColorResponceUnit put:value. |
|
516 | 545 |
^ self |
546 |
]. |
|
547 |
(tagType == 301) ifTrue:[ |
|
3693 | 548 |
"/ 'colorResponceCurve' print. value printNewline. |
549 |
metaData at:#ColorResponceCurve put:value. |
|
516 | 550 |
^ self |
551 |
]. |
|
552 |
(tagType == 305) ifTrue:[ |
|
553 |
"software - info only" |
|
3693 | 554 |
"/ 'software' print. value printNewline. |
555 |
metaData at:#Software put:value. |
|
516 | 556 |
^ self |
557 |
]. |
|
558 |
(tagType == 306) ifTrue:[ |
|
559 |
"dateTime - info only" |
|
3693 | 560 |
"/ 'dateTime ' print. value printNewline. |
561 |
metaData at:#DateTime put:value. |
|
516 | 562 |
^ self |
563 |
]. |
|
564 |
(tagType == 315) ifTrue:[ |
|
565 |
"artist - info only" |
|
3693 | 566 |
"/ 'artist ' print. value printNewline. |
567 |
metaData at:#Artist put:value. |
|
516 | 568 |
^ self |
569 |
]. |
|
570 |
(tagType == 316) ifTrue:[ |
|
571 |
"host computer - info only" |
|
3693 | 572 |
"/ 'host ' print. value printNewline. |
573 |
metaData at:#HostComputer put:value. |
|
516 | 574 |
^ self |
575 |
]. |
|
576 |
(tagType == 317) ifTrue:[ |
|
3974 | 577 |
"/ 'predictor ' print. predictor printNewline. |
516 | 578 |
predictor := value. |
579 |
^ self |
|
580 |
]. |
|
581 |
(tagType == 318) ifTrue:[ |
|
3693 | 582 |
"/ 'whitePoint ' print. value printNewline. |
583 |
metaData at:#WhitePoint put:value. |
|
516 | 584 |
^ self |
585 |
]. |
|
586 |
(tagType == 319) ifTrue:[ |
|
3693 | 587 |
"/ 'primaryChromatics ' print. value printNewline. |
588 |
metaData at:#PrimaryChromatics put:value. |
|
516 | 589 |
^ self |
590 |
]. |
|
591 |
(tagType == 320) ifTrue:[ |
|
3693 | 592 |
"/ 'colorMap (size=' print. valueArray size print. ')' printNewline. |
516 | 593 |
|
594 |
" |
|
595 |
the tiff colormap contains 16bit values; |
|
596 |
our colormap expects 8bit values |
|
597 |
" |
|
598 |
n := valueArray size // 3. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
599 |
|
516 | 600 |
rV := ByteArray uninitializedNew:n. |
601 |
gV := ByteArray uninitializedNew:n. |
|
602 |
bV := ByteArray uninitializedNew:n. |
|
603 |
scaleFactor := 255.0 / 16rFFFF. |
|
604 |
i2 := n+1. |
|
605 |
i3 := 2*n+1. |
|
606 |
1 to:n do:[:vi | |
|
607 |
val := ((valueArray at:vi) * scaleFactor) rounded. |
|
608 |
rV at:vi put:val. |
|
609 |
val := ((valueArray at:i2) * scaleFactor) rounded. |
|
610 |
gV at:vi put:val. |
|
611 |
val := ((valueArray at:i3) * scaleFactor) rounded. |
|
612 |
bV at:vi put:val. |
|
613 |
i2 := i2 + 1. |
|
614 |
i3 := i3 + 1. |
|
615 |
]. |
|
1759
f52382e5a9b8
slowly getting rid of the Colormap class
Claus Gittinger <cg@exept.de>
parents:
1748
diff
changeset
|
616 |
colorMap := MappedPalette redVector:rV greenVector:gV blueVector:bV. |
516 | 617 |
^ self |
618 |
]. |
|
619 |
(tagType == 321) ifTrue:[ |
|
3693 | 620 |
"/ 'halftonehints' print. value printNewline. |
621 |
metaData at:#HalftoneHints put:value. |
|
516 | 622 |
^ self |
623 |
]. |
|
624 |
(tagType == 322) ifTrue:[ |
|
3693 | 625 |
"/ 'tilewidth' print. value printNewline. |
626 |
metaData at:#TileWidth put:value. |
|
516 | 627 |
^ self |
628 |
]. |
|
629 |
(tagType == 323) ifTrue:[ |
|
3693 | 630 |
"/ 'tilelength' print. value printNewline. |
631 |
metaData at:#TileLength put:value. |
|
516 | 632 |
^ self |
633 |
]. |
|
634 |
(tagType == 324) ifTrue:[ |
|
3693 | 635 |
"/ 'tileoffsets' print. value printNewline. |
3975 | 636 |
metaData at:#TileOffsets put:valueArray. |
516 | 637 |
^ self |
638 |
]. |
|
639 |
(tagType == 325) ifTrue:[ |
|
3693 | 640 |
"/ 'tilebytecounts' print. value printNewline. |
3975 | 641 |
metaData at:#TileByteCounts put:valueArray. |
516 | 642 |
^ self |
643 |
]. |
|
1827 | 644 |
(tagType == 326) ifTrue:[ |
3693 | 645 |
"/ 'badFaxLines' print. value printNewline. |
1827 | 646 |
^ self |
647 |
]. |
|
516 | 648 |
(tagType == 327) ifTrue:[ |
1827 | 649 |
"CleanFaxData" |
516 | 650 |
|
3974 | 651 |
"/ 'cleanfaxdata' print. value printNewline. |
652 |
"/ (value == 0) ifTrue:[ |
|
653 |
"/ 'no lines with incorrect pixel counts' printNewline |
|
654 |
"/ ] ifFalse:[ |
|
655 |
"/ (value == 1) ifTrue:[ |
|
656 |
"/ 'incorrect lines were regenerated' printNewline |
|
657 |
"/ ] ifFalse:[ |
|
658 |
"/ (value == 2) ifTrue:[ |
|
659 |
"/ 'incorrect lines were not regenerated' printNewline |
|
660 |
"/ ] ifFalse:[ |
|
661 |
"/ 'cleanfaxdata invalid' printNewline |
|
662 |
"/ ] |
|
663 |
"/ ] |
|
664 |
"/ ]. |
|
516 | 665 |
|
666 |
^ self |
|
667 |
]. |
|
668 |
(tagType == 328) ifTrue:[ |
|
3974 | 669 |
"/ 'consecutiveBadFaxLines' print. value printNewline. |
516 | 670 |
^ self |
671 |
]. |
|
672 |
(tagType == 330) ifTrue:[ |
|
3974 | 673 |
"/ 'subifd' print. value printNewline. |
516 | 674 |
^ self |
675 |
]. |
|
676 |
(tagType == 332) ifTrue:[ |
|
3974 | 677 |
"/ 'ink set' print. value printNewline. |
516 | 678 |
^ self |
679 |
]. |
|
680 |
(tagType == 333) ifTrue:[ |
|
3693 | 681 |
"/ 'ink names' print. value printNewline. |
682 |
metaData at:#IncNames put:value. |
|
516 | 683 |
^ self |
684 |
]. |
|
3974 | 685 |
(tagType == 334) ifTrue:[ |
686 |
"/ 'numinks' print. value printNewline. |
|
687 |
^ self |
|
688 |
]. |
|
516 | 689 |
(tagType == 336) ifTrue:[ |
3693 | 690 |
"/ 'dot range' print. value printNewline. |
516 | 691 |
^ self |
692 |
]. |
|
693 |
(tagType == 337) ifTrue:[ |
|
3693 | 694 |
"/ 'target printer' print. value printNewline. |
516 | 695 |
^ self |
696 |
]. |
|
697 |
(tagType == 338) ifTrue:[ |
|
3693 | 698 |
"/ 'extrasamples' print. value printNewline. |
516 | 699 |
^ self |
700 |
]. |
|
701 |
(tagType == 339) ifTrue:[ |
|
3693 | 702 |
"/ 'sample format' print. value printNewline. |
516 | 703 |
^ self |
704 |
]. |
|
705 |
(tagType == 340) ifTrue:[ |
|
3974 | 706 |
"/ 'min sample value' print. value printNewline. |
516 | 707 |
^ self |
708 |
]. |
|
709 |
(tagType == 341) ifTrue:[ |
|
3974 | 710 |
"/ 'max sample value' print. value printNewline. |
711 |
^ self |
|
712 |
]. |
|
713 |
(tagType == 342) ifTrue:[ |
|
714 |
"/ 'transfer range' print. value printNewline. |
|
715 |
^ self |
|
716 |
]. |
|
717 |
(tagType == 343) ifTrue:[ |
|
718 |
"/ 'clip path' print. value printNewline. |
|
719 |
^ self |
|
720 |
]. |
|
721 |
(tagType == 344) ifTrue:[ |
|
722 |
"/ 'xclip path units' print. value printNewline. |
|
723 |
^ self |
|
724 |
]. |
|
725 |
(tagType == 345) ifTrue:[ |
|
726 |
"/ 'yclip path units' print. value printNewline. |
|
516 | 727 |
^ self |
728 |
]. |
|
729 |
(tagType == 347) ifTrue:[ |
|
3974 | 730 |
"/ 'jpegtables' print. value printNewline. |
516 | 731 |
^ self |
732 |
]. |
|
0 | 733 |
]. |
516 | 734 |
|
3974 | 735 |
(tagType between:400 and:499) ifTrue:[ |
736 |
(tagType == 400) ifTrue:[ |
|
737 |
"/ 'GlobalParametersIFD' print. value printNewline. |
|
738 |
^ self |
|
739 |
]. |
|
740 |
(tagType == 401) ifTrue:[ |
|
741 |
"/ 'ProfileType' print. value printNewline. |
|
742 |
^ self |
|
743 |
]. |
|
744 |
(tagType == 402) ifTrue:[ |
|
745 |
"/ 'FaxProfile' print. value printNewline. |
|
746 |
^ self |
|
747 |
]. |
|
748 |
(tagType == 403) ifTrue:[ |
|
749 |
"/ 'CodingMethods' print. value printNewline. |
|
750 |
^ self |
|
751 |
]. |
|
752 |
(tagType == 404) ifTrue:[ |
|
753 |
"/ 'VersionYear' print. value printNewline. |
|
754 |
^ self |
|
755 |
]. |
|
756 |
(tagType == 405) ifTrue:[ |
|
757 |
"/ 'ModeNumber' print. value printNewline. |
|
758 |
^ self |
|
759 |
]. |
|
760 |
(tagType == 433) ifTrue:[ |
|
761 |
"/ 'Decode' print. value printNewline. |
|
762 |
^ self |
|
763 |
]. |
|
764 |
(tagType == 434) ifTrue:[ |
|
765 |
"/ 'DefaultImageColor' print. value printNewline. |
|
766 |
^ self |
|
767 |
]. |
|
768 |
]. |
|
769 |
||
770 |
(tagType between:500 and:599) ifTrue:[ |
|
516 | 771 |
"/ obsolete JPEG tags |
772 |
(tagType == 512) ifTrue:[ |
|
3974 | 773 |
"/ 'jpeg proc' print. value printNewline. |
516 | 774 |
^ self |
775 |
]. |
|
776 |
(tagType == 513) ifTrue:[ |
|
3974 | 777 |
"/ 'jpeg proc' print. value printNewline. |
516 | 778 |
^ self |
779 |
]. |
|
780 |
(tagType == 514) ifTrue:[ |
|
3974 | 781 |
"/ 'jpeg ifByteCount' print. value printNewline. |
516 | 782 |
^ self |
783 |
]. |
|
784 |
(tagType == 515) ifTrue:[ |
|
3974 | 785 |
"/ 'jpeg restartInterval' print. value printNewline. |
516 | 786 |
^ self |
787 |
]. |
|
788 |
(tagType == 517) ifTrue:[ |
|
3974 | 789 |
"/ 'jpeg glossLessPredictors' print. value printNewline. |
516 | 790 |
^ self |
791 |
]. |
|
792 |
(tagType == 518) ifTrue:[ |
|
3974 | 793 |
"/ 'jpeg pointTransform' print. value printNewline. |
516 | 794 |
^ self |
795 |
]. |
|
796 |
(tagType == 519) ifTrue:[ |
|
3974 | 797 |
"/ 'jpeg qTables' print. value printNewline. |
516 | 798 |
^ self |
799 |
]. |
|
800 |
(tagType == 520) ifTrue:[ |
|
3974 | 801 |
"/ 'jpeg dcTables' print. value printNewline. |
802 |
^ self |
|
516 | 803 |
]. |
804 |
(tagType == 521) ifTrue:[ |
|
3974 | 805 |
"/ 'jpeg acTables' print. value printNewline. |
516 | 806 |
^ self |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
807 |
]. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
808 |
|
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
809 |
|
516 | 810 |
(tagType == 529) ifTrue:[ |
3974 | 811 |
"/ 'ycbr coeff' print. value printNewline. |
516 | 812 |
^ self |
813 |
]. |
|
814 |
(tagType == 530) ifTrue:[ |
|
3974 | 815 |
"/ 'ycbr subsampling' print. value printNewline. |
516 | 816 |
^ self |
817 |
]. |
|
818 |
(tagType == 531) ifTrue:[ |
|
3974 | 819 |
"/ 'ycbr positioning' print. value printNewline. |
516 | 820 |
^ self |
821 |
]. |
|
822 |
(tagType == 532) ifTrue:[ |
|
3974 | 823 |
"/ 'referenceBlackWhite' print. value printNewline. |
824 |
^ self |
|
825 |
]. |
|
826 |
(tagType == 559) ifTrue:[ |
|
827 |
"/ 'stripRowCounts' print. value printNewline. |
|
516 | 828 |
^ self |
829 |
]. |
|
30 | 830 |
]. |
516 | 831 |
|
3974 | 832 |
(tagType between:700 and:799) ifTrue:[ |
833 |
(tagType == 700) ifTrue:[ |
|
834 |
"XMLPACKET" |
|
835 |
||
836 |
"/ In TIFF files, the XML Packet containing XMP metadata is pointed to |
|
837 |
"/ by an entry in the Image File Directory (IFD). That entry has a Tag |
|
838 |
"/ value of 700, as shown in Table 1.1, "TIFF IFD Directory Entry for |
|
839 |
"/ XML Packets |
|
840 |
||
841 |
"/ 'XMLPACKET' print. value printNewline. |
|
842 |
^ self |
|
843 |
]. |
|
844 |
]. |
|
845 |
||
516 | 846 |
(tagType > 32000) ifTrue:[ |
3974 | 847 |
(tagType == 32781) ifTrue:[ |
848 |
"/'imageid' print. value printNewline. |
|
849 |
^ self |
|
850 |
]. |
|
851 |
(tagType == 32932) ifTrue:[ |
|
852 |
"/'wang annotation' print. value printNewline. |
|
853 |
^ self |
|
854 |
]. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
855 |
|
516 | 856 |
"/ Private Island graphics tags |
857 |
(tagType == 32953) ifTrue:[ |
|
3974 | 858 |
"/'ref points' print. value printNewline. |
516 | 859 |
^ self |
860 |
]. |
|
861 |
(tagType == 32954) ifTrue:[ |
|
3974 | 862 |
"/ 'regionTagPoint' print. value printNewline. |
516 | 863 |
^ self |
864 |
]. |
|
865 |
(tagType == 32955) ifTrue:[ |
|
3974 | 866 |
"/ 'regionWarpCorners' print. value printNewline. |
516 | 867 |
^ self |
868 |
]. |
|
869 |
(tagType == 32956) ifTrue:[ |
|
3974 | 870 |
"/ 'regionAffine' print. value printNewline. |
516 | 871 |
^ self |
872 |
]. |
|
873 |
||
874 |
||
875 |
"/ Private SGI tags |
|
876 |
(tagType == 32995) ifTrue:[ |
|
3974 | 877 |
"/ 'matteing' print. value printNewline. |
516 | 878 |
^ self |
879 |
]. |
|
880 |
(tagType == 32996) ifTrue:[ |
|
3974 | 881 |
"/ 'datatype' print. value printNewline. |
516 | 882 |
^ self |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
883 |
]. |
516 | 884 |
(tagType == 32997) ifTrue:[ |
3974 | 885 |
"/ 'imagedepth' print. value printNewline. |
516 | 886 |
^ self |
887 |
]. |
|
888 |
(tagType == 32998) ifTrue:[ |
|
3974 | 889 |
"/ 'tiledepth' print. value printNewline. |
516 | 890 |
^ self |
891 |
]. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
892 |
|
516 | 893 |
"/ Private Pixar tags |
894 |
(tagType == 33300) ifTrue:[ |
|
3974 | 895 |
"/ 'image full width' print. value printNewline. |
516 | 896 |
^ self |
897 |
]. |
|
898 |
(tagType == 33301) ifTrue:[ |
|
3974 | 899 |
"/ 'image full length' print. value printNewline. |
516 | 900 |
^ self |
901 |
]. |
|
902 |
||
903 |
"/ Private Eastman Kodak tags |
|
904 |
(tagType == 33405) ifTrue:[ |
|
3974 | 905 |
"/ 'write serial number' print. value printNewline. |
516 | 906 |
^ self |
907 |
]. |
|
908 |
||
909 |
"/ unknown |
|
3974 | 910 |
(tagType == 33432) ifTrue:[ |
911 |
"/ 'copyright' print. value printNewline. |
|
912 |
^ self |
|
913 |
]. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
914 |
|
3974 | 915 |
(tagType == 33550) ifTrue:[ |
916 |
"/ 'geotiff modelpixelscaletag' print. value printNewline. |
|
917 |
^ self |
|
918 |
]. |
|
516 | 919 |
|
3974 | 920 |
(tagType == 33723) ifTrue:[ |
921 |
"/ 'RICHTIFFIPTC' print. value printNewline. |
|
516 | 922 |
^ self |
923 |
]. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
924 |
|
516 | 925 |
"/ Private Texas instruments |
926 |
(tagType == 34232) ifTrue:[ |
|
3974 | 927 |
"/ 'sequence frame count' print. value printNewline. |
516 | 928 |
^ self |
929 |
]. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
930 |
|
516 | 931 |
"/ Private Pixel magic |
932 |
(tagType == 34232) ifTrue:[ |
|
3974 | 933 |
"/ 'jbig options' print. value printNewline. |
516 | 934 |
^ self |
935 |
]. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
936 |
|
3974 | 937 |
"/ private Photoshop |
938 |
(tagType == 34377) ifTrue:[ |
|
939 |
"/ 'photoshop RICHTIFFIPTC' print. value printNewline. |
|
940 |
^ self |
|
941 |
]. |
|
942 |
(tagType == 34665) ifTrue:[ |
|
943 |
"/ 'EXIFIFD' print. value printNewline. |
|
944 |
^ self |
|
945 |
]. |
|
946 |
(tagType == 34675) ifTrue:[ |
|
947 |
"/ 'ICCPROFILE' print. value printNewline. |
|
948 |
^ self |
|
949 |
]. |
|
950 |
||
951 |
(tagType == 34732) ifTrue:[ |
|
952 |
"/ 'ImageLayer' print. value printNewline. |
|
953 |
^ self |
|
954 |
]. |
|
955 |
||
516 | 956 |
"/ More Private SGI |
957 |
(tagType == 34908) ifTrue:[ |
|
3974 | 958 |
"/ 'fax recv params' print. value printNewline. |
516 | 959 |
^ self |
960 |
]. |
|
961 |
(tagType == 34909) ifTrue:[ |
|
3974 | 962 |
"/ 'fax subaddress' print. value printNewline. |
516 | 963 |
^ self |
964 |
]. |
|
965 |
(tagType == 34910) ifTrue:[ |
|
3974 | 966 |
"/ 'fax recv time' print. value printNewline. |
516 | 967 |
^ self |
968 |
]. |
|
30 | 969 |
]. |
0 | 970 |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
971 |
"/ |
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
972 |
"/ 'TIFFReader: tag:' print. tagType print. ' typ:' print. numberType print. |
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
973 |
"/ ' len:' print. length print. ' offs:' print. offset print. |
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
974 |
"/ ' val:' print. value print. ' valArr:' print. valueArray printNewline. |
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
975 |
"/ |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
976 |
'TIFFReader [warning]: unknown tag type ' errorPrint. tagType errorPrintCR |
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
977 |
|
3957 | 978 |
"Modified (format): / 23-05-2017 / 16:12:58 / mawalch" |
3975 | 979 |
"Modified: / 25-08-2017 / 00:24:44 / cg" |
440 | 980 |
! ! |
981 |
||
1762 | 982 |
!TIFFReader methodsFor:'private-data reading'! |
0 | 983 |
|
135 | 984 |
readCCITT3RLETiffImageData |
1826 | 985 |
^ self fileFormatError:'ccitt G3 mod Huffman (rle) compression not implemented' |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
986 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
987 |
"Modified: / 3.2.1998 / 18:03:14 / cg" |
135 | 988 |
! |
989 |
||
990 |
readCCITT3RLEWTiffImageData |
|
1826 | 991 |
^ self fileFormatError:'ccitt G3 mod Huffman (rlew) compression not implemented'. |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
992 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
993 |
"Modified: / 3.2.1998 / 18:03:30 / cg" |
135 | 994 |
! |
995 |
||
996 |
readCCITTGroup3TiffImageData |
|
1826 | 997 |
"not really tested - all I got is a single fax from NeXT step" |
135 | 998 |
|
999 |
|bytesPerRow bitsPerRow compressedStrip nPlanes |
|
1000 |
stripNr "{ Class: SmallInteger }" |
|
1001 |
offset "{ Class: SmallInteger }" |
|
1002 |
row "{ Class: SmallInteger }" |
|
1003 |
bytesPerStrip "{ Class: SmallInteger }" | |
|
1004 |
||
1005 |
nPlanes := samplesPerPixel. |
|
1006 |
(nPlanes == 2) ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1007 |
'TIFFReader [info]: ignoring alpha plane' infoPrintCR. |
335 | 1008 |
nPlanes := 1 |
135 | 1009 |
]. |
1010 |
||
1011 |
(nPlanes ~~ 1) ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1012 |
^ self fileFormatError:'only monochrome/greyscale ccitt3supported'. |
135 | 1013 |
]. |
0 | 1014 |
|
135 | 1015 |
stripByteCounts isNil ifTrue:[ |
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1016 |
^ self fileFormatError:'currently require stripByteCounts'. |
135 | 1017 |
]. |
1018 |
(rowsPerStrip ~~ 1) isNil ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1019 |
^ self fileFormatError:'currently require rowsPerStrip to be 1'. |
135 | 1020 |
]. |
1021 |
||
335 | 1022 |
"/ 'TIFFReader: decompressing CCITT-3 ...' infoPrintNL. |
135 | 1023 |
|
1024 |
bitsPerRow := width * (bitsPerSample at:1). |
|
1025 |
bytesPerRow := bitsPerRow // 8. |
|
1026 |
((bitsPerRow \\ 8) ~~ 0) ifTrue:[ |
|
335 | 1027 |
bytesPerRow := bytesPerRow + 1 |
135 | 1028 |
]. |
1029 |
||
1030 |
data := ByteArray new:(bytesPerRow * height). |
|
1031 |
compressedStrip := ByteArray uninitializedNew:bytesPerRow. |
|
1032 |
||
1033 |
offset := 1. |
|
1034 |
stripNr := 0. |
|
1035 |
||
1036 |
row := 1. |
|
1037 |
bytesPerStrip := bytesPerRow * rowsPerStrip. |
|
1038 |
[row <= height] whileTrue:[ |
|
335 | 1039 |
stripNr := stripNr + 1. |
1702
75a595a70c86
stream position is going to be 0-based soon
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
1040 |
self positionToStrip:stripNr. |
335 | 1041 |
inStream nextBytes:(stripByteCounts at:stripNr) into:compressedStrip. |
1042 |
self class decompressCCITT3From:compressedStrip |
|
1043 |
into:data |
|
1044 |
startingAt:offset |
|
1045 |
count:width. |
|
1046 |
offset := offset + bytesPerStrip. |
|
1047 |
row := row + rowsPerStrip |
|
135 | 1048 |
] |
335 | 1049 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1050 |
"Modified: / 3.2.1998 / 18:04:21 / cg" |
135 | 1051 |
! |
1052 |
||
1053 |
readCCITTGroup4TiffImageData |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1054 |
^ self fileFormatError:'ccitt group4 fax compression not implemented'. |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1055 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1056 |
"Modified: / 3.2.1998 / 18:04:34 / cg" |
135 | 1057 |
! |
0 | 1058 |
|
1826 | 1059 |
readCCITTRLEWTiffImageData |
1060 |
^ self fileFormatError:'ccitt mod Huffman (rlew) compression not implemented' |
|
1061 |
! |
|
1062 |
||
516 | 1063 |
readDCSTiffImageData |
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1064 |
^ self fileFormatError:'dcs compression not implemented'. |
329
5fb99e0734e4
handle empty character-strings
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1065 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1066 |
"Modified: / 3.2.1998 / 18:04:44 / cg" |
135 | 1067 |
! |
1068 |
||
516 | 1069 |
readDeflateTiffImageData |
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1070 |
^ self fileFormatError:'deflate compression not implemented'. |
135 | 1071 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1072 |
"Modified: / 3.2.1998 / 18:04:54 / cg" |
516 | 1073 |
! |
1074 |
||
1075 |
readJBIGTiffImageData |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1076 |
^ self fileFormatError:'jbig compression not implemented'. |
516 | 1077 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1078 |
"Modified: / 3.2.1998 / 18:05:04 / cg" |
135 | 1079 |
! |
1080 |
||
1081 |
readJPEGTiffImageData |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1082 |
^ self fileFormatError:'jpeg compression not implemented'. |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1083 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1084 |
"Modified: / 3.2.1998 / 18:05:12 / cg" |
135 | 1085 |
! |
1086 |
||
1087 |
readLZWTiffImageData |
|
1088 |
"read LZW compressed tiff data; this method only |
|
1089 |
handles 3x8 rgb and 1x2 or 2x2 greyscale images. |
|
1090 |
For 2x2 greyscale images, the alpha plane is ignored. |
|
1091 |
(maybe other formats work also - its simply not |
|
1092 |
tested)" |
|
1093 |
||
1037
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1094 |
|bytesPerRow compressedStrip nPlanes overAllBytes |
135 | 1095 |
bytesPerStrip "{ Class: SmallInteger }" |
1096 |
nBytes "{ Class: SmallInteger }" |
|
1097 |
prevSize "{ Class: SmallInteger }" |
|
1098 |
stripNr "{ Class: SmallInteger }" |
|
1099 |
offset "{ Class: SmallInteger }" |
|
1100 |
row "{ Class: SmallInteger }" | |
|
1101 |
||
1102 |
nPlanes := samplesPerPixel. |
|
1103 |
||
3974 | 1104 |
(nPlanes >= 3) ifTrue:[ |
1105 |
(bitsPerSample conform:[:each | each == 8]) ifFalse:[ |
|
1106 |
^ self fileFormatError:'only 8/8/8(/8) bits/sample are supported'. |
|
335 | 1107 |
]. |
1108 |
bytesPerRow := width * samplesPerPixel. |
|
0 | 1109 |
] ifFalse:[ |
335 | 1110 |
(nPlanes == 2) ifTrue:[ |
1111 |
(planarConfiguration ~~ 2) ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1112 |
^ self fileFormatError:'only separate planes are supported'. |
335 | 1113 |
]. |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1114 |
'TIFFReader [info]: ignoring alpha plane' infoPrintCR. |
335 | 1115 |
nPlanes := 1 |
1116 |
]. |
|
1117 |
(nPlanes == 1) ifFalse:[ |
|
1830 | 1118 |
^ self fileFormatError:'unsupported nPlanes: ' , nPlanes printString, '; only 3-sample rgb / monochrome supported'. |
335 | 1119 |
]. |
1120 |
bytesPerRow := (width * (bitsPerSample at:1) + 7) // 8. |
|
135 | 1121 |
]. |
1122 |
||
1123 |
stripByteCounts isNil ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1124 |
^ self fileFormatError:'currently require stripByteCounts'. |
135 | 1125 |
]. |
1126 |
||
335 | 1127 |
"/ 'TIFFReader: decompressing LZW ...' infoPrintNL. |
135 | 1128 |
|
1037
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1129 |
overAllBytes := bytesPerRow * height. |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1130 |
bytesPerRow == width ifTrue:[ |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1131 |
data := ByteArray uninitializedNew:overAllBytes. |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1132 |
] ifFalse:[ |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1133 |
data := ByteArray new:overAllBytes. |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1134 |
]. |
135 | 1135 |
|
1136 |
offset := 1. |
|
1137 |
stripNr := 0. |
|
1138 |
||
1139 |
row := 1. |
|
1140 |
bytesPerStrip := bytesPerRow * rowsPerStrip. |
|
1141 |
prevSize := 0. |
|
1142 |
[row <= height] whileTrue:[ |
|
335 | 1143 |
stripNr := stripNr + 1. |
1702
75a595a70c86
stream position is going to be 0-based soon
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
1144 |
self positionToStrip:stripNr. |
335 | 1145 |
nBytes := stripByteCounts at:stripNr. |
1146 |
(nBytes > prevSize) ifTrue:[ |
|
1147 |
compressedStrip := ByteArray uninitializedNew:nBytes. |
|
1148 |
prevSize := nBytes |
|
1149 |
]. |
|
3974 | 1150 |
inStream nextBytes:nBytes into:compressedStrip. |
1151 |
self class |
|
1152 |
decompressLZWFrom:compressedStrip count:nBytes |
|
1153 |
into:data startingAt:offset. |
|
335 | 1154 |
offset := offset + bytesPerStrip. |
1155 |
row := row + rowsPerStrip |
|
135 | 1156 |
]. |
1157 |
||
1158 |
(predictor == 2) ifTrue:[ |
|
335 | 1159 |
self class decodeDelta:3 in:data width:width height:height |
135 | 1160 |
] |
335 | 1161 |
|
3974 | 1162 |
"Modified: / 24-08-2017 / 20:58:59 / cg" |
1163 |
"Modified (format): / 24-08-2017 / 22:16:41 / cg" |
|
135 | 1164 |
! |
1165 |
||
1166 |
readNeXTJPEGTiffImageData |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1167 |
^ self fileFormatError:'next jpeg compression not implemented'. |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1168 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1169 |
"Modified: / 3.2.1998 / 18:10:45 / cg" |
135 | 1170 |
! |
1171 |
||
1172 |
readNeXTRLE2TiffImageData |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1173 |
^ self fileFormatError:'next 2bit rle compression not implemented'. |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1174 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1175 |
"Modified: / 3.2.1998 / 18:10:54 / cg" |
135 | 1176 |
! |
1177 |
||
1826 | 1178 |
readNewJPEGTiffImageData |
1179 |
^ self fileFormatError:'new jpeg compression not implemented'. |
|
1180 |
! |
|
1181 |
||
135 | 1182 |
readPackbitsTiffImageData |
744 | 1183 |
"this has only been tested with monochrome images" |
1184 |
||
1185 |
|bytesPerRow bitsPerRow nPlanes |
|
1186 |
stripNr "{ Class: SmallInteger }" |
|
1187 |
offset "{ Class: SmallInteger }" |
|
1188 |
row "{ Class: SmallInteger }" |
|
1189 |
nBytes "{ Class: SmallInteger }" |
|
1190 |
nDecompressedBytes "{ Class: SmallInteger }" |
|
1191 |
bitsPerPixel overAllBytes buffer| |
|
1192 |
||
1193 |
nPlanes := samplesPerPixel. |
|
1194 |
||
1195 |
"only support 1-sample/pixel, |
|
1196 |
with alpha - if separate planes, |
|
1197 |
or rgb - if non separate planes and no alpha" |
|
135 | 1198 |
|
744 | 1199 |
(nPlanes == 2) ifTrue:[ |
1200 |
(planarConfiguration ~~ 2) ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1201 |
^ self fileFormatError:'with alpha, only separate planes supported'. |
744 | 1202 |
]. |
1203 |
'TIFFReader [info]: ignoring alpha plane' infoPrintCR. |
|
1204 |
nPlanes := 1. |
|
1205 |
bitsPerPixel := bitsPerSample at:1. |
|
1206 |
bitsPerSample := Array with:bitsPerPixel. |
|
1207 |
samplesPerPixel := 1. |
|
1208 |
] ifFalse:[ |
|
1209 |
(nPlanes == 3) ifTrue:[ |
|
1210 |
(planarConfiguration ~~ 1) ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1211 |
^ self fileFormatError:'only non separate planes supported'. |
744 | 1212 |
]. |
1213 |
bitsPerSample ~= #(8 8 8) ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1214 |
^ self fileFormatError:'only 8/8/8 rgb images supported'. |
744 | 1215 |
]. |
1216 |
bitsPerPixel := 24 |
|
1217 |
] ifFalse:[ |
|
1218 |
(nPlanes ~~ 1) ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1219 |
^ self fileFormatError:'format not supported'. |
744 | 1220 |
]. |
1221 |
bitsPerPixel := bitsPerSample at:1. |
|
1222 |
] |
|
1223 |
]. |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1224 |
|
744 | 1225 |
bitsPerRow := width * bitsPerPixel. |
1226 |
bytesPerRow := bitsPerRow // 8. |
|
1227 |
((bitsPerRow \\ 8) ~~ 0) ifTrue:[ |
|
1228 |
bytesPerRow := bytesPerRow + 1 |
|
1229 |
]. |
|
1230 |
||
1231 |
overAllBytes := bytesPerRow * height. |
|
1037
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1232 |
bytesPerRow == width ifTrue:[ |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1233 |
data := ByteArray uninitializedNew:overAllBytes. |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1234 |
] ifFalse:[ |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1235 |
data := ByteArray new:overAllBytes. |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1236 |
]. |
744 | 1237 |
|
1238 |
offset := 1. |
|
1239 |
stripNr := 0. |
|
1240 |
||
1241 |
buffer := nil. |
|
1242 |
row := 1. |
|
1243 |
[row <= height] whileTrue:[ |
|
1244 |
stripNr := stripNr + 1. |
|
1245 |
nBytes := stripByteCounts at:stripNr. |
|
1702
75a595a70c86
stream position is going to be 0-based soon
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
1246 |
self positionToStrip:stripNr. |
744 | 1247 |
|
1248 |
nBytes > buffer size ifTrue:[ |
|
1249 |
"/ realloc |
|
1250 |
buffer := ByteArray uninitializedNew:nBytes. |
|
1251 |
]. |
|
1252 |
inStream nextBytes:nBytes into:buffer. |
|
1253 |
||
3382 | 1254 |
nDecompressedBytes := self class decompressPackBits:nBytes from:buffer to:data startingAt:offset. |
744 | 1255 |
|
1256 |
offset := offset + nDecompressedBytes. |
|
1257 |
row := row + rowsPerStrip |
|
1258 |
] |
|
1259 |
||
1037
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1260 |
"Modified: / 12.8.1998 / 13:57:34 / cg" |
135 | 1261 |
! |
1262 |
||
516 | 1263 |
readPixarFilmTiffImageData |
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1264 |
^ self fileFormatError:'pixar film compression not implemented'. |
135 | 1265 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1266 |
"Modified: / 3.2.1998 / 18:11:45 / cg" |
516 | 1267 |
! |
1268 |
||
1269 |
readPixarLogTiffImageData |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1270 |
^ self fileFormatError:'pixar log compression not implemented'. |
0 | 1271 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1272 |
"Modified: / 3.2.1998 / 18:11:53 / cg" |
516 | 1273 |
! |
135 | 1274 |
|
516 | 1275 |
readThunderScanTiffImageData |
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1276 |
^ self fileFormatError:'thunderScan compression not implemented' . |
516 | 1277 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1278 |
"Modified: / 3.2.1998 / 18:12:01 / cg" |
516 | 1279 |
! |
135 | 1280 |
|
516 | 1281 |
readTiffImageData |
1282 |
(compression == 1) ifTrue:[ |
|
1283 |
^ self readUncompressedTiffImageData. |
|
1284 |
]. |
|
1285 |
(compression == 2) ifTrue:[ |
|
1286 |
^ self readCCITT3RLETiffImageData. |
|
1287 |
]. |
|
1288 |
(compression == 3) ifTrue:[ |
|
1289 |
^ self readCCITTGroup3TiffImageData. |
|
1290 |
]. |
|
1291 |
(compression == 4) ifTrue:[ |
|
1292 |
^ self readCCITTGroup4TiffImageData. |
|
1293 |
]. |
|
1294 |
(compression == 5) ifTrue:[ |
|
1295 |
^ self readLZWTiffImageData. |
|
1296 |
]. |
|
1297 |
(compression == 6) ifTrue:[ |
|
1298 |
^ self readJPEGTiffImageData. |
|
1299 |
]. |
|
1300 |
(compression == 7) ifTrue:[ |
|
1301 |
^ self readNewJPEGTiffImageData. |
|
1302 |
]. |
|
1303 |
||
1304 |
(compression == 32766) ifTrue:[ |
|
1305 |
^ self readNeXTRLE2TiffImageData. |
|
1306 |
]. |
|
1307 |
(compression == 32771) ifTrue:[ |
|
1308 |
^ self readCCITTRLEWTiffImageData. |
|
135 | 1309 |
]. |
516 | 1310 |
(compression == 32773) ifTrue:[ |
1311 |
^ self readPackbitsTiffImageData. |
|
1312 |
]. |
|
1313 |
(compression == 32809) ifTrue:[ |
|
1314 |
^ self readThunderScanTiffImageData. |
|
1315 |
]. |
|
1316 |
(compression == 32908) ifTrue:[ |
|
1317 |
^ self readPixarFilmTiffImageData. |
|
1318 |
]. |
|
1319 |
(compression == 32909) ifTrue:[ |
|
1320 |
^ self readPixarLogTiffImageData. |
|
1321 |
]. |
|
1322 |
(compression == 32946) ifTrue:[ |
|
1323 |
^ self readDeflateTiffImageData. |
|
1324 |
]. |
|
1325 |
(compression == 32947) ifTrue:[ |
|
1326 |
^ self readDCSTiffImageData. |
|
1327 |
]. |
|
1328 |
(compression == 32865) ifTrue:[ |
|
1329 |
^ self readNeXTJPEGTiffImageData. |
|
1330 |
]. |
|
1331 |
(compression == 34661) ifTrue:[ |
|
1332 |
^ self readJBIGTiffImageData. |
|
1333 |
]. |
|
1334 |
||
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1335 |
^ self fileFormatError:('compression type ' , compression printString , ' not known'). |
516 | 1336 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1337 |
"Created: / 11.4.1997 / 00:19:44 / cg" |
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1338 |
"Modified: / 3.2.1998 / 18:12:36 / cg" |
135 | 1339 |
! |
1340 |
||
3975 | 1341 |
readTiledTiffImageData |
1342 |
(compression == 1) ifTrue:[ |
|
1343 |
^ self readTiledUncompressedTiffImageData. |
|
1344 |
]. |
|
1345 |
(compression == 5) ifTrue:[ |
|
1346 |
^ self readTiledLZWTiffImageData. |
|
1347 |
]. |
|
1348 |
||
1349 |
^ self fileFormatError:('compression type ' , compression printString , ' not known'). |
|
1350 |
||
1351 |
"Created: / 25-08-2017 / 00:19:14 / cg" |
|
1352 |
! |
|
1353 |
||
1354 |
readTiledUncompressedTiffImageData |
|
1355 |
|bytesPerRow "{ Class: SmallInteger }" |
|
1356 |
bitsPerRow "{ Class: SmallInteger }" |
|
1357 |
nPlanes |
|
1358 |
stripNr "{ Class: SmallInteger }" |
|
1359 |
offset "{ Class: SmallInteger }" |
|
1360 |
row "{ Class: SmallInteger }" |
|
1361 |
nBytes "{ Class: SmallInteger }" |
|
1362 |
bitsPerPixel |
|
1363 |
overAllBytes "{ Class: SmallInteger }" |
|
1364 |
where "{ Class: SmallInteger }" |
|
1365 |
stripPos |
|
1366 |
tileWidth tileLength tileOffsets tileByteCounts| |
|
1367 |
||
1368 |
tileWidth := metaData at:#TileWidth. |
|
1369 |
tileLength := metaData at:#TileLength. |
|
1370 |
tileOffsets := metaData at:#TileOffsets. |
|
1371 |
tileByteCounts := metaData at:#TileByteCounts. |
|
1372 |
self halt. |
|
1373 |
nPlanes := samplesPerPixel. |
|
1374 |
||
1375 |
"/ not all formats are supported here, |
|
1376 |
||
1377 |
(nPlanes == 2) ifTrue:[ |
|
1378 |
(planarConfiguration ~~ 2) ifTrue:[ |
|
1379 |
^ self fileFormatError:'with alpha, only separate planes supported'. |
|
1380 |
]. |
|
1381 |
'TIFFReader [info]: ignoring alpha plane' infoPrintCR. |
|
1382 |
nPlanes := 1. |
|
1383 |
bitsPerPixel := bitsPerSample at:1. |
|
1384 |
bitsPerSample := Array with:bitsPerPixel. |
|
1385 |
samplesPerPixel := 1. |
|
1386 |
] ifFalse:[ |
|
1387 |
(nPlanes == 4) ifTrue:[ |
|
1388 |
(planarConfiguration ~~ 1) ifTrue:[ |
|
1389 |
^ self fileFormatError:'only non separate planes supported'. |
|
1390 |
]. |
|
1391 |
bitsPerSample ~= #(8 8 8 8) ifTrue:[ |
|
1392 |
^ self fileFormatError:'only 8/8/8/8 cmyk images supported'. |
|
1393 |
]. |
|
1394 |
bitsPerPixel := 32. |
|
1395 |
] ifFalse:[ |
|
1396 |
(nPlanes == 3) ifTrue:[ |
|
1397 |
(planarConfiguration ~~ 1) ifTrue:[ |
|
1398 |
^ self fileFormatError:'only non separate planes supported'. |
|
1399 |
]. |
|
1400 |
bitsPerSample ~= #(8 8 8) ifTrue:[ |
|
1401 |
^ self fileFormatError:'only 8/8/8 rgb images supported (is: ' , bitsPerSample printString , ')'. |
|
1402 |
]. |
|
1403 |
bitsPerPixel := 24 |
|
1404 |
] ifFalse:[ |
|
1405 |
(nPlanes ~~ 1) ifTrue:[ |
|
1406 |
^ self fileFormatError:('unsupported format: nplanes=' , nPlanes printString). |
|
1407 |
]. |
|
1408 |
bitsPerPixel := bitsPerSample at:1. |
|
1409 |
] |
|
1410 |
] |
|
1411 |
]. |
|
1412 |
||
1413 |
bitsPerRow := width * bitsPerPixel. |
|
1414 |
bytesPerRow := bitsPerRow // 8. |
|
1415 |
((bitsPerRow \\ 8) ~~ 0) ifTrue:[ |
|
1416 |
bytesPerRow := bytesPerRow + 1 |
|
1417 |
]. |
|
1418 |
||
1419 |
overAllBytes := bytesPerRow * height. |
|
1420 |
bytesPerRow == width ifTrue:[ |
|
1421 |
data := ByteArray uninitializedNew:overAllBytes. |
|
1422 |
] ifFalse:[ |
|
1423 |
data := ByteArray new:overAllBytes. |
|
1424 |
]. |
|
1425 |
||
1426 |
offset := 0. |
|
1427 |
stripNr := 0. |
|
1428 |
where := -1. |
|
1429 |
row := 1. |
|
1430 |
[row <= height] whileTrue:[ |
|
1431 |
stripNr := stripNr + 1. |
|
1432 |
nBytes := stripByteCounts at:stripNr. |
|
1433 |
stripPos := stripOffsets at:stripNr. |
|
1434 |
where ~~ stripPos ifTrue:[ |
|
1435 |
inStream position:stripPos. |
|
1436 |
where := stripPos. |
|
1437 |
]. |
|
1438 |
||
1439 |
offset + nBytes > overAllBytes ifTrue:[ |
|
1440 |
nBytes := overAllBytes - offset. |
|
1441 |
]. |
|
1442 |
||
1443 |
"/ read it 4k-wise; this leads to a better behavior, |
|
1444 |
"/ when reading big images from a slow device (such as a cdrom) |
|
1445 |
inStream nextBytes:nBytes into:data startingAt:offset+1 blockSize:4096. |
|
1446 |
||
1447 |
offset := offset + nBytes. |
|
1448 |
row := row + rowsPerStrip. |
|
1449 |
where := where + nBytes. |
|
1450 |
]. |
|
1451 |
||
1452 |
"Created: / 25-08-2017 / 00:22:31 / cg" |
|
1453 |
! |
|
1454 |
||
135 | 1455 |
readUncompressedTiffImageData |
3610 | 1456 |
|bytesPerRow "{ Class: SmallInteger }" |
1457 |
bitsPerRow "{ Class: SmallInteger }" |
|
1458 |
nPlanes |
|
135 | 1459 |
stripNr "{ Class: SmallInteger }" |
1460 |
offset "{ Class: SmallInteger }" |
|
1461 |
row "{ Class: SmallInteger }" |
|
1462 |
nBytes "{ Class: SmallInteger }" |
|
3610 | 1463 |
bitsPerPixel |
1464 |
overAllBytes "{ Class: SmallInteger }" |
|
1465 |
where "{ Class: SmallInteger }" |
|
1466 |
stripPos | |
|
135 | 1467 |
|
1468 |
nPlanes := samplesPerPixel. |
|
1469 |
||
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1470 |
"/ not all formats are supported here, |
135 | 1471 |
|
1472 |
(nPlanes == 2) ifTrue:[ |
|
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1473 |
(planarConfiguration ~~ 2) ifTrue:[ |
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1474 |
^ self fileFormatError:'with alpha, only separate planes supported'. |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1475 |
]. |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1476 |
'TIFFReader [info]: ignoring alpha plane' infoPrintCR. |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1477 |
nPlanes := 1. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1478 |
bitsPerPixel := bitsPerSample at:1. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1479 |
bitsPerSample := Array with:bitsPerPixel. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1480 |
samplesPerPixel := 1. |
135 | 1481 |
] ifFalse:[ |
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1482 |
(nPlanes == 4) ifTrue:[ |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1483 |
(planarConfiguration ~~ 1) ifTrue:[ |
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1484 |
^ self fileFormatError:'only non separate planes supported'. |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1485 |
]. |
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1486 |
bitsPerSample ~= #(8 8 8 8) ifTrue:[ |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1487 |
^ self fileFormatError:'only 8/8/8/8 cmyk images supported'. |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1488 |
]. |
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1489 |
bitsPerPixel := 32. |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1490 |
] ifFalse:[ |
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1491 |
(nPlanes == 3) ifTrue:[ |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1492 |
(planarConfiguration ~~ 1) ifTrue:[ |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1493 |
^ self fileFormatError:'only non separate planes supported'. |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1494 |
]. |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1495 |
bitsPerSample ~= #(8 8 8) ifTrue:[ |
1785
16917d309b46
oops - position incompatibility fixed
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
1496 |
^ self fileFormatError:'only 8/8/8 rgb images supported (is: ' , bitsPerSample printString , ')'. |
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1497 |
]. |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1498 |
bitsPerPixel := 24 |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1499 |
] ifFalse:[ |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1500 |
(nPlanes ~~ 1) ifTrue:[ |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1501 |
^ self fileFormatError:('unsupported format: nplanes=' , nPlanes printString). |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1502 |
]. |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1503 |
bitsPerPixel := bitsPerSample at:1. |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1504 |
] |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1505 |
] |
0 | 1506 |
]. |
135 | 1507 |
|
1508 |
bitsPerRow := width * bitsPerPixel. |
|
1509 |
bytesPerRow := bitsPerRow // 8. |
|
1510 |
((bitsPerRow \\ 8) ~~ 0) ifTrue:[ |
|
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1511 |
bytesPerRow := bytesPerRow + 1 |
135 | 1512 |
]. |
1513 |
||
1514 |
overAllBytes := bytesPerRow * height. |
|
1037
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1515 |
bytesPerRow == width ifTrue:[ |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1516 |
data := ByteArray uninitializedNew:overAllBytes. |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1517 |
] ifFalse:[ |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1518 |
data := ByteArray new:overAllBytes. |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1519 |
]. |
135 | 1520 |
|
336
9789b02d95bf
oops - the very last pixel was not read (in readUncompressed ...)
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1521 |
offset := 0. |
135 | 1522 |
stripNr := 0. |
3610 | 1523 |
where := -1. |
135 | 1524 |
row := 1. |
1525 |
[row <= height] whileTrue:[ |
|
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1526 |
stripNr := stripNr + 1. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1527 |
nBytes := stripByteCounts at:stripNr. |
3610 | 1528 |
stripPos := stripOffsets at:stripNr. |
1529 |
where ~~ stripPos ifTrue:[ |
|
1530 |
inStream position:stripPos. |
|
1531 |
where := stripPos. |
|
1532 |
]. |
|
1533 |
||
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1534 |
offset + nBytes > overAllBytes ifTrue:[ |
336
9789b02d95bf
oops - the very last pixel was not read (in readUncompressed ...)
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1535 |
nBytes := overAllBytes - offset. |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1536 |
]. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1537 |
|
563
38cbee875bfa
read data in blocks - better if images are read from a CD
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
1538 |
"/ read it 4k-wise; this leads to a better behavior, |
1748 | 1539 |
"/ when reading big images from a slow device (such as a cdrom) |
563
38cbee875bfa
read data in blocks - better if images are read from a CD
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
1540 |
inStream nextBytes:nBytes into:data startingAt:offset+1 blockSize:4096. |
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1541 |
|
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1542 |
offset := offset + nBytes. |
3610 | 1543 |
row := row + rowsPerStrip. |
1544 |
where := where + nBytes. |
|
1748 | 1545 |
]. |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1546 |
|
1037
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1547 |
"Modified: / 12.8.1998 / 13:57:14 / cg" |
440 | 1548 |
! ! |
1549 |
||
1762 | 1550 |
!TIFFReader methodsFor:'private-reading'! |
516 | 1551 |
|
1702
75a595a70c86
stream position is going to be 0-based soon
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
1552 |
positionToStrip:stripNr |
3211 | 1553 |
inStream position:(stripOffsets at:stripNr). |
1702
75a595a70c86
stream position is going to be 0-based soon
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
1554 |
! |
75a595a70c86
stream position is going to be 0-based soon
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
1555 |
|
1838
2476baed377c
make it compilable with old stc's, which do not care for the signed keyword.
Claus Gittinger <cg@exept.de>
parents:
1830
diff
changeset
|
1556 |
readBytes:n signed:isSigned |
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1557 |
"read n 8bit signed or unsigned integers and return them in an array or byteArray" |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1558 |
|
3975 | 1559 |
|oldPos offset bytes nInline| |
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1560 |
|
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1561 |
n == 0 ifTrue:[^ '']. |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1562 |
|
3975 | 1563 |
nInline := isBigTiff ifTrue:[8] ifFalse:[4]. |
1838
2476baed377c
make it compilable with old stc's, which do not care for the signed keyword.
Claus Gittinger <cg@exept.de>
parents:
1830
diff
changeset
|
1564 |
bytes := (isSigned ifTrue:[Array] ifFalse:[ByteArray]) new:n. |
3975 | 1565 |
(n <= nInline) ifTrue:[ |
1838
2476baed377c
make it compilable with old stc's, which do not care for the signed keyword.
Claus Gittinger <cg@exept.de>
parents:
1830
diff
changeset
|
1566 |
isSigned ifTrue:[ |
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1567 |
1 to:n do:[:i | bytes at:i put:(inStream nextSignedByte) ]. |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1568 |
] ifFalse:[ |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1569 |
inStream nextBytes:n into:bytes. |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1570 |
]. |
3975 | 1571 |
(n < nInline) ifTrue:[ |
1572 |
inStream skip:(nInline - n). |
|
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1573 |
] |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1574 |
] ifFalse:[ |
3552 | 1575 |
offset := inStream nextInt32MSB:(byteOrder ~~ #lsb). |
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1576 |
oldPos := inStream position. |
3211 | 1577 |
inStream position:offset. |
1838
2476baed377c
make it compilable with old stc's, which do not care for the signed keyword.
Claus Gittinger <cg@exept.de>
parents:
1830
diff
changeset
|
1578 |
isSigned ifTrue:[ |
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1579 |
1 to:n do:[:i | bytes at:i put:(inStream nextSignedByte) ]. |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1580 |
] ifFalse:[ |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1581 |
inStream nextBytes:n into:bytes. |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1582 |
]. |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1583 |
inStream position:oldPos |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1584 |
]. |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1585 |
^ bytes |
3975 | 1586 |
|
1587 |
"Modified: / 24-08-2017 / 23:25:30 / cg" |
|
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1588 |
! |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1589 |
|
516 | 1590 |
readChars:n |
1591 |
"read n characters and return them in a string" |
|
1592 |
||
3975 | 1593 |
|oldPos offset string nInline| |
516 | 1594 |
|
1595 |
n == 0 ifTrue:[^ '']. |
|
1596 |
||
3975 | 1597 |
nInline := isBigTiff ifTrue:[8] ifFalse:[4]. |
1598 |
||
516 | 1599 |
string := String new:(n - 1). |
3975 | 1600 |
(n <= nInline) ifTrue:[ |
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1601 |
inStream nextBytes:(n - 1) into:string. |
3975 | 1602 |
(n < nInline) ifTrue:[ |
1603 |
inStream skip:(nInline - n). |
|
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1604 |
] |
516 | 1605 |
] ifFalse:[ |
3552 | 1606 |
offset := inStream nextInt32MSB:(byteOrder ~~ #lsb). |
516 | 1607 |
oldPos := inStream position. |
3211 | 1608 |
inStream position:offset. |
516 | 1609 |
inStream nextBytes:(n - 1) into:string. |
1610 |
inStream position:oldPos |
|
1611 |
]. |
|
1612 |
^ string |
|
1613 |
||
3975 | 1614 |
"Modified: / 24-08-2017 / 23:25:03 / cg" |
516 | 1615 |
! |
1616 |
||
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1617 |
readDoubles:nFloats |
3112 | 1618 |
"read nFloats IEEE 64bit doubles and return them in an array" |
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1619 |
|
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1620 |
|oldPos offset values val msb |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1621 |
n "{ Class: SmallInteger }" | |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1622 |
|
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1623 |
n := nFloats. |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1624 |
|
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1625 |
msb := byteOrder ~~ #lsb. |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1626 |
values := DoubleArray basicNew:n. |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1627 |
(n == 1) ifTrue:[ |
3112 | 1628 |
val := Float readBinaryIEEEDoubleFrom:inStream MSB:msb. |
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1629 |
values at:1 put:val. |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1630 |
] ifFalse:[ |
3552 | 1631 |
offset := inStream nextInt32MSB:msb. |
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1632 |
oldPos := inStream position. |
3211 | 1633 |
inStream position:offset. |
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1634 |
1 to:n do:[:index | |
3112 | 1635 |
val := Float readBinaryIEEEDoubleFrom:inStream MSB:msb. |
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1636 |
values at:index put:val |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1637 |
]. |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1638 |
inStream position:oldPos |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1639 |
]. |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1640 |
^ values |
3975 | 1641 |
|
1642 |
"Modified: / 24-08-2017 / 23:28:22 / cg" |
|
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1643 |
! |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1644 |
|
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1645 |
readFloats:nFloats |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1646 |
"read nFloats IEEE 32bit floats and return them in an array" |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1647 |
|
3975 | 1648 |
|oldPos offset values val val1 val2 msb |
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1649 |
n "{ Class: SmallInteger }" | |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1650 |
|
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1651 |
n := nFloats. |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1652 |
|
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1653 |
msb := byteOrder ~~ #lsb. |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1654 |
values := FloatArray basicNew:n. |
3975 | 1655 |
(isBigTiff and:[ n == 2 ]) ifTrue:[ |
1656 |
val1 := ShortFloat readBinaryIEEESingleFrom:inStream MSB:msb. |
|
1657 |
val2 := ShortFloat readBinaryIEEESingleFrom:inStream MSB:msb. |
|
1658 |
values at:1 put:val1. |
|
1659 |
n == 2 ifTrue:[ |
|
1660 |
values at:2 put:val2. |
|
1661 |
]. |
|
1662 |
] ifFalse:[ |
|
1663 |
(n == 1) ifTrue:[ |
|
3112 | 1664 |
val := ShortFloat readBinaryIEEESingleFrom:inStream MSB:msb. |
3975 | 1665 |
values at:1 put:val. |
1666 |
] ifFalse:[ |
|
1667 |
offset := inStream nextInt32MSB:msb. |
|
1668 |
oldPos := inStream position. |
|
1669 |
inStream position:offset. |
|
1670 |
1 to:n do:[:index | |
|
1671 |
val := ShortFloat readBinaryIEEESingleFrom:inStream MSB:msb. |
|
1672 |
values at:index put:val |
|
1673 |
]. |
|
1674 |
inStream position:oldPos |
|
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1675 |
]. |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1676 |
]. |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1677 |
^ values |
3975 | 1678 |
|
1679 |
"Modified: / 24-08-2017 / 23:36:39 / cg" |
|
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1680 |
! |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1681 |
|
1838
2476baed377c
make it compilable with old stc's, which do not care for the signed keyword.
Claus Gittinger <cg@exept.de>
parents:
1830
diff
changeset
|
1682 |
readFracts:nFracts signed:isSigned |
516 | 1683 |
"read nFracts fractions (2 32bit words) and return them in an array" |
1684 |
||
1685 |
|oldPos offset values numerator denominator msb |
|
1686 |
n "{ Class: SmallInteger }" | |
|
1687 |
||
1688 |
n := nFracts. |
|
1689 |
||
1690 |
msb := byteOrder ~~ #lsb. |
|
1691 |
values := Array basicNew:n. |
|
3552 | 1692 |
offset := inStream nextInt32MSB:msb. |
516 | 1693 |
oldPos := inStream position. |
3211 | 1694 |
inStream position:offset. |
516 | 1695 |
1 to:n do:[:index | |
3552 | 1696 |
numerator := isSigned ifTrue:[inStream nextInt32MSB:msb] ifFalse:[inStream nextUnsignedInt32MSB:msb]. |
1697 |
denominator := isSigned ifTrue:[inStream nextInt32MSB:msb] ifFalse:[inStream nextUnsignedInt32MSB:msb]. |
|
1702
75a595a70c86
stream position is going to be 0-based soon
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
1698 |
values at:index put:(Fraction numerator:numerator denominator:denominator) |
516 | 1699 |
]. |
1700 |
inStream position:oldPos. |
|
1701 |
^ values |
|
1702 |
! |
|
1703 |
||
3974 | 1704 |
readLong8s:nLongs signed:isSigned |
1705 |
"read nLongs signed or unsigned long8 numbers (64bit) and return them in an array" |
|
1706 |
||
1707 |
|oldPos offset values val msb |
|
1708 |
n "{ Class: SmallInteger }" | |
|
1709 |
||
1710 |
n := nLongs. |
|
1711 |
||
1712 |
msb := byteOrder ~~ #lsb. |
|
1713 |
values := Array basicNew:n. |
|
1714 |
(n == 1) ifTrue:[ |
|
1715 |
val := isSigned ifTrue:[inStream nextInt64MSB:msb] ifFalse:[inStream nextUnsignedInt64MSB:msb]. |
|
1716 |
values at:1 put:val. |
|
1717 |
] ifFalse:[ |
|
1718 |
offset := inStream nextInt64MSB:msb. |
|
1719 |
oldPos := inStream position. |
|
1720 |
inStream position:offset. |
|
1721 |
1 to:n do:[:index | |
|
1722 |
val := isSigned ifTrue:[inStream nextInt64MSB:msb] ifFalse:[inStream nextUnsignedInt64MSB:msb]. |
|
1723 |
values at:index put:val |
|
1724 |
]. |
|
1725 |
inStream position:oldPos |
|
1726 |
]. |
|
1727 |
^ values |
|
1728 |
||
1729 |
"Created: / 24-08-2017 / 22:01:26 / cg" |
|
1730 |
! |
|
1731 |
||
1838
2476baed377c
make it compilable with old stc's, which do not care for the signed keyword.
Claus Gittinger <cg@exept.de>
parents:
1830
diff
changeset
|
1732 |
readLongs:nLongs signed:isSigned |
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1733 |
"read nLongs signed or unsigned long numbers (32bit) and return them in an array" |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1734 |
|
3975 | 1735 |
|oldPos offset values val val1 val2 msb |
516 | 1736 |
n "{ Class: SmallInteger }" | |
1737 |
||
1738 |
n := nLongs. |
|
1739 |
||
1740 |
msb := byteOrder ~~ #lsb. |
|
1741 |
values := Array basicNew:n. |
|
3975 | 1742 |
(isBigTiff and:[ n <= 2 ]) ifTrue:[ |
1743 |
val1 := isSigned ifTrue:[inStream nextInt32MSB:msb] ifFalse:[inStream nextUnsignedInt32MSB:msb]. |
|
1744 |
val2 := isSigned ifTrue:[inStream nextInt32MSB:msb] ifFalse:[inStream nextUnsignedInt32MSB:msb]. |
|
1745 |
values at:1 put:val1. |
|
1746 |
n == 2 ifTrue:[ |
|
1747 |
values at:2 put:val2. |
|
1748 |
]. |
|
516 | 1749 |
] ifFalse:[ |
3975 | 1750 |
(n == 1) ifTrue:[ |
3552 | 1751 |
val := isSigned ifTrue:[inStream nextInt32MSB:msb] ifFalse:[inStream nextUnsignedInt32MSB:msb]. |
3975 | 1752 |
values at:1 put:val. |
1753 |
] ifFalse:[ |
|
1754 |
offset := inStream nextInt32MSB:msb. |
|
1755 |
oldPos := inStream position. |
|
1756 |
inStream position:offset. |
|
1757 |
1 to:n do:[:index | |
|
1758 |
val := isSigned ifTrue:[inStream nextInt32MSB:msb] ifFalse:[inStream nextUnsignedInt32MSB:msb]. |
|
1759 |
values at:index put:val |
|
1760 |
]. |
|
1761 |
inStream position:oldPos |
|
1702
75a595a70c86
stream position is going to be 0-based soon
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
1762 |
]. |
516 | 1763 |
]. |
1764 |
^ values |
|
3975 | 1765 |
|
1766 |
"Modified: / 24-08-2017 / 23:35:38 / cg" |
|
516 | 1767 |
! |
1768 |
||
1838
2476baed377c
make it compilable with old stc's, which do not care for the signed keyword.
Claus Gittinger <cg@exept.de>
parents:
1830
diff
changeset
|
1769 |
readShorts:nShorts signed:isSigned |
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1770 |
"read nShorts signed or unsigned short numbers (16bit) and return them in an array" |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1771 |
|
3975 | 1772 |
|oldPos offset values msb val1 val2 val3 val4 |
516 | 1773 |
n "{ Class: SmallInteger }" | |
1774 |
||
1775 |
n := nShorts. |
|
1776 |
||
1777 |
msb := (byteOrder ~~ #lsb). |
|
1778 |
values := Array basicNew:n. |
|
3975 | 1779 |
(isBigTiff and:[ (n <= 4) ]) ifTrue:[ |
1838
2476baed377c
make it compilable with old stc's, which do not care for the signed keyword.
Claus Gittinger <cg@exept.de>
parents:
1830
diff
changeset
|
1780 |
isSigned ifTrue:[ |
3552 | 1781 |
val1 := inStream nextInt16MSB:msb. |
1782 |
val2 := inStream nextInt16MSB:msb. |
|
3975 | 1783 |
val3 := inStream nextInt16MSB:msb. |
1784 |
val4 := inStream nextInt16MSB:msb. |
|
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1785 |
] ifFalse:[ |
3552 | 1786 |
val1 := inStream nextUnsignedInt16MSB:msb. |
1787 |
val2 := inStream nextUnsignedInt16MSB:msb. |
|
3975 | 1788 |
val3 := inStream nextUnsignedInt16MSB:msb. |
1789 |
val4 := inStream nextUnsignedInt16MSB:msb. |
|
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1790 |
]. |
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1791 |
values at:1 put:val1. |
3975 | 1792 |
(n >= 2) ifTrue:[ |
1793 |
values at:2 put:val2. |
|
1794 |
(n >= 3) ifTrue:[ |
|
1795 |
values at:3 put:val3. |
|
1796 |
(n == 4) ifTrue:[ |
|
1797 |
values at:4 put:val4. |
|
1798 |
] |
|
1799 |
] |
|
1702
75a595a70c86
stream position is going to be 0-based soon
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
1800 |
] |
516 | 1801 |
] ifFalse:[ |
3975 | 1802 |
(n <= 2) ifTrue:[ |
1838
2476baed377c
make it compilable with old stc's, which do not care for the signed keyword.
Claus Gittinger <cg@exept.de>
parents:
1830
diff
changeset
|
1803 |
isSigned ifTrue:[ |
3552 | 1804 |
val1 := inStream nextInt16MSB:msb. |
3975 | 1805 |
val2 := inStream nextInt16MSB:msb. |
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1806 |
] ifFalse:[ |
3552 | 1807 |
val1 := inStream nextUnsignedInt16MSB:msb. |
3975 | 1808 |
val2 := inStream nextUnsignedInt16MSB:msb. |
1829
af94d3366af3
tiff6 tag values added (signed byte,....)
Claus Gittinger <cg@exept.de>
parents:
1827
diff
changeset
|
1809 |
]. |
3975 | 1810 |
values at:1 put:val1. |
1811 |
(n == 2) ifTrue:[ |
|
1812 |
values at:2 put:val2 |
|
1813 |
] |
|
1814 |
] ifFalse:[ |
|
1815 |
offset := inStream nextInt32MSB:msb. |
|
1816 |
oldPos := inStream position. |
|
1817 |
inStream position:offset. |
|
1818 |
1 to:n do:[:index | |
|
1819 |
isSigned ifTrue:[ |
|
1820 |
val1 := inStream nextInt16MSB:msb. |
|
1821 |
] ifFalse:[ |
|
1822 |
val1 := inStream nextUnsignedInt16MSB:msb. |
|
1823 |
]. |
|
1824 |
values at:index put:val1 |
|
1825 |
]. |
|
1826 |
inStream position:oldPos |
|
1702
75a595a70c86
stream position is going to be 0-based soon
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
1827 |
]. |
516 | 1828 |
]. |
1829 |
^ values |
|
3975 | 1830 |
|
1831 |
"Modified: / 24-08-2017 / 23:33:09 / cg" |
|
516 | 1832 |
! ! |
1833 |
||
1762 | 1834 |
!TIFFReader methodsFor:'private-writing'! |
135 | 1835 |
|
1836 |
writeBitsPerSample |
|
14 | 1837 |
" |
135 | 1838 |
'bitsPerSample: ' print. bitsPerSample printNewline. |
1839 |
'store bitspersample at: ' print. outStream position printNewline. |
|
14 | 1840 |
" |
3211 | 1841 |
bitsPerSamplePos := outStream position. |
135 | 1842 |
bitsPerSample do:[:n | |
1785
16917d309b46
oops - position incompatibility fixed
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
1843 |
self writeShort:n |
135 | 1844 |
] |
0 | 1845 |
! |
1846 |
||
1847 |
writeColorMap |
|
28 | 1848 |
|n| |
1849 |
||
3211 | 1850 |
colorMapPos := outStream position. |
35 | 1851 |
#(red green blue) do:[:component | |
440 | 1852 |
n := 0. |
1853 |
colorMap do:[:clr | |
|
1854 |
|entry| |
|
35 | 1855 |
|
440 | 1856 |
clr isNil ifTrue:[ |
1857 |
entry := 0 |
|
1858 |
] ifFalse:[ |
|
1859 |
entry := clr perform:component. |
|
1860 |
" |
|
1861 |
tiff map is 16 bit - scale from percent to 0..16rFFFF |
|
1862 |
" |
|
1863 |
entry := (entry * 16rFFFF / 100) rounded. |
|
1864 |
]. |
|
1865 |
self writeShort:entry. |
|
1866 |
n := n + 1 |
|
1867 |
]. |
|
1868 |
||
1869 |
" |
|
1870 |
fill to 256 entries |
|
1871 |
" |
|
1872 |
[n < 256] whileTrue:[ |
|
1873 |
self writeShort:0. |
|
1874 |
n := n + 1. |
|
1875 |
] |
|
0 | 1876 |
] |
440 | 1877 |
|
1878 |
"Modified: 20.2.1997 / 18:06:10 / cg" |
|
0 | 1879 |
! |
1880 |
||
1881 |
writeStripByteCounts |
|
3 | 1882 |
" |
0 | 1883 |
'stripByteCounts: ' print. stripByteCounts printNewline. |
1884 |
'store stripbytecounts at: ' print. outStream position printNewline. |
|
3 | 1885 |
" |
3211 | 1886 |
stripByteCountsPos := outStream position. |
0 | 1887 |
stripByteCounts do:[:c | |
1785
16917d309b46
oops - position incompatibility fixed
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
1888 |
self writeShort:c |
0 | 1889 |
] |
1890 |
! |
|
1891 |
||
135 | 1892 |
writeStripOffsets |
3 | 1893 |
" |
135 | 1894 |
'stripOffsets: ' print. stripOffsets printNewline. |
1895 |
'store stripoffsets at: ' print. outStream position printNewline. |
|
3 | 1896 |
" |
3211 | 1897 |
stripOffsetsPos := outStream position. |
135 | 1898 |
stripOffsets do:[:o | |
1785
16917d309b46
oops - position incompatibility fixed
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
1899 |
self writeLong:o |
0 | 1900 |
] |
1901 |
! |
|
1902 |
||
1903 |
writeTag:tagType |
|
1904 |
self writeTiffTag:tagType. |
|
1905 |
! |
|
1906 |
||
1907 |
writeTiffTag:tagType |
|
1908 |
|value valueArray numberType count address| |
|
1909 |
||
1910 |
count := 1. |
|
1911 |
address := nil. |
|
1912 |
(tagType == 253) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1913 |
"tiff class" |
0 | 1914 |
]. |
1915 |
(tagType == 254) ifTrue:[ |
|
1916 |
]. |
|
1917 |
(tagType == 255) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1918 |
"SubfileType" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1919 |
value := subFileType. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1920 |
numberType := #long. |
0 | 1921 |
]. |
1922 |
(tagType == 256) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1923 |
"ImageWidth" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1924 |
value := width. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1925 |
numberType := #short. |
0 | 1926 |
]. |
1927 |
(tagType == 257) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1928 |
"ImageHeight" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1929 |
value := height. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1930 |
numberType := #short. |
0 | 1931 |
]. |
1932 |
(tagType == 258) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1933 |
"bitspersample" |
1785
16917d309b46
oops - position incompatibility fixed
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
1934 |
address := bitsPerSamplePos. |
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1935 |
numberType := #short. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1936 |
count := bitsPerSample size. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1937 |
valueArray := bitsPerSample |
0 | 1938 |
]. |
1939 |
(tagType == 259) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1940 |
"compression" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1941 |
value := compression. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1942 |
numberType := #short. |
0 | 1943 |
]. |
1944 |
(tagType == 262) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1945 |
"photometric" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1946 |
(photometric == #whiteIs0) ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1947 |
value := 0 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1948 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1949 |
(photometric == #blackIs0) ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1950 |
value := 1 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1951 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1952 |
(photometric == #rgb) ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1953 |
value := 2 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1954 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1955 |
(photometric == #palette) ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1956 |
value := 3 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1957 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1958 |
(photometric == #transparency) ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1959 |
value := 4 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1960 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1961 |
self error:'bad photometric' mayProceed:true. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1962 |
] |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1963 |
] |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1964 |
] |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1965 |
] |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1966 |
]. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1967 |
numberType := #short. |
0 | 1968 |
]. |
1969 |
(tagType == 263) ifTrue:[ |
|
1970 |
]. |
|
1971 |
(tagType == 264) ifTrue:[ |
|
1972 |
]. |
|
1973 |
(tagType == 265) ifTrue:[ |
|
1974 |
]. |
|
1975 |
(tagType == 266) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1976 |
"fillOrder" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1977 |
(fillOrder == #msb) ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1978 |
value := 1 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1979 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1980 |
(fillOrder == #lsb) ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1981 |
value := 2 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1982 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1983 |
self error:'bad fillOrder' mayProceed:true |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1984 |
] |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1985 |
]. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1986 |
numberType := #short. |
0 | 1987 |
]. |
1988 |
(tagType == 269) ifTrue:[ |
|
1989 |
]. |
|
1990 |
(tagType == 270) ifTrue:[ |
|
1991 |
]. |
|
1992 |
(tagType == 271) ifTrue:[ |
|
1993 |
]. |
|
1994 |
(tagType == 272) ifTrue:[ |
|
1995 |
]. |
|
1996 |
(tagType == 273) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1997 |
"stripoffsets" |
1785
16917d309b46
oops - position incompatibility fixed
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
1998 |
address := stripOffsetsPos. |
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1999 |
numberType := #long. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2000 |
count := stripOffsets size. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2001 |
valueArray := stripOffsets |
0 | 2002 |
]. |
2003 |
(tagType == 274) ifTrue:[ |
|
2004 |
]. |
|
2005 |
(tagType == 277) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2006 |
"samplesPerPixel" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2007 |
value := samplesPerPixel. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2008 |
numberType := #short. |
0 | 2009 |
]. |
2010 |
(tagType == 278) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2011 |
"rowsperstrip" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2012 |
value := rowsPerStrip. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2013 |
numberType := #short. |
0 | 2014 |
]. |
2015 |
(tagType == 279) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2016 |
"stripbytecount" |
1785
16917d309b46
oops - position incompatibility fixed
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
2017 |
address := stripByteCountsPos. |
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2018 |
numberType := #short. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2019 |
count := stripByteCounts size. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2020 |
valueArray := stripByteCounts |
0 | 2021 |
]. |
2022 |
(tagType == 280) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2023 |
"min sample value" |
0 | 2024 |
]. |
2025 |
(tagType == 281) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2026 |
"max sample value" |
0 | 2027 |
]. |
2028 |
(tagType == 282) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2029 |
"x resolution" |
0 | 2030 |
]. |
2031 |
(tagType == 283) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2032 |
"y resolution" |
0 | 2033 |
]. |
2034 |
(tagType == 284) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2035 |
"planarconfig" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2036 |
value := planarConfiguration. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2037 |
numberType := #short. |
0 | 2038 |
]. |
2039 |
(tagType == 285) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2040 |
"pageName" |
0 | 2041 |
]. |
2042 |
(tagType == 286) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2043 |
"xPosition" |
0 | 2044 |
]. |
2045 |
(tagType == 287) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2046 |
"yPosition" |
0 | 2047 |
]. |
2048 |
(tagType == 288) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2049 |
"freeOffsets" |
0 | 2050 |
]. |
2051 |
(tagType == 289) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2052 |
"freeByteCounts" |
0 | 2053 |
]. |
2054 |
(tagType == 290) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2055 |
"grayResponceUnit" |
0 | 2056 |
]. |
2057 |
(tagType == 291) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2058 |
"grayResponceCurve" |
0 | 2059 |
]. |
2060 |
(tagType == 292) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2061 |
"group3options" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2062 |
value := group3options. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2063 |
numberType := #long. |
0 | 2064 |
]. |
2065 |
(tagType == 293) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2066 |
"group4options" |
0 | 2067 |
]. |
2068 |
(tagType == 296) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2069 |
"resolutionunit" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2070 |
^ self |
0 | 2071 |
]. |
2072 |
(tagType == 297) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2073 |
"pageNumber" |
0 | 2074 |
]. |
2075 |
(tagType == 300) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2076 |
"colorResponceUnit" |
0 | 2077 |
]. |
2078 |
(tagType == 301) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2079 |
"colorResponceCurve" |
0 | 2080 |
]. |
2081 |
(tagType == 306) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2082 |
"dateTime" |
0 | 2083 |
]. |
2084 |
(tagType == 315) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2085 |
"artist" |
0 | 2086 |
]. |
2087 |
(tagType == 317) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2088 |
"predictor" |
0 | 2089 |
]. |
2090 |
(tagType == 320) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2091 |
"colormap" |
1785
16917d309b46
oops - position incompatibility fixed
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
2092 |
address := colorMapPos. |
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2093 |
numberType := #short. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2094 |
count := 256 "(colorMap at:1) size" * 3. |
0 | 2095 |
]. |
2096 |
||
2097 |
(value isNil and:[address isNil]) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2098 |
self error:'unhandled tag' mayProceed:true. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2099 |
^ self |
0 | 2100 |
]. |
2101 |
||
14 | 2102 |
" |
0 | 2103 |
'tag:' print. tagType print. ' typ:' print. numberType print. |
2104 |
' len:' print. count print. |
|
2105 |
' val:' print. value printNewline. |
|
14 | 2106 |
" |
0 | 2107 |
|
2108 |
self writeShort:tagType. |
|
2109 |
numberType == #short ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2110 |
self writeShort:3. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2111 |
self writeLong:count. |
0 | 2112 |
] ifFalse:[ |
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2113 |
numberType == #long ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2114 |
self writeShort:4. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2115 |
self writeLong:count. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2116 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2117 |
numberType == #byte ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2118 |
self writeShort:1. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2119 |
self writeLong:count. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2120 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2121 |
self error:'bad numbertype' |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2122 |
] |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2123 |
] |
0 | 2124 |
]. |
2125 |
address notNil ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2126 |
(numberType == #long and:[count == 1]) ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2127 |
self writeLong:(valueArray at:1). |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2128 |
^ self |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2129 |
]. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2130 |
(numberType == #short and:[count <= 2]) ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2131 |
self writeShort:(valueArray at:1). |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2132 |
count == 2 ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2133 |
self writeShort:(valueArray at:2). |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2134 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2135 |
self writeShort:0 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2136 |
]. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2137 |
^ self |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2138 |
]. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2139 |
(numberType == #byte and:[count <= 4]) ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2140 |
outStream nextPut:(valueArray at:1). |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2141 |
count > 1 ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2142 |
outStream nextPut:(valueArray at:2). |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2143 |
count > 2 ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2144 |
outStream nextPut:(valueArray at:3). |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2145 |
count > 3 ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2146 |
outStream nextPut:(valueArray at:4). |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2147 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2148 |
outStream nextPut:0 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2149 |
]. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2150 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2151 |
outStream nextPut:0 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2152 |
]. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2153 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2154 |
outStream nextPut:0 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2155 |
]. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2156 |
^ self |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2157 |
]. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2158 |
self writeLong:address. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2159 |
^ self |
0 | 2160 |
]. |
2161 |
numberType == #short ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2162 |
self writeShort:value. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2163 |
self writeShort:0 |
0 | 2164 |
] ifFalse:[ |
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2165 |
numberType == #long ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2166 |
self writeLong:value |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2167 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2168 |
numberType == #byte ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2169 |
outStream nextPut:value. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2170 |
outStream nextPut:0. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2171 |
outStream nextPut:0. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2172 |
outStream nextPut:0. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2173 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2174 |
self error:'bad numbertype' |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2175 |
] |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2176 |
] |
0 | 2177 |
]. |
2178 |
! |
|
2179 |
||
135 | 2180 |
writeUncompressedBits |
2181 |
"write bits as one or multiple strips" |
|
2182 |
||
2183 |
|offs bytesPerRow nBytes |
|
2184 |
h "{ Class: SmallInteger }"| |
|
0 | 2185 |
|
135 | 2186 |
nBytes := data size. |
2187 |
nBytes < 16rFFFF ifTrue:[ |
|
3211 | 2188 |
stripOffsets := Array with:(outStream position). |
1703
5a08db3f0013
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
2189 |
stripByteCounts := Array with:nBytes. |
5a08db3f0013
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
2190 |
outStream nextPutBytes:nBytes from:data. |
5a08db3f0013
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
2191 |
rowsPerStrip := height |
135 | 2192 |
] ifFalse:[ |
1703
5a08db3f0013
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
2193 |
stripOffsets := Array basicNew:height. |
5a08db3f0013
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
2194 |
bytesPerRow := nBytes // height. |
5a08db3f0013
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
2195 |
stripByteCounts := (Array basicNew:height) atAllPut:bytesPerRow. |
0 | 2196 |
|
1703
5a08db3f0013
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
2197 |
offs := 1. |
5a08db3f0013
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
2198 |
h := height. |
5a08db3f0013
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
2199 |
1 to:h do:[:row | |
3211 | 2200 |
stripOffsets at:row put:(outStream position). |
1703
5a08db3f0013
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
2201 |
outStream nextPutBytes:bytesPerRow from:data startingAt:offs. |
5a08db3f0013
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
2202 |
offs := offs + bytesPerRow |
5a08db3f0013
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
2203 |
]. |
5a08db3f0013
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
2204 |
rowsPerStrip := 1 |
135 | 2205 |
]. |
2206 |
" |
|
2207 |
'stripOffsets: ' print. stripOffsets printNewline. |
|
2208 |
'stripByteCounts: ' print. stripByteCounts printNewline. |
|
2209 |
" |
|
2210 |
! ! |
|
2211 |
||
1805 | 2212 |
!TIFFReader methodsFor:'reading'! |
135 | 2213 |
|
2214 |
fromStream:aStream |
|
192 | 2215 |
"read a stream containing a TIFF image. |
3899 | 2216 |
Leave image description in instance variables. |
2217 |
(i.e. to get the image, ask with image)." |
|
135 | 2218 |
|
2219 |
|char1 char2 version |
|
2220 |
numberOfTags "{ Class: SmallInteger }" |
|
2221 |
tagType "{ Class: SmallInteger }" |
|
2222 |
numberType "{ Class: SmallInteger }" |
|
2223 |
length "{ Class: SmallInteger }" |
|
516 | 2224 |
result offset msb |
3975 | 2225 |
bytesPerRow offset1 offset2 tmp |
2226 |
pos1| |
|
135 | 2227 |
|
2228 |
inStream := aStream. |
|
331
304f9c439efa
allow reading from ByteArray-readStreams
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
2229 |
aStream binary. |
135 | 2230 |
|
2231 |
char1 := aStream next. |
|
2232 |
char2 := aStream next. |
|
3975 | 2233 |
|
2234 |
"/ first two chars are either II (intel byte order) |
|
2235 |
"/ or MM (motorola byte orrder) |
|
135 | 2236 |
(char1 ~~ char2) ifTrue:[ |
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
2237 |
^ self fileFormatError:'not a tiff file'. |
135 | 2238 |
]. |
1953
90f3c42ef3c1
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1846
diff
changeset
|
2239 |
(char1 == $I codePoint) ifTrue:[ |
192 | 2240 |
byteOrder := #lsb. |
2241 |
msb := false. |
|
0 | 2242 |
] ifFalse:[ |
1953
90f3c42ef3c1
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1846
diff
changeset
|
2243 |
(char1 == $M codePoint) ifTrue:[ |
192 | 2244 |
byteOrder := #msb. |
2245 |
msb := true. |
|
2246 |
] ifFalse:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
2247 |
^ self fileFormatError:'not a tiff file'. |
192 | 2248 |
] |
0 | 2249 |
]. |
3975 | 2250 |
isBigTiff := false. |
2251 |
||
3974 | 2252 |
version := aStream nextUnsignedInt16MSB:msb. |
2253 |
(version == 42) ifTrue:[ |
|
2254 |
offset := aStream nextUnsignedInt32MSB:msb. |
|
2255 |
aStream position:offset. |
|
2256 |
] ifFalse:[ |
|
2257 |
(version == 43) ifTrue:[ |
|
2258 |
|byteSizeOfOffsets always0| |
|
3975 | 2259 |
|
3974 | 2260 |
"/ 43 is the proposed bigtiff format |
3975 | 2261 |
isBigTiff := true. |
3974 | 2262 |
byteSizeOfOffsets := aStream nextUnsignedInt16MSB:msb. |
2263 |
byteSizeOfOffsets == 8 ifFalse:[ |
|
2264 |
^ self fileFormatError:'version of bigtiff-file not supported'. |
|
2265 |
]. |
|
2266 |
always0 := aStream nextUnsignedInt16MSB:msb. |
|
3975 | 2267 |
always0 == 0 ifFalse:[ |
3974 | 2268 |
^ self fileFormatError:'version of bigtiff-file not supported'. |
2269 |
]. |
|
2270 |
offset := aStream nextUnsignedInt64MSB:msb. |
|
2271 |
aStream position:offset. |
|
2272 |
] ifFalse:[ |
|
2273 |
^ self fileFormatError:'version of tiff-file not supported'. |
|
2274 |
]. |
|
0 | 2275 |
]. |
2276 |
||
135 | 2277 |
"setup default values" |
3693 | 2278 |
metaData := TIFFMetaData new. |
2279 |
||
135 | 2280 |
compression := 1. "none" |
2281 |
fillOrder := #msb. |
|
2282 |
planarConfiguration := 1. |
|
2283 |
photometric := nil. |
|
2284 |
bitsPerSample := 1. |
|
2285 |
samplesPerPixel := 1. |
|
2286 |
width := nil. |
|
2287 |
height := nil. |
|
2288 |
stripOffsets := nil. |
|
2289 |
rowsPerStrip := nil. |
|
2290 |
"resolutionUnit := 2." |
|
2291 |
predictor := 1. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
2292 |
orientation := nil. |
0 | 2293 |
|
3974 | 2294 |
(version == 42) ifTrue:[ |
2295 |
numberOfTags := aStream nextUnsignedInt16MSB:msb. |
|
135 | 2296 |
|
3974 | 2297 |
1 to:numberOfTags do:[:index | |
2298 |
tagType := aStream nextUnsignedInt16MSB:msb. |
|
2299 |
numberType := aStream nextUnsignedInt16MSB:msb. |
|
2300 |
length := aStream nextInt32MSB:msb. |
|
2301 |
self decodeTiffTag:tagType numberType:numberType length:length |
|
2302 |
]. |
|
2303 |
offset := aStream nextInt32MSB:msb. |
|
2304 |
] ifFalse:[ |
|
2305 |
numberOfTags := aStream nextUnsignedInt64MSB:msb. |
|
2306 |
||
2307 |
1 to:numberOfTags do:[:index | |
|
2308 |
tagType := aStream nextUnsignedInt16MSB:msb. |
|
2309 |
numberType := aStream nextUnsignedInt16MSB:msb. |
|
2310 |
length := aStream nextInt64MSB:msb. |
|
3975 | 2311 |
pos1 := aStream position. |
2312 |
self decodeTiffTag:tagType numberType:numberType length:length. |
|
3974 | 2313 |
]. |
2314 |
offset := aStream nextInt32MSB:msb. |
|
135 | 2315 |
]. |
2316 |
(offset ~~ 0) ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2317 |
'TIFFReader [info]: more tags ignored' infoPrintCR |
135 | 2318 |
]. |
0 | 2319 |
|
135 | 2320 |
"check for required tags" |
2321 |
width isNil ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
2322 |
^ self fileFormatError:'missing width tag'. |
135 | 2323 |
]. |
0 | 2324 |
|
135 | 2325 |
height isNil ifTrue:[ |
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
2326 |
^ self fileFormatError:'missing length tag'. |
135 | 2327 |
]. |
2328 |
||
2329 |
photometric isNil ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
2330 |
^ self fileFormatError:'missing photometric tag'. |
135 | 2331 |
]. |
2332 |
||
3975 | 2333 |
"given all the information, read the bits" |
135 | 2334 |
stripOffsets isNil ifTrue:[ |
3975 | 2335 |
(metaData notNil |
2336 |
and:[(metaData includesKey:#TileWidth) |
|
2337 |
and:[(metaData includesKey:#TileLength) |
|
2338 |
and:[(metaData includesKey:#TileOffsets) |
|
2339 |
and:[(metaData includesKey:#TileByteCounts) ]]]] |
|
2340 |
) ifFalse:[ |
|
2341 |
^ self fileFormatError:'missing stripOffsets tag'. |
|
2342 |
]. |
|
2343 |
self reportDimension. |
|
2344 |
result := self readTiledTiffImageData. |
|
2345 |
] ifFalse:[ |
|
2346 |
stripByteCounts isNil ifTrue:[ |
|
2347 |
stripOffsets size == 1 ifTrue:[ |
|
2348 |
stripByteCounts := Array with:(self bitsPerPixel // 8) * width * height |
|
2349 |
] ifFalse:[ |
|
2350 |
^ self fileFormatError:'missing stripByteCounts tag'. |
|
2351 |
]. |
|
2352 |
]. |
|
2353 |
self reportDimension. |
|
2354 |
rowsPerStrip isNil ifTrue:[ |
|
2355 |
rowsPerStrip := height |
|
2356 |
]. |
|
135 | 2357 |
|
3975 | 2358 |
result := self readTiffImageData. |
0 | 2359 |
]. |
3975 | 2360 |
|
743
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2361 |
result isNil ifTrue:[ |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2362 |
"/ unsupported format. |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2363 |
^ nil |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2364 |
]. |
516 | 2365 |
|
743
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2366 |
orientation == #vFlip ifTrue:[ |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2367 |
"/ reverse rows to top-to bottom |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
2368 |
|
743
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2369 |
bytesPerRow := self bytesPerRow. |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2370 |
tmp := ByteArray new:bytesPerRow. |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2371 |
offset1 := 1. |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2372 |
offset2 := (height-1)*bytesPerRow + 1. |
3693 | 2373 |
0 to:((height-1)//2) do:[:row | |
3975 | 2374 |
tmp replaceFrom:1 to:bytesPerRow with:data startingAt:offset1. |
2375 |
data replaceFrom:offset1 to:(offset1+bytesPerRow-1) with:data startingAt:offset2. |
|
2376 |
data replaceFrom:offset2 to:(offset2+bytesPerRow-1) with:tmp startingAt:1. |
|
743
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2377 |
offset1 := offset1 + bytesPerRow. |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2378 |
offset2 := offset2 - bytesPerRow. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
2379 |
]. |
743
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2380 |
]. |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2381 |
orientation == #unsupported ifTrue:[ |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2382 |
'TIFFReader [warning]: unsupported orientation' errorPrintCR |
393 | 2383 |
]. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
2384 |
|
135 | 2385 |
^ result |
192 | 2386 |
|
3975 | 2387 |
"Modified: / 25-08-2017 / 00:20:58 / cg" |
135 | 2388 |
! ! |
0 | 2389 |
|
1805 | 2390 |
!TIFFReader methodsFor:'writing'! |
135 | 2391 |
|
1571 | 2392 |
save:image onStream:aStream |
2393 |
"save image as (uncompressed) TIFF file on aFileName" |
|
2394 |
||
2395 |
|pos1 pos indicator| |
|
0 | 2396 |
|
1078
fc33e172bbbc
raise informationLostSignal before attemting to write the file
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
2397 |
image mask notNil ifTrue:[ |
fc33e172bbbc
raise informationLostSignal before attemting to write the file
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
2398 |
Image informationLostQuerySignal |
fc33e172bbbc
raise informationLostSignal before attemting to write the file
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
2399 |
raiseWith:image |
fc33e172bbbc
raise informationLostSignal before attemting to write the file
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
2400 |
errorString:('TIFF writer does not (yet) support an imageMask'). |
fc33e172bbbc
raise informationLostSignal before attemting to write the file
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
2401 |
]. |
fc33e172bbbc
raise informationLostSignal before attemting to write the file
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
2402 |
|
1571 | 2403 |
outStream := aStream. |
2404 |
outStream binary. |
|
461
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
2405 |
|
135 | 2406 |
"save as msb" |
2407 |
||
2408 |
byteOrder := #msb. |
|
2409 |
" |
|
2410 |
byteOrder := #lsb. |
|
2411 |
" |
|
2412 |
fillOrder := #msb. |
|
2413 |
width := image width. |
|
2414 |
height := image height. |
|
2415 |
photometric := image photometric. |
|
2416 |
samplesPerPixel := image samplesPerPixel. |
|
2417 |
bitsPerSample := image bitsPerSample. |
|
1785
16917d309b46
oops - position incompatibility fixed
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
2418 |
|
135 | 2419 |
colorMap := image colorMap. |
2420 |
planarConfiguration := 1. |
|
2421 |
compression := 1. "none" |
|
2422 |
data := image bits. |
|
2423 |
||
2424 |
currentOffset := 0. |
|
2425 |
||
2426 |
(byteOrder == #msb) ifTrue:[ |
|
1953
90f3c42ef3c1
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1846
diff
changeset
|
2427 |
indicator := $M codePoint. |
135 | 2428 |
] ifFalse:[ |
1953
90f3c42ef3c1
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1846
diff
changeset
|
2429 |
indicator := $I codePoint. |
0 | 2430 |
]. |
1571 | 2431 |
outStream nextPut:indicator; nextPut:indicator. |
135 | 2432 |
currentOffset := currentOffset + 2. |
0 | 2433 |
|
135 | 2434 |
self writeShort:42. |
2435 |
currentOffset := currentOffset + 2. |
|
0 | 2436 |
|
135 | 2437 |
pos1 := outStream position. |
2438 |
self writeLong:0. "start of tags - filled in later" |
|
2439 |
currentOffset := currentOffset + 4. |
|
2440 |
||
2441 |
"output strips" |
|
2442 |
||
2443 |
self writeUncompressedBits. "this outputs bits as strips, sets stripOffsets and stripByteCounts" |
|
2444 |
self writeStripOffsets. "this outputs strip offsets, sets stripOffsetsPos" |
|
2445 |
self writeStripByteCounts. "this outputs strip bytecounts, sets stripByteCountPos" |
|
2446 |
self writeBitsPerSample. "this outputs bitsPerSample, sets bitsPerSamplePos" |
|
2447 |
photometric == #palette ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2448 |
self writeColorMap "this outputs colorMap, sets colorMapPos" |
0 | 2449 |
]. |
2450 |
||
3211 | 2451 |
pos := outStream position. "backpatch tag offset" |
135 | 2452 |
outStream position:pos1. |
1704
1526c7b84920
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1703
diff
changeset
|
2453 |
self writeLong:pos. "fill in tag offset" |
3211 | 2454 |
outStream position:pos. |
135 | 2455 |
" |
2456 |
('patch tag offset at: ', (pos1 printStringRadix:16) , ' to ', |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2457 |
(pos printStringRadix:16)) printNewline. |
135 | 2458 |
" |
2459 |
"output tag data" |
|
0 | 2460 |
|
135 | 2461 |
photometric == #palette ifTrue:[ |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2462 |
self writeShort:11. "11 tags" |
135 | 2463 |
] ifFalse:[ |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2464 |
self writeShort:10. "10 tags" |
135 | 2465 |
]. |
2466 |
self writeTag:256. "image width" |
|
2467 |
self writeTag:257. "image height" |
|
2468 |
self writeTag:258. "bits per sample" |
|
2469 |
self writeTag:259. "compression" |
|
2470 |
self writeTag:262. "photometric" |
|
2471 |
self writeTag:273. "strip offsets" |
|
159
327da5085900
fixed saving of 24bit RGB images (forgot samplesPerPixel-TAG)
Claus Gittinger <cg@exept.de>
parents:
135
diff
changeset
|
2472 |
self writeTag:277. "samplesPerPixel" |
135 | 2473 |
self writeTag:278. "rowsPerStrip" |
2474 |
self writeTag:279. "strip byte counts" |
|
2475 |
self writeTag:284. "planarconfig" |
|
2476 |
photometric == #palette ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2477 |
self writeTag:320 "colorMap" |
135 | 2478 |
]. |
2479 |
self writeLong:0. "end of tags mark" |
|
2480 |
! ! |
|
30 | 2481 |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2482 |
!TIFFReader class methodsFor:'documentation'! |
30 | 2483 |
|
135 | 2484 |
version |
3552 | 2485 |
^ '$Header$' |
0 | 2486 |
! ! |
1702
75a595a70c86
stream position is going to be 0-based soon
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
2487 |
|
3112 | 2488 |
|
135 | 2489 |
TIFFReader initialize! |