History

gdigrab: grab right desktop size if DPI in use, based on patch from Alexander Brotzge

Matt Oliver committed 11 years ago

Commit e82883a1 parent 8d9f86b1 file · +17 −11Browse files

Unified · Split

libavdevice/gdigrab.c+17−11
@@ -235,6 +235,8 @@ gdigrab_read_header(AVFormatContext *s1) · 234 unmodified lines
235235 AVStream *st = NULL;
236236
237237 int bpp;
238+ int vertres;
239+ int desktopvertres;
238240 RECT virtual_rect;
239241 RECT clip_rect;
240242 BITMAP bmp;
@@ -263,13 +265,26 @@ gdigrab_read_header(AVFormatContext *s1) · 22 unmodified lines
263265 goto error;
264266 }
265267
268+ /* This will get the device context for the selected window, or if
269+ * none, the primary screen */
270+ source_hdc = GetDC(hwnd);
271+ if (!source_hdc) {
272+ WIN32_API_ERROR("Couldn't get window device context");
273+ ret = AVERROR(EIO);
274+ goto error;
275+ }
276+ bpp = GetDeviceCaps(source_hdc, BITSPIXEL);
277+
266278 if (hwnd) {
267279 GetClientRect(hwnd, &virtual_rect);
268280 } else {
281+ /* desktop -- get the right height and width for scaling DPI */
282+ vertres = GetDeviceCaps(source_hdc, VERTRES);
283+ desktopvertres = GetDeviceCaps(source_hdc, DESKTOPVERTRES);
269284 virtual_rect.left = GetSystemMetrics(SM_XVIRTUALSCREEN);
270285 virtual_rect.top = GetSystemMetrics(SM_YVIRTUALSCREEN);
271− virtual_rect.right = virtual_rect.left + GetSystemMetrics(SM_CXVIRTUALSCREEN);
272− virtual_rect.bottom = virtual_rect.top + GetSystemMetrics(SM_CYVIRTUALSCREEN);
286+ virtual_rect.right = (virtual_rect.left + GetSystemMetrics(SM_CXVIRTUALSCREEN)) * desktopvertres / vertres;
287+ virtual_rect.bottom = (virtual_rect.top + GetSystemMetrics(SM_CYVIRTUALSCREEN)) * desktopvertres / vertres;
273288 }
274289
275290 /* If no width or height set, use full screen/window area */
@@ -299,15 +314,6 @@ gdigrab_read_header(AVFormatContext *s1) · 23 unmodified lines
299314 goto error;
300315 }
301316
302− /* This will get the device context for the selected window, or if
303− * none, the primary screen */
304− source_hdc = GetDC(hwnd);
305− if (!source_hdc) {
306− WIN32_API_ERROR("Couldn't get window device context");
307− ret = AVERROR(EIO);
308− goto error;
309− }
310− bpp = GetDeviceCaps(source_hdc, BITSPIXEL);
311317
312318 if (name) {
313319 av_log(s1, AV_LOG_INFO,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t