Python에서 bmp 크기 변경하기
Python :
2008. 5. 28. 22:03
반응형

아랫 부분에 찌그러진 그림이 크기를 변경한거다.
혜진이가 물어보길래 도와주면서 해봤다.
- import wx
- import images
- class DrawFrame(wx.Frame):
- def __init__(self, parent, id, title):
- wx.Frame.__init__(self, parent, id, title)
- wx.EVT_PAINT(self, self.OnPaint)
- self.SetBackgroundColour("WHITE")
- bmp = images.getTest2Bitmap()
- mask = wx.Mask(bmp, wx.BLUE)
- bmp.SetMask(mask)
- self.bmp = bmp
- SSize=(23,100)
- self.bmp.SetSize(SSize)
- def OnPaint(self, evt):
- pdc = wx.PaintDC(self)
- try:
- dc = wx.GCDC(pdc)
- except:
- dc = pdc
- rect = wx.Rect(0,0, 100, 100)
- dc.DrawBitmap(self.bmp, 200, 250, True)
- for RGB, pos in [((178, 34, 34), ( 50, 90)),
- (( 35, 142, 35), (110, 150)),
- (( 0, 0, 139), (170, 90))
- ]:
- r, g, b = RGB
- penclr = wx.Colour(r, g, b, wx.ALPHA_OPAQUE)
- brushclr = wx.Colour(r, g, b, 128) # half transparent
- dc.SetPen(wx.Pen(penclr))
- dc.SetBrush(wx.Brush(brushclr))
- rect.SetPosition(pos)
- dc.DrawRoundedRectangleRect(rect, 8)
- app = wx.PySimpleApp(0)
- frame = DrawFrame(None, -1, "Draw on Frame")
- frame.Show(True)
- app.MainLoop()
반응형
'Python' 카테고리의 다른 글
Python 웹프레임워크 Django (0) | 2008.05.30 |
---|---|
운영체제 과제 프로세스 스케쥴링 시뮬레이션 (2) | 2008.05.12 |
python list deepcopy, 형변환 (0) | 2008.05.07 |