author | Claus Gittinger <cg@exept.de> |
Wed, 08 Sep 1999 18:30:21 +0200 | |
changeset 1230 | 993aaef8a28a |
parent 1215 | e40392a58092 |
child 1571 | cffaf89a0c6e |
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:[ |
|
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
107 |
inStream close. |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
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:[ |
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
237 |
photometric := #transparencyMask |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
238 |
] ifFalse:[ |
516 | 239 |
(value == 5) ifTrue:[ |
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
240 |
photometric := #cmyk "/ color separations |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
241 |
] ifFalse:[ |
516 | 242 |
(value == 6) ifTrue:[ |
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
243 |
photometric := #ycbcr "/ CCIR 601 |
516 | 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" |
744 | 1000 |
! |
1001 |
||
1002 |
decompressPackBits:nIn from:srcBytes to:dstBytes startingAt:dstOffset |
|
1003 |
|i b v dstOffs| |
|
1004 |
||
1005 |
dstOffs := dstOffset. |
|
1006 |
i := 1. |
|
1007 |
||
1008 |
[i <= nIn] whileTrue:[ |
|
1009 |
b := srcBytes at:i. |
|
1010 |
i := i + 1. |
|
1011 |
||
1012 |
b ~~ 16rFF ifTrue:[ "/ not a NOP |
|
1013 |
b <= 127 ifTrue:[ |
|
1014 |
"/ 0..127 literal bytes |
|
1015 |
dstBytes replaceFrom:dstOffs to:dstOffs+b with:srcBytes startingAt:i. |
|
1016 |
i := i + b+1. |
|
1017 |
dstOffs := dstOffs + b+1. |
|
1018 |
||
1019 |
"/ 1 to:(b+1) do:[:nLit| |
|
1020 |
"/ dstBytes at:dstOffs put:(srcBytes at:i). |
|
1021 |
"/ i := i + 1. |
|
1022 |
"/ dstOffs := dstOffs + 1 |
|
1023 |
"/ ] |
|
1024 |
] ifFalse:[ |
|
1025 |
"/ 128..254 a run |
|
1026 |
b := b - 256. |
|
1027 |
b := b negated + 1. |
|
1028 |
||
1029 |
v := srcBytes at:i. |
|
1030 |
i := i + 1. |
|
1031 |
||
1032 |
dstBytes from:dstOffs to:dstOffs+b-1 put:v. |
|
1033 |
dstOffs := dstOffs+b. |
|
1034 |
||
1035 |
"/ 1 to:b do:[:nRun | |
|
1036 |
"/ dstBytes at:dstOffs put:v. |
|
1037 |
"/ dstOffs := dstOffs + 1. |
|
1038 |
"/ ] |
|
1039 |
] |
|
1040 |
] |
|
1041 |
]. |
|
1042 |
^ dstOffs - dstOffset |
|
1043 |
||
1044 |
"Created: / 1.12.1997 / 18:39:23 / cg" |
|
1045 |
"Modified: / 1.12.1997 / 18:49:58 / cg" |
|
440 | 1046 |
! ! |
1047 |
||
516 | 1048 |
!TIFFReader methodsFor:'private - data reading'! |
0 | 1049 |
|
135 | 1050 |
readCCITT3RLETiffImageData |
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1051 |
^ self fileFormatError:'ccitt mod Huffman (rle) compression not implemented' |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1052 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1053 |
"Modified: / 3.2.1998 / 18:03:14 / cg" |
135 | 1054 |
! |
1055 |
||
1056 |
readCCITT3RLEWTiffImageData |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1057 |
^ self fileFormatError:'ccitt mod Huffman (rlew) compression not implemented'. |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1058 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1059 |
"Modified: / 3.2.1998 / 18:03:30 / cg" |
135 | 1060 |
! |
1061 |
||
1062 |
readCCITTGroup3TiffImageData |
|
1063 |
"not really tested - all I got is a single |
|
1064 |
fax from NeXT step" |
|
1065 |
||
1066 |
|bytesPerRow bitsPerRow compressedStrip nPlanes |
|
1067 |
stripNr "{ Class: SmallInteger }" |
|
1068 |
offset "{ Class: SmallInteger }" |
|
1069 |
row "{ Class: SmallInteger }" |
|
1070 |
bytesPerStrip "{ Class: SmallInteger }" | |
|
1071 |
||
1072 |
nPlanes := samplesPerPixel. |
|
1073 |
(nPlanes == 2) ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1074 |
'TIFFReader [info]: ignoring alpha plane' infoPrintCR. |
335 | 1075 |
nPlanes := 1 |
135 | 1076 |
]. |
1077 |
||
1078 |
(nPlanes ~~ 1) ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1079 |
^ self fileFormatError:'only monochrome/greyscale ccitt3supported'. |
135 | 1080 |
]. |
0 | 1081 |
|
135 | 1082 |
stripByteCounts isNil ifTrue:[ |
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1083 |
^ self fileFormatError:'currently require stripByteCounts'. |
135 | 1084 |
]. |
1085 |
(rowsPerStrip ~~ 1) isNil ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1086 |
^ self fileFormatError:'currently require rowsPerStrip to be 1'. |
135 | 1087 |
]. |
1088 |
||
335 | 1089 |
"/ 'TIFFReader: decompressing CCITT-3 ...' infoPrintNL. |
135 | 1090 |
|
1091 |
bitsPerRow := width * (bitsPerSample at:1). |
|
1092 |
bytesPerRow := bitsPerRow // 8. |
|
1093 |
((bitsPerRow \\ 8) ~~ 0) ifTrue:[ |
|
335 | 1094 |
bytesPerRow := bytesPerRow + 1 |
135 | 1095 |
]. |
1096 |
||
1097 |
data := ByteArray new:(bytesPerRow * height). |
|
1098 |
compressedStrip := ByteArray uninitializedNew:bytesPerRow. |
|
1099 |
||
1100 |
offset := 1. |
|
1101 |
stripNr := 0. |
|
1102 |
||
1103 |
row := 1. |
|
1104 |
bytesPerStrip := bytesPerRow * rowsPerStrip. |
|
1105 |
[row <= height] whileTrue:[ |
|
335 | 1106 |
stripNr := stripNr + 1. |
1107 |
inStream position:((stripOffsets at:stripNr) + 1). |
|
1108 |
inStream nextBytes:(stripByteCounts at:stripNr) into:compressedStrip. |
|
1109 |
self class decompressCCITT3From:compressedStrip |
|
1110 |
into:data |
|
1111 |
startingAt:offset |
|
1112 |
count:width. |
|
1113 |
offset := offset + bytesPerStrip. |
|
1114 |
row := row + rowsPerStrip |
|
135 | 1115 |
] |
335 | 1116 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1117 |
"Modified: / 3.2.1998 / 18:04:21 / cg" |
135 | 1118 |
! |
1119 |
||
1120 |
readCCITTGroup4TiffImageData |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1121 |
^ self fileFormatError:'ccitt group4 fax compression not implemented'. |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1122 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1123 |
"Modified: / 3.2.1998 / 18:04:34 / cg" |
135 | 1124 |
! |
0 | 1125 |
|
516 | 1126 |
readDCSTiffImageData |
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1127 |
^ self fileFormatError:'dcs compression not implemented'. |
329
5fb99e0734e4
handle empty character-strings
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1128 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1129 |
"Modified: / 3.2.1998 / 18:04:44 / cg" |
135 | 1130 |
! |
1131 |
||
516 | 1132 |
readDeflateTiffImageData |
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1133 |
^ self fileFormatError:'deflate compression not implemented'. |
135 | 1134 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1135 |
"Modified: / 3.2.1998 / 18:04:54 / cg" |
516 | 1136 |
! |
1137 |
||
1138 |
readJBIGTiffImageData |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1139 |
^ self fileFormatError:'jbig compression not implemented'. |
516 | 1140 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1141 |
"Modified: / 3.2.1998 / 18:05:04 / cg" |
135 | 1142 |
! |
1143 |
||
1144 |
readJPEGTiffImageData |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1145 |
^ self fileFormatError:'jpeg compression not implemented'. |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1146 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1147 |
"Modified: / 3.2.1998 / 18:05:12 / cg" |
135 | 1148 |
! |
1149 |
||
1150 |
readLZWTiffImageData |
|
1151 |
"read LZW compressed tiff data; this method only |
|
1152 |
handles 3x8 rgb and 1x2 or 2x2 greyscale images. |
|
1153 |
For 2x2 greyscale images, the alpha plane is ignored. |
|
1154 |
(maybe other formats work also - its simply not |
|
1155 |
tested)" |
|
1156 |
||
1037
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1157 |
|bytesPerRow compressedStrip nPlanes overAllBytes |
135 | 1158 |
bytesPerStrip "{ Class: SmallInteger }" |
1159 |
nBytes "{ Class: SmallInteger }" |
|
1160 |
prevSize "{ Class: SmallInteger }" |
|
1161 |
stripNr "{ Class: SmallInteger }" |
|
1162 |
offset "{ Class: SmallInteger }" |
|
1163 |
row "{ Class: SmallInteger }" | |
|
1164 |
||
1165 |
nPlanes := samplesPerPixel. |
|
1166 |
||
1167 |
(nPlanes == 3) ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1168 |
(((bitsPerSample at:1) ~~ 8) |
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1169 |
or:[((bitsPerSample at:2) ~~ 8) |
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1170 |
or:[((bitsPerSample at:3) ~~ 8)]]) ifTrue:[ |
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1171 |
^ self fileFormatError:'only 8/8/8 bit/sample are supported'. |
335 | 1172 |
]. |
1173 |
bytesPerRow := width * samplesPerPixel. |
|
0 | 1174 |
] ifFalse:[ |
335 | 1175 |
(nPlanes == 2) ifTrue:[ |
1176 |
(planarConfiguration ~~ 2) ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1177 |
^ self fileFormatError:'only separate planes are supported'. |
335 | 1178 |
]. |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1179 |
'TIFFReader [info]: ignoring alpha plane' infoPrintCR. |
335 | 1180 |
nPlanes := 1 |
1181 |
]. |
|
1182 |
(nPlanes == 1) ifFalse:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1183 |
^ self fileFormatError:'only 3-sample rgb / monochrome supported'. |
335 | 1184 |
]. |
1185 |
bytesPerRow := (width * (bitsPerSample at:1) + 7) // 8. |
|
135 | 1186 |
]. |
1187 |
||
1188 |
stripByteCounts isNil ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1189 |
^ self fileFormatError:'currently require stripByteCounts'. |
135 | 1190 |
]. |
1191 |
||
335 | 1192 |
"/ 'TIFFReader: decompressing LZW ...' infoPrintNL. |
135 | 1193 |
|
1037
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1194 |
overAllBytes := bytesPerRow * height. |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1195 |
bytesPerRow == width ifTrue:[ |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1196 |
data := ByteArray uninitializedNew:overAllBytes. |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1197 |
] ifFalse:[ |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1198 |
data := ByteArray new:overAllBytes. |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1199 |
]. |
135 | 1200 |
|
1201 |
offset := 1. |
|
1202 |
stripNr := 0. |
|
1203 |
||
1204 |
row := 1. |
|
1205 |
bytesPerStrip := bytesPerRow * rowsPerStrip. |
|
1206 |
prevSize := 0. |
|
1207 |
[row <= height] whileTrue:[ |
|
335 | 1208 |
stripNr := stripNr + 1. |
1209 |
inStream position:((stripOffsets at:stripNr) + 1). |
|
1210 |
nBytes := stripByteCounts at:stripNr. |
|
1211 |
(nBytes > prevSize) ifTrue:[ |
|
1212 |
compressedStrip := ByteArray uninitializedNew:nBytes. |
|
1213 |
prevSize := nBytes |
|
1214 |
]. |
|
1215 |
inStream nextBytes:nBytes |
|
1216 |
into:compressedStrip. |
|
1217 |
self class decompressLZWFrom:compressedStrip |
|
1218 |
count:nBytes |
|
1219 |
into:data |
|
1220 |
startingAt:offset. |
|
1221 |
offset := offset + bytesPerStrip. |
|
1222 |
row := row + rowsPerStrip |
|
135 | 1223 |
]. |
1224 |
||
1225 |
(predictor == 2) ifTrue:[ |
|
335 | 1226 |
self class decodeDelta:3 in:data width:width height:height |
135 | 1227 |
] |
335 | 1228 |
|
1037
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1229 |
"Modified: / 12.8.1998 / 13:58:13 / cg" |
135 | 1230 |
! |
1231 |
||
1232 |
readNeXTJPEGTiffImageData |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1233 |
^ self fileFormatError:'next jpeg compression not implemented'. |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1234 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1235 |
"Modified: / 3.2.1998 / 18:10:45 / cg" |
135 | 1236 |
! |
1237 |
||
1238 |
readNeXTRLE2TiffImageData |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1239 |
^ self fileFormatError:'next 2bit rle compression not implemented'. |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1240 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1241 |
"Modified: / 3.2.1998 / 18:10:54 / cg" |
135 | 1242 |
! |
1243 |
||
1244 |
readPackbitsTiffImageData |
|
744 | 1245 |
"this has only been tested with monochrome images" |
1246 |
||
1247 |
|bytesPerRow bitsPerRow nPlanes |
|
1248 |
stripNr "{ Class: SmallInteger }" |
|
1249 |
offset "{ Class: SmallInteger }" |
|
1250 |
row "{ Class: SmallInteger }" |
|
1251 |
nBytes "{ Class: SmallInteger }" |
|
1252 |
nDecompressedBytes "{ Class: SmallInteger }" |
|
1253 |
bitsPerPixel overAllBytes buffer| |
|
1254 |
||
1255 |
nPlanes := samplesPerPixel. |
|
1256 |
||
1257 |
"only support 1-sample/pixel, |
|
1258 |
with alpha - if separate planes, |
|
1259 |
or rgb - if non separate planes and no alpha" |
|
135 | 1260 |
|
744 | 1261 |
(nPlanes == 2) ifTrue:[ |
1262 |
(planarConfiguration ~~ 2) ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1263 |
^ self fileFormatError:'with alpha, only separate planes supported'. |
744 | 1264 |
]. |
1265 |
'TIFFReader [info]: ignoring alpha plane' infoPrintCR. |
|
1266 |
nPlanes := 1. |
|
1267 |
bitsPerPixel := bitsPerSample at:1. |
|
1268 |
bitsPerSample := Array with:bitsPerPixel. |
|
1269 |
samplesPerPixel := 1. |
|
1270 |
] ifFalse:[ |
|
1271 |
(nPlanes == 3) ifTrue:[ |
|
1272 |
(planarConfiguration ~~ 1) ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1273 |
^ self fileFormatError:'only non separate planes supported'. |
744 | 1274 |
]. |
1275 |
bitsPerSample ~= #(8 8 8) ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1276 |
^ self fileFormatError:'only 8/8/8 rgb images supported'. |
744 | 1277 |
]. |
1278 |
bitsPerPixel := 24 |
|
1279 |
] ifFalse:[ |
|
1280 |
(nPlanes ~~ 1) ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1281 |
^ self fileFormatError:'format not supported'. |
744 | 1282 |
]. |
1283 |
bitsPerPixel := bitsPerSample at:1. |
|
1284 |
] |
|
1285 |
]. |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1286 |
|
744 | 1287 |
bitsPerRow := width * bitsPerPixel. |
1288 |
bytesPerRow := bitsPerRow // 8. |
|
1289 |
((bitsPerRow \\ 8) ~~ 0) ifTrue:[ |
|
1290 |
bytesPerRow := bytesPerRow + 1 |
|
1291 |
]. |
|
1292 |
||
1293 |
overAllBytes := bytesPerRow * height. |
|
1037
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1294 |
bytesPerRow == width ifTrue:[ |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1295 |
data := ByteArray uninitializedNew:overAllBytes. |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1296 |
] ifFalse:[ |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1297 |
data := ByteArray new:overAllBytes. |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1298 |
]. |
744 | 1299 |
|
1300 |
offset := 1. |
|
1301 |
stripNr := 0. |
|
1302 |
||
1303 |
buffer := nil. |
|
1304 |
row := 1. |
|
1305 |
[row <= height] whileTrue:[ |
|
1306 |
stripNr := stripNr + 1. |
|
1307 |
nBytes := stripByteCounts at:stripNr. |
|
1308 |
inStream position:((stripOffsets at:stripNr) + 1). |
|
1309 |
||
1310 |
nBytes > buffer size ifTrue:[ |
|
1311 |
"/ realloc |
|
1312 |
buffer := ByteArray uninitializedNew:nBytes. |
|
1313 |
]. |
|
1314 |
inStream nextBytes:nBytes into:buffer. |
|
1315 |
||
1316 |
nDecompressedBytes := self decompressPackBits:nBytes from:buffer to:data startingAt:offset. |
|
1317 |
||
1318 |
offset := offset + nDecompressedBytes. |
|
1319 |
row := row + rowsPerStrip |
|
1320 |
] |
|
1321 |
||
1037
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1322 |
"Modified: / 12.8.1998 / 13:57:34 / cg" |
135 | 1323 |
! |
1324 |
||
516 | 1325 |
readPixarFilmTiffImageData |
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1326 |
^ self fileFormatError:'pixar film compression not implemented'. |
135 | 1327 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1328 |
"Modified: / 3.2.1998 / 18:11:45 / cg" |
516 | 1329 |
! |
1330 |
||
1331 |
readPixarLogTiffImageData |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1332 |
^ self fileFormatError:'pixar log compression not implemented'. |
0 | 1333 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1334 |
"Modified: / 3.2.1998 / 18:11:53 / cg" |
516 | 1335 |
! |
135 | 1336 |
|
516 | 1337 |
readThunderScanTiffImageData |
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1338 |
^ self fileFormatError:'thunderScan compression not implemented' . |
516 | 1339 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1340 |
"Modified: / 3.2.1998 / 18:12:01 / cg" |
516 | 1341 |
! |
135 | 1342 |
|
516 | 1343 |
readTiffImageData |
1344 |
(compression == 1) ifTrue:[ |
|
1345 |
^ self readUncompressedTiffImageData. |
|
1346 |
]. |
|
1347 |
(compression == 2) ifTrue:[ |
|
1348 |
^ self readCCITT3RLETiffImageData. |
|
1349 |
]. |
|
1350 |
(compression == 3) ifTrue:[ |
|
1351 |
^ self readCCITTGroup3TiffImageData. |
|
1352 |
]. |
|
1353 |
(compression == 4) ifTrue:[ |
|
1354 |
^ self readCCITTGroup4TiffImageData. |
|
1355 |
]. |
|
1356 |
(compression == 5) ifTrue:[ |
|
1357 |
^ self readLZWTiffImageData. |
|
1358 |
]. |
|
1359 |
(compression == 6) ifTrue:[ |
|
1360 |
^ self readJPEGTiffImageData. |
|
1361 |
]. |
|
1362 |
(compression == 7) ifTrue:[ |
|
1363 |
^ self readNewJPEGTiffImageData. |
|
1364 |
]. |
|
1365 |
||
1366 |
(compression == 32766) ifTrue:[ |
|
1367 |
^ self readNeXTRLE2TiffImageData. |
|
1368 |
]. |
|
1369 |
(compression == 32771) ifTrue:[ |
|
1370 |
^ self readCCITTRLEWTiffImageData. |
|
135 | 1371 |
]. |
516 | 1372 |
(compression == 32773) ifTrue:[ |
1373 |
^ self readPackbitsTiffImageData. |
|
1374 |
]. |
|
1375 |
(compression == 32809) ifTrue:[ |
|
1376 |
^ self readThunderScanTiffImageData. |
|
1377 |
]. |
|
1378 |
(compression == 32908) ifTrue:[ |
|
1379 |
^ self readPixarFilmTiffImageData. |
|
1380 |
]. |
|
1381 |
(compression == 32909) ifTrue:[ |
|
1382 |
^ self readPixarLogTiffImageData. |
|
1383 |
]. |
|
1384 |
(compression == 32946) ifTrue:[ |
|
1385 |
^ self readDeflateTiffImageData. |
|
1386 |
]. |
|
1387 |
(compression == 32947) ifTrue:[ |
|
1388 |
^ self readDCSTiffImageData. |
|
1389 |
]. |
|
1390 |
(compression == 32865) ifTrue:[ |
|
1391 |
^ self readNeXTJPEGTiffImageData. |
|
1392 |
]. |
|
1393 |
(compression == 34661) ifTrue:[ |
|
1394 |
^ self readJBIGTiffImageData. |
|
1395 |
]. |
|
1396 |
||
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1397 |
^ self fileFormatError:('compression type ' , compression printString , ' not known'). |
516 | 1398 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1399 |
"Created: / 11.4.1997 / 00:19:44 / cg" |
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1400 |
"Modified: / 3.2.1998 / 18:12:36 / cg" |
135 | 1401 |
! |
1402 |
||
1403 |
readUncompressedTiffImageData |
|
1404 |
|bytesPerRow bitsPerRow nPlanes |
|
1405 |
stripNr "{ Class: SmallInteger }" |
|
1406 |
offset "{ Class: SmallInteger }" |
|
1407 |
row "{ Class: SmallInteger }" |
|
1408 |
nBytes "{ Class: SmallInteger }" |
|
1409 |
bitsPerPixel overAllBytes| |
|
1410 |
||
1411 |
nPlanes := samplesPerPixel. |
|
1412 |
||
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1413 |
"/ not all formats are supported here, |
135 | 1414 |
|
1415 |
(nPlanes == 2) ifTrue:[ |
|
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1416 |
(planarConfiguration ~~ 2) ifTrue:[ |
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1417 |
^ self fileFormatError:'with alpha, only separate planes supported'. |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1418 |
]. |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
1419 |
'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
|
1420 |
nPlanes := 1. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1421 |
bitsPerPixel := bitsPerSample at:1. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1422 |
bitsPerSample := Array with:bitsPerPixel. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1423 |
samplesPerPixel := 1. |
135 | 1424 |
] ifFalse:[ |
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1425 |
(nPlanes == 4) ifTrue:[ |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1426 |
(planarConfiguration ~~ 1) ifTrue:[ |
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1427 |
^ self fileFormatError:'only non separate planes supported'. |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1428 |
]. |
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1429 |
bitsPerSample ~= #(8 8 8 8) ifTrue:[ |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1430 |
^ self fileFormatError:'only 8/8/8/8 cmyk images supported'. |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1431 |
]. |
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1432 |
bitsPerPixel := 32. |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1433 |
] ifFalse:[ |
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1434 |
(nPlanes == 3) ifTrue:[ |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1435 |
(planarConfiguration ~~ 1) ifTrue:[ |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1436 |
^ self fileFormatError:'only non separate planes supported'. |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1437 |
]. |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1438 |
bitsPerSample ~= #(8 8 8) ifTrue:[ |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1439 |
^ self fileFormatError:'only 8/8/8 rgb images supported'. |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1440 |
]. |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1441 |
bitsPerPixel := 24 |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1442 |
] ifFalse:[ |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1443 |
(nPlanes ~~ 1) ifTrue:[ |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1444 |
^ self fileFormatError:('unsupported format: nplanes=' , nPlanes printString). |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1445 |
]. |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1446 |
bitsPerPixel := bitsPerSample at:1. |
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1447 |
] |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1448 |
] |
0 | 1449 |
]. |
135 | 1450 |
|
1451 |
bitsPerRow := width * bitsPerPixel. |
|
1452 |
bytesPerRow := bitsPerRow // 8. |
|
1453 |
((bitsPerRow \\ 8) ~~ 0) ifTrue:[ |
|
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1454 |
bytesPerRow := bytesPerRow + 1 |
135 | 1455 |
]. |
1456 |
||
1457 |
overAllBytes := bytesPerRow * height. |
|
1037
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1458 |
bytesPerRow == width ifTrue:[ |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1459 |
data := ByteArray uninitializedNew:overAllBytes. |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1460 |
] ifFalse:[ |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1461 |
data := ByteArray new:overAllBytes. |
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1462 |
]. |
135 | 1463 |
|
336
9789b02d95bf
oops - the very last pixel was not read (in readUncompressed ...)
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1464 |
offset := 0. |
135 | 1465 |
stripNr := 0. |
1466 |
||
1467 |
row := 1. |
|
1468 |
[row <= height] whileTrue:[ |
|
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1469 |
stripNr := stripNr + 1. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1470 |
nBytes := stripByteCounts at:stripNr. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1471 |
inStream position:((stripOffsets at:stripNr) + 1). |
135 | 1472 |
|
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1473 |
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
|
1474 |
nBytes := overAllBytes - offset. |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1475 |
]. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1476 |
|
563
38cbee875bfa
read data in blocks - better if images are read from a CD
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
1477 |
"/ 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
|
1478 |
"/ 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
|
1479 |
inStream nextBytes:nBytes into:data startingAt:offset+1 blockSize:4096. |
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
1480 |
|
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1481 |
offset := offset + nBytes. |
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1482 |
row := row + rowsPerStrip |
135 | 1483 |
] |
317
5de89b17ed48
care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
1484 |
|
1037
90d38c8e3f5f
use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1485 |
"Modified: / 12.8.1998 / 13:57:14 / cg" |
440 | 1486 |
! ! |
1487 |
||
516 | 1488 |
!TIFFReader methodsFor:'private - reading'! |
1489 |
||
1490 |
readChars:n |
|
1491 |
"read n characters and return them in a string" |
|
1492 |
||
1493 |
|oldPos offset string| |
|
1494 |
||
1495 |
n == 0 ifTrue:[^ '']. |
|
1496 |
||
1497 |
string := String new:(n - 1). |
|
1498 |
(n <= 4) ifTrue:[ |
|
1499 |
inStream nextBytes:(n - 1) into:string |
|
1500 |
] ifFalse:[ |
|
1501 |
offset := inStream nextLongMSB:(byteOrder ~~ #lsb). |
|
1502 |
oldPos := inStream position. |
|
1503 |
inStream position:(offset + 1). |
|
1504 |
inStream nextBytes:(n - 1) into:string. |
|
1505 |
inStream position:oldPos |
|
1506 |
]. |
|
1507 |
^ string |
|
1508 |
||
1509 |
"Modified: 5.9.1996 / 12:21:08 / cg" |
|
1510 |
! |
|
1511 |
||
1512 |
readFracts:nFracts |
|
1513 |
"read nFracts fractions (2 32bit words) and return them in an array" |
|
1514 |
||
1515 |
|oldPos offset values numerator denominator msb |
|
1516 |
n "{ Class: SmallInteger }" | |
|
1517 |
||
1518 |
n := nFracts. |
|
1519 |
||
1520 |
msb := byteOrder ~~ #lsb. |
|
1521 |
values := Array basicNew:n. |
|
1522 |
offset := inStream nextLongMSB:msb. |
|
1523 |
oldPos := inStream position. |
|
1524 |
inStream position:(offset + 1). |
|
1525 |
1 to:n do:[:index | |
|
1526 |
numerator := inStream nextLongMSB:msb. |
|
1527 |
denominator := inStream nextLongMSB:msb. |
|
1528 |
values at:index put:(Fraction numerator:numerator denominator:denominator) |
|
1529 |
]. |
|
1530 |
inStream position:oldPos. |
|
1531 |
^ values |
|
1532 |
! |
|
1533 |
||
1534 |
readLongs:nLongs |
|
1535 |
"read nLongs long numbers (32bit) and return them in an array" |
|
1536 |
||
1537 |
|oldPos offset values msb |
|
1538 |
n "{ Class: SmallInteger }" | |
|
1539 |
||
1540 |
n := nLongs. |
|
1541 |
||
1542 |
msb := byteOrder ~~ #lsb. |
|
1543 |
values := Array basicNew:n. |
|
1544 |
(n == 1) ifTrue:[ |
|
1545 |
values at:1 put:(inStream nextLongMSB:msb). |
|
1546 |
] ifFalse:[ |
|
1547 |
offset := inStream nextLongMSB:msb. |
|
1548 |
oldPos := inStream position. |
|
1549 |
inStream position:(offset + 1). |
|
1550 |
1 to:n do:[:index | |
|
1551 |
values at:index put:(inStream nextLongMSB:msb) |
|
1552 |
]. |
|
1553 |
inStream position:oldPos |
|
1554 |
]. |
|
1555 |
^ values |
|
1556 |
! |
|
1557 |
||
1558 |
readShorts:nShorts |
|
1559 |
"read nShorts short numbers (16bit) and return them in an array" |
|
1560 |
||
1561 |
|oldPos offset values msb val2 |
|
1562 |
n "{ Class: SmallInteger }" | |
|
1563 |
||
1564 |
n := nShorts. |
|
1565 |
||
1566 |
msb := (byteOrder ~~ #lsb). |
|
1567 |
values := Array basicNew:n. |
|
1568 |
(n <= 2) ifTrue:[ |
|
1569 |
values at:1 put:(inStream nextUnsignedShortMSB:msb). |
|
1570 |
val2 := inStream nextUnsignedShortMSB:msb. |
|
1571 |
||
1572 |
(n == 2) ifTrue:[ |
|
1573 |
values at:2 put:val2 |
|
1574 |
] |
|
1575 |
] ifFalse:[ |
|
1576 |
offset := inStream nextLongMSB:msb. |
|
1577 |
oldPos := inStream position. |
|
1578 |
inStream position:(offset + 1). |
|
1579 |
1 to:n do:[:index | |
|
1580 |
values at:index put:(inStream nextUnsignedShortMSB:msb) |
|
1581 |
]. |
|
1582 |
inStream position:oldPos |
|
1583 |
]. |
|
1584 |
^ values |
|
1585 |
! ! |
|
1586 |
||
440 | 1587 |
!TIFFReader methodsFor:'private - writing'! |
135 | 1588 |
|
1589 |
writeBitsPerSample |
|
14 | 1590 |
" |
135 | 1591 |
'bitsPerSample: ' print. bitsPerSample printNewline. |
1592 |
'store bitspersample at: ' print. outStream position printNewline. |
|
14 | 1593 |
" |
135 | 1594 |
bitsPerSamplePos := outStream position. |
1595 |
bitsPerSample do:[:n | |
|
1596 |
self writeShort:n |
|
1597 |
] |
|
0 | 1598 |
! |
1599 |
||
1600 |
writeColorMap |
|
28 | 1601 |
|n| |
1602 |
||
0 | 1603 |
colorMapPos := outStream position. |
35 | 1604 |
#(red green blue) do:[:component | |
440 | 1605 |
n := 0. |
1606 |
colorMap do:[:clr | |
|
1607 |
|entry| |
|
35 | 1608 |
|
440 | 1609 |
clr isNil ifTrue:[ |
1610 |
entry := 0 |
|
1611 |
] ifFalse:[ |
|
1612 |
entry := clr perform:component. |
|
1613 |
" |
|
1614 |
tiff map is 16 bit - scale from percent to 0..16rFFFF |
|
1615 |
" |
|
1616 |
entry := (entry * 16rFFFF / 100) rounded. |
|
1617 |
]. |
|
1618 |
self writeShort:entry. |
|
1619 |
n := n + 1 |
|
1620 |
]. |
|
1621 |
||
1622 |
" |
|
1623 |
fill to 256 entries |
|
1624 |
" |
|
1625 |
[n < 256] whileTrue:[ |
|
1626 |
self writeShort:0. |
|
1627 |
n := n + 1. |
|
1628 |
] |
|
0 | 1629 |
] |
440 | 1630 |
|
1631 |
"Modified: 20.2.1997 / 18:06:10 / cg" |
|
0 | 1632 |
! |
1633 |
||
1634 |
writeStripByteCounts |
|
3 | 1635 |
" |
0 | 1636 |
'stripByteCounts: ' print. stripByteCounts printNewline. |
1637 |
'store stripbytecounts at: ' print. outStream position printNewline. |
|
3 | 1638 |
" |
0 | 1639 |
stripByteCountsPos := outStream position. |
1640 |
stripByteCounts do:[:c | |
|
28 | 1641 |
self writeShort:c |
0 | 1642 |
] |
1643 |
! |
|
1644 |
||
135 | 1645 |
writeStripOffsets |
3 | 1646 |
" |
135 | 1647 |
'stripOffsets: ' print. stripOffsets printNewline. |
1648 |
'store stripoffsets at: ' print. outStream position printNewline. |
|
3 | 1649 |
" |
135 | 1650 |
stripOffsetsPos := outStream position. |
1651 |
stripOffsets do:[:o | |
|
1652 |
self writeLong:o |
|
0 | 1653 |
] |
1654 |
! |
|
1655 |
||
1656 |
writeTag:tagType |
|
1657 |
self writeTiffTag:tagType. |
|
1658 |
! |
|
1659 |
||
1660 |
writeTiffTag:tagType |
|
1661 |
|value valueArray numberType count address| |
|
1662 |
||
1663 |
count := 1. |
|
1664 |
address := nil. |
|
1665 |
(tagType == 253) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1666 |
"tiff class" |
0 | 1667 |
]. |
1668 |
(tagType == 254) ifTrue:[ |
|
1669 |
]. |
|
1670 |
(tagType == 255) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1671 |
"SubfileType" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1672 |
value := subFileType. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1673 |
numberType := #long. |
0 | 1674 |
]. |
1675 |
(tagType == 256) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1676 |
"ImageWidth" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1677 |
value := width. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1678 |
numberType := #short. |
0 | 1679 |
]. |
1680 |
(tagType == 257) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1681 |
"ImageHeight" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1682 |
value := height. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1683 |
numberType := #short. |
0 | 1684 |
]. |
1685 |
(tagType == 258) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1686 |
"bitspersample" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1687 |
address := bitsPerSamplePos - 1. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1688 |
numberType := #short. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1689 |
count := bitsPerSample size. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1690 |
valueArray := bitsPerSample |
0 | 1691 |
]. |
1692 |
(tagType == 259) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1693 |
"compression" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1694 |
value := compression. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1695 |
numberType := #short. |
0 | 1696 |
]. |
1697 |
(tagType == 262) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1698 |
"photometric" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1699 |
(photometric == #whiteIs0) ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1700 |
value := 0 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1701 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1702 |
(photometric == #blackIs0) ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1703 |
value := 1 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1704 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1705 |
(photometric == #rgb) ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1706 |
value := 2 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1707 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1708 |
(photometric == #palette) ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1709 |
value := 3 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1710 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1711 |
(photometric == #transparency) ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1712 |
value := 4 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1713 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1714 |
self error:'bad photometric' mayProceed:true. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1715 |
] |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1716 |
] |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1717 |
] |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1718 |
] |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1719 |
]. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1720 |
numberType := #short. |
0 | 1721 |
]. |
1722 |
(tagType == 263) ifTrue:[ |
|
1723 |
]. |
|
1724 |
(tagType == 264) ifTrue:[ |
|
1725 |
]. |
|
1726 |
(tagType == 265) ifTrue:[ |
|
1727 |
]. |
|
1728 |
(tagType == 266) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1729 |
"fillOrder" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1730 |
(fillOrder == #msb) ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1731 |
value := 1 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1732 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1733 |
(fillOrder == #lsb) ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1734 |
value := 2 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1735 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1736 |
self error:'bad fillOrder' mayProceed:true |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1737 |
] |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1738 |
]. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1739 |
numberType := #short. |
0 | 1740 |
]. |
1741 |
(tagType == 269) ifTrue:[ |
|
1742 |
]. |
|
1743 |
(tagType == 270) ifTrue:[ |
|
1744 |
]. |
|
1745 |
(tagType == 271) ifTrue:[ |
|
1746 |
]. |
|
1747 |
(tagType == 272) ifTrue:[ |
|
1748 |
]. |
|
1749 |
(tagType == 273) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1750 |
"stripoffsets" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1751 |
address := stripOffsetsPos - 1. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1752 |
numberType := #long. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1753 |
count := stripOffsets size. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1754 |
valueArray := stripOffsets |
0 | 1755 |
]. |
1756 |
(tagType == 274) ifTrue:[ |
|
1757 |
]. |
|
1758 |
(tagType == 277) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1759 |
"samplesPerPixel" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1760 |
value := samplesPerPixel. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1761 |
numberType := #short. |
0 | 1762 |
]. |
1763 |
(tagType == 278) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1764 |
"rowsperstrip" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1765 |
value := rowsPerStrip. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1766 |
numberType := #short. |
0 | 1767 |
]. |
1768 |
(tagType == 279) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1769 |
"stripbytecount" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1770 |
address := stripByteCountsPos - 1. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1771 |
numberType := #short. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1772 |
count := stripByteCounts size. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1773 |
valueArray := stripByteCounts |
0 | 1774 |
]. |
1775 |
(tagType == 280) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1776 |
"min sample value" |
0 | 1777 |
]. |
1778 |
(tagType == 281) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1779 |
"max sample value" |
0 | 1780 |
]. |
1781 |
(tagType == 282) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1782 |
"x resolution" |
0 | 1783 |
]. |
1784 |
(tagType == 283) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1785 |
"y resolution" |
0 | 1786 |
]. |
1787 |
(tagType == 284) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1788 |
"planarconfig" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1789 |
value := planarConfiguration. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1790 |
numberType := #short. |
0 | 1791 |
]. |
1792 |
(tagType == 285) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1793 |
"pageName" |
0 | 1794 |
]. |
1795 |
(tagType == 286) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1796 |
"xPosition" |
0 | 1797 |
]. |
1798 |
(tagType == 287) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1799 |
"yPosition" |
0 | 1800 |
]. |
1801 |
(tagType == 288) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1802 |
"freeOffsets" |
0 | 1803 |
]. |
1804 |
(tagType == 289) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1805 |
"freeByteCounts" |
0 | 1806 |
]. |
1807 |
(tagType == 290) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1808 |
"grayResponceUnit" |
0 | 1809 |
]. |
1810 |
(tagType == 291) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1811 |
"grayResponceCurve" |
0 | 1812 |
]. |
1813 |
(tagType == 292) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1814 |
"group3options" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1815 |
value := group3options. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1816 |
numberType := #long. |
0 | 1817 |
]. |
1818 |
(tagType == 293) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1819 |
"group4options" |
0 | 1820 |
]. |
1821 |
(tagType == 296) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1822 |
"resolutionunit" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1823 |
^ self |
0 | 1824 |
]. |
1825 |
(tagType == 297) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1826 |
"pageNumber" |
0 | 1827 |
]. |
1828 |
(tagType == 300) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1829 |
"colorResponceUnit" |
0 | 1830 |
]. |
1831 |
(tagType == 301) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1832 |
"colorResponceCurve" |
0 | 1833 |
]. |
1834 |
(tagType == 306) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1835 |
"dateTime" |
0 | 1836 |
]. |
1837 |
(tagType == 315) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1838 |
"artist" |
0 | 1839 |
]. |
1840 |
(tagType == 317) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1841 |
"predictor" |
0 | 1842 |
]. |
1843 |
(tagType == 320) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1844 |
"colormap" |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1845 |
address := colorMapPos - 1. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1846 |
numberType := #short. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1847 |
count := 256 "(colorMap at:1) size" * 3. |
0 | 1848 |
]. |
1849 |
||
1850 |
(value isNil and:[address isNil]) ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1851 |
self error:'unhandled tag' mayProceed:true. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1852 |
^ self |
0 | 1853 |
]. |
1854 |
||
14 | 1855 |
" |
0 | 1856 |
'tag:' print. tagType print. ' typ:' print. numberType print. |
1857 |
' len:' print. count print. |
|
1858 |
' val:' print. value printNewline. |
|
14 | 1859 |
" |
0 | 1860 |
|
1861 |
self writeShort:tagType. |
|
1862 |
numberType == #short ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1863 |
self writeShort:3. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1864 |
self writeLong:count. |
0 | 1865 |
] ifFalse:[ |
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1866 |
numberType == #long ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1867 |
self writeShort:4. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1868 |
self writeLong:count. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1869 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1870 |
numberType == #byte ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1871 |
self writeShort:1. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1872 |
self writeLong:count. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1873 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1874 |
self error:'bad numbertype' |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1875 |
] |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1876 |
] |
0 | 1877 |
]. |
1878 |
address notNil ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1879 |
(numberType == #long and:[count == 1]) ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1880 |
self writeLong:(valueArray at:1). |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1881 |
^ self |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1882 |
]. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1883 |
(numberType == #short and:[count <= 2]) ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1884 |
self writeShort:(valueArray at:1). |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1885 |
count == 2 ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1886 |
self writeShort:(valueArray at:2). |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1887 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1888 |
self writeShort:0 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1889 |
]. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1890 |
^ self |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1891 |
]. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1892 |
(numberType == #byte and:[count <= 4]) ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1893 |
outStream nextPut:(valueArray at:1). |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1894 |
count > 1 ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1895 |
outStream nextPut:(valueArray at:2). |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1896 |
count > 2 ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1897 |
outStream nextPut:(valueArray at:3). |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1898 |
count > 3 ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1899 |
outStream nextPut:(valueArray at:4). |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1900 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1901 |
outStream nextPut:0 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1902 |
]. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1903 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1904 |
outStream nextPut:0 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1905 |
]. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1906 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1907 |
outStream nextPut:0 |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1908 |
]. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1909 |
^ self |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1910 |
]. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1911 |
self writeLong:address. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1912 |
^ self |
0 | 1913 |
]. |
1914 |
numberType == #short ifTrue:[ |
|
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1915 |
self writeShort:value. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1916 |
self writeShort:0 |
0 | 1917 |
] ifFalse:[ |
1215
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1918 |
numberType == #long ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1919 |
self writeLong:value |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1920 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1921 |
numberType == #byte ifTrue:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1922 |
outStream nextPut:value. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1923 |
outStream nextPut:0. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1924 |
outStream nextPut:0. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1925 |
outStream nextPut:0. |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1926 |
] ifFalse:[ |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1927 |
self error:'bad numbertype' |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1928 |
] |
e40392a58092
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
1929 |
] |
0 | 1930 |
]. |
1931 |
! |
|
1932 |
||
135 | 1933 |
writeUncompressedBits |
1934 |
"write bits as one or multiple strips" |
|
1935 |
||
1936 |
|offs bytesPerRow nBytes |
|
1937 |
h "{ Class: SmallInteger }"| |
|
0 | 1938 |
|
135 | 1939 |
nBytes := data size. |
1940 |
nBytes < 16rFFFF ifTrue:[ |
|
1941 |
stripOffsets := Array with:(outStream position - 1). |
|
1942 |
stripByteCounts := Array with:nBytes. |
|
1943 |
outStream nextPutBytes:nBytes from:data. |
|
1944 |
rowsPerStrip := height |
|
1945 |
] ifFalse:[ |
|
1946 |
stripOffsets := Array basicNew:height. |
|
1947 |
bytesPerRow := nBytes // height. |
|
1948 |
stripByteCounts := (Array basicNew:height) atAllPut:bytesPerRow. |
|
0 | 1949 |
|
135 | 1950 |
offs := 1. |
1951 |
h := height. |
|
1952 |
1 to:h do:[:row | |
|
1953 |
stripOffsets at:row put:(outStream position - 1). |
|
1954 |
outStream nextPutBytes:bytesPerRow from:data startingAt:offs. |
|
1955 |
offs := offs + bytesPerRow |
|
28 | 1956 |
]. |
135 | 1957 |
rowsPerStrip := 1 |
1958 |
]. |
|
1959 |
" |
|
1960 |
'stripOffsets: ' print. stripOffsets printNewline. |
|
1961 |
'stripByteCounts: ' print. stripByteCounts printNewline. |
|
1962 |
" |
|
1963 |
! ! |
|
1964 |
||
1965 |
!TIFFReader methodsFor:'reading from file'! |
|
1966 |
||
1967 |
fromStream:aStream |
|
192 | 1968 |
"read a stream containing a TIFF image. |
1969 |
Leave image description in instance variables." |
|
135 | 1970 |
|
1971 |
|char1 char2 version |
|
1972 |
numberOfTags "{ Class: SmallInteger }" |
|
1973 |
tagType "{ Class: SmallInteger }" |
|
1974 |
numberType "{ Class: SmallInteger }" |
|
1975 |
length "{ Class: SmallInteger }" |
|
516 | 1976 |
result offset msb |
918 | 1977 |
bytesPerRow offset1 offset2 tmp| |
135 | 1978 |
|
1979 |
inStream := aStream. |
|
331
304f9c439efa
allow reading from ByteArray-readStreams
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1980 |
aStream binary. |
135 | 1981 |
|
1982 |
char1 := aStream next. |
|
1983 |
char2 := aStream next. |
|
1984 |
(char1 ~~ char2) ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1985 |
^ self fileFormatError:'not a tiff file'. |
135 | 1986 |
]. |
331
304f9c439efa
allow reading from ByteArray-readStreams
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1987 |
(char1 == $I asciiValue) ifTrue:[ |
192 | 1988 |
byteOrder := #lsb. |
1989 |
msb := false. |
|
0 | 1990 |
] ifFalse:[ |
331
304f9c439efa
allow reading from ByteArray-readStreams
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1991 |
(char1 == $M asciiValue) ifTrue:[ |
192 | 1992 |
byteOrder := #msb. |
1993 |
msb := true. |
|
1994 |
] ifFalse:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
1995 |
^ self fileFormatError:'not a tiff file'. |
192 | 1996 |
] |
0 | 1997 |
]. |
1998 |
||
135 | 1999 |
version := self readShort. |
2000 |
(version ~~ 42) ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
2001 |
^ self fileFormatError:'version of tiff-file not supported'. |
0 | 2002 |
]. |
2003 |
||
135 | 2004 |
"setup default values" |
0 | 2005 |
|
135 | 2006 |
compression := 1. "none" |
2007 |
fillOrder := #msb. |
|
2008 |
planarConfiguration := 1. |
|
2009 |
photometric := nil. |
|
2010 |
bitsPerSample := 1. |
|
2011 |
samplesPerPixel := 1. |
|
2012 |
width := nil. |
|
2013 |
height := nil. |
|
2014 |
stripOffsets := nil. |
|
2015 |
rowsPerStrip := nil. |
|
2016 |
"resolutionUnit := 2." |
|
2017 |
predictor := 1. |
|
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
2018 |
orientation := nil. |
0 | 2019 |
|
135 | 2020 |
offset := aStream nextLongMSB:msb. |
2021 |
aStream position:offset + 1. |
|
2022 |
||
2023 |
numberOfTags := self readShort. |
|
2024 |
1 to:numberOfTags do:[:index | |
|
192 | 2025 |
tagType := self readShort. |
2026 |
numberType := self readShort. |
|
2027 |
length := aStream nextLongMSB:msb. |
|
2028 |
self decodeTiffTag:tagType numberType:numberType length:length |
|
135 | 2029 |
]. |
0 | 2030 |
|
135 | 2031 |
offset := aStream nextLongMSB:msb. |
2032 |
(offset ~~ 0) ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2033 |
'TIFFReader [info]: more tags ignored' infoPrintCR |
135 | 2034 |
]. |
0 | 2035 |
|
135 | 2036 |
"check for required tags" |
2037 |
width isNil ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
2038 |
^ self fileFormatError:'missing width tag'. |
135 | 2039 |
]. |
0 | 2040 |
|
135 | 2041 |
height isNil ifTrue:[ |
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
2042 |
^ self fileFormatError:'missing length tag'. |
135 | 2043 |
]. |
2044 |
||
2045 |
photometric isNil ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
2046 |
^ self fileFormatError:'missing photometric tag'. |
135 | 2047 |
]. |
2048 |
||
2049 |
stripOffsets isNil ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
2050 |
^ self fileFormatError:'missing stripOffsets tag'. |
0 | 2051 |
]. |
2052 |
||
2053 |
stripByteCounts isNil ifTrue:[ |
|
192 | 2054 |
stripOffsets size == 1 ifTrue:[ |
2055 |
stripByteCounts := Array with:(self bitsPerPixel // 8) * width * height |
|
2056 |
] |
|
135 | 2057 |
]. |
2058 |
||
2059 |
stripByteCounts isNil ifTrue:[ |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
2060 |
^ self fileFormatError:'missing stripByteCounts tag'. |
0 | 2061 |
]. |
2062 |
||
334 | 2063 |
dimensionCallBack notNil ifTrue:[ |
2064 |
dimensionCallBack value:self |
|
2065 |
]. |
|
2066 |
||
135 | 2067 |
"given all the information, read the bits" |
0 | 2068 |
|
135 | 2069 |
rowsPerStrip isNil ifTrue:[ |
192 | 2070 |
rowsPerStrip := height |
0 | 2071 |
]. |
2072 |
||
516 | 2073 |
result := self readTiffImageData. |
743
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2074 |
result isNil ifTrue:[ |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2075 |
"/ unsupported format. |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2076 |
^ nil |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2077 |
]. |
516 | 2078 |
|
743
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2079 |
orientation == #vFlip ifTrue:[ |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2080 |
"/ reverse rows to top-to bottom |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
2081 |
|
743
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2082 |
bytesPerRow := self bytesPerRow. |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2083 |
tmp := ByteArray new:bytesPerRow. |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2084 |
offset1 := 1. |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2085 |
offset2 := (height-1)*bytesPerRow + 1. |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2086 |
0 to:(height-1//2) do:[:row | |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2087 |
tmp replaceFrom:1 to:bytesPerRow |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2088 |
with:data startingAt:offset1. |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2089 |
data replaceFrom:offset1 to:offset1+bytesPerRow-1 |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2090 |
with:data startingAt:offset2. |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2091 |
data replaceFrom:offset2 to:offset2+bytesPerRow-1 |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2092 |
with:tmp startingAt:1. |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2093 |
offset1 := offset1 + bytesPerRow. |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2094 |
offset2 := offset2 - bytesPerRow. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
2095 |
]. |
743
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2096 |
]. |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2097 |
orientation == #unsupported ifTrue:[ |
43be299fc515
return nil for unsupported formats.
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2098 |
'TIFFReader [warning]: unsupported orientation' errorPrintCR |
393 | 2099 |
]. |
392
7729a280960c
handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents:
359
diff
changeset
|
2100 |
|
135 | 2101 |
^ result |
192 | 2102 |
|
814
6240dfc2fd3b
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
2103 |
"Modified: / 3.2.1998 / 18:02:29 / cg" |
135 | 2104 |
! ! |
0 | 2105 |
|
135 | 2106 |
!TIFFReader methodsFor:'writing to file'! |
2107 |
||
2108 |
save:image onFile:aFileName |
|
2109 |
"save image as (uncompressed) TIFF file on aFileName" |
|
0 | 2110 |
|
135 | 2111 |
|pos1 pos| |
0 | 2112 |
|
1078
fc33e172bbbc
raise informationLostSignal before attemting to write the file
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
2113 |
image mask notNil ifTrue:[ |
fc33e172bbbc
raise informationLostSignal before attemting to write the file
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
2114 |
Image informationLostQuerySignal |
fc33e172bbbc
raise informationLostSignal before attemting to write the file
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
2115 |
raiseWith:image |
fc33e172bbbc
raise informationLostSignal before attemting to write the file
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
2116 |
errorString:('TIFF writer does not (yet) support an imageMask'). |
fc33e172bbbc
raise informationLostSignal before attemting to write the file
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
2117 |
]. |
fc33e172bbbc
raise informationLostSignal before attemting to write the file
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
2118 |
|
135 | 2119 |
outStream := FileStream newFileNamed:aFileName. |
2120 |
outStream isNil ifTrue:[ |
|
461
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
2121 |
^ Image fileCreationErrorSignal |
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
2122 |
raiseWith:image |
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
2123 |
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
|
2124 |
]. |
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
2125 |
|
135 | 2126 |
"save as msb" |
2127 |
||
2128 |
byteOrder := #msb. |
|
2129 |
" |
|
2130 |
byteOrder := #lsb. |
|
2131 |
" |
|
2132 |
fillOrder := #msb. |
|
2133 |
width := image width. |
|
2134 |
height := image height. |
|
2135 |
photometric := image photometric. |
|
2136 |
samplesPerPixel := image samplesPerPixel. |
|
2137 |
bitsPerSample := image bitsPerSample. |
|
2138 |
colorMap := image colorMap. |
|
2139 |
planarConfiguration := 1. |
|
2140 |
compression := 1. "none" |
|
2141 |
data := image bits. |
|
2142 |
||
2143 |
currentOffset := 0. |
|
2144 |
||
2145 |
(byteOrder == #msb) ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2146 |
outStream nextPut:$M. outStream nextPut:$M. |
135 | 2147 |
] ifFalse:[ |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2148 |
outStream nextPut:$I. outStream nextPut:$I. |
0 | 2149 |
]. |
135 | 2150 |
currentOffset := currentOffset + 2. |
0 | 2151 |
|
135 | 2152 |
outStream binary. |
2153 |
||
2154 |
self writeShort:42. |
|
2155 |
currentOffset := currentOffset + 2. |
|
0 | 2156 |
|
135 | 2157 |
pos1 := outStream position. |
2158 |
self writeLong:0. "start of tags - filled in later" |
|
2159 |
currentOffset := currentOffset + 4. |
|
2160 |
||
2161 |
"output strips" |
|
2162 |
||
2163 |
self writeUncompressedBits. "this outputs bits as strips, sets stripOffsets and stripByteCounts" |
|
2164 |
self writeStripOffsets. "this outputs strip offsets, sets stripOffsetsPos" |
|
2165 |
self writeStripByteCounts. "this outputs strip bytecounts, sets stripByteCountPos" |
|
2166 |
self writeBitsPerSample. "this outputs bitsPerSample, sets bitsPerSamplePos" |
|
2167 |
photometric == #palette ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2168 |
self writeColorMap "this outputs colorMap, sets colorMapPos" |
0 | 2169 |
]. |
2170 |
||
135 | 2171 |
pos := outStream position. "backpatch tag offset" |
2172 |
outStream position:pos1. |
|
2173 |
self writeLong:(pos - 1). "fill in tag offset" |
|
2174 |
outStream position:pos. |
|
2175 |
" |
|
2176 |
('patch tag offset at: ', (pos1 printStringRadix:16) , ' to ', |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2177 |
(pos printStringRadix:16)) printNewline. |
135 | 2178 |
" |
2179 |
"output tag data" |
|
0 | 2180 |
|
135 | 2181 |
photometric == #palette ifTrue:[ |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2182 |
self writeShort:11. "11 tags" |
135 | 2183 |
] ifFalse:[ |
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2184 |
self writeShort:10. "10 tags" |
135 | 2185 |
]. |
2186 |
self writeTag:256. "image width" |
|
2187 |
self writeTag:257. "image height" |
|
2188 |
self writeTag:258. "bits per sample" |
|
2189 |
self writeTag:259. "compression" |
|
2190 |
self writeTag:262. "photometric" |
|
2191 |
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
|
2192 |
self writeTag:277. "samplesPerPixel" |
135 | 2193 |
self writeTag:278. "rowsPerStrip" |
2194 |
self writeTag:279. "strip byte counts" |
|
2195 |
self writeTag:284. "planarconfig" |
|
2196 |
photometric == #palette ifTrue:[ |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2197 |
self writeTag:320 "colorMap" |
135 | 2198 |
]. |
2199 |
self writeLong:0. "end of tags mark" |
|
2200 |
outStream close |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2201 |
|
1078
fc33e172bbbc
raise informationLostSignal before attemting to write the file
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
2202 |
"Modified: / 30.9.1998 / 23:30:18 / cg" |
135 | 2203 |
! ! |
30 | 2204 |
|
357
4bcb93f5892e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
2205 |
!TIFFReader class methodsFor:'documentation'! |
30 | 2206 |
|
135 | 2207 |
version |
1230
993aaef8a28a
support reading of 4-plane cmyk uncompressed images.
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
2208 |
^ '$Header: /cvs/stx/stx/libview2/TIFFReader.st,v 1.64 1999-09-08 16:30:21 cg Exp $' |
0 | 2209 |
! ! |
135 | 2210 |
TIFFReader initialize! |