[Vm-dev] BitBlt looking for rule blitting an alpha mask + constant color

Juan Vuletich juan at jvuletich.org
Sat Jun 20 04:22:53 UTC 2009

Hi Folks,

Andreas Raab wrote:
> Igor Stasenko wrote:
>> 2009/6/20 Andreas Raab <andreas.raab at gmx.de>:
>>> Easy. Make a color map that is set up such that
>>> cmap := Bitmap new: 256.
>>> 0 to: 255 do:[:i|
>>>  cmap at: i+1 put: (constColor alpha: i/255.0) pixelValue32.
>>> ].
>> That is possible, but the price is generating a color map each time
>> the color changes :(
>> Much less price than converting/using 32 bpp, but still is not 
>> perfect :)
> It's utterly trivial to cache it. If you're using this for font 
> display you'll only have a few colors to deal with so the cache won't 
> be big.

You can see how to do all this in Cuis. It is what I do for font 
rendering. Take a look at GrafPort >> installStrikeFont:foregroundColor: 
. This works ok with source forms of any depth. For 8 bpp (and lower), 
it is considered to hold opacity (i.e. 1-alpha). It is trivial to adjust 
the colormaps for alpha instead. Take a look at the execution path for 
"(Preferences subPixelRenderFonts and: [ foregroundColor = Color black 
or: [ Preferences subPixelRenderColorFonts ]]) ifTrue: [". I use two 
passes of bitblt. The first one is rgbMul, the second is rgbAdd. 
Together they do the proper AA as you specified it. This only works for 
destForm of 16 or 32 bpp. On 8bpp or less destination, I just use paint 

If you want to test it with a soureForm that includes only opecity, evaluate
    StrikeFont allInstances do: [ :f | f
        setGlyphsDepthAtMost: 4 ].

You'll see that it works ok for any font color / background color 

Juan Vuletich

More information about the Vm-dev mailing list