ReactOS 0.4.16-dev-2104-gb84fa49
NtGdiBitBlt.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for NtGdiBitBlt
5 * PROGRAMMERS:
6 */
7
8#include "../win32nt.h"
9
11{
12 BOOL bRet;
13 HDC hdc1, hdc2;
14 HBITMAP hbmp1, hOldBmp1, hbmp2, hOldBmp2;
15 DWORD bytes1[4] = {0x00ff0000, 0x0000ff00, 0x000000ff, 0x00ffffff};
16 DWORD bytes2[4] = {0x00000000, 0x0000000, 0x0000000, 0x00000000};
17
18 /* Test NULL dc */
19 SetLastError(0xDEADBEEF);
20 bRet = NtGdiBitBlt((HDC)0, 0, 0, 10, 10, (HDC)0, 10, 10, SRCCOPY, 0, 0);
21 ok_int(bRet, FALSE);
22 ok_long(GetLastError(), 0xDEADBEEF);
23
24 /* Test invalid dc */
25 SetLastError(0xDEADBEEF);
26 bRet = NtGdiBitBlt((HDC)0x123456, 0, 0, 10, 10, (HDC)0x123456, 10, 10, SRCCOPY, 0, 0);
27 ok_int(bRet, FALSE);
28 ok_long(GetLastError(), 0xDEADBEEF);
29
31 ok(hdc1 != NULL, "hdc1 was NULL.\n");
32
34 ok(hdc2 != NULL, "hdc2 was NULL.\n");
35
36 BITMAPINFO bi = {0};
38 bi.bmiHeader.biWidth = 2;
39 bi.bmiHeader.biHeight = -2; // top-down
40 bi.bmiHeader.biPlanes = 1;
41 bi.bmiHeader.biBitCount = 32;
43 PVOID pvDibBits;
44
45 hbmp1 = CreateDIBSection(hdc1, &bi, DIB_RGB_COLORS, &pvDibBits, NULL, 0);
46 ok(hbmp1 != NULL, "hbmp1 was NULL.\n");
47 memcpy(pvDibBits, bytes1, sizeof(bytes1));
48 hOldBmp1 = SelectObject(hdc1, hbmp1);
49
50 ok_eq_hex(NtGdiGetPixel(hdc1, 0, 0), 0x000000ff);
51 ok_eq_hex(NtGdiGetPixel(hdc1, 0, 1), 0x00ff0000);
52 ok_eq_hex(NtGdiGetPixel(hdc1, 1, 0), 0x0000ff00);
53 ok_eq_hex(NtGdiGetPixel(hdc1, 1, 1), 0x00ffffff);
54
55 hbmp2 = CreateDIBSection(hdc2, &bi, DIB_RGB_COLORS, &pvDibBits, NULL, 0);
56 ok(hbmp2 != NULL, "hbmp2 was NULL.\n");
57 memcpy(pvDibBits, bytes2, sizeof(bytes1));
58 hOldBmp2 = SelectObject(hdc2, hbmp2);
59
60 bRet = NtGdiBitBlt(hdc2, 1, 1, -2, -2, hdc1, 0, 0, SRCCOPY, 0, 0);
61 ok_int(bRet, TRUE);
62 ok_eq_hex(NtGdiGetPixel(hdc2, 0, 0), 0x00000000);
63 ok_eq_hex(NtGdiGetPixel(hdc2, 0, 1), 0x00000000);
64 ok_eq_hex(NtGdiGetPixel(hdc2, 1, 0), 0x00000000);
65 ok_eq_hex(NtGdiGetPixel(hdc2, 1, 1), 0x00000000);
66
67 bRet = NtGdiBitBlt(hdc2, 1, 1, -2, -2, hdc1, 1, 1, SRCCOPY, 0, 0);
68 ok_int(bRet, TRUE);
69 ok_eq_hex(NtGdiGetPixel(hdc2, 0, 0), 0x000000ff);
70 ok_eq_hex(NtGdiGetPixel(hdc2, 0, 1), 0x00000000);
71 ok_eq_hex(NtGdiGetPixel(hdc2, 1, 0), 0x00000000);
72 ok_eq_hex(NtGdiGetPixel(hdc2, 1, 1), 0x00000000);
73
74 NtGdiSetPixel(hdc2, 0, 0, 0x00000000);
75
76 bRet = NtGdiBitBlt(hdc2, 1, 1, -2, -2, hdc1, 0, 0, SRCCOPY, 0, 0);
77 ok_int(bRet, TRUE);
78 ok_eq_hex(NtGdiGetPixel(hdc2, 0, 0), 0x00000000);
79 ok_eq_hex(NtGdiGetPixel(hdc2, 0, 1), 0x00000000);
80 ok_eq_hex(NtGdiGetPixel(hdc2, 1, 0), 0x00000000);
81 ok_eq_hex(NtGdiGetPixel(hdc2, 1, 1), 0x00000000);
82
83 bRet = NtGdiBitBlt(hdc2, 1, 1, -2, -2, hdc1, 2, 2, SRCCOPY, 0, 0);
84 ok_int(bRet, TRUE);
85 ok_eq_hex(NtGdiGetPixel(hdc2, 0, 0), 0x00ffffff);
86 ok_eq_hex(NtGdiGetPixel(hdc2, 0, 1), 0x00000000);
87 ok_eq_hex(NtGdiGetPixel(hdc2, 1, 0), 0x00000000);
88 ok_eq_hex(NtGdiGetPixel(hdc2, 1, 1), 0x00000000);
89
90 NtGdiSetPixel(hdc2, 0, 0, 0x00000000);
91
92 bRet = NtGdiBitBlt(hdc2, 2, 2, -2, -2, hdc1, 2, 2, SRCCOPY, 0, 0);
93 ok_int(bRet, TRUE);
94 ok_eq_hex(NtGdiGetPixel(hdc2, 0, 0), 0x000000ff);
95 ok_eq_hex(NtGdiGetPixel(hdc2, 0, 1), 0x00ff0000);
96 ok_eq_hex(NtGdiGetPixel(hdc2, 1, 0), 0x0000ff00);
97 ok_eq_hex(NtGdiGetPixel(hdc2, 1, 1), 0x00ffffff);
98
99 NtGdiSetPixel(hdc2, 0, 0, 0x00000000);
100 NtGdiSetPixel(hdc2, 1, 0, 0x00000000);
101 NtGdiSetPixel(hdc2, 0, 1, 0x00000000);
102 NtGdiSetPixel(hdc2, 1, 1, 0x00000000);
103
104 bRet = NtGdiBitBlt(hdc2, 0, 0, 2, 2, hdc1, 0, 0, SRCCOPY, 0, 0);
105 ok_int(bRet, TRUE);
106 ok_eq_hex(NtGdiGetPixel(hdc2, 0, 0), 0x000000ff);
107 ok_eq_hex(NtGdiGetPixel(hdc2, 0, 1), 0x00ff0000);
108 ok_eq_hex(NtGdiGetPixel(hdc2, 1, 0), 0x0000ff00);
109 ok_eq_hex(NtGdiGetPixel(hdc2, 1, 1), 0x00ffffff);
110
111 SelectObject(hdc2, hOldBmp2);
112 SelectObject(hdc1, hOldBmp1);
113
114 DeleteObject(hbmp2);
115 DeleteObject(hbmp1);
116
117 DeleteDC(hdc1);
118 DeleteDC(hdc2);
119}
HDC hdc1
Definition: SelectObject.c:10
HDC hdc2
Definition: SelectObject.c:10
#define ok_eq_hex(value, expected)
Definition: apitest.h:134
#define ok_long(expression, result)
Definition: atltest.h:133
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define SetLastError(x)
Definition: compat.h:752
#define BI_RGB
Definition: precomp.h:55
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
__kernel_entry W32KAPI DWORD APIENTRY NtGdiGetPixel(_In_ HDC hdc, _In_ INT x, _In_ INT y)
Definition: bitblt.c:1518
__kernel_entry W32KAPI HDC APIENTRY NtGdiCreateCompatibleDC(_In_opt_ HDC hdc)
__kernel_entry W32KAPI BOOL APIENTRY NtGdiBitBlt(_In_ HDC hdcDst, _In_ INT x, _In_ INT y, _In_ INT cx, _In_ INT cy, _In_opt_ HDC hdcSrc, _In_ INT xSrc, _In_ INT ySrc, _In_ DWORD rop4, _In_ DWORD crBackColor, _In_ FLONG fl)
__kernel_entry W32KAPI COLORREF APIENTRY NtGdiSetPixel(_In_ HDC hdcDst, _In_ INT x, _In_ INT y, _In_ COLORREF crColor)
Definition: bitblt.c:1429
USHORT biBitCount
Definition: precomp.h:45
ULONG biCompression
Definition: precomp.h:46
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1922
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define DIB_RGB_COLORS
Definition: wingdi.h:367
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
#define SRCCOPY
Definition: wingdi.h:333
BOOL WINAPI DeleteDC(_In_ HDC)