【发布时间】:2014-01-28 15:00:30
【问题描述】:
我正在尝试在 pyplot 中显示 wxpython 屏幕截图,但我不想保存图像。 这就是我所拥有的
import wx
from matplotlib import pyplot as plt
import matplotlib.image as mpimg
thisApp = wx.App( redirect=False )
def saveSnapshot(dcSource): #takes arg dcSource
# based largely on code posted to wxpython-users by Andrea Gavana 2006-11-08
size = dcSource.Size
bmp = wx.EmptyBitmap(size.width, size.height)
memDC = wx.MemoryDC()
memDC.SelectObject(bmp)
memDC.Blit( 0, 0, size.width, size.height, dcSource, 0, 0)
memDC.SelectObject(wx.NullBitmap)
img = bmp.ConvertToImage()
img.SaveFile('saved.png', wx.BITMAP_TYPE_PNG)
img = mpimg.imread('saved.png')
plt.imshow(img)
plt.show()
saveSnapshot(wx.ScreenDC())
这和我想要的差不多,基本上不保存文件只是显示而已。
img = bmp.ConvertToImage()
plt.imshow(img)
plt.show()
【问题讨论】:
标签: image matplotlib wxpython