Hi,
I have to draw an alpha blended rectangle on a wxPanel ... I tryed creating an empty bitmap, drawing on it a rectangle and then setting the alpha for the whole pixels. But wxPython gives a an assertion error:
PyAssertionError: C++ assertion "wxAssertFailure" failed in ..\..\src\common\image.cpp(948): invalid image or no alpha channel
I use this code (maybe its wrong ...):
bmp = wx.EmptyBitmap(w, h)
dc = wx.MemoryDC()
dc.SelectObject(bmp)
dc.SetBrush(wx.RED_BRUSH)
dc.SetPen(wx.RED_PEN)
dc.DrawRectangle(0, 0, w, h)
image = bmp.ConvertToImage()
for x in range(0, w):
for y in range(0, h):
image.SetAlpha(x, y, 120)
bmp = image.ConvertToBitmap()
and then a draw 'bmp' ... but it stops and 'image.SetAlpha(x, y, 120)'
what's wrong? How can I do?
bye