diff --git a/windows-snapshot-tool/bin/freeze.exe b/windows-snapshot-tool/bin/freeze.exe index 183bf6b..7e68698 100755 Binary files a/windows-snapshot-tool/bin/freeze.exe and b/windows-snapshot-tool/bin/freeze.exe differ diff --git a/windows-snapshot-tool/src/main.cpp b/windows-snapshot-tool/src/main.cpp index 4add802..22a60cc 100644 --- a/windows-snapshot-tool/src/main.cpp +++ b/windows-snapshot-tool/src/main.cpp @@ -347,19 +347,22 @@ int CaptureImage(HWND hWnd, const wchar_t* filename) { int width = GetDeviceCaps(hdcScreen, HORZRES); int height = GetDeviceCaps(hdcScreen, VERTRES); + HBITMAP hBmp = CreateCompatibleBitmap(hdcScreen, width, height); + // Select the compatible bitmap into the compatible memory DC. - SelectObject(hdcMemDC,hbmScreen); + SelectObject(hdcMemDC,hBmp); // Bit block transfer into our compatible memory DC. if(!BitBlt(hdcMemDC, - 0,0, - rcClient.right-rcClient.left, rcClient.bottom-rcClient.top, - hdcWindow, + 0,0, + width, height, + hdcScreen, 0,0, SRCCOPY)) { MessageBox(hWnd, L"BitBlt has failed", L"Failed", MB_OK); DeleteObject(hbmScreen); + DeleteObject(hBmp); DeleteObject(hdcMemDC); ReleaseDC(NULL,hdcScreen); ReleaseDC(hWnd,hdcWindow); @@ -367,7 +370,7 @@ int CaptureImage(HWND hWnd, const wchar_t* filename) { } // Get the BITMAP from the HBITMAP - GetObject(hbmScreen,sizeof(BITMAP),&bmpScreen); + GetObject(hBmp,sizeof(BITMAP),&bmpScreen); BITMAPFILEHEADER bmfHeader; 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 // which is pointed to by lpbitmap. - GetDIBits(hdcWindow, hbmScreen, 0, + GetDIBits(hdcScreen, hBmp, 0, (UINT)bmpScreen.bmHeight, lpbitmap, (BITMAPINFO *)&bi, DIB_RGB_COLORS); @@ -433,6 +436,7 @@ int CaptureImage(HWND hWnd, const wchar_t* filename) { // clean up DeleteObject(hbmScreen); + DeleteObject(hBmp); DeleteObject(hdcMemDC); ReleaseDC(NULL,hdcScreen); ReleaseDC(hWnd,hdcWindow);