mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 02:06:18 +03:00
Merge pull request #26 from nulano/imagegrab-dynamic-link
Fix GetWindowDpiAwarenessContext NULL check
This commit is contained in:
commit
c5e89ee914
|
@ -329,7 +329,7 @@ PyImaging_GrabScreenWin32(PyObject *self, PyObject *args) {
|
||||||
HWND wnd;
|
HWND wnd;
|
||||||
DWORD rop;
|
DWORD rop;
|
||||||
PyObject *buffer;
|
PyObject *buffer;
|
||||||
HANDLE dpiAwareness;
|
HANDLE dpiAwareness = NULL;
|
||||||
HMODULE user32;
|
HMODULE user32;
|
||||||
Func_GetWindowDpiAwarenessContext GetWindowDpiAwarenessContext_function;
|
Func_GetWindowDpiAwarenessContext GetWindowDpiAwarenessContext_function;
|
||||||
Func_SetThreadDpiAwarenessContext SetThreadDpiAwarenessContext_function;
|
Func_SetThreadDpiAwarenessContext SetThreadDpiAwarenessContext_function;
|
||||||
|
@ -360,22 +360,15 @@ PyImaging_GrabScreenWin32(PyObject *self, PyObject *args) {
|
||||||
SetThreadDpiAwarenessContext_function = (Func_SetThreadDpiAwarenessContext
|
SetThreadDpiAwarenessContext_function = (Func_SetThreadDpiAwarenessContext
|
||||||
)GetProcAddress(user32, "SetThreadDpiAwarenessContext");
|
)GetProcAddress(user32, "SetThreadDpiAwarenessContext");
|
||||||
if (SetThreadDpiAwarenessContext_function != NULL) {
|
if (SetThreadDpiAwarenessContext_function != NULL) {
|
||||||
if (screens == -1) {
|
GetWindowDpiAwarenessContext_function = (Func_GetWindowDpiAwarenessContext
|
||||||
GetWindowDpiAwarenessContext_function = (Func_GetWindowDpiAwarenessContext
|
)GetProcAddress(user32, "GetWindowDpiAwarenessContext");
|
||||||
)GetProcAddress(user32, "GetWindowDpiAwarenessContext");
|
if (screens == -1 && GetWindowDpiAwarenessContext_function != NULL) {
|
||||||
DPI_AWARENESS_CONTEXT dpiAwarenessContext =
|
dpiAwareness = GetWindowDpiAwarenessContext_function(wnd);
|
||||||
GetWindowDpiAwarenessContext_function(wnd);
|
|
||||||
if (GetWindowDpiAwarenessContext_function != NULL &&
|
|
||||||
dpiAwarenessContext != NULL) {
|
|
||||||
dpiAwareness =
|
|
||||||
SetThreadDpiAwarenessContext_function(dpiAwarenessContext);
|
|
||||||
} else {
|
|
||||||
dpiAwareness = SetThreadDpiAwarenessContext_function((HANDLE)-3);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = ((DPI_CONTEXT_HANDLE)-3)
|
|
||||||
dpiAwareness = SetThreadDpiAwarenessContext_function((HANDLE)-3);
|
|
||||||
}
|
}
|
||||||
|
// DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = ((DPI_CONTEXT_HANDLE)-3)
|
||||||
|
dpiAwareness = SetThreadDpiAwarenessContext_function(
|
||||||
|
dpiAwareness == NULL ? (HANDLE)-3 : dpiAwareness
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (screens == 1) {
|
if (screens == 1) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user