summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2011-03-03 09:35:02 -0800
committerBill Richardson <wfrichar@chromium.org>2011-03-03 09:35:02 -0800
commita933d11df84e83fccdd6e838070035cba4e59faf (patch)
tree9a5ee77bfc2f1decf5e5577c0c73a281c2f5a194
parent34092799b1cda3eddf6dfc8625c7699c5f5882ee (diff)
downloadvboot-a933d11df84e83fccdd6e838070035cba4e59faf.tar.gz
Add "File->Save snapshot" menu item to export the displayed screen.
Change-Id: Ia0e14a768d6ba6dadd520cd7c3961759771dab08 BUG=chromium-os:12643 TEST=none Review URL: http://codereview.chromium.org/6588139
-rwxr-xr-xscripts/newbitmaps/lib/bmpblock.py8
-rwxr-xr-xscripts/newbitmaps/lib/pixcontrol.py6
-rwxr-xr-xscripts/newbitmaps/lib/pixdisplay.py22
3 files changed, 36 insertions, 0 deletions
diff --git a/scripts/newbitmaps/lib/bmpblock.py b/scripts/newbitmaps/lib/bmpblock.py
index eacf72fa..c25f93e9 100755
--- a/scripts/newbitmaps/lib/bmpblock.py
+++ b/scripts/newbitmaps/lib/bmpblock.py
@@ -102,3 +102,11 @@ class BmpBlock(object):
sc = self.yaml['screens'][self.current_screen]
slist = [(x,y,self.yaml['images'][z]) for x,y,z in sc]
self.displayer.DisplayScreen(self.current_screen, slist)
+
+ def Saveit(self):
+ """Save current screen to file."""
+ if self.displayer:
+ if self.current_screen:
+ sc = self.yaml['screens'][self.current_screen]
+ slist = [(x,y,self.yaml['images'][z]) for x,y,z in sc]
+ self.displayer.SaveScreen(self.current_screen, slist)
diff --git a/scripts/newbitmaps/lib/pixcontrol.py b/scripts/newbitmaps/lib/pixcontrol.py
index 1f46558e..5d806df5 100755
--- a/scripts/newbitmaps/lib/pixcontrol.py
+++ b/scripts/newbitmaps/lib/pixcontrol.py
@@ -15,6 +15,7 @@ class Frame(wx.Frame):
m_about = menuFile.Append(wx.ID_ANY, "About...\tCtrl+A")
menuFile.AppendSeparator()
m_reload = menuFile.Append(wx.ID_ANY, "Reload\tCtrl+R")
+ m_snapshot = menuFile.Append(wx.ID_ANY, "Save snapshot")
m_quit = menuFile.Append(wx.ID_ANY, "Quit\tCtrl+Q")
menuBar = wx.MenuBar()
menuBar.Append(menuFile, "&File")
@@ -22,6 +23,7 @@ class Frame(wx.Frame):
self.CreateStatusBar()
self.Bind(wx.EVT_MENU, self.OnAbout, m_about)
self.Bind(wx.EVT_MENU, self.OnReload, m_reload)
+ self.Bind(wx.EVT_MENU, self.OnSaveit, m_snapshot)
self.Bind(wx.EVT_MENU, self.OnQuit, m_quit)
self.Bind(wx.EVT_CLOSE, self.OnQuit)
@@ -78,6 +80,10 @@ class Frame(wx.Frame):
self.do_update = True;
self.UpdateControls()
+ def OnSaveit(self, event):
+ """Tell the model object to save the view that the user sees."""
+ self.bmpblock.Saveit()
+
def OnSelected(self, event):
"""User may have picked one of the pulldowns."""
if event.IsSelection():
diff --git a/scripts/newbitmaps/lib/pixdisplay.py b/scripts/newbitmaps/lib/pixdisplay.py
index 0d40580b..339e2dfe 100755
--- a/scripts/newbitmaps/lib/pixdisplay.py
+++ b/scripts/newbitmaps/lib/pixdisplay.py
@@ -37,6 +37,24 @@ class MyPanel(wx.Panel):
bmp = img.ConvertToBitmap()
dc.DrawBitmap(bmp, x, y)
+ def OnSave(self, name):
+ """Draw the current image sequence into a file."""
+ dc = wx.MemoryDC()
+ done_first = False
+ for x, y, filename in self.imglist:
+ img = wx.Image(filename, wx.BITMAP_TYPE_ANY)
+ if (not done_first):
+ w,h = img.GetSize()
+ base = wx.EmptyBitmap(w,h)
+ dc.SelectObject(base)
+ done_first = True
+ bmp = img.ConvertToBitmap()
+ dc.DrawBitmap(bmp, x, y)
+ new = wx.ImageFromBitmap(base)
+ outfile = name + '.png'
+ new.SaveFile(outfile, wx.BITMAP_TYPE_PNG)
+ print "wrote", outfile
+
class Frame(wx.Frame):
@@ -60,3 +78,7 @@ class Frame(wx.Frame):
self.SetStatusText(name)
self.p.imglist = imglist
self.p.OnPaint()
+
+ def SaveScreen(self, name, imglist):
+ self.p.imglist = imglist
+ self.p.OnSave(name)