将WXpython位图转换为图像,然后再返回

时间:2011-02-03 02:47:20

标签: python image bitmap wxpython

我有一个用于在WXPython中创建矩形位图的函数。我想把它转换成图像。然后回到位图。怎么会这样呢?

摘录:

    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

1 个答案:

答案 0 :(得分:2)

使用wx.ImageFromBitmap(bitmap)wx.BitmapFromImage(image)