ReactOS 0.4.15-dev-7906-g1b85a5f
init.c File Reference
#include "precomp.h"
#include "init.h"
Include dependency graph for init.c:

Go to the source code of this file.

Functions

BOOL InitPerBitDepth (_In_ ULONG cBitsPerPixel, _In_ ULONG cx, _In_ ULONG cy, _Out_ HBITMAP *phbmp, _Out_ HDC *phdcDIB, _Out_ HBITMAP *phbmpDIB, _Out_ PVOID *ppvBits)
 
BOOL InitStuff (void)
 

Variables

HBITMAP ghbmp1
 
HBITMAP ghbmp4
 
HBITMAP ghbmp8
 
HBITMAP ghbmp16
 
HBITMAP ghbmp24
 
HBITMAP ghbmp32
 
HBITMAP ghbmpDIB1
 
HBITMAP ghbmpDIB4
 
HBITMAP ghbmpDIB8
 
HBITMAP ghbmpDIB16
 
HBITMAP ghbmpDIB24
 
HBITMAP ghbmpDIB32
 
HDC ghdcDIB1
 
HDC ghdcDIB4
 
HDC ghdcDIB8
 
HDC ghdcDIB16
 
HDC ghdcDIB24
 
HDC ghdcDIB32
 
PVOID gpvDIB1
 
PVOID gpvDIB4
 
PVOID gpvDIB8
 
PVOID gpvDIB16
 
PVOID gpvDIB24
 
PVOID gpvDIB32
 
ULONG(* gpDIB32 )[8][8]
 
HPALETTE ghpal
 
MYPAL gpal
 

Function Documentation

◆ InitPerBitDepth()

BOOL InitPerBitDepth ( _In_ ULONG  cBitsPerPixel,
_In_ ULONG  cx,
_In_ ULONG  cy,
_Out_ HBITMAP phbmp,
_Out_ HDC phdcDIB,
_Out_ HBITMAP phbmpDIB,
_Out_ PVOID ppvBits 
)

Definition at line 29 of file init.c.

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}
#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
#define printf
Definition: freeldr.h:93
_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
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)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
struct tagBITMAPINFO * LPBITMAPINFO

Referenced by InitStuff().

◆ InitStuff()

BOOL InitStuff ( void  )

Definition at line 95 of file init.c.

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}
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
HBITMAP ghbmpDIB4
Definition: init.c:7
HPALETTE WINAPI CreatePalette(_In_reads_(_Inexpressible_(2 *sizeof(WORD)+plpal->palNumEntries *sizeof(PALETTEENTRY))) const LOGPALETTE *)

Referenced by START_TEST().

Variable Documentation

◆ ghbmp1

HBITMAP ghbmp1

Definition at line 6 of file init.c.

Referenced by InitStuff().

◆ ghbmp16

HBITMAP ghbmp16

Definition at line 6 of file init.c.

Referenced by InitStuff().

◆ ghbmp24

HBITMAP ghbmp24

Definition at line 6 of file init.c.

Referenced by InitStuff(), and Test_MaskBlt_1bpp().

◆ ghbmp32

HBITMAP ghbmp32

Definition at line 6 of file init.c.

Referenced by InitStuff().

◆ ghbmp4

HBITMAP ghbmp4

Definition at line 6 of file init.c.

Referenced by InitStuff().

◆ ghbmp8

HBITMAP ghbmp8

Definition at line 6 of file init.c.

Referenced by InitStuff().

◆ ghbmpDIB1

HBITMAP ghbmpDIB1

Definition at line 7 of file init.c.

Referenced by InitStuff().

◆ ghbmpDIB16

HBITMAP ghbmpDIB16

Definition at line 7 of file init.c.

Referenced by InitStuff().

◆ ghbmpDIB24

HBITMAP ghbmpDIB24

Definition at line 7 of file init.c.

Referenced by InitStuff().

◆ ghbmpDIB32

HBITMAP ghbmpDIB32

Definition at line 7 of file init.c.

Referenced by InitStuff().

◆ ghbmpDIB4

HBITMAP ghbmpDIB4

Definition at line 7 of file init.c.

Referenced by InitStuff(), and Test_GetDIBits().

◆ ghbmpDIB8

HBITMAP ghbmpDIB8

Definition at line 7 of file init.c.

Referenced by InitStuff().

◆ ghdcDIB1

HDC ghdcDIB1

Definition at line 8 of file init.c.

Referenced by InitStuff(), and Test_PaintRgn().

◆ ghdcDIB16

HDC ghdcDIB16

Definition at line 8 of file init.c.

Referenced by InitStuff().

◆ ghdcDIB24

HDC ghdcDIB24

Definition at line 8 of file init.c.

Referenced by InitStuff().

◆ ghdcDIB32

◆ ghdcDIB4

HDC ghdcDIB4

Definition at line 8 of file init.c.

Referenced by InitStuff().

◆ ghdcDIB8

HDC ghdcDIB8

Definition at line 8 of file init.c.

Referenced by InitStuff().

◆ ghpal

HPALETTE ghpal

◆ gpal

MYPAL gpal
Initial value:
=
{
0x300, 8,
{
{ 0x10, 0x20, 0x30, PC_NOCOLLAPSE },
{ 0x20, 0x30, 0x40, PC_NOCOLLAPSE },
{ 0x30, 0x40, 0x50, PC_NOCOLLAPSE },
{ 0x40, 0x50, 0x60, PC_NOCOLLAPSE },
{ 0x50, 0x60, 0x70, PC_NOCOLLAPSE },
{ 0x60, 0x70, 0x80, PC_NOCOLLAPSE },
{ 0x70, 0x80, 0x90, PC_NOCOLLAPSE },
{ 0x80, 0x90, 0xA0, PC_NOCOLLAPSE },
}
}
#define PC_NOCOLLAPSE
Definition: wingdi.h:881

Definition at line 13 of file init.c.

Referenced by InitStuff().

◆ gpDIB32

ULONG(* gpDIB32)[8][8]

◆ gpvDIB1

PVOID gpvDIB1

Definition at line 9 of file init.c.

Referenced by InitStuff(), and Test_PaintRgn().

◆ gpvDIB16

PVOID gpvDIB16

Definition at line 9 of file init.c.

Referenced by InitStuff().

◆ gpvDIB24

PVOID gpvDIB24

Definition at line 9 of file init.c.

Referenced by InitStuff().

◆ gpvDIB32

PVOID gpvDIB32

Definition at line 9 of file init.c.

Referenced by InitStuff().

◆ gpvDIB4

PVOID gpvDIB4

Definition at line 9 of file init.c.

Referenced by InitStuff().

◆ gpvDIB8

PVOID gpvDIB8

Definition at line 9 of file init.c.

Referenced by InitStuff().