[W32KNAPI]
[reactos.git] / rostests / apitests / w32knapi / ntgdi / NtGdiBitBlt.c
1
2 INT
3 Test_NtGdiBitBlt(PTESTINFO pti)
4 {
5 BOOL bRet;
6 HDC hdc1, hdc2;
7 HBITMAP hbmp1, hOldBmp1, hbmp2, hOldBmp2;
8 DWORD bytes1[4] = {0x00ff0000, 0x0000ff00, 0x000000ff, 0x00ffffff};
9 DWORD bytes2[4] = {0x00000000, 0x0000000, 0x0000000, 0x00000000};
10
11 /* Test NULL dc */
12 SetLastError(ERROR_SUCCESS);
13 bRet = NtGdiBitBlt((HDC)0, 0, 0, 10, 10, (HDC)0, 10, 10, SRCCOPY, 0, 0);
14 TEST(bRet == FALSE);
15 TEST(GetLastError() == ERROR_SUCCESS);
16
17 /* Test invalid dc */
18 SetLastError(ERROR_SUCCESS);
19 bRet = NtGdiBitBlt((HDC)0x123456, 0, 0, 10, 10, (HDC)0x123456, 10, 10, SRCCOPY, 0, 0);
20 TEST(bRet == FALSE);
21 TEST(GetLastError() == ERROR_SUCCESS);
22
23 hdc1 = NtGdiCreateCompatibleDC(0);
24 TEST(hdc1 != NULL);
25
26 hdc2 = NtGdiCreateCompatibleDC(0);
27 TEST(hdc2 != NULL);
28
29 hbmp1 = NtGdiCreateBitmap(2, 2, 1, 32, (LPBYTE)bytes1 );
30 TEST(hbmp1 != NULL);
31 hOldBmp1 = SelectObject(hdc1, hbmp1);
32
33 TESTX(NtGdiGetPixel(hdc1, 0, 0) == 0x000000ff, "Pixel[0][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 0));
34 TESTX(NtGdiGetPixel(hdc1, 0, 1) == 0x00ff0000, "Pixel[0][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 1));
35 TESTX(NtGdiGetPixel(hdc1, 1, 0) == 0x0000ff00, "Pixel[1][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 0));
36 TESTX(NtGdiGetPixel(hdc1, 1, 1) == 0x00ffffff, "Pixel[1][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 1));
37
38 hbmp2 = NtGdiCreateBitmap(2, 2, 1, 32, (LPBYTE)bytes2 );
39 TEST(hbmp2 != NULL);
40 hOldBmp2 = SelectObject(hdc2, hbmp2);
41
42 bRet = NtGdiBitBlt(hdc2, 1, 1, -2, -2, hdc1, 0, 0, SRCCOPY, 0, 0);
43 TEST(bRet == TRUE);
44 TEST(GetLastError() == ERROR_SUCCESS);
45 TESTX(NtGdiGetPixel(hdc2, 0, 0) == 0x00000000, "Pixel[0][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 0));
46 TESTX(NtGdiGetPixel(hdc2, 0, 1) == 0x00000000, "Pixel[0][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 1));
47 TESTX(NtGdiGetPixel(hdc2, 1, 0) == 0x00000000, "Pixel[1][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 0));
48 TESTX(NtGdiGetPixel(hdc2, 1, 1) == 0x00000000, "Pixel[1][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 1));
49
50 bRet = NtGdiBitBlt(hdc2, 1, 1, -2, -2, hdc1, 1, 1, SRCCOPY, 0, 0);
51 TEST(bRet == TRUE);
52 TEST(GetLastError() == ERROR_SUCCESS);
53 TESTX(NtGdiGetPixel(hdc2, 0, 0) == 0x000000ff, "Pixel[0][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 0));
54 TESTX(NtGdiGetPixel(hdc2, 0, 1) == 0x00000000, "Pixel[0][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 1));
55 TESTX(NtGdiGetPixel(hdc2, 1, 0) == 0x00000000, "Pixel[1][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 0));
56 TESTX(NtGdiGetPixel(hdc2, 1, 1) == 0x00000000, "Pixel[1][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 1));
57
58 NtGdiSetPixel(hdc2, 0, 0, 0x00000000);
59
60 bRet = NtGdiBitBlt(hdc2, 1, 1, -2, -2, hdc1, 0, 0, SRCCOPY, 0, 0);
61 TEST(bRet == TRUE);
62 TEST(GetLastError() == ERROR_SUCCESS);
63 TESTX(NtGdiGetPixel(hdc2, 0, 0) == 0x00000000, "Pixel[0][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 0));
64 TESTX(NtGdiGetPixel(hdc2, 0, 1) == 0x00000000, "Pixel[0][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 1));
65 TESTX(NtGdiGetPixel(hdc2, 1, 0) == 0x00000000, "Pixel[1][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 0));
66 TESTX(NtGdiGetPixel(hdc2, 1, 1) == 0x00000000, "Pixel[1][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 1));
67
68 bRet = NtGdiBitBlt(hdc2, 1, 1, -2, -2, hdc1, 2, 2, SRCCOPY, 0, 0);
69 TEST(bRet == TRUE);
70 TEST(GetLastError() == ERROR_SUCCESS);
71 TESTX(NtGdiGetPixel(hdc2, 0, 0) == 0x00ffffff, "Pixel[0][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 0));
72 TESTX(NtGdiGetPixel(hdc2, 0, 1) == 0x00000000, "Pixel[0][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 1));
73 TESTX(NtGdiGetPixel(hdc2, 1, 0) == 0x00000000, "Pixel[1][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 0));
74 TESTX(NtGdiGetPixel(hdc2, 1, 1) == 0x00000000, "Pixel[1][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 1));
75
76 NtGdiSetPixel(hdc2, 0, 0, 0x00000000);
77
78 bRet = NtGdiBitBlt(hdc2, 2, 2, -2, -2, hdc1, 2, 2, SRCCOPY, 0, 0);
79 TEST(bRet == TRUE);
80 TEST(GetLastError() == ERROR_SUCCESS);
81 TESTX(NtGdiGetPixel(hdc2, 0, 0) == 0x000000ff, "Pixel[0][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 0));
82 TESTX(NtGdiGetPixel(hdc2, 0, 1) == 0x00ff0000, "Pixel[0][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 1));
83 TESTX(NtGdiGetPixel(hdc2, 1, 0) == 0x0000ff00, "Pixel[1][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 0));
84 TESTX(NtGdiGetPixel(hdc2, 1, 1) == 0x00ffffff, "Pixel[1][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 1));
85
86 NtGdiSetPixel(hdc2, 0, 0, 0x00000000);
87 NtGdiSetPixel(hdc2, 1, 0, 0x00000000);
88 NtGdiSetPixel(hdc2, 0, 1, 0x00000000);
89 NtGdiSetPixel(hdc2, 1, 1, 0x00000000);
90
91 bRet = NtGdiBitBlt(hdc2, 0, 0, 2, 2, hdc1, 0, 0, SRCCOPY, 0, 0);
92 TEST(bRet == TRUE);
93 TEST(GetLastError() == ERROR_SUCCESS);
94 TESTX(NtGdiGetPixel(hdc2, 0, 0) == 0x000000ff, "Pixel[0][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 0));
95 TESTX(NtGdiGetPixel(hdc2, 0, 1) == 0x00ff0000, "Pixel[0][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 1));
96 TESTX(NtGdiGetPixel(hdc2, 1, 0) == 0x0000ff00, "Pixel[1][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 0));
97 TESTX(NtGdiGetPixel(hdc2, 1, 1) == 0x00ffffff, "Pixel[1][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 1));
98
99 SelectObject(hdc2, hOldBmp2);
100 SelectObject(hdc1, hOldBmp1);
101
102 DeleteObject(hbmp2);
103 DeleteObject(hbmp1);
104
105 DeleteDC(hdc1);
106 DeleteDC(hdc2);
107
108 return APISTATUS_NORMAL;
109 }