I use wx.MemoryDC to draw on a empty wx.Bitmap
(wx.EmptyImage.ConvertToBitmap()).
Is it possible to make the entire canvas of the wx.Bitmap transparent?
And from there start drawing things on it?
So the goal is to get a transparent background, and when I put the
wx.bitmap (using wx.StaticBitmap) on a panel with a GradientFill
background the outline of the bitmap doesn't show. Only the stuff that
has been drawn on it after setting the background to transparent.
I use wx.MemoryDC to draw on a empty wx.Bitmap
(wx.EmptyImage.ConvertToBitmap()).
Is it possible to make the entire canvas of the wx.Bitmap transparent?
And from there start drawing things on it?
Depending on platform the wx.MemoryDC may or may not have any clue about the bitmap's alpha channel (for example, on Windows the wx.DC classes are all based on pre-alpha APIs,) so the behavior is pretty much undefined. However if you use the memory DC as the target of a wx.GraphicsContext then you can get it to honor the bitmap's alpha channel and blend properly.
So the goal is to get a transparent background, and when I put the
wx.bitmap (using wx.StaticBitmap) on a panel with a GradientFill
background the outline of the bitmap doesn't show. Only the stuff that
has been drawn on it after setting the background to transparent.
This is actually a different problem. The issue here is that since a wx.StaticBitmap is an independent widget then it has its own window background, and when it draws the bitmap on itself then that background is still there, and the parent's background is clipped. (In this specific case it is mainly just Windows that behaves this way, Mac and GTK do deal pretty well with transparencies in the static widget types.) If you want the bitmap to appear to be blended with the parent then I would go ahead and draw it directly on the parent and don't use the wx.StaticBitmap.
On Jun 17, 10:28 pm, Robin Dunn <ro...@alldunn.com> wrote:
Bart wrote:
> Hello,
> I use wx.MemoryDC to draw on a empty wx.Bitmap
> (wx.EmptyImage.ConvertToBitmap()).
> Is it possible to make the entire canvas of the wx.Bitmap transparent?
> And from there start drawing things on it?
Depending on platform the wx.MemoryDC may or may not have any clue about
the bitmap's alpha channel (for example, on Windows the wx.DC classes
are all based on pre-alpha APIs,) so the behavior is pretty much
undefined. However if you use the memory DC as the target of a
wx.GraphicsContext then you can get it to honor the bitmap's alpha
channel and blend properly.
> So the goal is to get a transparent background, and when I put the
> wx.bitmap (using wx.StaticBitmap) on a panel with a GradientFill
> background the outline of the bitmap doesn't show. Only the stuff that
> has been drawn on it after setting the background to transparent.
This is actually a different problem. The issue here is that since a
wx.StaticBitmap is an independent widget then it has its own window
background, and when it draws the bitmap on itself then that background
is still there, and the parent's background is clipped. (In this
specific case it is mainly just Windows that behaves this way, Mac and
GTK do deal pretty well with transparencies in the static widget types.)
If you want the bitmap to appear to be blended with the parent then I
would go ahead and draw it directly on the parent and don't use the
wx.StaticBitmap.
--
Robin Dunn
Software Craftsmanhttp://wxPython.org