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