简体   繁体   English

如何获取窗口工作区的每个像素的RGB值数组

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

有没有一种方法可以使用gdi接收窗口工作区中每个像素的颜色值?

As noted in comment by @JerryCoffin. 正如@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. 您应该在内存DC中选择一个位图对象,可以使用该对象使用GetPixel GDI函数,然后还可以使用GetRValue()GetGValue()GetBValue()宏提取颜色值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM