-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathBitmapFromPILTest.py
More file actions
executable file
·35 lines (26 loc) · 888 Bytes
/
BitmapFromPILTest.py
File metadata and controls
executable file
·35 lines (26 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
"""
A test of making wx.Bitmap from a PIL image
"""
import wx
import PIL.Image
class DemoFrame(wx.Frame):
""" This window displays a button """
def __init__(self, title = "Bitmap Demo"):
wx.Frame.__init__(self, None , -1, title)#, size = (800,600), style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE)
# load the PIL image:
image = PIL.Image.open('splash.png')
image = image.convert('RGB')
image = image.resize((100,100), PIL.Image.ANTIALIAS)
w, h = image.size
self.bitmap = wx.BitmapFromBuffer(w, h, image.tostring() )
self.Bind(wx.EVT_PAINT, self.OnPaint)
def OnPaint(self, evt):
dc = wx.PaintDC(self)
dc.DrawBitmap(self.bitmap, 10, 10 )
def OnQuit(self,Event):
self.Destroy()
app = wx.App(False)
frame = DemoFrame()
frame.Show()
app.MainLoop()