ReactOS  0.4.14-dev-554-g2f8d847
GetDIBColorTable.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS api tests
3  * LICENSE: GPL - See COPYING in the top level directory
4  * PURPOSE: Test for ...
5  * PROGRAMMERS: Timo Kreuzer
6  */
7 
8 #include "precomp.h"
9 
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 */
48  pbmi->bmiHeader.biWidth = 2;
49  pbmi->bmiHeader.biHeight = 2;
50  pbmi->bmiHeader.biPlanes = 1;
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 }
102 
104 {
106 }
107 
HGDIOBJ WINAPI GetStockObject(_In_ int)
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1475
DWORD biClrImportant
Definition: amvideo.idl:40
#define DIB_PAL_COLORS
Definition: wingdi.h:365
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO pbmi
Definition: ntgdi.h:2780
LONG biXPelsPerMeter
Definition: amvideo.idl:37
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define ok_long(expression, result)
Definition: atltest.h:133
LONG biYPelsPerMeter
Definition: amvideo.idl:38
HANDLE hbmpOld
Definition: magnifier.c:54
DWORD biCompression
Definition: amvideo.idl:35
smooth NULL
Definition: ftsmooth.c:416
UINT WINAPI SetDIBColorTable(_In_ HDC hdc, _In_ UINT iStart, _In_ UINT cEntries, _In_reads_(cEntries) const RGBQUAD *prgbq)
UINT WINAPI GetDIBColorTable(HDC hDC, UINT iStartIndex, UINT cEntries, RGBQUAD *pColors)
Definition: palette.c:123
void * PVOID
Definition: retypes.h:9
HBITMAP hbmp
void Test_GetDIBColorTable()
DWORD biSizeImage
Definition: amvideo.idl:36
#define SetLastError(x)
Definition: compat.h:417
HDC hdc
Definition: main.c:9
#define ok_err(error)
Definition: atltest.h:124
START_TEST(GetDIBColorTable)
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50
unsigned int ULONG
Definition: retypes.h:1
static HBITMAP
Definition: button.c:44
#define DIB_RGB_COLORS
Definition: wingdi.h:366
BYTE * PBYTE
Definition: pedump.c:66
#define BI_RGB
Definition: precomp.h:34
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)