diff options
author | Dilshod Mukhtarov <dilshodm@gmail.com> | 2019-01-27 23:09:53 +0400 |
---|---|---|
committer | Carl Eugen Hoyos <ceffmpeg@gmail.com> | 2019-01-30 21:55:11 +0100 |
commit | d7c9ddd0c4b02c1e8872a299a6613f9b55b858a4 (patch) | |
tree | b056d31b5d9ae3f40421ce9db8273e8fa0a49920 /libavdevice/gdigrab.c | |
parent | 789d3b98d1ded964c60213c05dbe1cf42ab8ae59 (diff) | |
download | ffmpeg-d7c9ddd0c4b02c1e8872a299a6613f9b55b858a4.tar.gz |
libavdevice/gdigrab: fix HIDPI support for window capture
In Windows if using scaling other than 100% then the grabbed window was not captured fully (cropped)
Signed-off-by: Dilshod Mukhtarov <dilshodm@gmail.com>
Diffstat (limited to 'libavdevice/gdigrab.c')
-rw-r--r-- | libavdevice/gdigrab.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c index ab08c11788..0e6ae2bd5d 100644 --- a/libavdevice/gdigrab.c +++ b/libavdevice/gdigrab.c @@ -277,14 +277,20 @@ gdigrab_read_header(AVFormatContext *s1) } bpp = GetDeviceCaps(source_hdc, BITSPIXEL); + horzres = GetDeviceCaps(source_hdc, HORZRES); + vertres = GetDeviceCaps(source_hdc, VERTRES); + desktophorzres = GetDeviceCaps(source_hdc, DESKTOPHORZRES); + desktopvertres = GetDeviceCaps(source_hdc, DESKTOPVERTRES); + if (hwnd) { GetClientRect(hwnd, &virtual_rect); + /* window -- get the right height and width for scaling DPI */ + virtual_rect.left = virtual_rect.left * desktophorzres / horzres; + virtual_rect.right = virtual_rect.right * desktophorzres / horzres; + virtual_rect.top = virtual_rect.top * desktopvertres / vertres; + virtual_rect.bottom = virtual_rect.bottom * desktopvertres / vertres; } else { /* desktop -- get the right height and width for scaling DPI */ - horzres = GetDeviceCaps(source_hdc, HORZRES); - vertres = GetDeviceCaps(source_hdc, VERTRES); - desktophorzres = GetDeviceCaps(source_hdc, DESKTOPHORZRES); - desktopvertres = GetDeviceCaps(source_hdc, DESKTOPVERTRES); virtual_rect.left = GetSystemMetrics(SM_XVIRTUALSCREEN); virtual_rect.top = GetSystemMetrics(SM_YVIRTUALSCREEN); virtual_rect.right = (virtual_rect.left + GetSystemMetrics(SM_CXVIRTUALSCREEN)) * desktophorzres / horzres; |