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