【发布时间】:2018-12-09 16:04:36
【问题描述】:
我正在尝试使用 PrintWindow 让 chrome 在我的画布上绘画。这是我用来呈现桌面捕获的代码
PRECT lpRect;
GetWindowRect(g_Window, lpRect);
HDC hDeviceContext =
CreateCompatibleDC(g_DeviceContextMain);
HBITMAP hBitmapWindow =
CreateCompatibleBitmap(g_DeviceContextMain, lpRect->right - lpRect->left, lpRect->bottom - lpRect->top);
SelectObject(hDeviceContext, hBitmapWindow);
if (PrintWindow(g_Window, hDeviceContext, g_IsAtleast81 ? 0x00000002 : NULL)) {
BitBlt(g_DeviceContextClient,
lpRect->left, lpRect->top, lpRect->right - lpRect->left, lpRect->bottom - lpRect->top, hDeviceContext, NULL, NULL, SRCCOPY);
}
DeleteObject(hBitmapWindow);
DeleteDC(hDeviceContext);
这是我打开 chrome 并捕获屏幕时的输出(Windows 7)
我可以在 Windows 10 中通过将 PW_RENDERFULLCONTENT 标志添加到 PrintWindow 来解决此问题,但不幸的是,此标志仅在 Windows 8.1 及更高版本中可用。我需要让它在 Windows 7/8 中工作。
在捕获屏幕之前,我还尝试在 chrome 中禁用硬件加速。结果还是一样!
我有什么办法可以解决这个问题,比如主窗口的绘制没有黑色矩形?或者复制 PW_RENDERFULLCONTENT 在 Windows = 8.1 所做的操作?
【问题讨论】:
标签: c google-chrome winapi