【问题标题】:How to take screenshot of whole screen using wxpython如何使用 wxpython 截取整个屏幕
【发布时间】:2019-10-24 10:26:44
【问题描述】:

我正在设置一个图像处理工具,输入应该是屏幕截图。

wx python截图功能适用于尺寸正确但图像被缩放,因此无法捕获整个屏幕。

def taking_screenshot():
    screen = wx.ScreenDC()
    size=screen.GetSize()
    bmp = wx.Bitmap(size[0],size[1])
    mem=wx.MemoryDC(bmp)
    mem.Blit(0,0,size[0],size[1],screen,0,0)
    del mem
    bmp.SaveFile('screenshot_for_working.PNG',wx.BITMAP_TYPE_PNG)
   ('window',cv2.imread('screenshot_for_working.PNG') )

打开的图像窗口覆盖了整个画面,实际图片被缩放,因此只显示部分屏幕

【问题讨论】:

  • windows 还是 linux? python和wx版本?发布屏幕截图并保持隐私信息模糊。

标签: python opencv wxpython


【解决方案1】:

非常感谢您的想法。我想到了。在我的基本屏幕设置中,所有放大的缩放设置为 150%。还是谢谢。

【讨论】:

    【解决方案2】:

    这里有一些小的调整应该可以解决问题。使用widthheight 之类的措辞,这样您就可以跟踪哪些值去了哪里。

    print (width, height),您可以与 DisplaySize 进行比较,如果不正确,您应该自己定义宽度/高度。

    def taking_screenshot():
        screen = wx.ScreenDC()
        size=screen.GetSize()
    
        print (wx.DisplaySize())                # debugging: see if pixel values are okay.
    
        width = size[0]
        height = size[1]
    
        print (width, height)                    # compare with above values.
    
        bmp = wx.EmptyBitmap(width,height)       # use EmptyBitmap here instead of wx.Bitmap.
        mem=wx.MemoryDC(bmp)
        mem.SelectObject(bmp)                   # tell mem to use the actual bitmap
        mem.Blit(0,0,width, height,screen,0,0)
        del mem
        bmp.SaveFile('screenshot_for_working.PNG',wx.BITMAP_TYPE_PNG)
       ('window', cv2.imread('screenshot_for_working.PNG') )
    

    您也可以在此处查看:https://github.com/ponty/pyscreenshot 以获取另一个“截图”工具。

    【讨论】:

      猜你喜欢
      • 2021-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-16
      • 2018-05-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多