rename parameter, add note to docs

This commit is contained in:
nulano 2019-09-20 17:35:08 +02:00
parent 19426417ff
commit 6a2d8f8da0
4 changed files with 9 additions and 8 deletions

View File

@ -11,7 +11,7 @@ try:
for im in [
ImageGrab.grab(),
ImageGrab.grab(include_layered_windows=True),
ImageGrab.grab(multimonitor=True),
ImageGrab.grab(all_screens=True),
]:
self.assert_image(im, im.mode, im.size)

View File

@ -11,7 +11,7 @@ or the clipboard to a PIL image memory.
.. versionadded:: 1.1.3
.. py:function:: PIL.ImageGrab.grab(bbox=None, include_layered_windows=False, multimonitor=False)
.. py:function:: PIL.ImageGrab.grab(bbox=None, include_layered_windows=False, all_screens=False)
Take a snapshot of the screen. The pixels inside the bounding box are
returned as an "RGB" image on Windows or "RGBA" on macOS.
@ -20,8 +20,9 @@ or the clipboard to a PIL image memory.
.. versionadded:: 1.1.3 (Windows), 3.0.0 (macOS)
:param bbox: What region to copy. Default is the entire screen.
Note that on Windows OS, the top-left point may be negative if ``all_screens=True`` is used.
:param include_layered_windows: Includes layered windows. Windows OS only.
:param multimonitor: Capture all monitors. Windows OS only.
:param all_screens: Capture all monitors. Windows OS only.
:return: An image
.. py:function:: PIL.ImageGrab.grabclipboard()

View File

@ -29,7 +29,7 @@ else:
raise ImportError("ImageGrab is macOS and Windows only")
def grab(bbox=None, include_layered_windows=False, multimonitor=False):
def grab(bbox=None, include_layered_windows=False, all_screens=False):
if sys.platform == "darwin":
fh, filepath = tempfile.mkstemp(".png")
os.close(fh)
@ -40,7 +40,7 @@ def grab(bbox=None, include_layered_windows=False, multimonitor=False):
if bbox:
im = im.crop(bbox)
else:
offset, size, data = grabber(include_layered_windows, multimonitor)
offset, size, data = grabber(include_layered_windows, all_screens)
im = Image.frombytes(
"RGB",
size,

View File

@ -323,14 +323,14 @@ PyObject*
PyImaging_GrabScreenWin32(PyObject* self, PyObject* args)
{
int x = 0, y = 0, width, height;
int includeLayeredWindows = 0, multimonitor = 0;
int includeLayeredWindows = 0, all_screens = 0;
HBITMAP bitmap;
BITMAPCOREHEADER core;
HDC screen, screen_copy;
DWORD rop;
PyObject* buffer;
if (!PyArg_ParseTuple(args, "|ii", &includeLayeredWindows, &multimonitor))
if (!PyArg_ParseTuple(args, "|ii", &includeLayeredWindows, &all_screens))
return NULL;
/* step 1: create a memory DC large enough to hold the
@ -339,7 +339,7 @@ PyImaging_GrabScreenWin32(PyObject* self, PyObject* args)
screen = CreateDC("DISPLAY", NULL, NULL, NULL);
screen_copy = CreateCompatibleDC(screen);
if (multimonitor) {
if (all_screens) {
x = GetSystemMetrics(SM_XVIRTUALSCREEN);
y = GetSystemMetrics(SM_YVIRTUALSCREEN);
width = GetSystemMetrics(SM_CXVIRTUALSCREEN);