ReactOS 0.4.15-dev-5672-gf73ac17
NtGdiSelectBitmap.c File Reference
#include <win32nt.h>
Include dependency graph for NtGdiSelectBitmap.c:

Go to the source code of this file.

Functions

void Test_SelectDIBSection (void)
 
 START_TEST (NtGdiSelectBitmap)
 

Function Documentation

◆ START_TEST()

START_TEST ( NtGdiSelectBitmap  )

Definition at line 46 of file NtGdiSelectBitmap.c.

47{
48 HDC hDC;
49 HBITMAP hBmp, hOldBmp;
50 HPALETTE hOldPalette, hPalette;
51 LOGPALETTE logpal = {0x300, 1, {{12,13,14,15}}};
52
53 hBmp = CreateBitmap(2,2,1,1,NULL);
54 ASSERT(hBmp);
55
56 /* We cannot select a bitmap into a display DC */
57 hDC = GetDC(NULL);
58 ASSERT(hDC);
59 hOldBmp = NtGdiSelectBitmap(hDC, hBmp);
60 TEST(hOldBmp == NULL);
61
63 ASSERT(hDC);
64
65 /* Check the palette before we mess it up*/
66 hPalette = CreatePalette(&logpal);
67 hOldPalette = SelectPalette(hDC, hPalette, 0);
68 TEST(hOldPalette == GetStockObject(DEFAULT_PALETTE));
69
70 /* Test NULL DC */
72 hOldBmp = NtGdiSelectBitmap(NULL, hBmp);
73 TEST(hOldBmp == NULL);
75
76 /* Test invalid DC */
78 hOldBmp = NtGdiSelectBitmap((HDC)((ULONG_PTR)hDC & 0x0000ffff), hBmp);
79 TEST(hOldBmp == NULL);
81
82 /* Test NULL bitmap */
84 hOldBmp = NtGdiSelectBitmap(hDC, NULL);
85 TEST(hOldBmp == NULL);
87
88 /* Test bitmap with only index */
90 hOldBmp = NtGdiSelectBitmap(hDC, (HBITMAP)((ULONG_PTR)hBmp & 0x0000ffff));
91 TEST(hOldBmp == NULL);
93
94 /* Test valid bitmap */
96 hOldBmp = NtGdiSelectBitmap(hDC, hBmp);
97 TEST(hOldBmp != NULL);
98 /* The default bitmap should be GetStockObject(21) */
99 TEST(hOldBmp == GetStockObject(21));
100
101 /* Check the palette */
102 hOldPalette = SelectPalette(hDC, hOldPalette, 0);
103 TEST(hOldPalette == hPalette);
104 DeleteObject(hPalette);
105
106 /* Select the old one again and check */
107 hOldBmp = NtGdiSelectBitmap(hDC, hOldBmp);
108 TEST(hOldBmp == hBmp);
110
111 /* cleanup */
112 DeleteObject(hBmp);
113 DeleteDC(hDC);
114
116
117}
static HDC hDC
Definition: 3dtext.c:33
void Test_SelectDIBSection(void)
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define SetLastError(x)
Definition: compat.h:752
pKey DeleteObject()
#define ASSERT(a)
Definition: mode.c:44
#define TEST(x)
Definition: precomp.h:20
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
__kernel_entry W32KAPI HBITMAP APIENTRY NtGdiSelectBitmap(_In_ HDC hdc, _In_ HBITMAP hbm)
uint32_t ULONG_PTR
Definition: typedefs.h:65
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
HGDIOBJ WINAPI GetStockObject(_In_ int)
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
#define DEFAULT_PALETTE
Definition: wingdi.h:913
HPALETTE WINAPI CreatePalette(_In_reads_(_Inexpressible_(2 *sizeof(WORD)+plpal->palNumEntries *sizeof(PALETTEENTRY))) const LOGPALETTE *)
HPALETTE WINAPI SelectPalette(_In_ HDC, _In_ HPALETTE, _In_ BOOL)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI DeleteDC(_In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

◆ Test_SelectDIBSection()

void Test_SelectDIBSection ( void  )

Definition at line 11 of file NtGdiSelectBitmap.c.

12{
13 HDC hdc;
15 struct
16 {
17 BITMAPINFOHEADER bmiHeader;
18 RGBQUAD bmiColors[100];
19 } bmi;
21 PVOID pvBits;
22
24 ASSERT(hdc);
25
26 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
27 bmi.bmiHeader.biWidth = 2;
28 bmi.bmiHeader.biHeight = 2;
29 bmi.bmiHeader.biPlanes = 1;
30 bmi.bmiHeader.biBitCount = 1;
31 bmi.bmiHeader.biCompression = BI_RGB;
32 bmi.bmiHeader.biSizeImage = 0;
33 bmi.bmiHeader.biXPelsPerMeter = 100;
34 bmi.bmiHeader.biYPelsPerMeter = 100;
35 bmi.bmiHeader.biClrUsed = 2;
36 bmi.bmiHeader.biClrImportant = 2;
37
39 ASSERT(hbmp);
40
42
43}
HBITMAP hbmp
#define BI_RGB
Definition: precomp.h:47
ULONG RGBQUAD
Definition: precomp.h:50
HDC hdc
Definition: main.c:9
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO pbmi
Definition: ntgdi.h:2780
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:199
#define DIB_PAL_COLORS
Definition: wingdi.h:366
struct tagBITMAPINFO * PBITMAPINFO

Referenced by START_TEST().