ReactOS 0.4.16-dev-329-g9223134
GetDIBColorTable.c File Reference
#include "precomp.h"
Include dependency graph for GetDIBColorTable.c:

Go to the source code of this file.

Functions

void Test_GetDIBColorTable ()
 
 START_TEST (GetDIBColorTable)
 

Function Documentation

◆ START_TEST()

START_TEST ( GetDIBColorTable  )

Definition at line 103 of file GetDIBColorTable.c.

104{
106}
void Test_GetDIBColorTable()

◆ Test_GetDIBColorTable()

void Test_GetDIBColorTable ( )

Definition at line 10 of file GetDIBColorTable.c.

11{
12 struct
13 {
14 BITMAPINFOHEADER bmiHeader;
15 ULONG bmiColors[8];
16 } bmibuffer;
17 BITMAPINFO *pbmi = (PVOID)&bmibuffer;
19 HDC hdc;
20 PBYTE pjBits;
21 UINT cColors;
22 ULONG aulColors[257];
23
25 ok(hdc != 0, "failed\n");
26
27 SetLastError(0);
28 cColors = GetDIBColorTable(hdc, 0, 257, (RGBQUAD*)aulColors);
29 ok_long(cColors, 2);
30 ok_err(0);
31 ok_long(aulColors[0], 0x000000);
32 ok_long(aulColors[1], 0xffffff);
33
34 hbmp = CreateBitmap(1, 1, 1, 1, NULL);
35 ok(hbmp != 0, "\n");
37 ok(hbmpOld != 0, "Failed to select bitmap\n");
38 cColors = GetDIBColorTable(hdc, 0, 257, (RGBQUAD*)aulColors);
39 ok_long(cColors, 2);
40 ok_err(0);
41 ok_long(aulColors[0], 0x000000);
42 ok_long(aulColors[1], 0xffffff);
45
46 /* Initialize a BITMAPINFO */
58 bmibuffer.bmiColors[0] = 0xff0000;
59 bmibuffer.bmiColors[1] = 0x00ff00;
60 bmibuffer.bmiColors[2] = 0x0000ff;
61
62 hbmp = CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, (PVOID*)&pjBits, 0, 0 );
63 ok( hbmp != NULL, "error=%ld\n", GetLastError() );
65
66 cColors = GetDIBColorTable(hdc, 0, 257, (RGBQUAD*)aulColors);
67 ok_long(cColors, 256);
68 ok_long(aulColors[0], 0xff0000);
69 ok_long(aulColors[1], 0x00ff00);
70 ok_long(aulColors[2], 0x0000ff);
71 ok_long(aulColors[3], 0x000000);
72
73
74 cColors = SetDIBColorTable(hdc, 0, 4, (RGBQUAD*)aulColors);
75 ok_long(cColors, 4);
76
77 aulColors[3] = 0x000F0F;
78 cColors = SetDIBColorTable(hdc, 0, 4, (RGBQUAD*)aulColors);
79 ok_long(cColors, 4);
80
81 cColors = GetDIBColorTable(hdc, 0, 257, (RGBQUAD*)aulColors);
82 ok_long(cColors, 256);
83 ok_long(aulColors[0], 0xff0000);
84 ok_long(aulColors[1], 0x00ff00);
85 ok_long(aulColors[2], 0x0000ff);
86 ok_long(aulColors[3], 0x000F0F);
87
88
91
92 bmibuffer.bmiColors[0] = 1;
93 bmibuffer.bmiColors[1] = 2;
94 bmibuffer.bmiColors[2] = 3;
95
96 hbmp = CreateDIBSection(hdc, pbmi, DIB_PAL_COLORS, (PVOID*)&pjBits, 0, 0 );
97 ok( hbmp != NULL, "error=%ld\n", GetLastError() );
99
100
101}
#define ok_long(expression, result)
Definition: atltest.h:133
#define ok(value,...)
Definition: atltest.h:57
#define ok_err(error)
Definition: atltest.h:124
HBITMAP hbmp
#define NULL
Definition: types.h:112
#define SetLastError(x)
Definition: compat.h:752
#define BI_RGB
Definition: precomp.h:56
ULONG RGBQUAD
Definition: precomp.h:59
pKey DeleteObject()
HANDLE hbmpOld
Definition: magnifier.c:54
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
unsigned int UINT
Definition: ndis.h:50
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO pbmi
Definition: ntgdi.h:2780
BYTE * PBYTE
Definition: pedump.c:66
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
void * PVOID
Definition: typedefs.h:50
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
UINT WINAPI GetDIBColorTable(HDC hDC, UINT iStartIndex, UINT cEntries, RGBQUAD *pColors)
Definition: palette.c:123
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define DIB_RGB_COLORS
Definition: wingdi.h:367
HGDIOBJ WINAPI GetStockObject(_In_ int)
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:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define DIB_PAL_COLORS
Definition: wingdi.h:366
UINT WINAPI SetDIBColorTable(_In_ HDC hdc, _In_ UINT iStart, _In_ UINT cEntries, _In_reads_(cEntries) const RGBQUAD *prgbq)

Referenced by START_TEST().