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