author | Stefan Vogel <sv@exept.de> |
Thu, 15 Jan 1998 16:38:47 +0100 | |
changeset 755 | f1135dda53b1 |
parent 749 | 49c372aaf613 |
child 757 | 094c6c7c4ce6 |
permissions | -rw-r--r-- |
0 | 1 |
" |
6 | 2 |
COPYRIGHT (c) 1991 by Claus Gittinger |
26 | 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 |
" |
|
12 |
||
13 |
ImageReader subclass:#GIFReader |
|
708 | 14 |
instanceVariableNames:'redMap greenMap blueMap pass xpos ypos rowByteSize remainBitCount |
15 |
bufByte bufStream prefixTable suffixTable clearCode eoiCode |
|
16 |
freeCode codeSize maxCode interlace' |
|
17 |
classVariableNames:'ImageSeparator Extension Terminator' |
|
154 | 18 |
poolDictionaries:'' |
259 | 19 |
category:'Graphics-Images-Support' |
0 | 20 |
! |
21 |
||
339 | 22 |
!GIFReader class methodsFor:'documentation'! |
0 | 23 |
|
21 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
26 | 27 |
All Rights Reserved |
21 | 28 |
|
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
0 | 38 |
documentation |
39 |
" |
|
40 |
this class provides methods for loading and saving GIF pictures. |
|
21 | 41 |
It has been tested with some different GIF87a pictures, I dont |
0 | 42 |
know, if it works with other GIF versions. |
43 |
GIF extension blocks are not handled. |
|
44 |
||
45 |
GIF file writing is not implemented (use TIFF). |
|
46 |
||
21 | 47 |
legal stuff extracted from GIF87a documentation: |
0 | 48 |
|
49 |
CompuServe Incorporated hereby grants a limited, non-exclusive, royalty-free |
|
50 |
license for the use of the Graphics Interchange Format(sm) in computer |
|
51 |
software; computer software utilizing GIF(sm) must acknowledge ownership of the |
|
52 |
Graphics Interchange Format and its Service Mark by CompuServe Incorporated, in |
|
53 |
User and Technical Documentation. |
|
54 |
||
55 |
The Graphics Interchange Format(c) is the Copyright property of |
|
56 |
CompuServe Incorporated. GIF(sm) is a Service Mark property of |
|
57 |
CompuServe Incorporated. |
|
194 | 58 |
|
59 |
[See also:] |
|
234 | 60 |
Image Form Icon |
194 | 61 |
BlitImageReader FaceReader JPEGReader PBMReader PCXReader |
210 | 62 |
ST80FormReader SunRasterReader TargaReader TIFFReader WindowsIconReader |
209 | 63 |
XBMReader XPMReader XWDReader |
220 | 64 |
|
65 |
[author:] |
|
66 |
Claus Gittinger |
|
0 | 67 |
" |
68 |
! ! |
|
69 |
||
339 | 70 |
!GIFReader class methodsFor:'initialization'! |
26 | 71 |
|
72 |
initialize |
|
198 | 73 |
"install myself in the Image classes fileFormat table |
398 | 74 |
for the `.gif' extensions." |
198 | 75 |
|
708 | 76 |
ImageSeparator := $, asciiValue. |
77 |
Extension := $!! asciiValue. |
|
78 |
Terminator := $; asciiValue. |
|
79 |
||
647 | 80 |
MIMETypes defineImageType:'image/gif' suffix:'gif' reader:self. |
198 | 81 |
|
708 | 82 |
"Modified: 14.10.1997 / 18:47:27 / cg" |
26 | 83 |
! ! |
84 |
||
339 | 85 |
!GIFReader class methodsFor:'testing'! |
1 | 86 |
|
713 | 87 |
canRepresent:anImage |
88 |
"return true, if anImage can be represented in my file format. |
|
89 |
GIF supports depth 8 images only." |
|
90 |
||
91 |
^ anImage depth == 8 |
|
92 |
||
93 |
"Created: 17.10.1997 / 20:19:20 / cg" |
|
94 |
! |
|
95 |
||
1 | 96 |
isValidImageFile:aFileName |
97 |
"return true, if aFileName contains a GIF image" |
|
98 |
||
99 |
|id inStream| |
|
100 |
||
9 | 101 |
inStream := self streamReadingFile:aFileName. |
1 | 102 |
inStream isNil ifTrue:[^ false]. |
103 |
||
332 | 104 |
inStream text. |
105 |
||
1 | 106 |
id := String new:6. |
107 |
inStream nextBytes:6 into:id. |
|
108 |
inStream close. |
|
109 |
||
110 |
(id = 'GIF87a') ifFalse:[ |
|
174 | 111 |
(id startsWith:'GIF') ifFalse:[^ false]. |
1 | 112 |
|
174 | 113 |
id ~= 'GIF89a' ifTrue:[ |
355 | 114 |
'GIFReader [info]: not a GIF87a/GIF89a file - hope that works' infoPrintCR. |
174 | 115 |
] |
1 | 116 |
]. |
117 |
^ true |
|
174 | 118 |
|
355 | 119 |
"Modified: 10.1.1997 / 15:40:34 / cg" |
1 | 120 |
! ! |
121 |
||
708 | 122 |
!GIFReader methodsFor:'private - writing'! |
123 |
||
714 | 124 |
assignTransparentPixelIn:image |
125 |
"find an usused pixelValue in the colorMap (or image)." |
|
126 |
||
127 |
|cmap usedPixelValues| |
|
128 |
||
129 |
(cmap := image colorMap) size > 0 ifTrue:[ |
|
130 |
cmap size < 256 ifTrue:[ |
|
131 |
maskPixel := cmap size. |
|
132 |
^ self |
|
133 |
] |
|
134 |
]. |
|
135 |
||
136 |
usedPixelValues := image usedValues. |
|
137 |
usedPixelValues size < (1 bitShift:image depth) ifTrue:[ |
|
138 |
"/ there must be an unused pixelValue |
|
139 |
maskPixel := ((0 to:(1 bitShift:image depth)-1) asSet removeAll:(usedPixelValues)) first. |
|
140 |
] ifFalse:[ |
|
141 |
Image informationLostQuerySignal |
|
142 |
raiseWith:image |
|
143 |
errorString:('GIF writer cannot assign a transparent pixel - all pixelValues used by image'). |
|
144 |
] |
|
145 |
! |
|
146 |
||
708 | 147 |
checkCodeSize |
148 |
(freeCode > maxCode and: [codeSize < 12]) |
|
149 |
ifTrue: |
|
150 |
[codeSize := codeSize + 1. |
|
151 |
maxCode := (1 bitShift: codeSize) - 1] |
|
152 |
||
153 |
"Created: 14.10.1997 / 18:42:01 / cg" |
|
154 |
! |
|
155 |
||
156 |
flushBits |
|
157 |
remainBitCount = 0 |
|
158 |
ifFalse: |
|
159 |
[self nextBytePut: bufByte. |
|
160 |
remainBitCount := 0]. |
|
161 |
self flushBuffer |
|
162 |
||
163 |
"Modified: 14.10.1997 / 18:58:06 / cg" |
|
164 |
! |
|
165 |
||
166 |
flushBuffer |
|
167 |
bufStream isEmpty ifTrue: [^ self]. |
|
168 |
outStream nextPut: bufStream size. |
|
169 |
outStream nextPutAll: bufStream contents. |
|
170 |
bufStream := WriteStream on: (ByteArray new: 256) |
|
171 |
||
172 |
"Modified: 14.10.1997 / 20:46:04 / cg" |
|
173 |
! |
|
174 |
||
175 |
flushCode |
|
176 |
self flushBits |
|
177 |
||
178 |
"Created: 14.10.1997 / 18:57:33 / cg" |
|
179 |
! |
|
180 |
||
710 | 181 |
nextBitsPut: anInteger |
182 |
| integer writeBitCount shiftCount | |
|
183 |
shiftCount _ 0. |
|
184 |
remainBitCount = 0 |
|
185 |
ifTrue: |
|
186 |
[writeBitCount _ 8. |
|
187 |
integer _ anInteger] |
|
188 |
ifFalse: |
|
189 |
[writeBitCount _ remainBitCount. |
|
190 |
integer _ bufByte + (anInteger bitShift: 8 - remainBitCount)]. |
|
191 |
[writeBitCount < codeSize] |
|
192 |
whileTrue: |
|
193 |
[self nextBytePut: ((integer bitShift: shiftCount) bitAnd: 255). |
|
194 |
shiftCount _ shiftCount - 8. |
|
195 |
writeBitCount _ writeBitCount + 8]. |
|
196 |
(remainBitCount _ writeBitCount - codeSize) = 0 |
|
197 |
ifTrue: [self nextBytePut: (integer bitShift: shiftCount)] |
|
198 |
ifFalse: [bufByte _ integer bitShift: shiftCount]. |
|
199 |
^anInteger |
|
708 | 200 |
|
710 | 201 |
"Modified: 15.10.1997 / 16:50:30 / cg" |
708 | 202 |
! |
203 |
||
710 | 204 |
nextBytePut: aByte |
205 |
bufStream nextPut: aByte. |
|
206 |
bufStream size >= 254 ifTrue: [self flushBuffer] |
|
708 | 207 |
|
710 | 208 |
"Modified: 15.10.1997 / 16:50:52 / cg" |
708 | 209 |
! |
210 |
||
710 | 211 |
readPixelFrom: bits |
212 |
| pixel | |
|
708 | 213 |
ypos >= height ifTrue: [^ nil]. |
714 | 214 |
(maskPixel notNil |
215 |
and:[(mask pixelAtX:xpos y:ypos) == 0]) ifTrue:[ |
|
216 |
pixel := maskPixel |
|
217 |
] ifFalse:[ |
|
218 |
pixel := bits at: ypos * rowByteSize + xpos + 1. |
|
219 |
]. |
|
708 | 220 |
self updatePixelPosition. |
710 | 221 |
^ pixel |
708 | 222 |
|
223 |
"Created: 14.10.1997 / 18:43:50 / cg" |
|
710 | 224 |
"Modified: 15.10.1997 / 16:46:43 / cg" |
708 | 225 |
! |
226 |
||
227 |
setParameters:bitsPerPixel |
|
228 |
clearCode := 1 bitShift:bitsPerPixel. |
|
229 |
eoiCode := clearCode + 1. |
|
230 |
freeCode := clearCode + 2. |
|
231 |
codeSize := bitsPerPixel + 1. |
|
232 |
maxCode := (1 bitShift: codeSize) - 1 |
|
233 |
||
234 |
"Modified: 14.10.1997 / 20:09:48 / cg" |
|
235 |
! |
|
236 |
||
237 |
updatePixelPosition |
|
238 |
(xpos _ xpos + 1) >= width ifFalse: [^ self]. |
|
239 |
xpos _ 0. |
|
240 |
interlace == true |
|
241 |
ifFalse: |
|
242 |
[ypos _ ypos + 1. |
|
243 |
^ self]. |
|
244 |
pass = 0 |
|
245 |
ifTrue: |
|
246 |
[(ypos _ ypos + 8) >= height |
|
247 |
ifTrue: |
|
248 |
[pass _ pass + 1. |
|
249 |
ypos _ 4]. |
|
250 |
^ self]. |
|
251 |
pass = 1 |
|
252 |
ifTrue: |
|
253 |
[(ypos _ ypos + 8) >= height |
|
254 |
ifTrue: |
|
255 |
[pass _ pass + 1. |
|
256 |
ypos _ 2]. |
|
257 |
^ self]. |
|
258 |
pass = 2 |
|
259 |
ifTrue: |
|
260 |
[(ypos _ ypos + 4) >= height |
|
261 |
ifTrue: |
|
262 |
[pass _ pass + 1. |
|
263 |
ypos _ 1]. |
|
264 |
^ self]. |
|
265 |
pass = 3 |
|
266 |
ifTrue: |
|
267 |
[ypos _ ypos + 2. |
|
268 |
^ self]. |
|
269 |
^ self error: 'can''t happen' |
|
270 |
||
271 |
"Modified: 14.10.1997 / 18:44:27 / cg" |
|
272 |
! |
|
273 |
||
710 | 274 |
writeCode: aCode |
275 |
self nextBitsPut: aCode |
|
708 | 276 |
|
277 |
"Created: 14.10.1997 / 18:38:35 / cg" |
|
710 | 278 |
"Modified: 15.10.1997 / 17:01:47 / cg" |
708 | 279 |
! |
280 |
||
281 |
writeCodeAndCheckCodeSize: t1 |
|
282 |
self writeCode: t1. |
|
283 |
self checkCodeSize |
|
284 |
||
285 |
"Created: 14.10.1997 / 18:38:24 / cg" |
|
286 |
"Modified: 14.10.1997 / 18:40:56 / cg" |
|
287 |
! ! |
|
288 |
||
0 | 289 |
!GIFReader methodsFor:'reading from file'! |
290 |
||
1 | 291 |
checkGreyscaleColormap |
239 | 292 |
"return true, if colormap is actually a greymap. |
293 |
Could be used to convert it into a greyScale image - which is not yet done." |
|
1 | 294 |
|
20 | 295 |
|sz "{ Class: SmallInteger }" |
296 |
redVal| |
|
297 |
||
298 |
sz := redMap size. |
|
299 |
||
300 |
1 to:sz do:[:i | |
|
239 | 301 |
redVal := redMap at:i. |
302 |
redVal ~~ (greenMap at:i) ifTrue:[^ false]. |
|
303 |
redVal ~~ (blueMap at:i) ifTrue:[^ false]. |
|
1 | 304 |
]. |
305 |
^ true |
|
239 | 306 |
|
307 |
"Modified: 2.5.1996 / 17:54:40 / cg" |
|
1 | 308 |
! |
309 |
||
43 | 310 |
fromStream:aStream |
192 | 311 |
"read a stream containing a GIF image. |
312 |
Leave image description in instance variables." |
|
43 | 313 |
|
708 | 314 |
|byte index flag count fileColorMap |
43 | 315 |
colorMapSize bitsPerPixel scrWidth scrHeight |
316 |
hasColorMap hasLocalColorMap interlaced id |
|
317 |
leftOffs topOffs codeLen |
|
318 |
compressedData compressedSize |
|
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
319 |
tmp srcOffset dstOffset isGif89 atEnd |
64 | 320 |
h "{ Class: SmallInteger }"| |
43 | 321 |
|
322 |
inStream := aStream. |
|
323 |
aStream binary. |
|
324 |
||
325 |
"GIF-files are always lsb (intel-world)" |
|
326 |
byteOrder := #lsb. |
|
327 |
||
331
304f9c439efa
allow reading from ByteArray-readStreams
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
328 |
id := ByteArray new:6. |
304f9c439efa
allow reading from ByteArray-readStreams
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
329 |
aStream nextBytes:6 into:id startingAt:1. |
304f9c439efa
allow reading from ByteArray-readStreams
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
330 |
id := id asString. |
43 | 331 |
|
332 |
"all I had for testing where GIF87a files; |
|
333 |
I hope later versions work too ..." |
|
334 |
||
154 | 335 |
isGif89 := false. |
43 | 336 |
(id ~= 'GIF87a') ifTrue:[ |
154 | 337 |
(id startsWith:'GIF') ifFalse:[ |
355 | 338 |
'GIFReader [info]: not a gif file' infoPrintCR. |
154 | 339 |
^ nil |
340 |
]. |
|
341 |
id ~= 'GIF89a' ifTrue:[ |
|
355 | 342 |
'GIFReader [info]: not a GIF87a/GIF89a file - hope that works' infoPrintCR. |
154 | 343 |
] |
43 | 344 |
]. |
345 |
||
346 |
"get screen dimensions (not used)" |
|
347 |
scrWidth := aStream nextShortMSB:false. |
|
348 |
scrHeight := aStream nextShortMSB:false. |
|
349 |
||
350 |
"get flag byte" |
|
351 |
flag := aStream nextByte. |
|
352 |
hasColorMap := (flag bitAnd:2r10000000) ~~ 0. |
|
353 |
"bitsPerRGB := ((flag bitAnd:2r01110000) bitShift:-4) + 1. " |
|
354 |
"colorMapSorted := ((flag bitAnd:2r00001000) ~~ 0. " |
|
355 |
bitsPerPixel := (flag bitAnd:2r00000111) + 1. |
|
356 |
colorMapSize := 1 bitShift:bitsPerPixel. |
|
357 |
||
358 |
"get background (not used)" |
|
359 |
aStream nextByte. |
|
360 |
||
361 |
"aspect ratio (not used)" |
|
362 |
aStream nextByte. |
|
363 |
||
364 |
"get colorMap" |
|
365 |
hasColorMap ifTrue:[ |
|
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
366 |
self readColorMap:colorMapSize. |
708 | 367 |
fileColorMap := Colormap |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
368 |
redVector:redMap |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
369 |
greenVector:greenMap |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
370 |
blueVector:blueMap. |
43 | 371 |
]. |
708 | 372 |
colorMap := fileColorMap. |
43 | 373 |
|
374 |
photometric := #palette. |
|
375 |
samplesPerPixel := 1. |
|
376 |
bitsPerSample := #(8). |
|
377 |
||
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
378 |
atEnd := false. |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
379 |
[atEnd] whileFalse:[ |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
380 |
"gif89a extensions" |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
381 |
byte := aStream nextByte. |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
382 |
|
708 | 383 |
byte == Extension ifTrue:[ |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
384 |
self readExtension:aStream. |
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
385 |
] ifFalse:[ |
708 | 386 |
(byte == Terminator) ifTrue:[ |
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
387 |
atEnd := true |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
388 |
] ifFalse:[ |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
389 |
"must be image separator" |
708 | 390 |
(byte ~~ ImageSeparator) ifTrue:[ |
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
391 |
('GIFReader [info]: corrupted gif file (no IMAGESEP): ' , (byte printStringRadix:16)) infoPrintCR. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
392 |
^ nil |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
393 |
]. |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
394 |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
395 |
"get image data" |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
396 |
leftOffs := aStream nextShortMSB:false. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
397 |
topOffs := aStream nextShortMSB:false. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
398 |
width := aStream nextShortMSB:false. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
399 |
height := aStream nextShortMSB:false. |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
400 |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
401 |
dimensionCallBack notNil ifTrue:[ |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
402 |
dimensionCallBack value:self |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
403 |
]. |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
404 |
|
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
405 |
"/ |
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
406 |
"/ 'width ' print. width printNewline. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
407 |
"/ 'height ' print. height printNewline. |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
408 |
"/ |
43 | 409 |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
410 |
"another flag byte" |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
411 |
flag := aStream nextByte. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
412 |
interlaced := (flag bitAnd:2r01000000) ~~ 0. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
413 |
hasLocalColorMap := (flag bitAnd:2r10000000) ~~ 0. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
414 |
"localColorMapSorted := (flag bitAnd:2r00100000) ~~ 0. " |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
415 |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
416 |
"if image has a local colormap, this one is used" |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
417 |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
418 |
hasLocalColorMap ifTrue:[ |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
419 |
"local descr. overwrites" |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
420 |
bitsPerPixel := (flag bitAnd:2r00000111) + 1. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
421 |
colorMapSize := 1 bitShift:bitsPerPixel. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
422 |
"overwrite colormap" |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
423 |
self readColorMap:colorMapSize. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
424 |
colorMap := Colormap |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
425 |
redVector:redMap |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
426 |
greenVector:greenMap |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
427 |
blueVector:blueMap. |
708 | 428 |
] ifFalse:[ |
429 |
colorMap := fileColorMap |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
430 |
]. |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
431 |
|
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
432 |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
433 |
"get codelen for decompression" |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
434 |
codeLen := aStream nextByte. |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
435 |
|
755
f1135dda53b1
be carefull when reading from non-fileStreams
Stefan Vogel <sv@exept.de>
parents:
749
diff
changeset
|
436 |
(aStream respondsTo:#fileSize) ifTrue:[ |
f1135dda53b1
be carefull when reading from non-fileStreams
Stefan Vogel <sv@exept.de>
parents:
749
diff
changeset
|
437 |
"get hint about length of compressed data" |
f1135dda53b1
be carefull when reading from non-fileStreams
Stefan Vogel <sv@exept.de>
parents:
749
diff
changeset
|
438 |
count := aStream fileSize. |
f1135dda53b1
be carefull when reading from non-fileStreams
Stefan Vogel <sv@exept.de>
parents:
749
diff
changeset
|
439 |
] ifFalse:[ |
f1135dda53b1
be carefull when reading from non-fileStreams
Stefan Vogel <sv@exept.de>
parents:
749
diff
changeset
|
440 |
count := 512. |
f1135dda53b1
be carefull when reading from non-fileStreams
Stefan Vogel <sv@exept.de>
parents:
749
diff
changeset
|
441 |
]. |
f1135dda53b1
be carefull when reading from non-fileStreams
Stefan Vogel <sv@exept.de>
parents:
749
diff
changeset
|
442 |
compressedData := ByteArray uninitializedNew:count. |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
443 |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
444 |
"get compressed data" |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
445 |
index := 1. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
446 |
count := aStream nextByte. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
447 |
[count notNil and:[count ~~ 0]] whileTrue:[ |
755
f1135dda53b1
be carefull when reading from non-fileStreams
Stefan Vogel <sv@exept.de>
parents:
749
diff
changeset
|
448 |
(compressedData size < (index+count)) ifTrue:[ |
f1135dda53b1
be carefull when reading from non-fileStreams
Stefan Vogel <sv@exept.de>
parents:
749
diff
changeset
|
449 |
|c| |
f1135dda53b1
be carefull when reading from non-fileStreams
Stefan Vogel <sv@exept.de>
parents:
749
diff
changeset
|
450 |
c := ByteArray uninitializedNew:(index+count*3//2). |
f1135dda53b1
be carefull when reading from non-fileStreams
Stefan Vogel <sv@exept.de>
parents:
749
diff
changeset
|
451 |
c replaceBytesFrom:1 to:index-1 |
f1135dda53b1
be carefull when reading from non-fileStreams
Stefan Vogel <sv@exept.de>
parents:
749
diff
changeset
|
452 |
with:compressedData startingAt:1. |
f1135dda53b1
be carefull when reading from non-fileStreams
Stefan Vogel <sv@exept.de>
parents:
749
diff
changeset
|
453 |
|
f1135dda53b1
be carefull when reading from non-fileStreams
Stefan Vogel <sv@exept.de>
parents:
749
diff
changeset
|
454 |
compressedData := c. |
f1135dda53b1
be carefull when reading from non-fileStreams
Stefan Vogel <sv@exept.de>
parents:
749
diff
changeset
|
455 |
]. |
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
456 |
aStream nextBytes:count into:compressedData startingAt:index blockSize:4096. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
457 |
index := index + count. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
458 |
count := aStream nextByte |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
459 |
]. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
460 |
compressedSize := index - 1. |
83 | 461 |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
462 |
h := height. |
749 | 463 |
data := ByteArray uninitializedNew:((width + 1) * (h + 1)). |
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
464 |
"/ 'GIFReader: decompressing ...' infoPrintCR. |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
465 |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
466 |
self class decompressGIFFrom:compressedData |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
467 |
count:compressedSize |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
468 |
into:data |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
469 |
startingAt:1 |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
470 |
codeLen:(codeLen + 1). |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
471 |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
472 |
interlaced ifTrue:[ |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
473 |
"/ 'GIFREADER: deinterlacing ...' infoPrintCR. |
749 | 474 |
tmp := ByteArray uninitializedNew:(data size). |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
475 |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
476 |
"phase 1: 0, 8, 16, 24, ..." |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
477 |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
478 |
srcOffset := 1. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
479 |
0 to:(h - 1) by:8 do:[:dstRow | |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
480 |
dstOffset := dstRow * width + 1. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
481 |
tmp replaceFrom:dstOffset to:(dstOffset + width - 1) |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
482 |
with:data startingAt:srcOffset. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
483 |
srcOffset := srcOffset + width. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
484 |
]. |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
485 |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
486 |
"phase 2: 4, 12, 20, 28, ..." |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
487 |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
488 |
4 to:(h - 1) by:8 do:[:dstRow | |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
489 |
dstOffset := dstRow * width + 1. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
490 |
tmp replaceFrom:dstOffset to:(dstOffset + width - 1) |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
491 |
with:data startingAt:srcOffset. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
492 |
srcOffset := srcOffset + width. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
493 |
]. |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
494 |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
495 |
"phase 3: 2, 6, 10, 14, ..." |
43 | 496 |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
497 |
2 to:(h - 1) by:4 do:[:dstRow | |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
498 |
dstOffset := dstRow * width + 1. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
499 |
tmp replaceFrom:dstOffset to:(dstOffset + width - 1) |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
500 |
with:data startingAt:srcOffset. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
501 |
srcOffset := srcOffset + width. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
502 |
]. |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
503 |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
504 |
"phase 4: 1, 3, 5, 7, ..." |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
505 |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
506 |
1 to:(h - 1) by:2 do:[:dstRow | |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
507 |
dstOffset := dstRow * width + 1. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
508 |
tmp replaceFrom:dstOffset to:(dstOffset + width - 1) |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
509 |
with:data startingAt:srcOffset. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
510 |
srcOffset := srcOffset + width. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
511 |
]. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
512 |
|
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
513 |
data := tmp. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
514 |
tmp := nil. |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
515 |
]. |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
516 |
|
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
517 |
imageSequence isNil ifTrue:[ |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
518 |
imageSequence := OrderedCollection new. |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
519 |
]. |
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
520 |
maskPixel notNil ifTrue:[ |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
521 |
"/ |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
522 |
"/ ok, there is a maskValue |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
523 |
"/ build a Depth1Image for it. |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
524 |
"/ |
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
525 |
self buildMaskFromColor:maskPixel |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
526 |
]. |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
527 |
|
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
528 |
imageSequence add:(self image). |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
529 |
|
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
530 |
aStream atEnd ifTrue:[ |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
531 |
atEnd := true. |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
532 |
] |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
533 |
] |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
534 |
]. |
307
9eaeaca798a5
create a mask-image, if present
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
535 |
]. |
9eaeaca798a5
create a mask-image, if present
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
536 |
|
43 | 537 |
" |
538 |
GIFReader fromFile:'../fileIn/bitmaps/claus.gif |
|
539 |
GIFReader fromFile:'../fileIn/bitmaps/garfield.gif' |
|
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
540 |
GIFReader new fromStream:('/home2/cg/.misc/circum.gif' asFilename readStream) |
43 | 541 |
" |
154 | 542 |
|
749 | 543 |
"Modified: / 18.12.1997 / 10:23:38 / cg" |
755
f1135dda53b1
be carefull when reading from non-fileStreams
Stefan Vogel <sv@exept.de>
parents:
749
diff
changeset
|
544 |
"Modified: / 15.1.1998 / 15:42:19 / stefan" |
135 | 545 |
! |
546 |
||
547 |
makeGreyscale |
|
548 |
"not yet implemented/needed" |
|
549 |
! |
|
550 |
||
551 |
readColorMap:colorMapSize |
|
552 |
"get gif colormap consisting of colorMapSize entries" |
|
553 |
||
554 |
|sz "{ Class: SmallInteger }"| |
|
555 |
||
556 |
redMap := ByteArray uninitializedNew:colorMapSize. |
|
557 |
greenMap := ByteArray uninitializedNew:colorMapSize. |
|
558 |
blueMap := ByteArray uninitializedNew:colorMapSize. |
|
239 | 559 |
|
135 | 560 |
sz := colorMapSize. |
561 |
1 to:sz do:[:i | |
|
239 | 562 |
redMap at:i put:(inStream nextByte). |
563 |
greenMap at:i put:(inStream nextByte). |
|
564 |
blueMap at:i put:(inStream nextByte) |
|
307
9eaeaca798a5
create a mask-image, if present
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
565 |
]. |
239 | 566 |
|
307
9eaeaca798a5
create a mask-image, if present
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
567 |
"Modified: 21.6.1996 / 12:32:43 / cg" |
154 | 568 |
! |
569 |
||
570 |
readExtension:aStream |
|
239 | 571 |
"get gif89 extension - this is currently ignored" |
154 | 572 |
|
573 |
|type blockSize subBlockSize |
|
304 | 574 |
aspNum aspDen left top width height cWidth cHeight fg bg |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
575 |
animationType animationTime animationMask |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
576 |
appID appAUTH |
625 | 577 |
iterationCount b ok| |
154 | 578 |
|
579 |
type := aStream nextByte. |
|
580 |
type == $R asciiValue ifTrue:[ |
|
239 | 581 |
"/ |
154 | 582 |
"/ Ratio extension |
239 | 583 |
"/ |
354
b4d2ce853c24
stefans suggested info/warning/error/fatal
Claus Gittinger <cg@exept.de>
parents:
339
diff
changeset
|
584 |
'GIFREADER [info]: ratio extension ignored' infoPrintCR. |
154 | 585 |
blockSize := aStream nextByte. |
586 |
(blockSize == 2) ifTrue:[ |
|
587 |
aspNum := aStream nextByte. |
|
588 |
aspDen := aStream nextByte |
|
589 |
] ifFalse:[ |
|
590 |
aStream skip:blockSize |
|
591 |
]. |
|
592 |
"/ eat subblocks |
|
593 |
||
594 |
[(subBlockSize := aStream nextByte) > 0] whileTrue:[ |
|
595 |
aStream skip:subBlockSize |
|
239 | 596 |
]. |
597 |
^ self |
|
598 |
]. |
|
599 |
||
600 |
type == 16r01 ifTrue:[ |
|
601 |
"/ |
|
602 |
"/ plaintext extension |
|
603 |
"/ |
|
625 | 604 |
"/ 'GIFREADER [info]: plaintext extension ignored' infoPrintCR. |
239 | 605 |
subBlockSize := aStream nextByte. |
606 |
left := aStream nextShortMSB:false. |
|
607 |
top := aStream nextShortMSB:false. |
|
608 |
width := aStream nextShortMSB:false. |
|
609 |
height := aStream nextShortMSB:false. |
|
610 |
cWidth := aStream nextByte. |
|
611 |
cHeight := aStream nextByte. |
|
612 |
fg := aStream nextByte. |
|
613 |
bg := aStream nextByte. |
|
614 |
aStream skip:12. |
|
615 |
[(subBlockSize := aStream nextByte) > 0] whileTrue:[ |
|
616 |
aStream skip:subBlockSize |
|
617 |
]. |
|
618 |
^ self |
|
619 |
]. |
|
620 |
||
621 |
type == 16rF9 ifTrue:[ |
|
622 |
"/ |
|
623 |
"/ graphic control extension |
|
624 |
"/ |
|
354
b4d2ce853c24
stefans suggested info/warning/error/fatal
Claus Gittinger <cg@exept.de>
parents:
339
diff
changeset
|
625 |
"/ 'GIFREADER [info]: graphic control extension ignored' infoPrintCR. |
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
626 |
|
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
627 |
[(subBlockSize := aStream nextByte) ~~ 0] whileTrue:[ |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
628 |
"/ type bitAnd:1 means: animationMask is transparent pixel |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
629 |
"/ to be implemented in Image ... |
305 | 630 |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
631 |
animationType := aStream nextByte. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
632 |
animationTime := aStream nextShortMSB:false. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
633 |
animationMask := aStream nextByte. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
634 |
subBlockSize := subBlockSize - 4. |
307
9eaeaca798a5
create a mask-image, if present
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
635 |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
636 |
(animationType bitTest: 1) ifTrue:[ |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
637 |
maskPixel := animationMask. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
638 |
"/ 'GIFREADER [info]: mask: ' infoPrint. (maskPixel printStringRadix:16) infoPrintCR. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
639 |
]. |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
640 |
"/ 'GIFREADER [info]: animationTime: ' infoPrint. (animationTime * (1/100)) infoPrintCR. |
307
9eaeaca798a5
create a mask-image, if present
Claus Gittinger <cg@exept.de>
parents:
305
diff
changeset
|
641 |
|
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
642 |
subBlockSize ~~ 0 ifTrue:[ |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
643 |
aStream skip:subBlockSize |
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
644 |
]. |
239 | 645 |
]. |
646 |
^ self |
|
647 |
]. |
|
648 |
||
519 | 649 |
type == 16rFE ifTrue:[ |
650 |
"/ |
|
651 |
"/ comment extension |
|
652 |
"/ |
|
625 | 653 |
"/ 'GIFREADER [info]: comment extension ignored' infoPrintCR. |
519 | 654 |
[(blockSize := aStream nextByte) ~~ 0] whileTrue:[ |
655 |
aStream skip:blockSize |
|
656 |
]. |
|
657 |
^ self |
|
658 |
]. |
|
659 |
||
239 | 660 |
type == 16rFF ifTrue:[ |
661 |
"/ |
|
662 |
"/ application extension |
|
663 |
"/ |
|
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
664 |
subBlockSize := aStream nextByte. |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
665 |
appID := (aStream nextBytes:8 ) asString. |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
666 |
appAUTH := aStream nextBytes:3. |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
667 |
|
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
668 |
subBlockSize := aStream nextByte. |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
669 |
|
625 | 670 |
ok := false. |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
671 |
appID = 'NETSCAPE' ifTrue:[ |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
672 |
appAUTH asString = '2.0' ifTrue:[ |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
673 |
subBlockSize == 3 ifTrue:[ |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
674 |
b := aStream nextByte. |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
675 |
iterationCount := aStream nextShortMSB:false. |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
676 |
subBlockSize := aStream nextByte. |
625 | 677 |
ok := true. |
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
678 |
] |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
679 |
] |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
680 |
]. |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
681 |
|
625 | 682 |
ok ifFalse:[ |
683 |
('GIFREADER [info]: application extension (' , appID , ') ignored') infoPrintCR. |
|
684 |
]. |
|
685 |
||
618
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
686 |
[subBlockSize > 0] whileTrue:[ |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
687 |
aStream skip:subBlockSize. |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
688 |
subBlockSize := aStream nextByte. |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
689 |
]. |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
690 |
^ self |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
691 |
]. |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
692 |
|
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
693 |
type == 16r2C ifTrue:[ |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
694 |
"/ |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
695 |
"/ image descriptor extension |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
696 |
"/ |
ab83e72fd105
support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
697 |
'GIFREADER [info]: image descriptor extension ignored' infoPrintCR. |
239 | 698 |
[(subBlockSize := aStream nextByte) > 0] whileTrue:[ |
699 |
aStream skip:subBlockSize |
|
700 |
]. |
|
701 |
^ self |
|
702 |
]. |
|
703 |
||
704 |
"/ |
|
705 |
"/ unknown extension |
|
706 |
"/ |
|
354
b4d2ce853c24
stefans suggested info/warning/error/fatal
Claus Gittinger <cg@exept.de>
parents:
339
diff
changeset
|
707 |
'GIFREADER [info]: unknown extension ignored' infoPrintCR. |
239 | 708 |
[(subBlockSize := aStream nextByte) > 0] whileTrue:[ |
709 |
aStream skip:subBlockSize |
|
154 | 710 |
] |
711 |
||
670
6a7f628ee66c
oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
712 |
"Modified: 24.7.1997 / 18:02:49 / cg" |
0 | 713 |
! ! |
43 | 714 |
|
708 | 715 |
!GIFReader methodsFor:'writing to file'! |
716 |
||
717 |
save:image onFile:aFileName |
|
718 |
"save image as GIF file on aFileName" |
|
719 |
||
718
41ade132da98
raise an error, if depth is not supported.
Claus Gittinger <cg@exept.de>
parents:
714
diff
changeset
|
720 |
image depth ~~ 8 ifTrue:[ |
41ade132da98
raise an error, if depth is not supported.
Claus Gittinger <cg@exept.de>
parents:
714
diff
changeset
|
721 |
^ Image cannotRepresentImageSignal |
41ade132da98
raise an error, if depth is not supported.
Claus Gittinger <cg@exept.de>
parents:
714
diff
changeset
|
722 |
raiseWith:image |
41ade132da98
raise an error, if depth is not supported.
Claus Gittinger <cg@exept.de>
parents:
714
diff
changeset
|
723 |
errorString:('GIF (currently) only supports depth8 images'). |
41ade132da98
raise an error, if depth is not supported.
Claus Gittinger <cg@exept.de>
parents:
714
diff
changeset
|
724 |
]. |
41ade132da98
raise an error, if depth is not supported.
Claus Gittinger <cg@exept.de>
parents:
714
diff
changeset
|
725 |
|
708 | 726 |
outStream := FileStream newFileNamed:aFileName. |
727 |
outStream isNil ifTrue:[ |
|
728 |
^ Image fileCreationErrorSignal |
|
729 |
raiseWith:image |
|
730 |
errorString:('file creation error: ' , aFileName asString). |
|
731 |
]. |
|
732 |
outStream binary. |
|
733 |
||
714 | 734 |
mask := image mask. |
735 |
mask notNil ifTrue:[ |
|
736 |
self assignTransparentPixelIn:image |
|
708 | 737 |
]. |
738 |
||
739 |
byteOrder := #lsb. |
|
740 |
width := image width. |
|
741 |
height := image height. |
|
742 |
photometric := image photometric. |
|
743 |
samplesPerPixel := image samplesPerPixel. |
|
744 |
bitsPerSample := image bitsPerSample. |
|
745 |
colorMap := image colorMap. |
|
746 |
data := image bits. |
|
747 |
||
748 |
self writeHeaderFor:image. |
|
714 | 749 |
maskPixel notNil ifTrue:[ |
750 |
self writeMaskExtensionHeaderFor:image. |
|
751 |
]. |
|
752 |
||
708 | 753 |
self writeBitDataFor:image. |
714 | 754 |
|
755 |
outStream nextPut: Terminator. |
|
708 | 756 |
outStream close. |
757 |
||
758 |
" |
|
759 |
|i| |
|
760 |
||
761 |
i := Image fromFile:'bitmaps/gifImages/garfield.gif'. |
|
762 |
GIFReader save:i onFile:'foo.gif'. |
|
763 |
(Image fromFile:'./foo.gif') inspect |
|
764 |
" |
|
765 |
||
718
41ade132da98
raise an error, if depth is not supported.
Claus Gittinger <cg@exept.de>
parents:
714
diff
changeset
|
766 |
"Created: / 14.10.1997 / 17:40:12 / cg" |
41ade132da98
raise an error, if depth is not supported.
Claus Gittinger <cg@exept.de>
parents:
714
diff
changeset
|
767 |
"Modified: / 27.10.1997 / 22:42:31 / cg" |
708 | 768 |
! |
769 |
||
710 | 770 |
writeBitDataFor: image |
771 |
"using modified Lempel-Ziv Welch algorithm." |
|
772 |
||
714 | 773 |
| bits bitsPerPixel t1 |
710 | 774 |
maxBits maxMaxCode tSize initCodeSize ent tShift fCode pixel index disp nomatch | |
775 |
||
714 | 776 |
outStream nextPut:ImageSeparator. |
777 |
self writeShort:0. "/ |
|
778 |
self writeShort:0. "/ |
|
779 |
self writeShort:width. "/ image size |
|
780 |
self writeShort:height. |
|
781 |
||
782 |
interlace == true ifTrue:[ |
|
783 |
t1 := 64 |
|
784 |
] ifFalse:[ |
|
785 |
t1 := 0 |
|
786 |
]. |
|
787 |
outStream nextPut:t1. "/ another flag |
|
788 |
||
710 | 789 |
bitsPerPixel := image bitsPerPixel. |
790 |
bits := image bits. |
|
791 |
||
792 |
pass := 0. |
|
793 |
xpos := 0. |
|
794 |
ypos := 0. |
|
712 | 795 |
rowByteSize := image bytesPerRow. "/ width * 8 + 31 // 32 * 4. |
710 | 796 |
remainBitCount := 0. |
797 |
bufByte := 0. |
|
798 |
bufStream := WriteStream on: (ByteArray new: 256). |
|
708 | 799 |
|
710 | 800 |
maxBits := 12. |
801 |
maxMaxCode := 1 bitShift: maxBits. |
|
802 |
tSize := 5003. |
|
803 |
prefixTable := Array new: tSize. |
|
804 |
suffixTable := Array new: tSize. |
|
805 |
||
806 |
initCodeSize := bitsPerPixel <= 1 ifTrue: [2] ifFalse: [bitsPerPixel]. |
|
807 |
outStream nextPut: initCodeSize. |
|
808 |
self setParameters: initCodeSize. |
|
809 |
||
810 |
tShift := 0. |
|
811 |
fCode := tSize. |
|
812 |
[fCode < 65536] whileTrue: |
|
813 |
[tShift := tShift + 1. |
|
814 |
fCode := fCode * 2]. |
|
815 |
tShift := 8 - tShift. |
|
816 |
1 to: tSize do: [:i | suffixTable at: i put: -1]. |
|
708 | 817 |
|
710 | 818 |
self writeCodeAndCheckCodeSize: clearCode. |
819 |
ent := self readPixelFrom: bits. |
|
820 |
[(pixel := self readPixelFrom: bits) == nil] whileFalse: |
|
708 | 821 |
[ |
710 | 822 |
fCode := (pixel bitShift: maxBits) + ent. |
823 |
index := ((pixel bitShift: tShift) bitXor: ent) + 1. |
|
824 |
(suffixTable at: index) = fCode |
|
825 |
ifTrue: [ent := prefixTable at: index] |
|
826 |
ifFalse: |
|
827 |
[nomatch := true. |
|
828 |
(suffixTable at: index) >= 0 |
|
829 |
ifTrue: |
|
830 |
[disp := tSize - index + 1. |
|
831 |
index = 1 ifTrue: [disp := 1]. |
|
832 |
"probe" |
|
833 |
[(index := index - disp) < 1 ifTrue: [index := index + tSize]. |
|
834 |
(suffixTable at: index) = fCode |
|
835 |
ifTrue: |
|
836 |
[ent := prefixTable at: index. |
|
837 |
nomatch := false. |
|
838 |
"continue whileFalse:"]. |
|
839 |
nomatch and: [(suffixTable at: index) > 0]] |
|
840 |
whileTrue: ["probe"]]. |
|
841 |
"nomatch" |
|
842 |
nomatch ifTrue: |
|
843 |
[self writeCodeAndCheckCodeSize: ent. |
|
844 |
ent := pixel. |
|
845 |
freeCode < maxMaxCode |
|
846 |
ifTrue: |
|
847 |
[prefixTable at: index put: freeCode. |
|
848 |
suffixTable at: index put: fCode. |
|
849 |
freeCode := freeCode + 1] |
|
850 |
ifFalse: |
|
851 |
[self writeCodeAndCheckCodeSize: clearCode. |
|
852 |
1 to: tSize do: [:i | suffixTable at: i put: -1]. |
|
853 |
self setParameters: initCodeSize]]]]. |
|
854 |
prefixTable := suffixTable := nil. |
|
855 |
self writeCodeAndCheckCodeSize: ent. |
|
856 |
self writeCodeAndCheckCodeSize: eoiCode. |
|
857 |
self flushCode. |
|
858 |
outStream nextPut: 0. "zero-length packet" |
|
859 |
||
712 | 860 |
"Modified: 15.10.1997 / 19:56:28 / cg" |
708 | 861 |
! |
862 |
||
863 |
writeHeaderFor:image |
|
714 | 864 |
"write the gif header" |
708 | 865 |
|
866 |
|bitsPerPixel t1 n| |
|
867 |
||
868 |
bitsPerPixel := image bitsPerPixel. |
|
869 |
||
732 | 870 |
outStream nextPutAll: 'GIF89a' asByteArray. |
712 | 871 |
self writeShort:width. "/ screen size |
872 |
self writeShort:height. |
|
708 | 873 |
t1 := 128. |
712 | 874 |
t1 := t1 bitOr:(bitsPerPixel - 1 bitShift:5). |
875 |
t1 := t1 bitOr:(bitsPerPixel - 1). |
|
876 |
outStream nextPut:t1. "/ flag |
|
877 |
outStream nextPut:0. "/ background (not used) |
|
878 |
outStream nextPut:0. "/ aspect ratio |
|
708 | 879 |
|
713 | 880 |
0 to:(1 bitShift:bitsPerPixel)-1 do:[:pixel | |
881 |
|clr red green blue| |
|
712 | 882 |
|
713 | 883 |
clr := image colorFromValue:pixel. |
884 |
clr isNil ifTrue:[ |
|
885 |
"/ unused colorMap slot |
|
886 |
red := green := blue := 0. |
|
887 |
] ifFalse:[ |
|
888 |
red := (clr redByte). |
|
889 |
green := (clr greenByte). |
|
890 |
blue := (clr blueByte). |
|
891 |
]. |
|
892 |
outStream |
|
893 |
nextPut:red; nextPut:green; nextPut:blue. |
|
894 |
]. |
|
895 |
"/ n := 0. |
|
896 |
"/ image colorMap notNil ifTrue:[ |
|
897 |
"/ image colorMap do:[:clr | |
|
898 |
"/ |red green blue| |
|
899 |
"/ |
|
900 |
"/ clr isNil ifTrue:[ |
|
901 |
"/ "/ unused colorMap slot |
|
902 |
"/ red := green := blue := 0. |
|
903 |
"/ ] ifFalse:[ |
|
904 |
"/ red := (clr redByte). |
|
905 |
"/ green := (clr greenByte). |
|
906 |
"/ blue := (clr blueByte). |
|
907 |
"/ ]. |
|
908 |
"/ outStream |
|
909 |
"/ nextPut:red; nextPut:green; nextPut:blue. |
|
910 |
"/ n := n + 1. |
|
911 |
"/ ] |
|
912 |
"/ ]. |
|
913 |
"/ n+1 to:(1 bitShift:bitsPerPixel) do:[:i | |
|
914 |
"/ outStream nextPut:0; nextPut:0; nextPut:0 |
|
915 |
"/ ]. |
|
708 | 916 |
|
732 | 917 |
"Created: / 14.10.1997 / 17:41:28 / cg" |
918 |
"Modified: / 31.10.1997 / 16:12:13 / cg" |
|
714 | 919 |
! |
920 |
||
921 |
writeMaskExtensionHeaderFor:image |
|
922 |
"write an extension header for the transparent pixel" |
|
923 |
||
924 |
outStream nextPut:Extension. |
|
925 |
outStream nextPut:16rF9. "/ graphic control extension |
|
926 |
outStream nextPut:4. "/ subBlockSize |
|
927 |
||
928 |
outStream nextPut:1. "/ animationType |
|
929 |
outStream nextPutShort:1 MSB:false. "/ animationTime |
|
930 |
outStream nextPut:maskPixel. "/ animationMask |
|
931 |
||
932 |
outStream nextPut:0. |
|
708 | 933 |
! ! |
934 |
||
339 | 935 |
!GIFReader class methodsFor:'documentation'! |
135 | 936 |
|
937 |
version |
|
755
f1135dda53b1
be carefull when reading from non-fileStreams
Stefan Vogel <sv@exept.de>
parents:
749
diff
changeset
|
938 |
^ '$Header: /cvs/stx/stx/libview2/GIFReader.st,v 1.65 1998-01-15 15:38:47 stefan Exp $' |
135 | 939 |
! ! |
43 | 940 |
GIFReader initialize! |