mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-28 02:04:36 +03:00
Windows Screengrab DPI fix improvements (#2)
* Load User32 after possible return * Removed unused setting of variable
This commit is contained in:
parent
cacbdc680c
commit
d46f81afba
|
@ -332,7 +332,7 @@ PyImaging_GrabScreenWin32(PyObject* self, PyObject* args)
|
||||||
DWORD rop;
|
DWORD rop;
|
||||||
PyObject* buffer;
|
PyObject* buffer;
|
||||||
HANDLE dpiAwareness;
|
HANDLE dpiAwareness;
|
||||||
HMODULE user32 = LoadLibraryA("User32.dll");
|
HMODULE user32;
|
||||||
Func_SetThreadDpiAwarenessContext SetThreadDpiAwarenessContext_function;
|
Func_SetThreadDpiAwarenessContext SetThreadDpiAwarenessContext_function;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "|i", &includeLayeredWindows))
|
if (!PyArg_ParseTuple(args, "|i", &includeLayeredWindows))
|
||||||
|
@ -346,6 +346,7 @@ PyImaging_GrabScreenWin32(PyObject* self, PyObject* args)
|
||||||
|
|
||||||
// added in Windows 10 (1607)
|
// added in Windows 10 (1607)
|
||||||
// loaded dynamically to avoid link errors
|
// loaded dynamically to avoid link errors
|
||||||
|
user32 = LoadLibraryA("User32.dll");
|
||||||
SetThreadDpiAwarenessContext_function =
|
SetThreadDpiAwarenessContext_function =
|
||||||
(Func_SetThreadDpiAwarenessContext)
|
(Func_SetThreadDpiAwarenessContext)
|
||||||
GetProcAddress(user32, "SetThreadDpiAwarenessContext");
|
GetProcAddress(user32, "SetThreadDpiAwarenessContext");
|
||||||
|
@ -358,7 +359,7 @@ PyImaging_GrabScreenWin32(PyObject* self, PyObject* args)
|
||||||
height = GetDeviceCaps(screen, VERTRES);
|
height = GetDeviceCaps(screen, VERTRES);
|
||||||
|
|
||||||
if (SetThreadDpiAwarenessContext_function != NULL) {
|
if (SetThreadDpiAwarenessContext_function != NULL) {
|
||||||
dpiAwareness = SetThreadDpiAwarenessContext_function(dpiAwareness);
|
SetThreadDpiAwarenessContext_function(dpiAwareness);
|
||||||
}
|
}
|
||||||
|
|
||||||
FreeLibrary(user32);
|
FreeLibrary(user32);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user