|
||
Transparent windows enable the user to display semi-transparent bitmaps
on a window. The window must be an RWindow
, which is a
window that receives redraw events. The window must be set as transparent
before it is activated.
There are two methods for creating a transparent window:
Using a Mask
There are three functions that can be called when using a mask to create transparency.
The function SetTransparencyFactor()
requires a
single colour mask. A grey colour on the palette is chosen to be the
transparency value.
SetTransparencyBitmap()
and
SetTransparencyWsBitmap()
both require a mask of greyscale
colours (the colour depth of the bitmap does not matter) which is then applied
to the bitmap to create varying degrees of transparency.
These three functions can be interchanged at any point following activation; however the second method below (using an alpha channel) cannot later be selected.
The mask is applied to the fully rendered content of the two windows and the resulting output is what will be displayed.
Using an Alpha Channel
With this method, everything is composed onto one bitmap which means
a separate mask bitmap is not necessary. The method
SetTransparencyAlphaChannel()
is used to set the window up
in this way, and when the window has been activated, it cannot be changed to
the first method above.
The alpha channel is written to in the same way the red, green and
blue channels are written to, except the alpha channel defines transparency. If
there are zero values all across the alpha channel for a pixel on the top
window, it will be completely transparent. If the alpha channel contains a
value, then this pixel will be rendered at the appropriate transparency,
ranging up to 255 (FF
) for completely opaque.
Do not combine pixels from the top and the bottom bitmaps when the alpha channel is set incorrectly as it might not create the required colour due to unintended effects.
Do not draw to the top bitmap twice. It is advisable to not have a background colour, or to make it fully transparent (unless a tint is required) as it is the first drawn to the window. This avoids other unintended effects.
For Symbian 9.5 and later, the Alpha Channel method is preferred. Symbian 9.5 is optimised to use alpha channels, and also the mask method is likely to be eventually deprecated.