There's one other issue I have with windows and making bitmaps. On mac
the background of a new EmptyBitmap is transparent, but on windows its
black and I can't seem make it transparent either.
this seems to work on linux but not windows:
dc.SetBackground(wx.TRANSPARENT_BRUSH)
dc.Clear()
It may look like it is working, but probably not really ;-). Using a wx.TRANSPARENT_BRUSH is supposed to only tell the drawing operations to leave the pixels untouched that would normally be painted by the brush. It doesn't actually set them to be transparent. If Clear is doing something different than that then it should probably be considered a bug.
and I've tried a bunch of other methods and searching which don't seem
to work either.
Setting a mask colour to black
This should work, but you'll probably need to do it after you've drawn your other stuff on the bitmap and deselected it from the memory dc. You may have to deal with jaggy edges though since a mask doesn't understand blending. However if you initialize the bitmap to have a background color that is the same or nearly the same as where the bitmap will be used, and then set that to be your masked color, then the jaggy edges will probably not be noticeable.
Converting to an image, setting a mask colour, calling InitAlpha and
converting back
I tried loading a 1x1 transparent png and scaling it into my desired
size, which works but I can't seem to draw anything on it afterward-
maybe what's drawing is inheriting the alpha channel and everything
that's drawn is invisible.
On Windows, and somewhat on wxGTK, things drawn with a normal wxDC will pretty much ignore the target's existing transparency and alpha. The native APIs just are not designed to handle them. Instead you should look into using wx.GraphicsContext or the wx.GCDC (a graphics context that implements most of the wxDC API) as the native APIs they are built upon do support alpha blending, anti-aliasing, etc.
On the other hand, you may still run into some differences across platforms even with wx.GraphicsContext, although the differences have been diminishing. One way to be totally consistent on all platforms is to use something like Cairo instead. There are some helpers in wx.lib.wxcairo for interfacing between wx and pycairo, and the wx.lib.graphics provides a pure python implementation of a wx.GraphicsContext-like API using pycairo.
···
On 6/15/12 6:39 AM, Paul Wiseman wrote:
--
Robin Dunn
Software Craftsman