2016-04-30 5 views
1

誰もMacとWindwosブラウザウィンドウのビットマップを取得する方法を知っていますか?私は、レンダリング時にChromeやFireFoxから画像をキャプチャし、C++ベースのプラグインに渡したいと考えています。ブラウザウィンドウのビットマップを取得

Chrome拡張機能を使用してみましたが、実用的ではありません。

MacとWindowsネイティブアプリをやりたい。

+0

拡張機能が考慮されていない場合は、そのタグを削除します。 –

答えて

1

Windows APIを使用すると、スクリーンショットを簡単に取得できます。

// get the device context of the screen 
HDC hScreenDC = CreateDC("DISPLAY", NULL, NULL, NULL);  
// and a device context to put it in 
HDC hMemoryDC = CreateCompatibleDC(hScreenDC); 

int width = GetDeviceCaps(hScreenDC, HORZRES); 
int height = GetDeviceCaps(hScreenDC, VERTRES); 

// maybe worth checking these are positive values 
HBITMAP hBitmap = CreateCompatibleBitmap(hScreenDC, width, height); 

// get a new bitmap 
HBITMAP hOldBitmap = SelectObject(hMemoryDC, hBitmap); 

BitBlt(hMemoryDC, 0, 0, width, height, hScreenDC, 0, 0, SRCCOPY); 
hBitmap = SelectObject(hMemoryDC, hOldBitmap); 

// clean up 
DeleteDC(hMemoryDC); 
DeleteDC(hScreenDC); 
// now your image is held in hBitmap. You can save it or do whatever with it 

ブラウザの正確な領域について、またはMac用に解決する方法についてはわかりません。他に何もなければ、その始まり。

関連する問題