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