Hi Image-SIG,
PIL very nicely supports taking screen shots in Win32. Unfortunately,
for a user with multiple monitors such as myself, only the primary
monitor is captured.
The attached patch, against 1.1.6, makes ImageGrab capture the entire
virtual screen, spanning all enabled monitors.
I have tested this with two (differently-sized) monitors.
Thanks,
Catalin Patulea
Only in Imaging-1.1.6-vres: build
diff -ur Imaging-1.1.6/display.c Imaging-1.1.6-vres/display.c
--- Imaging-1.1.6/display.c 2006-12-03 06:51:26.000000000 -0500
+++ Imaging-1.1.6-vres/display.c 2008-06-16 01:36:14.703125000 -0400
@@ -284,7 +284,7 @@
PyObject*
PyImaging_GrabScreenWin32(PyObject* self, PyObject* args)
{
- int width, height;
+ int left, top, width, height;
HBITMAP bitmap;
BITMAPCOREHEADER core;
HDC screen, screen_copy;
@@ -296,8 +296,11 @@
screen = CreateDC("DISPLAY", NULL, NULL, NULL);
screen_copy = CreateCompatibleDC(screen);
- width = GetDeviceCaps(screen, HORZRES);
- height = GetDeviceCaps(screen, VERTRES);
+ /* multi-display screens can have a non-zero origin */
+ left = GetSystemMetrics(SM_XVIRTUALSCREEN);
+ top = GetSystemMetrics(SM_YVIRTUALSCREEN);
+ width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
+ height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
bitmap = CreateCompatibleBitmap(screen, width, height);
if (!bitmap)
@@ -308,7 +311,7 @@
/* step 2: copy bits into memory DC bitmap */
- if (!BitBlt(screen_copy, 0, 0, width, height, screen, 0, 0, SRCCOPY))
+ if (!BitBlt(screen_copy, 0, 0, width, height, screen, left, top, SRCCOPY))
goto error;
/* step 3: extract bits from bitmap */
_______________________________________________
Image-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/image-sig