[squeak-dev] using color tables with forms and bitblt?
Lawson English
lenglish5 at cox.net
Sun Aug 5 06:43:06 UTC 2012
Thanks, that works.
Though I think the usecase of the ability to swiftly switch palettes is
of value, even in 32 bit forms.
form>>mapColor:to: and mapColors:to should be able to use a full 32 bit
color. The bitblt docs say that only 5 bits of the Color object's RGB
values are used no matter the depth of the destination form. This is a
serious limitation for anyone hoping to prototype/implement a modern
image-oriented application.
Cairo no doubt changes this, but Cairo also violates the port anywhere
paradigm that Squeak is based on, I think.
L
On 8/4/12 8:34 AM, Bob Arning wrote:
> 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
>>
>>
>>
>>
>>
>
>
>
--
Squeak from the very start (introduction to Squeak and Pharo Smalltalk for the (almost) complete and compleate beginner).
https://www.youtube.com/playlist?list=PL6601A198DF14788D&feature=view_all
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20120804/b1cbeebb/attachment.htm
More information about the Squeak-dev
mailing list
|