Browse Source

next try

main
Hendrik Langer 6 years ago
parent
commit
31fda2791a
  1. BIN
      windows-snapshot-tool/bin/freeze.exe
  2. 16
      windows-snapshot-tool/src/main.cpp

BIN
windows-snapshot-tool/bin/freeze.exe

Binary file not shown.

16
windows-snapshot-tool/src/main.cpp

@ -347,19 +347,22 @@ int CaptureImage(HWND hWnd, const wchar_t* filename) {
int width = GetDeviceCaps(hdcScreen, HORZRES); int width = GetDeviceCaps(hdcScreen, HORZRES);
int height = GetDeviceCaps(hdcScreen, VERTRES); int height = GetDeviceCaps(hdcScreen, VERTRES);
HBITMAP hBmp = CreateCompatibleBitmap(hdcScreen, width, height);
// Select the compatible bitmap into the compatible memory DC. // Select the compatible bitmap into the compatible memory DC.
SelectObject(hdcMemDC,hbmScreen); SelectObject(hdcMemDC,hBmp);
// Bit block transfer into our compatible memory DC. // Bit block transfer into our compatible memory DC.
if(!BitBlt(hdcMemDC, if(!BitBlt(hdcMemDC,
0,0, 0,0,
rcClient.right-rcClient.left, rcClient.bottom-rcClient.top, width, height,
hdcWindow, hdcScreen,
0,0, 0,0,
SRCCOPY)) SRCCOPY))
{ {
MessageBox(hWnd, L"BitBlt has failed", L"Failed", MB_OK); MessageBox(hWnd, L"BitBlt has failed", L"Failed", MB_OK);
DeleteObject(hbmScreen); DeleteObject(hbmScreen);
DeleteObject(hBmp);
DeleteObject(hdcMemDC); DeleteObject(hdcMemDC);
ReleaseDC(NULL,hdcScreen); ReleaseDC(NULL,hdcScreen);
ReleaseDC(hWnd,hdcWindow); ReleaseDC(hWnd,hdcWindow);
@ -367,7 +370,7 @@ int CaptureImage(HWND hWnd, const wchar_t* filename) {
} }
// Get the BITMAP from the HBITMAP // Get the BITMAP from the HBITMAP
GetObject(hbmScreen,sizeof(BITMAP),&bmpScreen); GetObject(hBmp,sizeof(BITMAP),&bmpScreen);
BITMAPFILEHEADER bmfHeader; BITMAPFILEHEADER bmfHeader;
BITMAPINFOHEADER bi; BITMAPINFOHEADER bi;
@ -394,7 +397,7 @@ int CaptureImage(HWND hWnd, const wchar_t* filename) {
// Gets the "bits" from the bitmap and copies them into a buffer // Gets the "bits" from the bitmap and copies them into a buffer
// which is pointed to by lpbitmap. // which is pointed to by lpbitmap.
GetDIBits(hdcWindow, hbmScreen, 0, GetDIBits(hdcScreen, hBmp, 0,
(UINT)bmpScreen.bmHeight, (UINT)bmpScreen.bmHeight,
lpbitmap, lpbitmap,
(BITMAPINFO *)&bi, DIB_RGB_COLORS); (BITMAPINFO *)&bi, DIB_RGB_COLORS);
@ -433,6 +436,7 @@ int CaptureImage(HWND hWnd, const wchar_t* filename) {
// clean up // clean up
DeleteObject(hbmScreen); DeleteObject(hbmScreen);
DeleteObject(hBmp);
DeleteObject(hdcMemDC); DeleteObject(hdcMemDC);
ReleaseDC(NULL,hdcScreen); ReleaseDC(NULL,hdcScreen);
ReleaseDC(hWnd,hdcWindow); ReleaseDC(hWnd,hdcWindow);

Loading…
Cancel
Save