Best way (morph) for working with pixels

Lex Spoon lex at cc.gatech.edu
Wed Feb 20 18:33:58 UTC 2002


> I've tried the ImageMorph with it's ColorForm inside, but it
> uses a colormap. But I would like to say "pixel x y set the value
> red 0.4 green 0.6 blue 0.0", regardless if this color is in any colormap
> or not (which is necessary for the colorAt: put: method of colorform).
> 

Try sending "asFormOfDepth: 32" to your form, and you'll get back a
32-bit form that allows you to use any colors you like.

As far as I know, operating on forms with colorAt: and colorAt:put: is
the simplest way to get going.  For speed, you will probably want to
hook into BitBlt eventually.  BitBlit isn't as limitting as it might
sound -- for example, it has an operation to mix rectangular regions of
two forms into another form, using alpha to mix.  Thus, for example, you
should be able to get a blur effect by mixing an image with itself at
various 1-pixel offsets.  You can do a Sierpienski triangle by turning
on a pixel at the top left corner, and then XOR-ing each row of a form
with that same row at a 1-pixel offset, and then copying the result to
the next row.



-Lex



More information about the Squeak-dev mailing list