2
2
* The Python Imaging Library.
3
* $Id: //modules/pil/display.c#3 $
8
* 96-05-13 fl Windows DIB support
9
* 96-05-21 fl Added palette stuff
10
* 96-05-28 fl Added display_mode stuff
11
* 97-09-21 fl Added draw primitive
8
* 1996-05-13 fl Windows DIB support
9
* 1996-05-21 fl Added palette stuff
10
* 1996-05-28 fl Added display_mode stuff
11
* 1997-09-21 fl Added draw primitive
12
* 2001-09-17 fl Added ImagingGrabScreen (from _grabscreen.c)
13
14
* Copyright (c) Secret Labs AB 1997.
14
15
* Copyright (c) Fredrik Lundh 1996-97.
202
203
return Py_BuildValue("s(ii)", mode, size[0], size[1]);
207
PyImaging_GrabScreenWin32(PyObject* self, PyObject* args)
211
BITMAPCOREHEADER core;
212
HDC screen, screen_copy;
215
/* step 1: create a memory DC large enough to hold the
218
screen = CreateDC("DISPLAY", NULL, NULL, NULL);
219
screen_copy = CreateCompatibleDC(screen);
221
width = GetDeviceCaps(screen, HORZRES);
222
height = GetDeviceCaps(screen, VERTRES);
224
bitmap = CreateCompatibleBitmap(screen, width, height);
228
if (!SelectObject(screen_copy, bitmap))
231
/* step 2: copy bits into memory DC bitmap */
233
if (!BitBlt(screen_copy, 0, 0, width, height, screen, 0, 0, SRCCOPY))
236
/* step 3: extract bits from bitmap */
238
buffer = PyString_FromStringAndSize(NULL, height * ((width*3 + 3) & -4));
242
core.bcSize = sizeof(core);
243
core.bcWidth = width;
244
core.bcHeight = height;
246
core.bcBitCount = 24;
247
if (!GetDIBits(screen_copy, bitmap, 0, height, PyString_AS_STRING(buffer),
248
(BITMAPINFO*) &core, DIB_RGB_COLORS))
251
DeleteObject(bitmap);
252
DeleteDC(screen_copy);
255
return Py_BuildValue("(ii)N", width, height, buffer);
258
PyErr_SetString(PyExc_IOError, "screen grab failed");
260
DeleteDC(screen_copy);
205
266
#endif /* WIN32 */