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