[NETAPI32]
[reactos.git] / rostests / apitests / gdi32 / init.c
1
2 #include <stdio.h>
3 #include <windef.h>
4 #include <wingdi.h>
5
6 HBITMAP ghbmpDIB32;
7 HDC ghdcDIB32;
8 PULONG pulDIB32Bits;
9 HBITMAP ghbmpDIB4;
10 HDC ghdcDIB4;
11 PULONG pulDIB4Bits;
12 HPALETTE ghpal;
13
14 struct
15 {
16 WORD palVersion;
17 WORD palNumEntries;
18 PALETTEENTRY logpalettedata[8];
19 } gpal =
20 {
21 0x300, 8,
22 {
23 { 0x10, 0x20, 0x30, PC_NOCOLLAPSE },
24 { 0x20, 0x30, 0x40, PC_NOCOLLAPSE },
25 { 0x30, 0x40, 0x50, PC_NOCOLLAPSE },
26 { 0x40, 0x50, 0x60, PC_NOCOLLAPSE },
27 { 0x50, 0x60, 0x70, PC_NOCOLLAPSE },
28 { 0x60, 0x70, 0x80, PC_NOCOLLAPSE },
29 { 0x70, 0x80, 0x90, PC_NOCOLLAPSE },
30 { 0x80, 0x90, 0xA0, PC_NOCOLLAPSE },
31 }
32 };
33
34 BOOL InitStuff(void)
35 {
36 BITMAPINFO bmi32 =
37 {{sizeof(BITMAPINFOHEADER), 4, -4, 1, 32, BI_RGB, 0, 1, 1, 0, 0}};
38 BITMAPINFO bmi4 =
39 {{sizeof(BITMAPINFOHEADER), 4, -4, 1, 4, BI_RGB, 0, 1, 1, 0, 0}};
40
41 ghdcDIB32 = CreateCompatibleDC(0);
42 ghdcDIB4 = CreateCompatibleDC(0);
43
44 ghbmpDIB32 = CreateDIBSection(ghdcDIB32, &bmi32, DIB_PAL_COLORS, (PVOID*)&pulDIB32Bits, 0, 0 );
45 if (!ghbmpDIB32) return FALSE;
46
47 ghbmpDIB4 = CreateDIBSection(ghdcDIB4, &bmi4, DIB_PAL_COLORS, (PVOID*)&pulDIB4Bits, 0, 0 );
48 if (!ghbmpDIB32) return FALSE;
49
50 SelectObject(ghdcDIB32, ghbmpDIB32);
51
52 /* Initialize a logical palette */
53 ghpal = CreatePalette((LOGPALETTE*)&gpal);
54 if (!ghpal)
55 {
56 printf("failed to create a palette \n");
57 return FALSE;
58 }
59
60 return TRUE;
61 }