我正在繪製文本(textOut)和我的窗口上的矩形... 我想從中獲取RGB緩衝區... 我該怎麼做?如何從窗口獲取像素數據像素緩衝區並提取RGB?
1
A
回答
2
有2個選項:
首先,您可以使用GetPixel()。我用了很多。它工作正常:
COLORREF GetPixel(
HDC hdc,
int nXPos,
int nYPos
);
隨着我們的日處理器使用此功能甚至使用rect可能在某些情況下工作。
其次,您可以將屏幕內容複製到位圖中。在此之後,你可以將它放在剪貼板中,與您的代碼工藝等核心功能有:
BOOL BitBlt(
_In_ HDC hdcDest,
_In_ int nXDest,
_In_ int nYDest,
_In_ int nWidth,
_In_ int nHeight,
_In_ HDC hdcSrc,
_In_ int nXSrc,
_In_ int nYSrc,
_In_ DWORD dwRop
);
如果需要我可以發佈更詳細的片斷。
// Pick up the DC.
HDC hDC = ::GetDC(m_control);
// Pick up the second DC.
HDC hDCMem = ::CreateCompatibleDC(hDC);
// Create the in memory bitmap.
HBITMAP hBitmap = ::CreateCompatibleBitmap(hDC, bmp_size_x, bmp_size_y);
// Put bitmat into the memory DC. This will make it functional.
HBITMAP hBmpOld = (HBITMAP)::SelectObject(hDCMem, hBitmap);
// Clear the background.
HBRUSH hBkgr = ::CreateSolidBrush(props.bkgr_brush);
RECT bitmap_rect = { 0, 0, bmp_size_x, bmp_size_y };
::FillRect(hDCMem, &bitmap_rect, hBkgr);
::DeleteObject(hBkgr);
// Do the job.
::BitBlt(hDCMem, margins_rect.left, margins_rect.top,
size_to_copy_x, size_to_copy_y, hDC,
screen_from_x, screen_from_y, SRCCOPY);
相關問題
- 1. 提取髒rents RGB像素緩衝區數據DirectX
- 2. 從CGImage獲取RGB像素數據
- 3. WebGL - 從渲染緩衝區中讀取像素數據
- 4. 從像素獲取RGB值並將rgb值設置回同一像素
- 5. 從鼠標的緩衝圖像中獲取像素RGB X和Y的位置
- 6. 從uint8獲取RGB像素值C++
- 7. 如何RGB像素緩衝區轉換爲IRandomAccessStream^
- 8. 抓取窗口的像素數據
- 9. 使用像素緩衝區對象異步讀取數據gpu
- 10. 在C++中用聚焦窗口獲取像素RGB顏色
- 11. 裁剪像素緩衝區
- 12. 從PythonMagick圖像獲取像素數據?
- 13. 如何將從緩衝器獲取的像素數據繪製回自己?
- 14. 如何獲得窗口客戶區域的每個像素的RGB值數組
- 15. 如何從TK窗口獲取x11緩衝區?
- 16. 如何從像素頂部獲取窗口位置
- 17. 如何使用Direct2D從窗口獲取像素
- 18. 使用PIL獲取像素的RGB
- 19. 如何獲取imageView的像素數據?
- 20. 如何通過C++獲取圖像的所有像素數據(RGB)
- 21. 如何從CGImageRef對象獲取像素的RGB值?
- 22. AVPlayerLayer獲取圖像到UIImageView緩衝區
- 23. 從hdc獲取像素數據
- 24. 從Kinetic JS Image獲取像素數據
- 25. 從BufferedImage獲取像素數據
- 26. 如何從圖像中獲取像素數據使用R
- 27. scanf並獲取緩衝區
- 28. 我如何從CollectionFS獲取文件(圖像)的緩衝區
- 29. 如何從ImageMagick獲取c緩衝區圖像
- 30. 從System.Drawing.Bitmap中提取像素
什麼環境? –