[squeak-dev] using color tables with forms and bitblt?
Bob Arning
arning315 at comcast.net
Sat Aug 4 15:34:51 UTC 2012
You could try something like this:
test1
"
BobsColorTest new test1
"
| target cmap1 inputData cmap2 nextPV cmap3 |
inputData _ Form extent: 800 at 800 depth: 16.
nextPV _ 1.
0 to: 799 do: [ :x |
0 to: 799 do: [ :y |
inputData pixelValueAt: x at y put: (nextPV _ nextPV + 1) \\
30000.
].
].
cmap1 _ Bitmap new: 32768.
1 to: cmap1 size do: [:i | cmap1 at: i put: i \\ 1023 * 32 + 1].
cmap2 _ Bitmap new: 32768.
1 to: cmap2 size do: [:i | cmap2 at: i put: i - 1 \\ 32 + 1].
cmap3 _ Bitmap new: 32768.
1 to: cmap3 size do: [:i | cmap3 at: i put: i - 1].
{cmap1. cmap2. cmap3} do: [ :map |
target _ Form extent: inputData extent depth: inputData depth.
(BitBlt current toForm: target)
sourceForm: inputData;
sourceOrigin: 0 at 0;
combinationRule: Form paint;
destX: 0 destY: 0 width: inputData width height: inputData
height;
colorMap: map;
copyBits.
target asMorph openInWorld.
].
Cheers,
Bob
On 8/3/12 7:30 PM, Lawson English wrote:
> OK, I'm such a noob here, that I'm not quite sure how to ask my
> question...
>
>
> I have a "dwell file" -an array of values generated by a Mandelbrot
> Set application, one per pixel, with arbitrary values between 1 and
> xxxxxxxxxxx (currently less than 2 billion, and right now far less
> than 1,000,000)- and I would like to use them, suitably tweaked, as
> indices into a ColorMap. The ColorMap need not have 1,000,000 entries.
> No-one can see that many color differences in a Mandelbrot set anyway.
>
> I can generate an array of Color (ColorArray?) but I'm not sure how to
> use them to create the ColorMap, and I'm not sure how to use the
> ColorMap to speedily change what is drawn in the first place.
>
> Right now, I'm creating a color dictionary and drawing via:
>
>
> 1 to: 800 do: [:y|
> 1 to: 800 do: [:x| |i|
> i := x+ ((y-1) *800). aForm colorAt: x at y put:( myDictColors
> at: (myArray at: i )).]
> ].
>
>
> where myDictColors is a dictionary whose keys are the dwells listed in
> the dwell array file and whose values are Color objects from my array
> of colors.
>
> Drawing the above takes about 1.5 seconds, which is a bit slow. I'd
> like realtime-ish updating as I play with colors in the palette. Can
> this be done, at least up to the 4096 color limit that BitBlt has for
> ColorMaps?
>
> If so, how? I've been trying to figure out the various classes and
> I'm stumped.
>
>
> Thanks
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20120804/b734bf59/attachment.htm
More information about the Squeak-dev
mailing list
|