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