Sync to trunk head(r38096)
[reactos.git] / rostests / apitests / w32knapi / ntgdi / NtGdiSetDIBitsToDeviceInternal.c
1 INT
2 Test_NtGdiSetDIBitsToDeviceInternal(PTESTINFO pti)
3 {
4 static const DWORD InBits[8] = { 0x81, 0x7E, 0x5A, 0x7E, 0x7E, 0x42, 0x7E, 0x81 };
5 DWORD OutBits[8];
6
7 HWND hWnd = CreateWindowW(L"Static", NULL, WS_VISIBLE,
8 100, 100, 200, 200,
9 NULL, NULL, NULL, NULL);
10 /* This DC has an nonzero origin */
11 HDC hDC = GetDC(hWnd);
12 struct
13 {
14 BITMAPINFOHEADER bmiHeader;
15 RGBQUAD bmiColors[2];
16 } bmi;
17 int x, y;
18
19 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
20 bmi.bmiHeader.biWidth = 8;
21 bmi.bmiHeader.biHeight = -8;
22 bmi.bmiHeader.biPlanes = 1;
23 bmi.bmiHeader.biBitCount = 1;
24 bmi.bmiHeader.biCompression = 0;
25 bmi.bmiHeader.biSizeImage = 0;
26 bmi.bmiHeader.biXPelsPerMeter = 0;
27 bmi.bmiHeader.biYPelsPerMeter = 0;
28 bmi.bmiHeader.biClrUsed = 0;
29 bmi.bmiHeader.biClrImportant = 0;
30 *(DWORD *)&bmi.bmiColors[0] = 0x000000;
31 *(DWORD *)&bmi.bmiColors[1] = 0xFFFFFF;
32
33 /* The destination coordinates are relative to the DC origin */
34 TEST(NtGdiSetDIBitsToDeviceInternal(hDC, 2, 3, 8, 8, 0, 0, 0, 8,
35 (PVOID)InBits, (BITMAPINFO *)&bmi, DIB_RGB_COLORS,
36 sizeof(InBits), sizeof(bmi), TRUE, NULL));
37
38 /* Now get the data from the screen, and see if it matches */
39 for (y = 0; y < 8; y++)
40 {
41 DWORD Row = 0;
42 for (x = 0; x < 8; x++)
43 Row |= (0x80 & GetPixel(hDC, 2 + x, 3 + y)) >> x;
44 OutBits[y] = Row;
45 }
46 TEST(memcmp(InBits, OutBits, sizeof(InBits)) == 0);
47
48 ReleaseDC(hWnd, hDC);
49 DestroyWindow(hWnd);
50
51 return APISTATUS_NORMAL;
52 }