6 imss_win32(unsigned hwnd_u, int include_decor) {
7 HWND hwnd = (HWND)hwnd_u;
10 HBITMAP work_bmp, old_dc_bmp;
13 unsigned char *di_bits;
19 hwnd = GetDesktopWindow();
22 wdc = GetWindowDC(hwnd);
23 GetWindowRect(hwnd, &rect);
27 GetClientRect(hwnd, &rect);
30 i_push_error(0, "Cannot get window DC - invalid hwnd?");
34 width = rect.right - rect.left;
35 height = rect.bottom - rect.top;
36 work_bmp = CreateCompatibleBitmap(wdc, width, height);
37 bmdc = CreateCompatibleDC(wdc);
38 old_dc_bmp = SelectObject(bmdc, work_bmp);
39 BitBlt(bmdc, 0, 0, width, height, wdc, 0, 0, SRCCOPY);
42 memset(&bmi, 0, sizeof(bmi));
43 bmi.bmiHeader.biSize = sizeof(bmi);
44 bmi.bmiHeader.biWidth = width;
45 bmi.bmiHeader.biHeight = -height;
46 bmi.bmiHeader.biPlanes = 1;
47 bmi.bmiHeader.biBitCount = 32;
48 bmi.bmiHeader.biCompression = BI_RGB;
50 di_bits = mymalloc(4 * width * height);
51 if (GetDIBits(bmdc, work_bmp, 0, height, di_bits, &bmi, DIB_RGB_COLORS)) {
52 i_color *line = mymalloc(sizeof(i_color) * width);
55 unsigned char *ch_pp = di_bits;
56 result = i_img_8_new(width, height, 3);
58 for (y = 0; y < height; ++y) {
60 for (x = 0; x < width; ++x) {
67 i_plin(result, 0, width, y, line);
74 SelectObject(bmdc, old_dc_bmp);
76 DeleteObject(work_bmp);