Created
July 15, 2014 11:55
-
-
Save JonasPf/e3c1447e2333b982788d to your computer and use it in GitHub Desktop.
wxPython: Create and save bitmap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
w = 500 | |
h = 300 | |
bmp = wx.EmptyBitmap(w, h) | |
dc = wx.MemoryDC() | |
dc.SelectObject(bmp) | |
dc.SetBackground(wx.Brush('black')) | |
dc.Clear() | |
dc.SetBrush(wx.Brush('green')) | |
dc.SetPen(wx.Pen('red', width=1)) | |
dc.DrawRectangle(10,10,w-10,h-10) | |
dc.SelectObject(wx.NullBitmap) | |
bmp.SetMaskColour('black') | |
img = bmp.ConvertToImage() | |
img.SaveFile('saved.png', wx.BITMAP_TYPE_PNG) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment