ReactOS 0.4.15-dev-8145-ga541a46
init.c
Go to the documentation of this file.
1
2#include "precomp.h"
3
4#include "init.h"
5
10ULONG (*gpDIB32)[8][8];
11HPALETTE ghpal;
12
14{
15 0x300, 8,
16 {
17 { 0x10, 0x20, 0x30, PC_NOCOLLAPSE },
18 { 0x20, 0x30, 0x40, PC_NOCOLLAPSE },
19 { 0x30, 0x40, 0x50, PC_NOCOLLAPSE },
20 { 0x40, 0x50, 0x60, PC_NOCOLLAPSE },
21 { 0x50, 0x60, 0x70, PC_NOCOLLAPSE },
22 { 0x60, 0x70, 0x80, PC_NOCOLLAPSE },
23 { 0x70, 0x80, 0x90, PC_NOCOLLAPSE },
24 { 0x80, 0x90, 0xA0, PC_NOCOLLAPSE },
25 }
26};
27
28BOOL
30 _In_ ULONG cBitsPerPixel,
33 _Out_ HBITMAP *phbmp,
34 _Out_ HDC *phdcDIB,
35 _Out_ HBITMAP *phbmpDIB,
36 _Out_ PVOID *ppvBits)
37{
38 struct
39 {
40 BITMAPINFOHEADER bmiHeader;
41 ULONG bmiColors[256];
42 } bmiBuffer;
43 LPBITMAPINFO pbmi = (LPBITMAPINFO)&bmiBuffer;
44
45 /* Create a bitmap */
46 *phbmp = CreateBitmap(cx, cy, 1, cBitsPerPixel, NULL);
47 if (*phbmp == NULL)
48 {
49 printf("CreateBitmap failed %lu\n", cBitsPerPixel);
50 return FALSE;
51 }
52
53 /* Setup bitmap info */
54 memset(&bmiBuffer, 0, sizeof(bmiBuffer));
59 pbmi->bmiHeader.biBitCount = cBitsPerPixel;
66
67 if (cBitsPerPixel == 1)
68 {
69 bmiBuffer.bmiColors[0] = 0;
70 bmiBuffer.bmiColors[1] = 0xFFFFFF;
72 }
73
74 /* Create a compatible DC for the DIB */
75 *phdcDIB = CreateCompatibleDC(0);
76 if (*phdcDIB == NULL)
77 {
78 printf("CreateCompatibleDC failed %lu\n", cBitsPerPixel);
79 return FALSE;
80 }
81
82 /* Create the DIB section with the same values */
83 *phbmpDIB = CreateDIBSection(*phdcDIB, pbmi, DIB_RGB_COLORS, ppvBits, 0, 0 );
84 if (*phbmpDIB == NULL)
85 {
86 printf("CreateDIBSection failed. %lu\n", cBitsPerPixel);
87 return FALSE;
88 }
89
90 SelectObject(*phdcDIB, *phbmpDIB);
91
92 return TRUE;
93}
94
96{
97
98 /* Initialize a logical palette */
100 if (!ghpal)
101 {
102 printf("failed to create a palette\n");
103 return FALSE;
104 }
105
106 if (!InitPerBitDepth(1, 9, 9, &ghbmp1, &ghdcDIB1, &ghbmpDIB1, &gpvDIB1) ||
107 !InitPerBitDepth(4, 5, 5, &ghbmp4, &ghdcDIB4, &ghbmpDIB4, &gpvDIB4) ||
108 !InitPerBitDepth(8, 5, 5, &ghbmp8, &ghdcDIB8, &ghbmpDIB8, &gpvDIB8) ||
112 {
113 printf("failed to create objects\n");
114 return FALSE;
115 }
116
118
119 return TRUE;
120}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define BI_RGB
Definition: precomp.h:56
unsigned int BOOL
Definition: ntddk_ex.h:94
#define printf
Definition: freeldr.h:97
HBITMAP ghbmp24
Definition: init.c:6
HBITMAP ghbmpDIB8
Definition: init.c:7
HBITMAP ghbmp4
Definition: init.c:6
BOOL InitPerBitDepth(_In_ ULONG cBitsPerPixel, _In_ ULONG cx, _In_ ULONG cy, _Out_ HBITMAP *phbmp, _Out_ HDC *phdcDIB, _Out_ HBITMAP *phbmpDIB, _Out_ PVOID *ppvBits)
Definition: init.c:29
HDC ghdcDIB8
Definition: init.c:8
PVOID gpvDIB8
Definition: init.c:9
HDC ghdcDIB16
Definition: init.c:8
HBITMAP ghbmpDIB24
Definition: init.c:7
ULONG(* gpDIB32)[8][8]
Definition: init.c:10
HBITMAP ghbmpDIB1
Definition: init.c:7
PVOID gpvDIB1
Definition: init.c:9
HDC ghdcDIB32
Definition: init.c:8
HPALETTE ghpal
Definition: init.c:11
HBITMAP ghbmpDIB16
Definition: init.c:7
HBITMAP ghbmp1
Definition: init.c:6
PVOID gpvDIB4
Definition: init.c:9
PVOID gpvDIB32
Definition: init.c:9
PVOID gpvDIB24
Definition: init.c:9
HDC ghdcDIB1
Definition: init.c:8
HBITMAP ghbmpDIB32
Definition: init.c:7
HBITMAP ghbmp8
Definition: init.c:6
MYPAL gpal
Definition: init.c:13
HDC ghdcDIB4
Definition: init.c:8
PVOID gpvDIB16
Definition: init.c:9
HBITMAP ghbmp32
Definition: init.c:6
HDC ghdcDIB24
Definition: init.c:8
HBITMAP ghbmp16
Definition: init.c:6
BOOL InitStuff(void)
Definition: init.c:95
HBITMAP ghbmpDIB4
Definition: init.c:7
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO pbmi
Definition: ntgdi.h:2780
long LONG
Definition: pedump.c:60
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
#define memset(x, y, z)
Definition: compat.h:39
Definition: init.h:13
ULONG biClrImportant
Definition: precomp.h:52
USHORT biBitCount
Definition: precomp.h:46
LONG biYPelsPerMeter
Definition: precomp.h:50
ULONG biCompression
Definition: precomp.h:47
LONG biXPelsPerMeter
Definition: precomp.h:49
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
uint32_t ULONG
Definition: typedefs.h:59
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
#define DIB_RGB_COLORS
Definition: wingdi.h:367
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
HPALETTE WINAPI CreatePalette(_In_reads_(_Inexpressible_(2 *sizeof(WORD)+plpal->palNumEntries *sizeof(PALETTEENTRY))) const LOGPALETTE *)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
struct tagBITMAPINFO * LPBITMAPINFO
#define PC_NOCOLLAPSE
Definition: wingdi.h:881