[screenweaver] How ScreenWeaver gets alpha

Edwin van Rijkom swos at vanrijkom.org
Sat Sep 10 06:15:41 PDT 2005


campbell at andersons.net.nz wrote:

>So this means you can only have 0% and 100% alpha. How
>did you work out the varing degrees of alpha? 
>
Not the case: when you have the RGBA quad for one pixel drawn over a 
white background, and that of the same image drawn over a black 
background, than you can easily calculate the pixel's alpha value like so:

pixelOnBlack.A = ~( pixelOnWhite.R - pixelOnBlack.R)

~ is a bitwise not. A means the alpha part of the quad, R means the read 
part - but this could be G or B too, doesn't matter: they'll all have 
the same delta.

>I thought the black and white
>thing was pretty smart. 
>
Thanks. I've tried a zillion different approaches before finally coming 
up with this one :) Things could be much simpeler if the Flash player 
didn't rely on the windows GDI functions for rendering text. Those 
routines don't support alpha channels and cause the otherwise perfectly 
usable alpha channel bitmap Flash produces (only when set to windowless 
mode, on a 32 bit color-depth running system) to go sour.

Cheers,
Edwin




More information about the screenweaver mailing list