author | Claus Gittinger <cg@exept.de> |
Mon, 30 Jun 1997 22:56:45 +0200 | |
changeset 647 | 6f26c76aa0c9 |
parent 623 | ea587e8fd435 |
child 743 | 43be299fc515 |
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 |
" |
|
12 |
||
13 |
ImageReader subclass:#TIFFReader |
|
192 | 14 |
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
|
15 |
fillOrder compression group3options predictor stripByteCounts |
327da5085900
fixed saving of 24bit RGB images (forgot samplesPerPixel-TAG)
Claus Gittinger <cg@exept.de>
parents:
135
diff
changeset
|
16 |
currentOffset stripOffsetsPos stripByteCountsPos bitsPerSamplePos |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
17 |
colorMapPos orientation' |
192 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
259 | 20 |
category:'Graphics-Images-Support' |
0 | 21 |
! |
22 |
||
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
23 |
!TIFFReader class methodsFor:'documentation'! |
0 | 24 |
|
21 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
28 | 28 |
All Rights Reserved |
21 | 29 |
|
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
0 | 39 |
documentation |
40 |
" |
|
21 | 41 |
This class knows how to read TIFF files and how to |
42 |
write uncompressed TIFF files. |
|
14 | 43 |
|
21 | 44 |
Only single image files are supported. |
38 | 45 |
Not all formats are implemented, and of those that are, not all are tested. |
159
327da5085900
fixed saving of 24bit RGB images (forgot samplesPerPixel-TAG)
Claus Gittinger <cg@exept.de>
parents:
135
diff
changeset
|
46 |
It should read with most rgb, mono and 2-plane greyscale |
38 | 47 |
images, since this is what I have as test material on the NeXT. |
21 | 48 |
It supports reading of uncompressed, LZW and G3 compressed |
517 | 49 |
images; JPEG, packbits and many others are currently not implemented. |
14 | 50 |
|
21 | 51 |
Only writing of uncompressed images is currently implemented. |
159
327da5085900
fixed saving of 24bit RGB images (forgot samplesPerPixel-TAG)
Claus Gittinger <cg@exept.de>
parents:
135
diff
changeset
|
52 |
It should write (at least) mono, 8-bit palette and 24 bit rgb formats. |
21 | 53 |
More formats will come ... |
30 | 54 |
|
55 |
TODO: since I dont want to spend all of my life adding more formats here and |
|
56 |
reinventing the wheel, this code should be changed to use the tiff library. |
|
57 |
That would give us most formats and also writing capabilities for free. |
|
195 | 58 |
|
220 | 59 |
[author:] |
60 |
Claus Gittinger |
|
61 |
||
195 | 62 |
[See also:] |
234 | 63 |
Image Form Icon |
197 | 64 |
BlitImageReader FaceReader GIFReader JPEGReader PBMReader PCXReader |
210 | 65 |
ST80FormReader SunRasterReader TargaReader WindowsIconReader |
209 | 66 |
XBMReader XPMReader XWDReader |
0 | 67 |
" |
68 |
! ! |
|
69 |
||
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
70 |
!TIFFReader class methodsFor:'initialization'! |
28 | 71 |
|
72 |
initialize |
|
198 | 73 |
"install myself in the Image classes fileFormat table |
398 | 74 |
for the `.tiff' and `.tif' extensions." |
198 | 75 |
|
647 | 76 |
MIMETypes defineImageType:'image/tiff' suffix:'tif' reader:self. |
77 |
MIMETypes defineImageType:nil suffix:'tiff' reader:self. |
|
198 | 78 |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
79 |
" |
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
80 |
self initialize |
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
81 |
" |
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
82 |
|
398 | 83 |
"Modified: 1.2.1997 / 15:00:01 / cg" |
28 | 84 |
! ! |
85 |
||
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
86 |
!TIFFReader class methodsFor:'testing'! |
3 | 87 |
|
135 | 88 |
canRepresent:anImage |
89 |
"return true, if anImage can be represented in my file format. |
|
90 |
Any image is supported." |
|
91 |
||
92 |
^ true |
|
93 |
! |
|
94 |
||
3 | 95 |
isValidImageFile:aFileName |
96 |
"return true, if aFileName contains a GIF image" |
|
97 |
||
98 |
|inStream char1 char2 version| |
|
99 |
||
11 | 100 |
inStream := self streamReadingFile:aFileName. |
3 | 101 |
inStream isNil ifTrue:[^ false]. |
102 |
||
103 |
char1 := inStream next. |
|
104 |
char2 := inStream next. |
|
105 |
||
106 |
((char1 ~~ char2) or:[(char1 ~~ $I) and:[char1 ~~ $M]]) ifTrue:[ |
|
28 | 107 |
inStream close. |
108 |
^ false |
|
3 | 109 |
]. |
110 |
||
111 |
inStream binary. |
|
112 |
version := inStream nextShortMSB:(char1 == $M). |
|
113 |
inStream close. |
|
114 |
||
115 |
(version ~~ 42) ifTrue:[^ false]. |
|
116 |
^ true |
|
0 | 117 |
! ! |
118 |
||
119 |
!TIFFReader methodsFor:'private'! |
|
120 |
||
121 |
decodeTiffTag:tagType numberType:numberType length:length |
|
122 |
|offset value valueArray |
|
40 | 123 |
val scaleFactor rV gV bV |
124 |
n "{ Class: SmallInteger }" |
|
35 | 125 |
i2 "{ Class: SmallInteger }" |
126 |
i3 "{ Class: SmallInteger }" | |
|
0 | 127 |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
128 |
"/ 'tiffTag: ' print. tagType printCR. |
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
129 |
|
516 | 130 |
(numberType == 3 "TIFF_SHORT") ifTrue:[ |
131 |
"16 bit ushort" |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
132 |
valueArray := self readShorts:length. |
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
133 |
value := valueArray at:1 |
516 | 134 |
] ifFalse:[(numberType == 4 "TIFF_LONG") ifTrue:[ |
135 |
"32 bit uinteger" |
|
136 |
valueArray := self readLongs:length. |
|
137 |
value := valueArray at:1 |
|
138 |
] ifFalse:[(numberType == 2 "TIFF_ASCII") ifTrue:[ |
|
139 |
"ascii characters" |
|
140 |
value := self readChars:length |
|
141 |
] ifFalse:[(numberType == 5 "TIFF_RATIONAL") ifTrue:[ |
|
142 |
"64 bit ufraction" |
|
143 |
valueArray := self readFracts:length. |
|
144 |
value := valueArray at:1 |
|
0 | 145 |
] ifFalse:[ |
516 | 146 |
offset := (inStream nextLongMSB:(byteOrder ~~ #lsb)) |
147 |
]]]]. |
|
148 |
||
149 |
(tagType < 300) ifTrue:[ |
|
150 |
(tagType == 254) ifTrue:[ |
|
151 |
"/ New SubfileType |
|
152 |
"/ REDUCEDIMAGE -> 1 |
|
153 |
"/ PAGE -> 2 |
|
154 |
"/ MASK -> 4 |
|
155 |
"newSubFileType := value." |
|
0 | 156 |
|
516 | 157 |
"/ 'newSubfiletype ' print. value printNewline. |
158 |
||
159 |
^ self |
|
160 |
]. |
|
161 |
(tagType == 255) ifTrue:[ |
|
162 |
"/ Old SubfileType |
|
163 |
"/ IMAGE -> 1 |
|
164 |
"/ REDUCEDIMAGE -> 2 |
|
165 |
"/ PAGE -> 3 |
|
166 |
subFileType := value. |
|
167 |
||
168 |
"/ 'subfiletype ' print. value printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
169 |
|
516 | 170 |
^ self |
171 |
]. |
|
172 |
(tagType == 256) ifTrue:[ |
|
173 |
"ImageWidth" |
|
174 |
width := value. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
175 |
|
516 | 176 |
"/ 'width ' print. width printNewline. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
177 |
|
516 | 178 |
^ self |
179 |
]. |
|
180 |
(tagType == 257) ifTrue:[ |
|
181 |
"ImageHeight" |
|
182 |
height := value. |
|
183 |
||
184 |
"/ 'height ' print. height printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
185 |
|
516 | 186 |
^ self |
187 |
]. |
|
188 |
(tagType == 258) ifTrue:[ |
|
189 |
"bitspersample" |
|
190 |
bitsPerSample := valueArray. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
191 |
|
516 | 192 |
"/ 'bitspersample ' print. bitsPerSample printNewline. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
193 |
|
516 | 194 |
^ self |
195 |
]. |
|
196 |
(tagType == 259) ifTrue:[ |
|
197 |
"/ compression |
|
198 |
"/ NONE -> 1 |
|
199 |
"/ CCITTRLE -> 2 |
|
200 |
"/ CCITTFAX3 -> 3 |
|
201 |
"/ CCITTFAX4 -> 4 |
|
202 |
"/ LZW -> 5 |
|
203 |
"/ OJPEG -> 6 |
|
204 |
"/ JPEG -> 7 |
|
205 |
"/ NEXT -> 32766 |
|
206 |
"/ CCITTRLEW -> 32771 |
|
520 | 207 |
"/ PACKBITS -> 32773 |
208 |
"/ THUNDERSCAN -> 32809 |
|
516 | 209 |
"/ PIXARFILM -> 32908 |
210 |
"/ PIXARLOG -> 32909 |
|
211 |
"/ DEFLATE -> 32946 |
|
212 |
"/ DCS -> 32947 |
|
213 |
"/ JBIG -> 34661 |
|
214 |
||
215 |
compression := value. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
216 |
|
516 | 217 |
"/ 'compression ' print. compression printNewline. |
30 | 218 |
|
516 | 219 |
^ self |
220 |
]. |
|
221 |
(tagType == 262) ifTrue:[ |
|
222 |
"photometric" |
|
223 |
||
224 |
(value == 0) ifTrue:[ |
|
225 |
photometric := #whiteIs0 |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
226 |
] ifFalse:[ |
516 | 227 |
(value == 1) ifTrue:[ |
228 |
photometric := #blackIs0 |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
229 |
] ifFalse:[ |
516 | 230 |
(value == 2) ifTrue:[ |
231 |
photometric := #rgb |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
232 |
] ifFalse:[ |
516 | 233 |
(value == 3) ifTrue:[ |
234 |
photometric := #palette |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
235 |
] ifFalse:[ |
516 | 236 |
(value == 4) ifTrue:[ |
237 |
photometric := #transparency |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
238 |
] ifFalse:[ |
516 | 239 |
(value == 5) ifTrue:[ |
240 |
photometric := #separated "/ color separations |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
241 |
] ifFalse:[ |
516 | 242 |
(value == 6) ifTrue:[ |
243 |
photometric := #ycbr "/ CCIR 601 |
|
244 |
] ifFalse:[ |
|
245 |
(value == 8) ifTrue:[ |
|
246 |
photometric := #cielab "/ 1976 CIE L*a*b* |
|
247 |
] ifFalse:[ |
|
248 |
photometric := nil |
|
249 |
] |
|
250 |
] |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
251 |
] |
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
252 |
] |
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
253 |
] |
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
254 |
] |
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
255 |
] |
516 | 256 |
]. |
257 |
||
258 |
"/ 'photometric ' print. photometric printNewline. |
|
259 |
||
260 |
^ self |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
261 |
]. |
516 | 262 |
(tagType == 263) ifTrue:[ |
263 |
"/ Treshholding |
|
264 |
"/ BILEVEL -> 1 |
|
265 |
"/ HALFTONE -> 2 |
|
266 |
"/ ERRORDIFFUSE -> 3 |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
267 |
|
516 | 268 |
"threshholding := value." |
269 |
||
270 |
"/ 'treshholding ' print. value printNewline. |
|
271 |
||
272 |
^ self |
|
273 |
]. |
|
274 |
(tagType == 264) ifTrue:[ |
|
275 |
"CellWidth" |
|
276 |
"cellWidth:= value." |
|
277 |
||
278 |
"/ 'cellWidth ' print. value printNewline. |
|
279 |
||
280 |
^ self |
|
281 |
]. |
|
282 |
(tagType == 265) ifTrue:[ |
|
283 |
"CellLength" |
|
284 |
"cellLength:= value." |
|
285 |
||
286 |
"/ 'cellLength ' print. value printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
287 |
|
516 | 288 |
^ self |
289 |
]. |
|
290 |
(tagType == 266) ifTrue:[ |
|
291 |
"fillOrder" |
|
292 |
(value == 1) ifTrue:[ |
|
293 |
fillOrder := #msb |
|
294 |
] ifFalse:[ |
|
295 |
(value == 2) ifTrue:[ |
|
296 |
fillOrder := #lsb |
|
297 |
] ifFalse:[ |
|
298 |
fillOrder := nil |
|
299 |
] |
|
300 |
]. |
|
301 |
||
302 |
"/ 'fillorder ' print. fillOrder printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
303 |
|
516 | 304 |
^ self |
305 |
]. |
|
306 |
(tagType == 269) ifTrue:[ |
|
307 |
"documentName - info only" |
|
308 |
||
309 |
"/ 'documentName ' print. value printNewline. |
|
310 |
||
311 |
^ self |
|
312 |
]. |
|
313 |
(tagType == 270) ifTrue:[ |
|
314 |
"imageDescription - info only" |
|
315 |
||
316 |
"/ 'imageDescription ' print. value printNewline. |
|
317 |
||
318 |
^ self |
|
319 |
]. |
|
320 |
(tagType == 271) ifTrue:[ |
|
321 |
"make - info only" |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
322 |
|
516 | 323 |
"/ 'make ' print. value printNewline. |
324 |
||
325 |
^ self |
|
326 |
]. |
|
327 |
(tagType == 272) ifTrue:[ |
|
328 |
"model - info only" |
|
329 |
||
330 |
"/ 'model ' print. value printNewline. |
|
331 |
||
332 |
^ self |
|
333 |
]. |
|
334 |
(tagType == 273) ifTrue:[ |
|
335 |
"stripoffsets" |
|
336 |
stripOffsets := valueArray. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
337 |
|
516 | 338 |
"/ 'stripOffsets Array(' print. stripOffsets size print. ')' printNewline. |
339 |
||
340 |
^ self |
|
341 |
]. |
|
342 |
(tagType == 274) ifTrue:[ |
|
343 |
"Orientation" |
|
344 |
||
345 |
orientation := |
|
346 |
#( nil "/ 1 normal (topLeft) |
|
347 |
unsupported "/ 2 horizontal flip |
|
348 |
unsupported "/ 3 horizontal & vertical flip |
|
349 |
vFlip "/ 4 vertical flip |
|
350 |
unsupported "/ 5 rot 90' counter clock-wise |
|
351 |
unsupported "/ 6 rot 90' clock-wise |
|
352 |
unsupported "/ 7 rot 90' & flip |
|
353 |
unsupported "/ 8 rot 90' ccw & flip |
|
354 |
) at:value ifAbsent:#unsupported. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
355 |
|
516 | 356 |
"/ 'orientation ' print. value printNewline. |
357 |
||
358 |
^ self |
|
359 |
]. |
|
360 |
(tagType == 277) ifTrue:[ |
|
361 |
"samplesPerPixel" |
|
362 |
samplesPerPixel := value. |
|
363 |
||
364 |
"/ 'samplesperpixel ' print. samplesPerPixel printNewline. |
|
365 |
||
366 |
^ self |
|
367 |
]. |
|
368 |
(tagType == 278) ifTrue:[ |
|
369 |
"rowsperstrip" |
|
370 |
rowsPerStrip := value. |
|
371 |
||
372 |
"/ 'rowsperstrip ' print. rowsPerStrip printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
373 |
|
516 | 374 |
^ self |
375 |
]. |
|
376 |
(tagType == 279) ifTrue:[ |
|
377 |
"stripbytecount" |
|
378 |
stripByteCounts := valueArray. |
|
379 |
||
380 |
"/ 'stripByteCounts Array(' print. |
|
381 |
"/ stripByteCounts size print. |
|
382 |
"/ ')' printNewline. |
|
383 |
||
384 |
^ self |
|
385 |
]. |
|
386 |
(tagType == 280) ifTrue:[ |
|
387 |
"MinSampleValue" |
|
388 |
"minSampleValue:= value." |
|
389 |
||
390 |
"/ 'minSampleValue ' print. value printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
391 |
|
516 | 392 |
^ self |
393 |
]. |
|
394 |
(tagType == 281) ifTrue:[ |
|
395 |
"MaxSampleValue" |
|
396 |
"maxSampleValue:= value." |
|
397 |
||
398 |
"/ 'maxSampleValue ' print. value printNewline. |
|
399 |
||
400 |
^ self |
|
401 |
]. |
|
402 |
(tagType == 282) ifTrue:[ |
|
403 |
"xResolution" |
|
404 |
||
405 |
"/ 'xres ' print. value printNewline. |
|
406 |
||
407 |
^ self |
|
408 |
]. |
|
409 |
(tagType == 283) ifTrue:[ |
|
410 |
"yResolution" |
|
411 |
||
412 |
"/ 'yres ' print. value printNewline. |
|
413 |
||
414 |
^ self |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
415 |
]. |
516 | 416 |
(tagType == 284) ifTrue:[ |
417 |
"planarconfig" |
|
418 |
(value == 1) ifTrue:[ |
|
419 |
planarConfiguration := 1 |
|
420 |
] ifFalse:[ |
|
421 |
(value == 2) ifTrue:[ |
|
422 |
planarConfiguration := 2 |
|
423 |
] ifFalse:[ |
|
424 |
planarConfiguration := nil |
|
425 |
] |
|
426 |
]. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
427 |
|
516 | 428 |
"/ 'planarconfig ' print. planarConfiguration printNewline. |
429 |
||
430 |
^ self |
|
431 |
]. |
|
432 |
(tagType == 285) ifTrue:[ |
|
433 |
"pageName" |
|
434 |
||
435 |
"/ 'pageName ' print. value printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
436 |
|
516 | 437 |
^ self |
438 |
]. |
|
439 |
(tagType == 286) ifTrue:[ |
|
440 |
"xPosition" |
|
441 |
||
442 |
"/ 'xPos ' print. value printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
443 |
|
516 | 444 |
^ self |
445 |
]. |
|
446 |
(tagType == 287) ifTrue:[ |
|
447 |
"yPosition" |
|
448 |
||
449 |
"/ 'yPos ' print. value printNewline. |
|
450 |
||
451 |
^ self |
|
452 |
]. |
|
453 |
(tagType == 288) ifTrue:[ |
|
454 |
"freeOffsets" |
|
455 |
||
456 |
"/ 'freeOffsets ' print. value printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
457 |
|
516 | 458 |
^ self |
459 |
]. |
|
460 |
(tagType == 289) ifTrue:[ |
|
461 |
"freeByteCounts" |
|
462 |
||
463 |
"/ 'freeByteCounts ' print. value printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
464 |
|
516 | 465 |
^ self |
466 |
]. |
|
467 |
(tagType == 290) ifTrue:[ |
|
468 |
"grayResponceUnit" |
|
469 |
||
470 |
"/ 'grayResponceUnit' print. value printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
471 |
|
516 | 472 |
^ self |
473 |
]. |
|
474 |
(tagType == 291) ifTrue:[ |
|
475 |
"grayResponceCurve" |
|
476 |
||
477 |
"/ 'grayResponceCurve' print. value printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
478 |
|
516 | 479 |
^ self |
480 |
]. |
|
481 |
(tagType == 292) ifTrue:[ |
|
482 |
"/ group3options |
|
483 |
"/ 2DENCODING -> 1 |
|
484 |
"/ UNCOMPRESSED -> 2 |
|
485 |
"/ FILLBITS -> 4 |
|
486 |
||
487 |
group3options := value. |
|
488 |
||
489 |
"/ 'group3options ' print. group3options printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
490 |
|
516 | 491 |
^ self |
492 |
]. |
|
493 |
(tagType == 293) ifTrue:[ |
|
494 |
"/ group4options |
|
495 |
"/ UNCOMPRESSED -> 2 |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
496 |
|
516 | 497 |
"group4options := value." |
498 |
||
499 |
"/ 'group4options ' print. value printNewline. |
|
500 |
||
501 |
^ self |
|
502 |
]. |
|
503 |
(tagType == 296) ifTrue:[ |
|
504 |
"resolutionunit" |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
505 |
|
516 | 506 |
"/ (value == 1) ifTrue:[ |
507 |
"/ 'res-unit pixel' printNewline |
|
508 |
"/ ] ifFalse:[ |
|
509 |
"/ (value == 2) ifTrue:[ |
|
510 |
"/ 'res-unit inch' printNewline |
|
511 |
"/ ] ifFalse:[ |
|
512 |
"/ (value == 3) ifTrue:[ |
|
513 |
"/ 'res-unit mm' printNewline |
|
514 |
"/ ] ifFalse:[ |
|
515 |
"/ 'res-unit invalid' printNewline |
|
516 |
"/ ] |
|
517 |
"/ ] |
|
518 |
"/ ]. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
519 |
|
516 | 520 |
"resolutionUnit := value." |
521 |
^ self |
|
522 |
]. |
|
523 |
(tagType == 297) ifTrue:[ |
|
524 |
"pageNumber" |
|
525 |
"pageNumber := value." |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
526 |
|
516 | 527 |
"/ 'pageNumber ' print. value printNewline. |
528 |
||
529 |
^ self |
|
530 |
]. |
|
0 | 531 |
]. |
516 | 532 |
|
533 |
(tagType < 400) ifTrue:[ |
|
534 |
(tagType == 300) ifTrue:[ |
|
535 |
"colorResponceUnit" |
|
536 |
||
537 |
"/ 'colorResponceUnit' print. value printNewline. |
|
538 |
||
539 |
^ self |
|
540 |
]. |
|
541 |
(tagType == 301) ifTrue:[ |
|
542 |
"colorResponceCurve" |
|
543 |
||
544 |
"/ 'colorResponceCurve' print. value printNewline. |
|
545 |
||
546 |
^ self |
|
547 |
]. |
|
548 |
(tagType == 305) ifTrue:[ |
|
549 |
"software - info only" |
|
550 |
||
551 |
"/ 'software' print. value printNewline. |
|
552 |
||
553 |
^ self |
|
554 |
]. |
|
555 |
(tagType == 306) ifTrue:[ |
|
556 |
"dateTime - info only" |
|
557 |
||
558 |
"/ 'dateTime ' print. value printNewline. |
|
559 |
||
560 |
^ self |
|
561 |
]. |
|
562 |
(tagType == 315) ifTrue:[ |
|
563 |
"artist - info only" |
|
393 | 564 |
|
516 | 565 |
"/ 'artist ' print. value printNewline. |
566 |
||
567 |
^ self |
|
568 |
]. |
|
569 |
(tagType == 316) ifTrue:[ |
|
570 |
"host computer - info only" |
|
571 |
||
572 |
"/ 'host ' print. value printNewline. |
|
573 |
||
574 |
^ self |
|
575 |
]. |
|
576 |
(tagType == 317) ifTrue:[ |
|
577 |
"predictor" |
|
578 |
predictor := value. |
|
579 |
||
580 |
"/ 'predictor ' print. predictor printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
581 |
|
516 | 582 |
^ self |
583 |
]. |
|
584 |
(tagType == 318) ifTrue:[ |
|
585 |
"whitePoint" |
|
586 |
||
587 |
"/ 'whitePoint ' print. value printNewline. |
|
588 |
||
589 |
^ self |
|
590 |
]. |
|
591 |
(tagType == 319) ifTrue:[ |
|
592 |
"primaryChromatics" |
|
593 |
||
594 |
"/ 'primaryChromatics ' print. value printNewline. |
|
595 |
||
596 |
^ self |
|
597 |
]. |
|
598 |
(tagType == 320) ifTrue:[ |
|
599 |
"colorMap" |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
600 |
|
516 | 601 |
"/ 'colorMap (size=' print. valueArray size print. ')' printNewline. |
602 |
||
603 |
" |
|
604 |
the tiff colormap contains 16bit values; |
|
605 |
our colormap expects 8bit values |
|
606 |
" |
|
607 |
n := valueArray size // 3. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
608 |
|
516 | 609 |
rV := ByteArray uninitializedNew:n. |
610 |
gV := ByteArray uninitializedNew:n. |
|
611 |
bV := ByteArray uninitializedNew:n. |
|
612 |
scaleFactor := 255.0 / 16rFFFF. |
|
613 |
i2 := n+1. |
|
614 |
i3 := 2*n+1. |
|
615 |
1 to:n do:[:vi | |
|
616 |
val := ((valueArray at:vi) * scaleFactor) rounded. |
|
617 |
rV at:vi put:val. |
|
618 |
val := ((valueArray at:i2) * scaleFactor) rounded. |
|
619 |
gV at:vi put:val. |
|
620 |
val := ((valueArray at:i3) * scaleFactor) rounded. |
|
621 |
bV at:vi put:val. |
|
622 |
i2 := i2 + 1. |
|
623 |
i3 := i3 + 1. |
|
624 |
]. |
|
625 |
colorMap := Colormap redVector:rV greenVector:gV blueVector:bV. |
|
626 |
^ self |
|
627 |
]. |
|
628 |
(tagType == 321) ifTrue:[ |
|
629 |
"halftonehints" |
|
630 |
||
631 |
"/ 'halftonehints' print. value printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
632 |
|
516 | 633 |
^ self |
634 |
]. |
|
635 |
(tagType == 322) ifTrue:[ |
|
636 |
"tilewidth" |
|
637 |
||
638 |
"/ 'tilewidth' print. value printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
639 |
|
516 | 640 |
^ self |
641 |
]. |
|
642 |
(tagType == 323) ifTrue:[ |
|
643 |
"tilelength" |
|
644 |
||
645 |
"/ 'tilelength' print. value printNewline. |
|
646 |
||
647 |
^ self |
|
648 |
]. |
|
649 |
(tagType == 324) ifTrue:[ |
|
650 |
"tileoffsets" |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
651 |
|
516 | 652 |
"/ 'tileoffsets' print. value printNewline. |
653 |
||
654 |
^ self |
|
655 |
]. |
|
656 |
(tagType == 325) ifTrue:[ |
|
657 |
"tilebytecounts" |
|
658 |
||
659 |
"/ 'tilebytecounts' print. value printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
660 |
|
516 | 661 |
^ self |
662 |
]. |
|
663 |
(tagType == 327) ifTrue:[ |
|
664 |
"cleanfaxdata" |
|
665 |
||
666 |
"/ 'tilebytecounts' print. value printNewline. |
|
667 |
||
668 |
^ self |
|
669 |
]. |
|
670 |
(tagType == 328) ifTrue:[ |
|
671 |
"consecutiveBadFaxLines" |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
672 |
|
516 | 673 |
"/ 'consecutiveBadFaxLines' print. value printNewline. |
674 |
||
675 |
^ self |
|
676 |
]. |
|
677 |
(tagType == 330) ifTrue:[ |
|
678 |
"subifd" |
|
679 |
||
680 |
"/ 'subifd' print. value printNewline. |
|
681 |
||
682 |
^ self |
|
683 |
]. |
|
684 |
(tagType == 332) ifTrue:[ |
|
685 |
"ink set" |
|
686 |
||
687 |
"/ 'ink set' print. value printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
688 |
|
516 | 689 |
^ self |
690 |
]. |
|
691 |
(tagType == 333) ifTrue:[ |
|
692 |
"ink names" |
|
693 |
||
694 |
"/ 'ink names' print. value printNewline. |
|
695 |
||
696 |
^ self |
|
697 |
]. |
|
698 |
(tagType == 336) ifTrue:[ |
|
699 |
"dot range" |
|
700 |
||
701 |
"/ 'dot range' print. value printNewline. |
|
702 |
||
703 |
^ self |
|
704 |
]. |
|
705 |
(tagType == 337) ifTrue:[ |
|
706 |
"target printer" |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
707 |
|
516 | 708 |
"/ 'target printer' print. value printNewline. |
709 |
||
710 |
^ self |
|
711 |
]. |
|
712 |
(tagType == 338) ifTrue:[ |
|
713 |
"extrasamples" |
|
714 |
||
715 |
"/ 'extrasamples' print. value printNewline. |
|
716 |
||
717 |
^ self |
|
718 |
]. |
|
719 |
(tagType == 339) ifTrue:[ |
|
720 |
"sample format" |
|
721 |
||
722 |
"/ 'sample format' print. value printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
723 |
|
516 | 724 |
^ self |
725 |
]. |
|
726 |
(tagType == 340) ifTrue:[ |
|
727 |
"min sample value" |
|
728 |
||
729 |
"/ 'min sample value' print. value printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
730 |
|
516 | 731 |
^ self |
732 |
]. |
|
733 |
(tagType == 341) ifTrue:[ |
|
734 |
"max sample value" |
|
735 |
||
736 |
"/ 'max sample value' print. value printNewline. |
|
737 |
||
738 |
^ self |
|
739 |
]. |
|
740 |
(tagType == 347) ifTrue:[ |
|
741 |
"jpegtables" |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
742 |
|
516 | 743 |
"/ 'jpegtables' print. value printNewline. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
744 |
|
516 | 745 |
^ self |
746 |
]. |
|
0 | 747 |
]. |
516 | 748 |
|
749 |
(tagType < 600) ifTrue:[ |
|
750 |
"/ obsolete JPEG tags |
|
751 |
(tagType == 512) ifTrue:[ |
|
752 |
"jpeg proc" |
|
753 |
||
754 |
"/ 'jpeg proc' print. value printNewline. |
|
755 |
||
756 |
^ self |
|
757 |
]. |
|
758 |
(tagType == 513) ifTrue:[ |
|
759 |
"jpeg proc" |
|
760 |
||
761 |
"/ 'jpeg proc' print. value printNewline. |
|
762 |
||
763 |
^ self |
|
764 |
]. |
|
765 |
(tagType == 514) ifTrue:[ |
|
766 |
"jpeg ifByteCount" |
|
767 |
||
768 |
"/ 'jpeg ifByteCount' print. value printNewline. |
|
769 |
||
770 |
^ self |
|
771 |
]. |
|
772 |
(tagType == 515) ifTrue:[ |
|
773 |
"jpeg restartInterval" |
|
774 |
||
775 |
"/ 'jpeg restartInterval' print. value printNewline. |
|
776 |
||
777 |
^ self |
|
778 |
]. |
|
779 |
(tagType == 517) ifTrue:[ |
|
780 |
"jpeg glossLessPredictors" |
|
781 |
||
782 |
"/ 'jpeg glossLessPredictors' print. value printNewline. |
|
783 |
||
784 |
^ self |
|
785 |
]. |
|
786 |
(tagType == 518) ifTrue:[ |
|
787 |
"jpeg pointTransform" |
|
788 |
||
789 |
"/ 'jpeg pointTransform' print. value printNewline. |
|
790 |
||
791 |
^ self |
|
792 |
]. |
|
793 |
(tagType == 519) ifTrue:[ |
|
794 |
"jpeg qTables" |
|
795 |
||
796 |
"/ 'jpeg qTables' print. value printNewline. |
|
797 |
||
798 |
^ self |
|
799 |
]. |
|
800 |
(tagType == 520) ifTrue:[ |
|
801 |
"jpeg dcTables" |
|
802 |
||
803 |
"/ 'jpeg dcTables' print. value printNewline. |
|
804 |
||
805 |
^ self |
|
806 |
]. |
|
807 |
(tagType == 521) ifTrue:[ |
|
808 |
"jpeg acTables" |
|
809 |
||
810 |
"/ 'jpeg acTables' print. value printNewline. |
|
811 |
||
812 |
^ self |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
813 |
]. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
814 |
|
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
815 |
|
516 | 816 |
(tagType == 529) ifTrue:[ |
817 |
"ycbr coeff" |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
818 |
|
516 | 819 |
"/ 'ycbr coeff' print. value printNewline. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
820 |
|
516 | 821 |
^ self |
822 |
]. |
|
823 |
(tagType == 530) ifTrue:[ |
|
824 |
"ycbr subsampling" |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
825 |
|
516 | 826 |
"/ 'ycbr subsampling' print. value printNewline. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
827 |
|
516 | 828 |
^ self |
829 |
]. |
|
830 |
(tagType == 531) ifTrue:[ |
|
831 |
"ycbr positioning" |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
832 |
|
516 | 833 |
"/ 'ycbr positioning' print. value printNewline. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
834 |
|
516 | 835 |
^ self |
836 |
]. |
|
837 |
(tagType == 532) ifTrue:[ |
|
838 |
"referenceBlackWhite" |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
839 |
|
516 | 840 |
"/ 'ycbr positioning' print. value printNewline. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
841 |
|
516 | 842 |
^ self |
843 |
]. |
|
30 | 844 |
]. |
516 | 845 |
|
846 |
(tagType > 32000) ifTrue:[ |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
847 |
|
516 | 848 |
"/ Private Island graphics tags |
849 |
(tagType == 32953) ifTrue:[ |
|
850 |
"ref points" |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
851 |
|
516 | 852 |
"/ 'ref points' print. value printNewline. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
853 |
|
516 | 854 |
^ self |
855 |
]. |
|
856 |
(tagType == 32954) ifTrue:[ |
|
857 |
"regionTagPoint" |
|
858 |
||
859 |
"/ 'regionTagPoint' print. value printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
860 |
|
516 | 861 |
^ self |
862 |
]. |
|
863 |
(tagType == 32955) ifTrue:[ |
|
864 |
"regionWarpCorners" |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
865 |
|
516 | 866 |
"/ 'regionWarpCorners' print. value printNewline. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
867 |
|
516 | 868 |
^ self |
869 |
]. |
|
870 |
(tagType == 32956) ifTrue:[ |
|
871 |
"regionAffine" |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
872 |
|
516 | 873 |
"/ 'regionAffine' print. value printNewline. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
874 |
|
516 | 875 |
^ self |
876 |
]. |
|
877 |
||
878 |
||
879 |
"/ Private SGI tags |
|
28 | 880 |
|
516 | 881 |
(tagType == 32995) ifTrue:[ |
882 |
"matteing" |
|
883 |
||
884 |
"/ 'matteing' print. value printNewline. |
|
885 |
||
886 |
^ self |
|
887 |
]. |
|
888 |
(tagType == 32996) ifTrue:[ |
|
889 |
"datatype" |
|
890 |
||
891 |
"/ 'datatype' print. value printNewline. |
|
892 |
||
893 |
^ self |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
894 |
]. |
516 | 895 |
(tagType == 32997) ifTrue:[ |
896 |
"imagedepth" |
|
897 |
||
898 |
"/ 'imagedepth' print. value printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
899 |
|
516 | 900 |
^ self |
901 |
]. |
|
902 |
(tagType == 32998) ifTrue:[ |
|
903 |
"tiledepth" |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
904 |
|
516 | 905 |
"/ 'tiledepth' print. value printNewline. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
906 |
|
516 | 907 |
^ self |
908 |
]. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
909 |
|
516 | 910 |
"/ Private Pixar tags |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
911 |
|
516 | 912 |
(tagType == 33300) ifTrue:[ |
913 |
"image full width" |
|
914 |
||
915 |
"/ 'image full width' print. value printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
916 |
|
516 | 917 |
^ self |
918 |
]. |
|
919 |
(tagType == 33301) ifTrue:[ |
|
920 |
"image full length" |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
921 |
|
516 | 922 |
"/ 'image full length' print. value printNewline. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
923 |
|
516 | 924 |
^ self |
925 |
]. |
|
926 |
||
927 |
"/ Private Eastman Kodak tags |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
928 |
|
516 | 929 |
(tagType == 33405) ifTrue:[ |
930 |
"write serial number" |
|
931 |
||
932 |
"/ 'write serial number' print. value printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
933 |
|
516 | 934 |
^ self |
935 |
]. |
|
936 |
||
937 |
"/ unknown |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
938 |
|
516 | 939 |
(tagType == 33432) ifTrue:[ |
940 |
"copyright" |
|
941 |
||
942 |
"/ 'copyright' print. value printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
943 |
|
516 | 944 |
^ self |
945 |
]. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
946 |
|
516 | 947 |
"/ Private Texas instruments |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
948 |
|
516 | 949 |
(tagType == 34232) ifTrue:[ |
950 |
"sequence frame count" |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
951 |
|
516 | 952 |
"/ 'sequence frame count' print. value printNewline. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
953 |
|
516 | 954 |
^ self |
955 |
]. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
956 |
|
516 | 957 |
"/ Private Pixel magic |
958 |
||
959 |
(tagType == 34232) ifTrue:[ |
|
960 |
"jbig options" |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
961 |
|
516 | 962 |
"/ 'jbig options' print. value printNewline. |
963 |
||
964 |
^ self |
|
965 |
]. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
966 |
|
516 | 967 |
"/ More Private SGI |
968 |
||
969 |
(tagType == 34908) ifTrue:[ |
|
970 |
"fax recv params" |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
971 |
|
516 | 972 |
"/ 'fax recv params' print. value printNewline. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
973 |
|
516 | 974 |
^ self |
975 |
]. |
|
976 |
(tagType == 34909) ifTrue:[ |
|
977 |
"fax subaddress" |
|
978 |
||
979 |
"/ 'fax subaddress' print. value printNewline. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
980 |
|
516 | 981 |
^ self |
982 |
]. |
|
983 |
(tagType == 34910) ifTrue:[ |
|
984 |
"fax recv time" |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
985 |
|
516 | 986 |
"/ 'fax recv time' print. value printNewline. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
987 |
|
516 | 988 |
^ self |
989 |
]. |
|
30 | 990 |
]. |
0 | 991 |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
992 |
"/ |
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
993 |
"/ '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
|
994 |
"/ ' 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
|
995 |
"/ ' 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
|
996 |
"/ |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
997 |
'TIFFReader [warning]: unknown tag type ' errorPrint. tagType errorPrintCR |
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
998 |
|
520 | 999 |
"Modified: 11.4.1997 / 01:11:17 / cg" |
440 | 1000 |
! ! |
1001 |
||
516 | 1002 |
!TIFFReader methodsFor:'private - data reading'! |
0 | 1003 |
|
135 | 1004 |
readCCITT3RLETiffImageData |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1005 |
'TIFFReader [warning]: ccitt mod Huffman (rle) compression not implemented' errorPrintCR. |
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1006 |
|
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1007 |
"Modified: 10.1.1997 / 18:09:02 / cg" |
135 | 1008 |
! |
1009 |
||
1010 |
readCCITT3RLEWTiffImageData |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1011 |
'TIFFReader [warning]: ccitt mod Huffman (rlew) compression not implemented' errorPrintCR. |
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1012 |
|
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1013 |
"Modified: 10.1.1997 / 18:09:11 / cg" |
135 | 1014 |
! |
1015 |
||
1016 |
readCCITTGroup3TiffImageData |
|
1017 |
"not really tested - all I got is a single |
|
1018 |
fax from NeXT step" |
|
1019 |
||
1020 |
|bytesPerRow bitsPerRow compressedStrip nPlanes |
|
1021 |
stripNr "{ Class: SmallInteger }" |
|
1022 |
offset "{ Class: SmallInteger }" |
|
1023 |
row "{ Class: SmallInteger }" |
|
1024 |
bytesPerStrip "{ Class: SmallInteger }" | |
|
1025 |
||
1026 |
nPlanes := samplesPerPixel. |
|
1027 |
(nPlanes == 2) ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1028 |
'TIFFReader [info]: ignoring alpha plane' infoPrintCR. |
335 | 1029 |
nPlanes := 1 |
135 | 1030 |
]. |
1031 |
||
1032 |
(nPlanes ~~ 1) ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1033 |
'TIFFReader [warning]: only monochrome/greyscale supported' errorPrintCR. |
335 | 1034 |
^ nil |
135 | 1035 |
]. |
0 | 1036 |
|
135 | 1037 |
stripByteCounts isNil ifTrue:[ |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1038 |
'TIFFReader [warning]: currently require stripByteCounts' errorPrintCR. |
335 | 1039 |
^ nil |
135 | 1040 |
]. |
1041 |
(rowsPerStrip ~~ 1) isNil ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1042 |
'TIFFReader [warning]: currently require rowsPerStrip to be 1' errorPrintCR. |
335 | 1043 |
^ nil |
135 | 1044 |
]. |
1045 |
||
335 | 1046 |
"/ 'TIFFReader: decompressing CCITT-3 ...' infoPrintNL. |
135 | 1047 |
|
1048 |
bitsPerRow := width * (bitsPerSample at:1). |
|
1049 |
bytesPerRow := bitsPerRow // 8. |
|
1050 |
((bitsPerRow \\ 8) ~~ 0) ifTrue:[ |
|
335 | 1051 |
bytesPerRow := bytesPerRow + 1 |
135 | 1052 |
]. |
1053 |
||
1054 |
data := ByteArray new:(bytesPerRow * height). |
|
1055 |
compressedStrip := ByteArray uninitializedNew:bytesPerRow. |
|
1056 |
||
1057 |
offset := 1. |
|
1058 |
stripNr := 0. |
|
1059 |
||
1060 |
row := 1. |
|
1061 |
bytesPerStrip := bytesPerRow * rowsPerStrip. |
|
1062 |
[row <= height] whileTrue:[ |
|
335 | 1063 |
stripNr := stripNr + 1. |
1064 |
inStream position:((stripOffsets at:stripNr) + 1). |
|
1065 |
inStream nextBytes:(stripByteCounts at:stripNr) into:compressedStrip. |
|
1066 |
self class decompressCCITT3From:compressedStrip |
|
1067 |
into:data |
|
1068 |
startingAt:offset |
|
1069 |
count:width. |
|
1070 |
offset := offset + bytesPerStrip. |
|
1071 |
row := row + rowsPerStrip |
|
135 | 1072 |
] |
335 | 1073 |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1074 |
"Modified: 10.1.1997 / 18:14:56 / cg" |
135 | 1075 |
! |
1076 |
||
1077 |
readCCITTGroup4TiffImageData |
|
359 | 1078 |
'TIFFReader [warning]: ccitt group4 fax compression not implemented' errorPrintCR. |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1079 |
|
359 | 1080 |
"Modified: 10.1.1997 / 19:10:59 / cg" |
135 | 1081 |
! |
0 | 1082 |
|
516 | 1083 |
readDCSTiffImageData |
1084 |
'TIFFReader [warning]: dcs compression not implemented' errorPrintCR |
|
329
5fb99e0734e4
handle empty character-strings
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1085 |
|
516 | 1086 |
"Modified: 10.1.1997 / 18:11:04 / cg" |
1087 |
"Created: 11.4.1997 / 00:30:54 / cg" |
|
135 | 1088 |
! |
1089 |
||
516 | 1090 |
readDeflateTiffImageData |
1091 |
'TIFFReader [warning]: deflate compression not implemented' errorPrintCR |
|
135 | 1092 |
|
516 | 1093 |
"Modified: 10.1.1997 / 18:11:04 / cg" |
1094 |
"Created: 11.4.1997 / 00:30:45 / cg" |
|
1095 |
! |
|
1096 |
||
1097 |
readJBIGTiffImageData |
|
1098 |
'TIFFReader [warning]: jbig compression not implemented' errorPrintCR |
|
1099 |
||
1100 |
"Modified: 10.1.1997 / 18:11:04 / cg" |
|
1101 |
"Created: 11.4.1997 / 00:31:00 / cg" |
|
135 | 1102 |
! |
1103 |
||
1104 |
readJPEGTiffImageData |
|
359 | 1105 |
'TIFFReader [warning]: jpeg compression not implemented' errorPrintCR |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1106 |
|
359 | 1107 |
"Modified: 10.1.1997 / 19:11:02 / cg" |
135 | 1108 |
! |
1109 |
||
1110 |
readLZWTiffImageData |
|
1111 |
"read LZW compressed tiff data; this method only |
|
1112 |
handles 3x8 rgb and 1x2 or 2x2 greyscale images. |
|
1113 |
For 2x2 greyscale images, the alpha plane is ignored. |
|
1114 |
(maybe other formats work also - its simply not |
|
1115 |
tested)" |
|
1116 |
||
1117 |
|bytesPerRow compressedStrip nPlanes |
|
1118 |
bytesPerStrip "{ Class: SmallInteger }" |
|
1119 |
nBytes "{ Class: SmallInteger }" |
|
1120 |
prevSize "{ Class: SmallInteger }" |
|
1121 |
stripNr "{ Class: SmallInteger }" |
|
1122 |
offset "{ Class: SmallInteger }" |
|
1123 |
row "{ Class: SmallInteger }" | |
|
1124 |
||
1125 |
nPlanes := samplesPerPixel. |
|
1126 |
||
1127 |
(nPlanes == 3) ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1128 |
(((bitsPerSample at:1) ~~ 8) |
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1129 |
or:[((bitsPerSample at:2) ~~ 8) |
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1130 |
or:[((bitsPerSample at:3) ~~ 8)]]) ifTrue:[ |
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1131 |
'TIFFReader [warning]: only 8/8/8 bit/sample are supported' errorPrintCR. |
335 | 1132 |
^ nil |
1133 |
]. |
|
1134 |
bytesPerRow := width * samplesPerPixel. |
|
0 | 1135 |
] ifFalse:[ |
335 | 1136 |
(nPlanes == 2) ifTrue:[ |
1137 |
(planarConfiguration ~~ 2) ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1138 |
'TIFFReader [warning]: only separate planes are supported' errorPrintCR. |
335 | 1139 |
^ nil |
1140 |
]. |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1141 |
'TIFFReader [info]: ignoring alpha plane' infoPrintCR. |
335 | 1142 |
nPlanes := 1 |
1143 |
]. |
|
1144 |
(nPlanes == 1) ifFalse:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1145 |
'TIFFReader [warning]: only 3-sample rgb / monochrome supported' errorPrintCR. |
335 | 1146 |
^ nil |
1147 |
]. |
|
1148 |
bytesPerRow := (width * (bitsPerSample at:1) + 7) // 8. |
|
135 | 1149 |
]. |
1150 |
||
1151 |
stripByteCounts isNil ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1152 |
'TIFFReader [warning]: currently require stripByteCounts' errorPrintCR. |
335 | 1153 |
^ nil |
135 | 1154 |
]. |
1155 |
||
335 | 1156 |
"/ 'TIFFReader: decompressing LZW ...' infoPrintNL. |
135 | 1157 |
|
1158 |
data := ByteArray uninitializedNew:(bytesPerRow * height). |
|
1159 |
||
1160 |
offset := 1. |
|
1161 |
stripNr := 0. |
|
1162 |
||
1163 |
row := 1. |
|
1164 |
bytesPerStrip := bytesPerRow * rowsPerStrip. |
|
1165 |
prevSize := 0. |
|
1166 |
[row <= height] whileTrue:[ |
|
335 | 1167 |
stripNr := stripNr + 1. |
1168 |
inStream position:((stripOffsets at:stripNr) + 1). |
|
1169 |
nBytes := stripByteCounts at:stripNr. |
|
1170 |
(nBytes > prevSize) ifTrue:[ |
|
1171 |
compressedStrip := ByteArray uninitializedNew:nBytes. |
|
1172 |
prevSize := nBytes |
|
1173 |
]. |
|
1174 |
inStream nextBytes:nBytes |
|
1175 |
into:compressedStrip. |
|
1176 |
self class decompressLZWFrom:compressedStrip |
|
1177 |
count:nBytes |
|
1178 |
into:data |
|
1179 |
startingAt:offset. |
|
1180 |
offset := offset + bytesPerStrip. |
|
1181 |
row := row + rowsPerStrip |
|
135 | 1182 |
]. |
1183 |
||
1184 |
(predictor == 2) ifTrue:[ |
|
335 | 1185 |
self class decodeDelta:3 in:data width:width height:height |
135 | 1186 |
] |
335 | 1187 |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1188 |
"Modified: 10.1.1997 / 18:13:21 / cg" |
135 | 1189 |
! |
1190 |
||
1191 |
readNeXTJPEGTiffImageData |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1192 |
'TIFFReader [warning]: jpeg compression not implemented' errorPrintCR |
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1193 |
|
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1194 |
"Modified: 10.1.1997 / 18:11:04 / cg" |
135 | 1195 |
! |
1196 |
||
1197 |
readNeXTRLE2TiffImageData |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1198 |
'TIFFReader [warning]: next 2bit rle compression not implemented' errorPrintCR. |
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1199 |
|
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1200 |
"Modified: 10.1.1997 / 18:11:01 / cg" |
135 | 1201 |
! |
1202 |
||
1203 |
readPackbitsTiffImageData |
|
1204 |
"had no samples yet - however, packbits decompression |
|
1205 |
is rather trivial to add ..." |
|
1206 |
||
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1207 |
'TIFFReader [warning]: packbits compression not implemented' errorPrintCR |
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1208 |
|
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1209 |
"Modified: 10.1.1997 / 18:10:57 / cg" |
135 | 1210 |
! |
1211 |
||
516 | 1212 |
readPixarFilmTiffImageData |
1213 |
'TIFFReader [warning]: pixar film compression not implemented' errorPrintCR |
|
135 | 1214 |
|
516 | 1215 |
"Modified: 10.1.1997 / 18:11:04 / cg" |
1216 |
"Created: 11.4.1997 / 00:30:33 / cg" |
|
1217 |
! |
|
1218 |
||
1219 |
readPixarLogTiffImageData |
|
1220 |
'TIFFReader [warning]: pixar log compression not implemented' errorPrintCR |
|
0 | 1221 |
|
516 | 1222 |
"Modified: 10.1.1997 / 18:11:04 / cg" |
1223 |
"Created: 11.4.1997 / 00:30:39 / cg" |
|
1224 |
! |
|
135 | 1225 |
|
516 | 1226 |
readThunderScanTiffImageData |
1227 |
'TIFFReader [warning]: thunderScan compression not implemented' errorPrintCR |
|
1228 |
||
1229 |
"Modified: 10.1.1997 / 18:11:04 / cg" |
|
1230 |
"Created: 11.4.1997 / 00:30:23 / cg" |
|
1231 |
! |
|
135 | 1232 |
|
516 | 1233 |
readTiffImageData |
1234 |
(compression == 1) ifTrue:[ |
|
1235 |
^ self readUncompressedTiffImageData. |
|
1236 |
]. |
|
1237 |
(compression == 2) ifTrue:[ |
|
1238 |
^ self readCCITT3RLETiffImageData. |
|
1239 |
]. |
|
1240 |
(compression == 3) ifTrue:[ |
|
1241 |
^ self readCCITTGroup3TiffImageData. |
|
1242 |
]. |
|
1243 |
(compression == 4) ifTrue:[ |
|
1244 |
^ self readCCITTGroup4TiffImageData. |
|
1245 |
]. |
|
1246 |
(compression == 5) ifTrue:[ |
|
1247 |
^ self readLZWTiffImageData. |
|
1248 |
]. |
|
1249 |
(compression == 6) ifTrue:[ |
|
1250 |
^ self readJPEGTiffImageData. |
|
1251 |
]. |
|
1252 |
(compression == 7) ifTrue:[ |
|
1253 |
^ self readNewJPEGTiffImageData. |
|
1254 |
]. |
|
1255 |
||
1256 |
(compression == 32766) ifTrue:[ |
|
1257 |
^ self readNeXTRLE2TiffImageData. |
|
1258 |
]. |
|
1259 |
(compression == 32771) ifTrue:[ |
|
1260 |
^ self readCCITTRLEWTiffImageData. |
|
135 | 1261 |
]. |
516 | 1262 |
(compression == 32773) ifTrue:[ |
1263 |
^ self readPackbitsTiffImageData. |
|
1264 |
]. |
|
1265 |
(compression == 32809) ifTrue:[ |
|
1266 |
^ self readThunderScanTiffImageData. |
|
1267 |
]. |
|
1268 |
(compression == 32908) ifTrue:[ |
|
1269 |
^ self readPixarFilmTiffImageData. |
|
1270 |
]. |
|
1271 |
(compression == 32909) ifTrue:[ |
|
1272 |
^ self readPixarLogTiffImageData. |
|
1273 |
]. |
|
1274 |
(compression == 32946) ifTrue:[ |
|
1275 |
^ self readDeflateTiffImageData. |
|
1276 |
]. |
|
1277 |
(compression == 32947) ifTrue:[ |
|
1278 |
^ self readDCSTiffImageData. |
|
1279 |
]. |
|
1280 |
(compression == 32865) ifTrue:[ |
|
1281 |
^ self readNeXTJPEGTiffImageData. |
|
1282 |
]. |
|
1283 |
(compression == 34661) ifTrue:[ |
|
1284 |
^ self readJBIGTiffImageData. |
|
1285 |
]. |
|
1286 |
||
1287 |
'TIFFReader [warning]: compression type ' errorPrint. compression errorPrint. |
|
1288 |
' not known' errorPrintCR. |
|
1289 |
||
1290 |
^ nil. |
|
1291 |
||
1292 |
"Created: 11.4.1997 / 00:19:44 / cg" |
|
1293 |
"Modified: 11.4.1997 / 00:29:54 / cg" |
|
135 | 1294 |
! |
1295 |
||
1296 |
readUncompressedTiffImageData |
|
1297 |
|bytesPerRow bitsPerRow nPlanes |
|
1298 |
stripNr "{ Class: SmallInteger }" |
|
1299 |
offset "{ Class: SmallInteger }" |
|
1300 |
row "{ Class: SmallInteger }" |
|
1301 |
nBytes "{ Class: SmallInteger }" |
|
1302 |
bitsPerPixel overAllBytes| |
|
1303 |
||
1304 |
nPlanes := samplesPerPixel. |
|
1305 |
||
1306 |
"only support 1-sample/pixel, |
|
1307 |
with alpha - if separate planes, |
|
1308 |
or rgb - if non separate planes and no alpha" |
|
1309 |
||
1310 |
(nPlanes == 2) ifTrue:[ |
|
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1311 |
(planarConfiguration ~~ 2) ifTrue:[ |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1312 |
'TIFFReader [warning]: with alpha, only separate planes supported' errorPrintCR. |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1313 |
^ nil |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1314 |
]. |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1315 |
'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
|
1316 |
nPlanes := 1. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1317 |
bitsPerPixel := bitsPerSample at:1. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1318 |
bitsPerSample := Array with:bitsPerPixel. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1319 |
samplesPerPixel := 1. |
135 | 1320 |
] ifFalse:[ |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1321 |
(nPlanes == 3) ifTrue:[ |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1322 |
(planarConfiguration ~~ 1) ifTrue:[ |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1323 |
'TIFFReader [warning]: only non separate planes supported' errorPrintCR. |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1324 |
^ nil |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1325 |
]. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1326 |
bitsPerSample ~= #(8 8 8) ifTrue:[ |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1327 |
'TIFFReader [warning]: only 8/8/8 rgb images supported' errorPrintCR. |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1328 |
^ nil |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1329 |
]. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1330 |
bitsPerPixel := 24 |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1331 |
] ifFalse:[ |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1332 |
(nPlanes ~~ 1) ifTrue:[ |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1333 |
'TIFFReader [warning]: format not supported' errorPrintCR. |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1334 |
^ nil |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1335 |
]. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1336 |
bitsPerPixel := bitsPerSample at:1. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1337 |
] |
0 | 1338 |
]. |
135 | 1339 |
|
1340 |
bitsPerRow := width * bitsPerPixel. |
|
1341 |
bytesPerRow := bitsPerRow // 8. |
|
1342 |
((bitsPerRow \\ 8) ~~ 0) ifTrue:[ |
|
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1343 |
bytesPerRow := bytesPerRow + 1 |
135 | 1344 |
]. |
1345 |
||
1346 |
overAllBytes := bytesPerRow * height. |
|
1347 |
data := ByteArray uninitializedNew:overAllBytes. |
|
1348 |
||
336
9789b02d95bf
oops - the very last pixel was not read (in readUncompressed ...)
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1349 |
offset := 0. |
135 | 1350 |
stripNr := 0. |
1351 |
||
1352 |
row := 1. |
|
1353 |
[row <= height] whileTrue:[ |
|
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1354 |
stripNr := stripNr + 1. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1355 |
nBytes := stripByteCounts at:stripNr. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1356 |
inStream position:((stripOffsets at:stripNr) + 1). |
135 | 1357 |
|
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1358 |
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
|
1359 |
nBytes := overAllBytes - offset. |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1360 |
]. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1361 |
|
563
38cbee875bfa
read data in blocks - better if images are read from a CD
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
1362 |
"/ read it 4k-wise; this leads to a better behavior, |
38cbee875bfa
read data in blocks - better if images are read from a CD
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
1363 |
"/ when big images reading from a slow cdrom |
38cbee875bfa
read data in blocks - better if images are read from a CD
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
1364 |
inStream nextBytes:nBytes into:data startingAt:offset+1 blockSize:4096. |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1365 |
offset := offset + nBytes. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1366 |
row := row + rowsPerStrip |
135 | 1367 |
] |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1368 |
|
563
38cbee875bfa
read data in blocks - better if images are read from a CD
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
1369 |
"Modified: 24.4.1997 / 21:10:07 / cg" |
440 | 1370 |
! ! |
1371 |
||
516 | 1372 |
!TIFFReader methodsFor:'private - reading'! |
1373 |
||
1374 |
readChars:n |
|
1375 |
"read n characters and return them in a string" |
|
1376 |
||
1377 |
|oldPos offset string| |
|
1378 |
||
1379 |
n == 0 ifTrue:[^ '']. |
|
1380 |
||
1381 |
string := String new:(n - 1). |
|
1382 |
(n <= 4) ifTrue:[ |
|
1383 |
inStream nextBytes:(n - 1) into:string |
|
1384 |
] ifFalse:[ |
|
1385 |
offset := inStream nextLongMSB:(byteOrder ~~ #lsb). |
|
1386 |
oldPos := inStream position. |
|
1387 |
inStream position:(offset + 1). |
|
1388 |
inStream nextBytes:(n - 1) into:string. |
|
1389 |
inStream position:oldPos |
|
1390 |
]. |
|
1391 |
^ string |
|
1392 |
||
1393 |
"Modified: 5.9.1996 / 12:21:08 / cg" |
|
1394 |
! |
|
1395 |
||
1396 |
readFracts:nFracts |
|
1397 |
"read nFracts fractions (2 32bit words) and return them in an array" |
|
1398 |
||
1399 |
|oldPos offset values numerator denominator msb |
|
1400 |
n "{ Class: SmallInteger }" | |
|
1401 |
||
1402 |
n := nFracts. |
|
1403 |
||
1404 |
msb := byteOrder ~~ #lsb. |
|
1405 |
values := Array basicNew:n. |
|
1406 |
offset := inStream nextLongMSB:msb. |
|
1407 |
oldPos := inStream position. |
|
1408 |
inStream position:(offset + 1). |
|
1409 |
1 to:n do:[:index | |
|
1410 |
numerator := inStream nextLongMSB:msb. |
|
1411 |
denominator := inStream nextLongMSB:msb. |
|
1412 |
values at:index put:(Fraction numerator:numerator denominator:denominator) |
|
1413 |
]. |
|
1414 |
inStream position:oldPos. |
|
1415 |
^ values |
|
1416 |
! |
|
1417 |
||
1418 |
readLongs:nLongs |
|
1419 |
"read nLongs long numbers (32bit) and return them in an array" |
|
1420 |
||
1421 |
|oldPos offset values msb |
|
1422 |
n "{ Class: SmallInteger }" | |
|
1423 |
||
1424 |
n := nLongs. |
|
1425 |
||
1426 |
msb := byteOrder ~~ #lsb. |
|
1427 |
values := Array basicNew:n. |
|
1428 |
(n == 1) ifTrue:[ |
|
1429 |
values at:1 put:(inStream nextLongMSB:msb). |
|
1430 |
] ifFalse:[ |
|
1431 |
offset := inStream nextLongMSB:msb. |
|
1432 |
oldPos := inStream position. |
|
1433 |
inStream position:(offset + 1). |
|
1434 |
1 to:n do:[:index | |
|
1435 |
values at:index put:(inStream nextLongMSB:msb) |
|
1436 |
]. |
|
1437 |
inStream position:oldPos |
|
1438 |
]. |
|
1439 |
^ values |
|
1440 |
! |
|
1441 |
||
1442 |
readShorts:nShorts |
|
1443 |
"read nShorts short numbers (16bit) and return them in an array" |
|
1444 |
||
1445 |
|oldPos offset values msb val2 |
|
1446 |
n "{ Class: SmallInteger }" | |
|
1447 |
||
1448 |
n := nShorts. |
|
1449 |
||
1450 |
msb := (byteOrder ~~ #lsb). |
|
1451 |
values := Array basicNew:n. |
|
1452 |
(n <= 2) ifTrue:[ |
|
1453 |
values at:1 put:(inStream nextUnsignedShortMSB:msb). |
|
1454 |
val2 := inStream nextUnsignedShortMSB:msb. |
|
1455 |
||
1456 |
(n == 2) ifTrue:[ |
|
1457 |
values at:2 put:val2 |
|
1458 |
] |
|
1459 |
] ifFalse:[ |
|
1460 |
offset := inStream nextLongMSB:msb. |
|
1461 |
oldPos := inStream position. |
|
1462 |
inStream position:(offset + 1). |
|
1463 |
1 to:n do:[:index | |
|
1464 |
values at:index put:(inStream nextUnsignedShortMSB:msb) |
|
1465 |
]. |
|
1466 |
inStream position:oldPos |
|
1467 |
]. |
|
1468 |
^ values |
|
1469 |
! ! |
|
1470 |
||
440 | 1471 |
!TIFFReader methodsFor:'private - writing'! |
135 | 1472 |
|
1473 |
writeBitsPerSample |
|
14 | 1474 |
" |
135 | 1475 |
'bitsPerSample: ' print. bitsPerSample printNewline. |
1476 |
'store bitspersample at: ' print. outStream position printNewline. |
|
14 | 1477 |
" |
135 | 1478 |
bitsPerSamplePos := outStream position. |
1479 |
bitsPerSample do:[:n | |
|
1480 |
self writeShort:n |
|
1481 |
] |
|
0 | 1482 |
! |
1483 |
||
1484 |
writeColorMap |
|
28 | 1485 |
|n| |
1486 |
||
0 | 1487 |
colorMapPos := outStream position. |
35 | 1488 |
#(red green blue) do:[:component | |
440 | 1489 |
n := 0. |
1490 |
colorMap do:[:clr | |
|
1491 |
|entry| |
|
35 | 1492 |
|
440 | 1493 |
clr isNil ifTrue:[ |
1494 |
entry := 0 |
|
1495 |
] ifFalse:[ |
|
1496 |
entry := clr perform:component. |
|
1497 |
" |
|
1498 |
tiff map is 16 bit - scale from percent to 0..16rFFFF |
|
1499 |
" |
|
1500 |
entry := (entry * 16rFFFF / 100) rounded. |
|
1501 |
]. |
|
1502 |
self writeShort:entry. |
|
1503 |
n := n + 1 |
|
1504 |
]. |
|
1505 |
||
1506 |
" |
|
1507 |
fill to 256 entries |
|
1508 |
" |
|
1509 |
[n < 256] whileTrue:[ |
|
1510 |
self writeShort:0. |
|
1511 |
n := n + 1. |
|
1512 |
] |
|
0 | 1513 |
] |
440 | 1514 |
|
1515 |
"Modified: 20.2.1997 / 18:06:10 / cg" |
|
0 | 1516 |
! |
1517 |
||
1518 |
writeStripByteCounts |
|
3 | 1519 |
" |
0 | 1520 |
'stripByteCounts: ' print. stripByteCounts printNewline. |
1521 |
'store stripbytecounts at: ' print. outStream position printNewline. |
|
3 | 1522 |
" |
0 | 1523 |
stripByteCountsPos := outStream position. |
1524 |
stripByteCounts do:[:c | |
|
28 | 1525 |
self writeShort:c |
0 | 1526 |
] |
1527 |
! |
|
1528 |
||
135 | 1529 |
writeStripOffsets |
3 | 1530 |
" |
135 | 1531 |
'stripOffsets: ' print. stripOffsets printNewline. |
1532 |
'store stripoffsets at: ' print. outStream position printNewline. |
|
3 | 1533 |
" |
135 | 1534 |
stripOffsetsPos := outStream position. |
1535 |
stripOffsets do:[:o | |
|
1536 |
self writeLong:o |
|
0 | 1537 |
] |
1538 |
! |
|
1539 |
||
1540 |
writeTag:tagType |
|
1541 |
self writeTiffTag:tagType. |
|
1542 |
! |
|
1543 |
||
1544 |
writeTiffTag:tagType |
|
1545 |
|value valueArray numberType count address| |
|
1546 |
||
1547 |
count := 1. |
|
1548 |
address := nil. |
|
1549 |
(tagType == 253) ifTrue:[ |
|
28 | 1550 |
"tiff class" |
0 | 1551 |
]. |
1552 |
(tagType == 254) ifTrue:[ |
|
1553 |
]. |
|
1554 |
(tagType == 255) ifTrue:[ |
|
28 | 1555 |
"SubfileType" |
1556 |
value := subFileType. |
|
1557 |
numberType := #long. |
|
0 | 1558 |
]. |
1559 |
(tagType == 256) ifTrue:[ |
|
28 | 1560 |
"ImageWidth" |
1561 |
value := width. |
|
1562 |
numberType := #short. |
|
0 | 1563 |
]. |
1564 |
(tagType == 257) ifTrue:[ |
|
28 | 1565 |
"ImageHeight" |
1566 |
value := height. |
|
1567 |
numberType := #short. |
|
0 | 1568 |
]. |
1569 |
(tagType == 258) ifTrue:[ |
|
28 | 1570 |
"bitspersample" |
1571 |
address := bitsPerSamplePos - 1. |
|
1572 |
numberType := #short. |
|
1573 |
count := bitsPerSample size. |
|
1574 |
valueArray := bitsPerSample |
|
0 | 1575 |
]. |
1576 |
(tagType == 259) ifTrue:[ |
|
28 | 1577 |
"compression" |
1578 |
value := compression. |
|
1579 |
numberType := #short. |
|
0 | 1580 |
]. |
1581 |
(tagType == 262) ifTrue:[ |
|
28 | 1582 |
"photometric" |
1583 |
(photometric == #whiteIs0) ifTrue:[ |
|
1584 |
value := 0 |
|
1585 |
] ifFalse:[ |
|
1586 |
(photometric == #blackIs0) ifTrue:[ |
|
1587 |
value := 1 |
|
1588 |
] ifFalse:[ |
|
1589 |
(photometric == #rgb) ifTrue:[ |
|
1590 |
value := 2 |
|
1591 |
] ifFalse:[ |
|
1592 |
(photometric == #palette) ifTrue:[ |
|
1593 |
value := 3 |
|
1594 |
] ifFalse:[ |
|
1595 |
(photometric == #transparency) ifTrue:[ |
|
1596 |
value := 4 |
|
1597 |
] ifFalse:[ |
|
1598 |
self error:'bad photometric' |
|
1599 |
] |
|
1600 |
] |
|
1601 |
] |
|
1602 |
] |
|
1603 |
]. |
|
1604 |
numberType := #short. |
|
0 | 1605 |
]. |
1606 |
(tagType == 263) ifTrue:[ |
|
1607 |
]. |
|
1608 |
(tagType == 264) ifTrue:[ |
|
1609 |
]. |
|
1610 |
(tagType == 265) ifTrue:[ |
|
1611 |
]. |
|
1612 |
(tagType == 266) ifTrue:[ |
|
28 | 1613 |
"fillOrder" |
1614 |
(fillOrder == #msb) ifTrue:[ |
|
1615 |
value := 1 |
|
1616 |
] ifFalse:[ |
|
1617 |
(fillOrder == #lsb) ifTrue:[ |
|
1618 |
value := 2 |
|
1619 |
] ifFalse:[ |
|
1620 |
self error:'bad fillOrder' |
|
1621 |
] |
|
1622 |
]. |
|
1623 |
numberType := #short. |
|
0 | 1624 |
]. |
1625 |
(tagType == 269) ifTrue:[ |
|
1626 |
]. |
|
1627 |
(tagType == 270) ifTrue:[ |
|
1628 |
]. |
|
1629 |
(tagType == 271) ifTrue:[ |
|
1630 |
]. |
|
1631 |
(tagType == 272) ifTrue:[ |
|
1632 |
]. |
|
1633 |
(tagType == 273) ifTrue:[ |
|
28 | 1634 |
"stripoffsets" |
1635 |
address := stripOffsetsPos - 1. |
|
1636 |
numberType := #long. |
|
1637 |
count := stripOffsets size. |
|
1638 |
valueArray := stripOffsets |
|
0 | 1639 |
]. |
1640 |
(tagType == 274) ifTrue:[ |
|
1641 |
]. |
|
1642 |
(tagType == 277) ifTrue:[ |
|
28 | 1643 |
"samplesPerPixel" |
1644 |
value := samplesPerPixel. |
|
1645 |
numberType := #short. |
|
0 | 1646 |
]. |
1647 |
(tagType == 278) ifTrue:[ |
|
28 | 1648 |
"rowsperstrip" |
1649 |
value := rowsPerStrip. |
|
1650 |
numberType := #short. |
|
0 | 1651 |
]. |
1652 |
(tagType == 279) ifTrue:[ |
|
28 | 1653 |
"stripbytecount" |
1654 |
address := stripByteCountsPos - 1. |
|
1655 |
numberType := #short. |
|
1656 |
count := stripByteCounts size. |
|
1657 |
valueArray := stripByteCounts |
|
0 | 1658 |
]. |
1659 |
(tagType == 280) ifTrue:[ |
|
28 | 1660 |
"min sample value" |
0 | 1661 |
]. |
1662 |
(tagType == 281) ifTrue:[ |
|
28 | 1663 |
"max sample value" |
0 | 1664 |
]. |
1665 |
(tagType == 282) ifTrue:[ |
|
28 | 1666 |
"x resolution" |
0 | 1667 |
]. |
1668 |
(tagType == 283) ifTrue:[ |
|
28 | 1669 |
"y resolution" |
0 | 1670 |
]. |
1671 |
(tagType == 284) ifTrue:[ |
|
28 | 1672 |
"planarconfig" |
1673 |
value := planarConfiguration. |
|
1674 |
numberType := #short. |
|
0 | 1675 |
]. |
1676 |
(tagType == 285) ifTrue:[ |
|
28 | 1677 |
"pageName" |
0 | 1678 |
]. |
1679 |
(tagType == 286) ifTrue:[ |
|
28 | 1680 |
"xPosition" |
0 | 1681 |
]. |
1682 |
(tagType == 287) ifTrue:[ |
|
28 | 1683 |
"yPosition" |
0 | 1684 |
]. |
1685 |
(tagType == 288) ifTrue:[ |
|
28 | 1686 |
"freeOffsets" |
0 | 1687 |
]. |
1688 |
(tagType == 289) ifTrue:[ |
|
28 | 1689 |
"freeByteCounts" |
0 | 1690 |
]. |
1691 |
(tagType == 290) ifTrue:[ |
|
28 | 1692 |
"grayResponceUnit" |
0 | 1693 |
]. |
1694 |
(tagType == 291) ifTrue:[ |
|
28 | 1695 |
"grayResponceCurve" |
0 | 1696 |
]. |
1697 |
(tagType == 292) ifTrue:[ |
|
28 | 1698 |
"group3options" |
1699 |
value := group3options. |
|
1700 |
numberType := #long. |
|
0 | 1701 |
]. |
1702 |
(tagType == 293) ifTrue:[ |
|
28 | 1703 |
"group4options" |
0 | 1704 |
]. |
1705 |
(tagType == 296) ifTrue:[ |
|
28 | 1706 |
"resolutionunit" |
1707 |
^ self |
|
0 | 1708 |
]. |
1709 |
(tagType == 297) ifTrue:[ |
|
28 | 1710 |
"pageNumber" |
0 | 1711 |
]. |
1712 |
(tagType == 300) ifTrue:[ |
|
28 | 1713 |
"colorResponceUnit" |
0 | 1714 |
]. |
1715 |
(tagType == 301) ifTrue:[ |
|
28 | 1716 |
"colorResponceCurve" |
0 | 1717 |
]. |
1718 |
(tagType == 306) ifTrue:[ |
|
28 | 1719 |
"dateTime" |
0 | 1720 |
]. |
1721 |
(tagType == 315) ifTrue:[ |
|
28 | 1722 |
"artist" |
0 | 1723 |
]. |
1724 |
(tagType == 317) ifTrue:[ |
|
28 | 1725 |
"predictor" |
0 | 1726 |
]. |
1727 |
(tagType == 320) ifTrue:[ |
|
28 | 1728 |
"colormap" |
1729 |
address := colorMapPos - 1. |
|
1730 |
numberType := #short. |
|
1731 |
count := 256 "(colorMap at:1) size" * 3. |
|
0 | 1732 |
]. |
1733 |
||
1734 |
(value isNil and:[address isNil]) ifTrue:[ |
|
28 | 1735 |
self error:'unhandled tag'. |
1736 |
^ self |
|
0 | 1737 |
]. |
1738 |
||
14 | 1739 |
" |
0 | 1740 |
'tag:' print. tagType print. ' typ:' print. numberType print. |
1741 |
' len:' print. count print. |
|
1742 |
' val:' print. value printNewline. |
|
14 | 1743 |
" |
0 | 1744 |
|
1745 |
self writeShort:tagType. |
|
1746 |
numberType == #short ifTrue:[ |
|
28 | 1747 |
self writeShort:3. |
1748 |
self writeLong:count. |
|
0 | 1749 |
] ifFalse:[ |
28 | 1750 |
numberType == #long ifTrue:[ |
1751 |
self writeShort:4. |
|
1752 |
self writeLong:count. |
|
1753 |
] ifFalse:[ |
|
1754 |
numberType == #byte ifTrue:[ |
|
1755 |
self writeShort:1. |
|
1756 |
self writeLong:count. |
|
1757 |
] ifFalse:[ |
|
1758 |
self error:'bad numbertype' |
|
1759 |
] |
|
1760 |
] |
|
0 | 1761 |
]. |
1762 |
address notNil ifTrue:[ |
|
28 | 1763 |
(numberType == #long and:[count == 1]) ifTrue:[ |
1764 |
self writeLong:(valueArray at:1). |
|
1765 |
^ self |
|
1766 |
]. |
|
1767 |
(numberType == #short and:[count <= 2]) ifTrue:[ |
|
1768 |
self writeShort:(valueArray at:1). |
|
1769 |
count == 2 ifTrue:[ |
|
1770 |
self writeShort:(valueArray at:2). |
|
1771 |
] ifFalse:[ |
|
1772 |
self writeShort:0 |
|
1773 |
]. |
|
1774 |
^ self |
|
1775 |
]. |
|
1776 |
(numberType == #byte and:[count <= 4]) ifTrue:[ |
|
1777 |
outStream nextPut:(valueArray at:1). |
|
1778 |
count > 1 ifTrue:[ |
|
1779 |
outStream nextPut:(valueArray at:2). |
|
1780 |
count > 2 ifTrue:[ |
|
1781 |
outStream nextPut:(valueArray at:3). |
|
1782 |
count > 3 ifTrue:[ |
|
1783 |
outStream nextPut:(valueArray at:4). |
|
1784 |
] ifFalse:[ |
|
1785 |
outStream nextPut:0 |
|
1786 |
]. |
|
1787 |
] ifFalse:[ |
|
1788 |
outStream nextPut:0 |
|
1789 |
]. |
|
1790 |
] ifFalse:[ |
|
1791 |
outStream nextPut:0 |
|
1792 |
]. |
|
1793 |
^ self |
|
1794 |
]. |
|
1795 |
self writeLong:address. |
|
1796 |
^ self |
|
0 | 1797 |
]. |
1798 |
numberType == #short ifTrue:[ |
|
28 | 1799 |
self writeShort:value. |
1800 |
self writeShort:0 |
|
0 | 1801 |
] ifFalse:[ |
28 | 1802 |
numberType == #long ifTrue:[ |
1803 |
self writeLong:value |
|
1804 |
] ifFalse:[ |
|
1805 |
numberType == #byte ifTrue:[ |
|
1806 |
outStream nextPut:value. |
|
1807 |
outStream nextPut:0. |
|
1808 |
outStream nextPut:0. |
|
1809 |
outStream nextPut:0. |
|
1810 |
] ifFalse:[ |
|
1811 |
self error:'bad numbertype' |
|
1812 |
] |
|
1813 |
] |
|
0 | 1814 |
]. |
1815 |
! |
|
1816 |
||
135 | 1817 |
writeUncompressedBits |
1818 |
"write bits as one or multiple strips" |
|
1819 |
||
1820 |
|offs bytesPerRow nBytes |
|
1821 |
h "{ Class: SmallInteger }"| |
|
0 | 1822 |
|
135 | 1823 |
nBytes := data size. |
1824 |
nBytes < 16rFFFF ifTrue:[ |
|
1825 |
stripOffsets := Array with:(outStream position - 1). |
|
1826 |
stripByteCounts := Array with:nBytes. |
|
1827 |
outStream nextPutBytes:nBytes from:data. |
|
1828 |
rowsPerStrip := height |
|
1829 |
] ifFalse:[ |
|
1830 |
stripOffsets := Array basicNew:height. |
|
1831 |
bytesPerRow := nBytes // height. |
|
1832 |
stripByteCounts := (Array basicNew:height) atAllPut:bytesPerRow. |
|
0 | 1833 |
|
135 | 1834 |
offs := 1. |
1835 |
h := height. |
|
1836 |
1 to:h do:[:row | |
|
1837 |
stripOffsets at:row put:(outStream position - 1). |
|
1838 |
outStream nextPutBytes:bytesPerRow from:data startingAt:offs. |
|
1839 |
offs := offs + bytesPerRow |
|
28 | 1840 |
]. |
135 | 1841 |
rowsPerStrip := 1 |
1842 |
]. |
|
1843 |
" |
|
1844 |
'stripOffsets: ' print. stripOffsets printNewline. |
|
1845 |
'stripByteCounts: ' print. stripByteCounts printNewline. |
|
1846 |
" |
|
1847 |
! ! |
|
1848 |
||
1849 |
!TIFFReader methodsFor:'reading from file'! |
|
1850 |
||
1851 |
fromStream:aStream |
|
192 | 1852 |
"read a stream containing a TIFF image. |
1853 |
Leave image description in instance variables." |
|
135 | 1854 |
|
1855 |
|char1 char2 version |
|
1856 |
numberOfTags "{ Class: SmallInteger }" |
|
1857 |
tagType "{ Class: SmallInteger }" |
|
1858 |
numberType "{ Class: SmallInteger }" |
|
1859 |
length "{ Class: SmallInteger }" |
|
516 | 1860 |
result offset msb |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
1861 |
bitsPerPixel bytesPerRow offset1 offset2 tmp| |
135 | 1862 |
|
1863 |
inStream := aStream. |
|
331
304f9c439efa
allow reading from ByteArray-readStreams
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1864 |
aStream binary. |
135 | 1865 |
|
1866 |
char1 := aStream next. |
|
1867 |
char2 := aStream next. |
|
1868 |
(char1 ~~ char2) ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1869 |
'TIFFReader [warning]: not a tiff file' errorPrintCR. |
192 | 1870 |
^ nil |
135 | 1871 |
]. |
331
304f9c439efa
allow reading from ByteArray-readStreams
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1872 |
(char1 == $I asciiValue) ifTrue:[ |
192 | 1873 |
byteOrder := #lsb. |
1874 |
msb := false. |
|
0 | 1875 |
] ifFalse:[ |
331
304f9c439efa
allow reading from ByteArray-readStreams
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1876 |
(char1 == $M asciiValue) ifTrue:[ |
192 | 1877 |
byteOrder := #msb. |
1878 |
msb := true. |
|
1879 |
] ifFalse:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1880 |
'TIFFReader [warning]: not a tiff file' errorPrintCR. |
192 | 1881 |
^ nil |
1882 |
] |
|
0 | 1883 |
]. |
1884 |
||
135 | 1885 |
version := self readShort. |
1886 |
(version ~~ 42) ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1887 |
'TIFFReader [warning]: version of tiff-file not supported' errorPrintCR. |
192 | 1888 |
^ nil |
0 | 1889 |
]. |
1890 |
||
135 | 1891 |
"setup default values" |
0 | 1892 |
|
135 | 1893 |
compression := 1. "none" |
1894 |
fillOrder := #msb. |
|
1895 |
planarConfiguration := 1. |
|
1896 |
photometric := nil. |
|
1897 |
bitsPerSample := 1. |
|
1898 |
samplesPerPixel := 1. |
|
1899 |
width := nil. |
|
1900 |
height := nil. |
|
1901 |
stripOffsets := nil. |
|
1902 |
rowsPerStrip := nil. |
|
1903 |
"resolutionUnit := 2." |
|
1904 |
predictor := 1. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
1905 |
orientation := nil. |
0 | 1906 |
|
135 | 1907 |
offset := aStream nextLongMSB:msb. |
1908 |
aStream position:offset + 1. |
|
1909 |
||
1910 |
numberOfTags := self readShort. |
|
1911 |
1 to:numberOfTags do:[:index | |
|
192 | 1912 |
tagType := self readShort. |
1913 |
numberType := self readShort. |
|
1914 |
length := aStream nextLongMSB:msb. |
|
1915 |
self decodeTiffTag:tagType numberType:numberType length:length |
|
135 | 1916 |
]. |
0 | 1917 |
|
135 | 1918 |
offset := aStream nextLongMSB:msb. |
1919 |
(offset ~~ 0) ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1920 |
'TIFFReader [info]: more tags ignored' infoPrintCR |
135 | 1921 |
]. |
0 | 1922 |
|
135 | 1923 |
"check for required tags" |
1924 |
width isNil ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1925 |
'TIFFReader [warning]: missing width tag' errorPrintCR. |
516 | 1926 |
^ nil |
135 | 1927 |
]. |
0 | 1928 |
|
135 | 1929 |
height isNil ifTrue:[ |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1930 |
'TIFFReader [warning]: missing length tag' errorPrintCR. |
516 | 1931 |
^ nil |
135 | 1932 |
]. |
1933 |
||
1934 |
photometric isNil ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1935 |
'TIFFReader [warning]: missing photometric tag' errorPrintCR. |
516 | 1936 |
^ nil |
135 | 1937 |
]. |
1938 |
||
1939 |
stripOffsets isNil ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1940 |
'TIFFReader [warning]: missing stripOffsets tag' errorPrintCR. |
516 | 1941 |
^ nil |
0 | 1942 |
]. |
1943 |
||
1944 |
stripByteCounts isNil ifTrue:[ |
|
192 | 1945 |
stripOffsets size == 1 ifTrue:[ |
1946 |
stripByteCounts := Array with:(self bitsPerPixel // 8) * width * height |
|
1947 |
] |
|
135 | 1948 |
]. |
1949 |
||
1950 |
stripByteCounts isNil ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1951 |
'TIFFReader [warning]: missing stripByteCounts tag' errorPrintCR. |
192 | 1952 |
^ nil |
0 | 1953 |
]. |
1954 |
||
334 | 1955 |
dimensionCallBack notNil ifTrue:[ |
1956 |
dimensionCallBack value:self |
|
1957 |
]. |
|
1958 |
||
135 | 1959 |
"given all the information, read the bits" |
0 | 1960 |
|
135 | 1961 |
rowsPerStrip isNil ifTrue:[ |
192 | 1962 |
rowsPerStrip := height |
0 | 1963 |
]. |
1964 |
||
516 | 1965 |
result := self readTiffImageData. |
1966 |
result notNil ifTrue:[ |
|
1967 |
||
1968 |
orientation == #vFlip ifTrue:[ |
|
1969 |
"/ reverse rows to top-to bottom |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
1970 |
|
516 | 1971 |
bytesPerRow := self bytesPerRow. |
1972 |
tmp := ByteArray new:bytesPerRow. |
|
1973 |
offset1 := 1. |
|
1974 |
offset2 := (height-1)*bytesPerRow + 1. |
|
1975 |
0 to:(height-1//2) do:[:row | |
|
1976 |
tmp replaceFrom:1 to:bytesPerRow |
|
1977 |
with:data startingAt:offset1. |
|
1978 |
data replaceFrom:offset1 to:offset1+bytesPerRow-1 |
|
1979 |
with:data startingAt:offset2. |
|
1980 |
data replaceFrom:offset2 to:offset2+bytesPerRow-1 |
|
1981 |
with:tmp startingAt:1. |
|
1982 |
offset1 := offset1 + bytesPerRow. |
|
1983 |
offset2 := offset2 - bytesPerRow. |
|
1984 |
]. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
1985 |
]. |
516 | 1986 |
orientation == #unsupported ifTrue:[ |
1987 |
'TIFFReader [warning]: unsupported orientation' errorPrintCR |
|
1988 |
]. |
|
393 | 1989 |
]. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
1990 |
|
135 | 1991 |
^ result |
192 | 1992 |
|
516 | 1993 |
"Modified: 11.4.1997 / 00:21:58 / cg" |
135 | 1994 |
! ! |
0 | 1995 |
|
135 | 1996 |
!TIFFReader methodsFor:'writing to file'! |
1997 |
||
1998 |
save:image onFile:aFileName |
|
1999 |
"save image as (uncompressed) TIFF file on aFileName" |
|
0 | 2000 |
|
135 | 2001 |
|pos1 pos| |
0 | 2002 |
|
135 | 2003 |
outStream := FileStream newFileNamed:aFileName. |
2004 |
outStream isNil ifTrue:[ |
|
461
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
2005 |
^ Image fileCreationErrorSignal |
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
2006 |
raiseWith:image |
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
2007 |
errorString:('file creation error: ' , aFileName asString). |
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
2008 |
]. |
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
2009 |
|
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
2010 |
image mask notNil ifTrue:[ |
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
2011 |
Image informationLostQuerySignal |
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
2012 |
raiseWith:image |
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
2013 |
errorString:('TIFF writer does not (yet) support an imageMask'). |
0 | 2014 |
]. |
2015 |
||
135 | 2016 |
"save as msb" |
2017 |
||
2018 |
byteOrder := #msb. |
|
2019 |
" |
|
2020 |
byteOrder := #lsb. |
|
2021 |
" |
|
2022 |
fillOrder := #msb. |
|
2023 |
width := image width. |
|
2024 |
height := image height. |
|
2025 |
photometric := image photometric. |
|
2026 |
samplesPerPixel := image samplesPerPixel. |
|
2027 |
bitsPerSample := image bitsPerSample. |
|
2028 |
colorMap := image colorMap. |
|
2029 |
planarConfiguration := 1. |
|
2030 |
compression := 1. "none" |
|
2031 |
data := image bits. |
|
2032 |
||
2033 |
currentOffset := 0. |
|
2034 |
||
2035 |
(byteOrder == #msb) ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2036 |
outStream nextPut:$M. outStream nextPut:$M. |
135 | 2037 |
] ifFalse:[ |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2038 |
outStream nextPut:$I. outStream nextPut:$I. |
0 | 2039 |
]. |
135 | 2040 |
currentOffset := currentOffset + 2. |
0 | 2041 |
|
135 | 2042 |
outStream binary. |
2043 |
||
2044 |
self writeShort:42. |
|
2045 |
currentOffset := currentOffset + 2. |
|
0 | 2046 |
|
135 | 2047 |
pos1 := outStream position. |
2048 |
self writeLong:0. "start of tags - filled in later" |
|
2049 |
currentOffset := currentOffset + 4. |
|
2050 |
||
2051 |
"output strips" |
|
2052 |
||
2053 |
self writeUncompressedBits. "this outputs bits as strips, sets stripOffsets and stripByteCounts" |
|
2054 |
self writeStripOffsets. "this outputs strip offsets, sets stripOffsetsPos" |
|
2055 |
self writeStripByteCounts. "this outputs strip bytecounts, sets stripByteCountPos" |
|
2056 |
self writeBitsPerSample. "this outputs bitsPerSample, sets bitsPerSamplePos" |
|
2057 |
photometric == #palette ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2058 |
self writeColorMap "this outputs colorMap, sets colorMapPos" |
0 | 2059 |
]. |
2060 |
||
135 | 2061 |
pos := outStream position. "backpatch tag offset" |
2062 |
outStream position:pos1. |
|
2063 |
self writeLong:(pos - 1). "fill in tag offset" |
|
2064 |
outStream position:pos. |
|
2065 |
" |
|
2066 |
('patch tag offset at: ', (pos1 printStringRadix:16) , ' to ', |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2067 |
(pos printStringRadix:16)) printNewline. |
135 | 2068 |
" |
2069 |
"output tag data" |
|
0 | 2070 |
|
135 | 2071 |
photometric == #palette ifTrue:[ |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2072 |
self writeShort:11. "11 tags" |
135 | 2073 |
] ifFalse:[ |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2074 |
self writeShort:10. "10 tags" |
135 | 2075 |
]. |
2076 |
self writeTag:256. "image width" |
|
2077 |
self writeTag:257. "image height" |
|
2078 |
self writeTag:258. "bits per sample" |
|
2079 |
self writeTag:259. "compression" |
|
2080 |
self writeTag:262. "photometric" |
|
2081 |
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
|
2082 |
self writeTag:277. "samplesPerPixel" |
135 | 2083 |
self writeTag:278. "rowsPerStrip" |
2084 |
self writeTag:279. "strip byte counts" |
|
2085 |
self writeTag:284. "planarconfig" |
|
2086 |
photometric == #palette ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2087 |
self writeTag:320 "colorMap" |
135 | 2088 |
]. |
2089 |
self writeLong:0. "end of tags mark" |
|
2090 |
outStream close |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2091 |
|
461
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
2092 |
"Modified: 27.2.1997 / 12:46:26 / cg" |
135 | 2093 |
! ! |
30 | 2094 |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2095 |
!TIFFReader class methodsFor:'documentation'! |
30 | 2096 |
|
135 | 2097 |
version |
647 | 2098 |
^ '$Header: /cvs/stx/stx/libview2/TIFFReader.st,v 1.56 1997-06-30 20:56:20 cg Exp $' |
0 | 2099 |
! ! |
135 | 2100 |
TIFFReader initialize! |