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