Showing the changes to libavdevice (1 of 1 file). Show all
Unified · Split
| @@ -235,6 +235,8 @@ gdigrab_read_header(AVFormatContext *s1) · 234 unmodified lines | ||
| 235 | 235 | AVStream *st = NULL; |
| 236 | 236 | |
| 237 | 237 | int bpp; |
| 238 | + int vertres; | |
| 239 | + int desktopvertres; | |
| 238 | 240 | RECT virtual_rect; |
| 239 | 241 | RECT clip_rect; |
| 240 | 242 | BITMAP bmp; |
| @@ -263,13 +265,26 @@ gdigrab_read_header(AVFormatContext *s1) · 22 unmodified lines | ||
| 263 | 265 | goto error; |
| 264 | 266 | } |
| 265 | 267 | |
| 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 | + | |
| 266 | 278 | if (hwnd) { |
| 267 | 279 | GetClientRect(hwnd, &virtual_rect); |
| 268 | 280 | } else { |
| 281 | + /* desktop -- get the right height and width for scaling DPI */ | |
| 282 | + vertres = GetDeviceCaps(source_hdc, VERTRES); | |
| 283 | + desktopvertres = GetDeviceCaps(source_hdc, DESKTOPVERTRES); | |
| 269 | 284 | virtual_rect.left = GetSystemMetrics(SM_XVIRTUALSCREEN); |
| 270 | 285 | 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; | |
| 273 | 288 | } |
| 274 | 289 | |
| 275 | 290 | /* If no width or height set, use full screen/window area */ |
| @@ -299,15 +314,6 @@ gdigrab_read_header(AVFormatContext *s1) · 23 unmodified lines | ||
| 299 | 314 | goto error; |
| 300 | 315 | } |
| 301 | 316 | |
| 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); | |
| 311 | 317 | |
| 312 | 318 | if (name) { |
| 313 | 319 | av_log(s1, AV_LOG_INFO, |