[squeak-dev] using color tables with forms and bitblt?

Lawson English lenglish5 at cox.net
Sun Aug 5 13:08:54 UTC 2012




On 8/5/12 4:30 AM, Bob Arning wrote:
> Maybe the VM folks will see the value in adding this or maybe you 
> could write a plugin. 
Actually, I've been looking at the BitBltPlugin.c source (it apparently 
isn't written in slang?) but...


you've saved me a lot of time (and saved me from my ADHD distraction) 
with this.

Thanks!

L

> Barring that, this speeds things up quite a bit over the naive 
> implementation:
>
> test2
> "
> BobsColorTest new test2
> "
>     | target cmap1 inputData cmap2 nextPV cmap3 inputDataBits 
> targetBits results t forceAlpha preAlloc |
>
>     inputData _ Form extent: 800 at 800 depth: 32.
>     nextPV _ 1.
>     0 to: 799 do: [ :x |
>         0 to: 799 do: [ :y |
>             inputData pixelValueAt: x at y put: ((nextPV _ nextPV + 1) \\ 
> 30000 bitAnd: 16rffffff).
>         ].
>     ].
>     forceAlpha _ 16rff000000.
>     cmap1 _  Bitmap new: 256*256*256.
>     1 to: cmap1 size do: [:i | cmap1 at: i put:( i  \\ 65536 * 256 + 1 
> bitOr: forceAlpha)].
>     cmap2 _  Bitmap new: 256*256*256.
>     1 to: cmap2 size do: [:i | cmap2 at: i put: (i - 1 \\ 256 + 1 
> bitOr: forceAlpha)].
>     cmap3 _  Bitmap new: 256*256*256.
>     1 to: cmap3 size do: [:i | cmap3 at: i put: (i - 1 bitOr: 
> forceAlpha)].
>
>     preAlloc _ {cmap1. cmap2. cmap3} collect: [ :map |
>         {map. Form extent: inputData extent depth: inputData depth}
>     ].
>     t _ [
>         results _ preAlloc collect: [ :pair |
>             target _ pair second.
>             targetBits _ target bits.
>             inputDataBits _ inputData bits.
>             1 to: targetBits size do: [ :i |
>                 targetBits at: i put: (pair first at: (inputDataBits 
> at: i) +1)
>             ].
>             target
>         ].
>     ] timeToRun.
>     results do: [ :each |
>         each  asMorph openInWorld.
>     ].
>     self inform: t asString,'ms to map ',results size asString,' times'.
>
> Cheers,
> Bob



> -- 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/20120805/f5dbc7c4/attachment.htm


More information about the Squeak-dev mailing list