Status: Layer organisation

Chris Barker Chris.Barker at
Mon Jan 3 18:43:19 CET 2005

Russell Nelson wrote:
> bh at (Bernhard Herzog) writes:
>  > Martin Schulze <joey at> writes:
>  > >  2. If 1. we should see why transparency is currently not supported by
>  > >     Thuban
>  > 
>  > The reason is simple: It's not easy to do with a wxDC.  It would be
>  > possible and probably not even difficult to do a gif-like transparency
>  > (effecively one bit alpha channel, every pixel is either drawn or not).

Yes, this is a major deficiency of wxDCs. However, I think the wx 2.5 
series supports bitmaps with an alpha channel, at least on a platforms 
that support it natively. I don't think there is such thing as a wxColor 
with an alpha channel, however, which is what is really needed.

Currently, you can do a bitmap with a mask, which provides the above 
mentioned gif-like behaviour, but it is pretty darn slow. I tried to use 
it in my FLoatCanvas so that I could cach layers in off-screen bitmaps. 
It ended up being slower than just re-drawing the objects, at least for 
my application. This, from the docs, seems to explain why it's slow:



If true, Blit does a transparent blit using the mask that is associated 
with the bitmap selected into the source device context. The Windows 
implementation does the following if MaskBlt cannot be used:

-Creates a temporary bitmap and copies the destination area into it.
Copies the source area into the temporary bitmap using the specified 
logical function.

-Sets the masked area in the temporary bitmap to BLACK by ANDing the 
mask bitmap with the temp bitmap with the foreground colour set to WHITE 
and the bg colour set to BLACK.

-Sets the unmasked area in the destination area to BLACK by ANDing the 
mask bitmap with the destination area with the foreground colour set to 
BLACK and the background colour set to WHITE.
ORs the temporary bitmap with the destination area.

-Deletes the temporary bitmap.

This sequence of operations ensures that the source's transparent area 
need not be black, and logical functions are supported.


Another option would be to use AGG ( to do the 
rendering, and blit the result to the screen. This is being done by at 
least a couple of Python plotting libraries (Chaco and Matplotlib), and 
a version is being developed for use with PIL 
( It seems to provide very high 
quality drawing and full alpha support. Has anyone considered this?

By the way, what are the plans for upgrading to wxPython 2.5.* 
(eventually 2.6)? I have personally converted all my code to the newer 
versions, and it really is a lot better, particularly on OS-X, where 2.4 
is essentially useless.


Christopher Barker, Ph.D.
NOAA/OR&R/HAZMAT         (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at

More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)