开发者

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

开发者 https://www.devze.com 2023-04-10 00:11 出处:网络
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

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

精彩评论

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

关注公众号