我在这里按照此代码截取屏幕截图。它把东西放到HDC上。我想知道如何从这个HDC中取出一些像素数据。我想将它复制到剪贴板,并将其绘制到HTML5画布。
我是否必须为HDC上的每个点运行GetPixel
,这是获取位图数组的唯一方法吗?
HBITMAP MakePrintScreen()
{
HWND hWindow = GetDesktopWindow();
HDC hdcScreen = GetDC(hWindow);
RECT rect;
HBITMAP hbmC;
GetClientRect(hWindow,&rect);
if((hbmC = CreateCompatibleBitmap(hdcScreen,rect.right,rect.bottom)) != NULL)
{
HDC hdcC;
if((hdcC = CreateCompatibleDC(hdcScreen)) != NULL)
{
HBITMAP hbmOld = (HBITMAP)SelectObject(hdcC,hbmC);
BitBlt(hdcC,0,0,rect.right,rect.bottom,hdcScreen,0,0,SRCCOPY);
SelectObject(hdcC,hbmOld);
DeleteDC(hdcC);
}
}
ReleaseDC(hWindow,hdcScreen);
return hbmC;
}