ReactOS  0.4.13-dev-982-g9853eab
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));
58  pbmi->bmiHeader.biPlanes = 1;
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 TRUE
Definition: types.h:120
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1461
DWORD biClrImportant
Definition: amvideo.idl:40
struct tagBITMAPINFO * LPBITMAPINFO
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO pbmi
Definition: ntgdi.h:2780
LONG biXPelsPerMeter
Definition: amvideo.idl:37
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
LONG biYPelsPerMeter
Definition: amvideo.idl:38
long LONG
Definition: pedump.c:60
DWORD biCompression
Definition: amvideo.idl:35
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
smooth NULL
Definition: ftsmooth.c:416
DWORD biSizeImage
Definition: amvideo.idl:36
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
_Out_opt_ int * cx
Definition: commctrl.h:570
unsigned int ULONG
Definition: retypes.h:1
#define DIB_RGB_COLORS
Definition: wingdi.h:366
#define memset(x, y, z)
Definition: compat.h:39
#define BI_RGB
Definition: precomp.h:34
#define printf
Definition: config.h:203
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)

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) ||
109  !InitPerBitDepth(16, 8, 8, &ghbmp16, &ghdcDIB16, &ghbmpDIB16, &gpvDIB16) ||
110  !InitPerBitDepth(24, 8, 8, &ghbmp24, &ghdcDIB24, &ghbmpDIB24, &gpvDIB24) ||
112  {
113  printf("failed to create objects \n");
114  return FALSE;
115  }
116 
117  gpDIB32 = gpvDIB32;
118 
119  return TRUE;
120 }
HBITMAP ghbmp16
Definition: init.c:6
HBITMAP ghbmp4
Definition: init.c:6
#define TRUE
Definition: types.h:120
HBITMAP ghbmpDIB16
Definition: init.c:7
HPALETTE ghpal
Definition: init.c:11
HBITMAP ghbmp1
Definition: init.c:6
PVOID gpvDIB4
Definition: init.c:9
HBITMAP ghbmp8
Definition: init.c:6
ULONG(* gpDIB32)[8][8]
Definition: init.c:10
HDC ghdcDIB1
Definition: init.c:8
HBITMAP ghbmp32
Definition: init.c:6
HBITMAP ghbmpDIB4
Definition: init.c:7
HBITMAP ghbmpDIB8
Definition: init.c:7
PVOID gpvDIB32
Definition: init.c:9
HBITMAP ghbmpDIB1
Definition: init.c:7
MYPAL gpal
Definition: init.c:13
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
HPALETTE WINAPI CreatePalette(_In_reads_(_Inexpressible_(2 *sizeof(WORD)+plpal->palNumEntries *sizeof(PALETTEENTRY))) const LOGPALETTE *)
PVOID gpvDIB24
Definition: init.c:9
PVOID gpvDIB16
Definition: init.c:9
PVOID gpvDIB1
Definition: init.c:9
HDC ghdcDIB16
Definition: init.c:8
HBITMAP ghbmpDIB32
Definition: init.c:7
PVOID gpvDIB8
Definition: init.c:9
HDC ghdcDIB24
Definition: init.c:8
HDC ghdcDIB8
Definition: init.c:8
HDC ghdcDIB4
Definition: init.c:8
HDC ghdcDIB32
Definition: init.c:8
HBITMAP ghbmp24
Definition: init.c:6
HBITMAP ghbmpDIB24
Definition: init.c:7
#define printf
Definition: config.h:203

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:880

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().