| @@ -845,15 +845,32 @@ Image createSnapshotOfNativeWindow (void* nativeWindowHandle) | |||||
| { | { | ||||
| auto hwnd = (HWND) nativeWindowHandle; | auto hwnd = (HWND) nativeWindowHandle; | ||||
| auto r = getWindowRect (hwnd); | |||||
| const int w = r.right - r.left; | |||||
| const int h = r.bottom - r.top; | |||||
| auto r = convertPhysicalScreenRectangleToLogical (rectangleFromRECT (getWindowRect (hwnd)), hwnd); | |||||
| const int w = r.getWidth(); | |||||
| const int h = r.getHeight(); | |||||
| auto nativeBitmap = new WindowsBitmapImage (Image::RGB, w, h, true); | auto nativeBitmap = new WindowsBitmapImage (Image::RGB, w, h, true); | ||||
| Image bitmap (nativeBitmap); | Image bitmap (nativeBitmap); | ||||
| HDC dc = GetDC (hwnd); | HDC dc = GetDC (hwnd); | ||||
| BitBlt (nativeBitmap->hdc, 0, 0, w, h, dc, 0, 0, SRCCOPY); | |||||
| if (isPerMonitorDPIAwareProcess()) | |||||
| { | |||||
| auto scale = getScaleFactorForWindow (hwnd); | |||||
| auto prevStretchMode = SetStretchBltMode (nativeBitmap->hdc, HALFTONE); | |||||
| SetBrushOrgEx (nativeBitmap->hdc, 0, 0, NULL); | |||||
| StretchBlt (nativeBitmap->hdc, 0, 0, w, h, | |||||
| dc, 0, 0, roundToInt (w * scale), roundToInt (h * scale), | |||||
| SRCCOPY); | |||||
| SetStretchBltMode (nativeBitmap->hdc, prevStretchMode); | |||||
| } | |||||
| else | |||||
| { | |||||
| BitBlt (nativeBitmap->hdc, 0, 0, w, h, dc, 0, 0, SRCCOPY); | |||||
| } | |||||
| ReleaseDC (hwnd, dc); | ReleaseDC (hwnd, dc); | ||||
| return SoftwareImageType().convert (bitmap); | return SoftwareImageType().convert (bitmap); | ||||