| OLD | NEW |
| 1 #!/usr/bin/python -tt | 1 #!/usr/bin/python -tt |
| 2 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Display for bmpblock object.""" | 6 """Display for bmpblock object.""" |
| 7 import wx | 7 import wx |
| 8 | 8 |
| 9 class MyPanel(wx.Panel): | 9 class MyPanel(wx.Panel): |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 size = img.GetSize() | 30 size = img.GetSize() |
| 31 self.SetMinSize(size) | 31 self.SetMinSize(size) |
| 32 self.SetSize(size) | 32 self.SetSize(size) |
| 33 self.Fit() | 33 self.Fit() |
| 34 w,h = self.parent.GetBestSize() | 34 w,h = self.parent.GetBestSize() |
| 35 self.parent.SetDimensions(-1, -1, w, h, wx.SIZE_AUTO) | 35 self.parent.SetDimensions(-1, -1, w, h, wx.SIZE_AUTO) |
| 36 done_first = True | 36 done_first = True |
| 37 bmp = img.ConvertToBitmap() | 37 bmp = img.ConvertToBitmap() |
| 38 dc.DrawBitmap(bmp, x, y) | 38 dc.DrawBitmap(bmp, x, y) |
| 39 | 39 |
| 40 def OnSave(self, name): |
| 41 """Draw the current image sequence into a file.""" |
| 42 dc = wx.MemoryDC() |
| 43 done_first = False |
| 44 for x, y, filename in self.imglist: |
| 45 img = wx.Image(filename, wx.BITMAP_TYPE_ANY) |
| 46 if (not done_first): |
| 47 w,h = img.GetSize() |
| 48 base = wx.EmptyBitmap(w,h) |
| 49 dc.SelectObject(base) |
| 50 done_first = True |
| 51 bmp = img.ConvertToBitmap() |
| 52 dc.DrawBitmap(bmp, x, y) |
| 53 new = wx.ImageFromBitmap(base) |
| 54 outfile = name + '.png' |
| 55 new.SaveFile(outfile, wx.BITMAP_TYPE_PNG) |
| 56 print "wrote", outfile |
| 57 |
| 40 | 58 |
| 41 class Frame(wx.Frame): | 59 class Frame(wx.Frame): |
| 42 | 60 |
| 43 def __init__(self, bmpblock=None, title=None): | 61 def __init__(self, bmpblock=None, title=None): |
| 44 wx.Frame.__init__(self, None, wx.ID_ANY, title=title) | 62 wx.Frame.__init__(self, None, wx.ID_ANY, title=title) |
| 45 self.CreateStatusBar() | 63 self.CreateStatusBar() |
| 46 self.SetStatusText(title) | 64 self.SetStatusText(title) |
| 47 self.Bind(wx.EVT_CLOSE, self.OnQuit) | 65 self.Bind(wx.EVT_CLOSE, self.OnQuit) |
| 48 | 66 |
| 49 self.bmpblock = bmpblock | 67 self.bmpblock = bmpblock |
| 50 if self.bmpblock: | 68 if self.bmpblock: |
| 51 self.bmpblock.RegisterScreenDisplayObject(self) | 69 self.bmpblock.RegisterScreenDisplayObject(self) |
| 52 | 70 |
| 53 self.p = MyPanel(self) | 71 self.p = MyPanel(self) |
| 54 | 72 |
| 55 | 73 |
| 56 def OnQuit(self, event): | 74 def OnQuit(self, event): |
| 57 wx.GetApp().ExitMainLoop() | 75 wx.GetApp().ExitMainLoop() |
| 58 | 76 |
| 59 def DisplayScreen(self, name, imglist): | 77 def DisplayScreen(self, name, imglist): |
| 60 self.SetStatusText(name) | 78 self.SetStatusText(name) |
| 61 self.p.imglist = imglist | 79 self.p.imglist = imglist |
| 62 self.p.OnPaint() | 80 self.p.OnPaint() |
| 81 |
| 82 def SaveScreen(self, name, imglist): |
| 83 self.p.imglist = imglist |
| 84 self.p.OnSave(name) |
| OLD | NEW |