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