I have a function that I use to create a rectangular bitmap, in WXPython. I’d like to convert it to an image. Then back to a bitmap. How would one go about this?
Snippet:
def make_shape(self, w, h, r ):
maskc = wx.Color(0, 0, 0)
shownc = wx.Color(0, 0, 1)
bitmap = wx.EmptyBitmap(w, h)
dc = wx.MemoryDC(bitmap)
# Fill
dc.SetBrush(wx.Brush(shownc))
# Rounding
dc.SetPen(wx.Pen(shownc))
# Shape
dc.DrawRoundedRectangle(0, 0, w, h, r)
dc.SelectObject(wx.NullBitmap)
bitmap.SetMaskColour(maskc)
return bitmap
Use
wx.ImageFromBitmap(bitmap)andwx.BitmapFromImage(image)