4
A
回答
12
了我的頭頂部,直接的方式:
#include <stdio.h>
#include <Windows.h>
int main(void) {
POINT p;
COLORREF color;
HDC hDC;
BOOL b;
// Get the device context for the screen
hDC = GetDC(NULL);
if (hDC == NULL)
return 3;
// Get the current cursor position
b = GetCursorPos(&p);
if (!b)
return 2;
// Retrieve the color at that position
color = GetPixel(hDC, p.x, p.y);
if (color == CLR_INVALID)
return 1;
// Release the device context again
ReleaseDC(GetDesktopWindow(), hDC);
printf("%i %i %i", GetRValue(color), GetGValue(color), GetBValue(color));
return 0;
}
ETA:似乎工作,至少對我來說。
ETA2:增加了一些錯誤檢查
ETA3:註釋代碼,編譯成可執行和Visual Studio解決方案可以在my SVN repository找到。
相關問題
- 1. 硒 - 如何獲得像素顏色?
- 2. 顏色有色UIImages獲得像素化
- 3. 試圖獲得像素的顏色值
- 4. Circle - Canvas獲得lineWidth的像素顏色
- 5. 如何使用VB.NET獲取光標位置處的像素的RGB顏色?
- 6. 如何在Silverlight中的光標下獲取顏色?
- 7. 如何獲取光標下圖像框中的像素數據?
- 8. WriteableImage - 如何獲取像素的顏色?
- 9. 如何獲得一個像素的顏色在UIView的
- 10. 如何獲得我剛纔觸摸的像素的顏色
- 11. 如何獲得一個像素的顏色
- 12. 如何使用c#獲得X,Y像素的顏色?
- 13. 如何從像素獲取顏色? OpenGL
- 14. 什麼是在鼠標下獲得QWidget像素顏色的最快方法?
- 15. 以顏色對象的形式獲得緩衝圖像中像素的顏色
- 16. 如何獲取圖像中像素的顏色(加載灰色)?
- 17. 試圖獲取光標的顏色
- 18. 查看光標下元素的顏色(#xxxxxx)
- 19. FreeImage:獲取像素顏色
- 20. GDAL獲取像素顏色
- 21. Java - 獲取像素顏色
- 22. 如何獲取當前在鼠標指針下的像素顏色
- 23. 得到一個像素的顏色
- 24. 得到x,y的像素顏色
- 25. 如何在沒有BufferedImage的情況下獲取圖像的像素顏色?
- 26. 如何更改光標顏色而不更改文字顏色?
- 27. iPhone:如何獲取圖像的每個像素的顏色?
- 28. 如何在UINavigationBar上獲得「無光澤」顏色?
- 29. 從鼠標光標下的像素獲取alphachannel值
- 30. 從圖像中獲取像素顏色
非常感謝!我想我在「Win32控制檯應用程序」中構建這個? – 2010-06-20 11:01:45
@Jeremy:是的。我無法弄清楚如何從命令行構建它,但作爲來自Visual Studio的控制檯應用程序,它工作正常。 – Joey 2010-06-20 11:06:15
謝謝!還有一件事,我試圖從另一個應用程序調用這個幕後,所以有沒有辦法隱藏黑色命令行窗口顯示? – 2010-06-20 11:58:56