ReactOS 0.4.15-dev-8219-ge8b88cf
NtGdiSelectBitmap.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 NtGdiSelectBitmap
5 * PROGRAMMERS:
6 */
7
8#include "../win32nt.h"
9
10void
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}
44
45
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}
118
static HDC hDC
Definition: 3dtext.c:33
void Test_SelectDIBSection(void)
#define START_TEST(x)
Definition: atltest.h:75
HBITMAP hbmp
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define SetLastError(x)
Definition: compat.h:752
#define BI_RGB
Definition: precomp.h:56
ULONG RGBQUAD
Definition: precomp.h:59
pKey DeleteObject()
#define ASSERT(a)
Definition: mode.c:44
#define TEST(x)
Definition: precomp.h:20
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
__kernel_entry W32KAPI HBITMAP APIENTRY NtGdiSelectBitmap(_In_ HDC hdc, _In_ HBITMAP hbm)
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO pbmi
Definition: ntgdi.h:2780
uint32_t ULONG_PTR
Definition: typedefs.h:65
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
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)
#define DIB_PAL_COLORS
Definition: wingdi.h:366
struct tagBITMAPINFO * PBITMAPINFO
BOOL WINAPI DeleteDC(_In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)