开发者

How to get the array of RGB values for each pixel of the client area of a window

Is there a way to receive the c开发者_如何学Colour values for each pixel in the client area of a window, with gdi?


As noted in comment by @JerryCoffin. Here's a simple example

hDC = GetDC(hwnd);
hBitmap = CreateCompatibleBitmap(hDC, width, height);
hMemDC = CreateCompatibleDC(hDC);
hOld = SelectObject(hMemDC, hBitmap);
BitBlt(hMemDC, 0, 0, width, height, hDC, x, y, SRCCOPY);

// Clean up
DeleteDC(hMemDC);
ReleaseDC(hwnd, hDC);

You should have a bitmap object selected into memory DC for which you can use GetPixel GDI function and then you can also extract the color values using GetRValue() , GetGValue() , and GetBValue() macros.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜