Exporting a Squeak Animation

Bert Freudenberg bert at isg.cs.uni-magdeburg.de
Thu May 29 18:48:40 UTC 2003


Am Donnerstag, 29.05.03 um 15:37 Uhr schrieb David Faught:

> On 29/05/03 03:01, "Bert Freudenberg"<bert at isg.cs.uni-magdeburg.de>
> wrote:
>> On 28/05/03 12:00, "David Faught" <dave_faught at yahoo.com> wrote:
>>>
>>> I have several animations of 80 to 100 frames each, so it would be
>>> really nice to do this in a fairly automated way.  Any suggestions?
>>
>> I wrote a GIFWriter that could handle animated GIFs back in 1996. I
>> just resurrected it, see next post.
>
> Thanks Bert!  Unfortunately when I tried this it seems to mess up the
> color palette.  I set the display depth to 8 so that I could use a
> ColorForm as in:
>
> 	image := ColorForm fromDisplay: (Rectangle origin: (x1 at y1) corner:
> (x2 at y2)).
> 	writer nextPutImage: image.
>
> Does the color screw-up come from the fact that I am using a new
> ColorForm for each frame?

Probably. Only the colormap (palette) of the first image is used. As a 
quick fix, you can disable the color map reduction: in 
GIFReadWriter>>nextPutImage:, comment out the #colorReduced call.

	f := aForm "colorReduced".

That worked for me in this test:

	| writer image |
	writer := (GIFReadWriter on: (FileStream newFileNamed: 'anim.gif'))
		loopCount: 0; delay:10.
	[0 to: 80 by: 4 do: [:i |
		image := Form fromDisplay: (i at 0 extent: 32 at 32).
		writer nextPutImage: image]
	] ensure: [writer close].

A better fix would be to first collect all forms, convert them to an 
optimal color map, and write them out:

GIFReadWriter>>#nextPutAllImages: images
	| temp |
	temp := images first copy.
	temp colorMap: (self optimalColorMapFor: images).
	images do: [:img |
		img displayOn: temp.
		self nextPutImage: temp].

Details to be filled in by the kind reader ;-)

-- Bert



More information about the Squeak-dev mailing list