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