windows.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:ATX 作者: NetEaseGame 项目源码 文件源码
def screen_cv2(self):
        """cv2 Image of current window screen"""
        hwnd = win32gui.GetDesktopWindow()
        left, top, right, bottom = self.rect
        width, height = right-left, bottom-top
        # copy bits to temporary dc
        win32gui.BitBlt(self._hdcmem, 0, 0, width, height, 
                        self._hdcwin, left, top, win32con.SRCCOPY)
        # read bits into buffer
        windll.gdi32.GetDIBits(self._hdcmem, self._hbmp.handle, 0, height, self._buf, ctypes.byref(self._bi), win32con.DIB_RGB_COLORS)
        # make a cv2 Image
        arr = np.fromstring(self._buf, dtype=np.uint8)
        img = arr.reshape(height, width, 4)
        img = img[::-1,:, 0:3]
        return img
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号