Saving a Form within the image

Dan Ingalls DanI at wdi.disney.com
Thu Feb 11 07:42:03 UTC 1999


Ivan Brusic <ivan at cc.gatech.edu> wrote...
>Is there a simple way to save a Form within code so that it can be
>returned via a method?

A Form, yes.  A ColorForm, no.

However it ought to be simple to write.  Start with the super storeOn: method to write text, and the extent:depth:fromArray:offset: that you found to read it back.  To this you have to add writing and reading of the colors array.  This should not be hard, since every color is characterized by its privateRGB, a small integer, so you should be able to write a literal array with, eg,
	(colors collect:  [:c | c privateRGB]),
similar to the bitmap data in fromArray.

>I am trying to re-esemble the pieces of the Form using the
>ColorForm>>extent:depth:fromArray:offset: method, but the
>result is incorrect.  There are several variables in ColorForm that are
>required such as colors, cachedDepth, and cachedColormap, but I have not
>found constructors for ColorForms or accessors methods that allow me to
>set the values.

You do not need to preserve cachedDepth and cachedColorMap -- it's fine if these start out as nil.  They are simply a cache so that ColorForms can display at any depth, quickly, and without having to save every possible color map.  Similarly, the two cache variables in colors do not have to be saved.

Hope this helps.

	- Dan





More information about the Squeak-dev mailing list