2

ウィンドウにテキスト(textOut)と長方形を描画しています...そしてそこからRGBバッファを取得したいのですが...どうすればよいですか?

4

1 に答える 1

3

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);
于 2012-11-11T20:39:45.500 に答える