ReactOS  0.4.15-dev-449-g64abd9f
palette.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "mmsystem.h"
#include "wine/test.h"
Include dependency graph for palette.c:

Go to the source code of this file.

Functions

static void test_DIB_PAL_COLORS (void)
 
static void test_palette_entries (void)
 
static void test_halftone_palette (void)
 
static void check_system_palette_entries (HDC hdc)
 
static void test_system_palette_entries (void)
 
 START_TEST (palette)
 

Variables

static const PALETTEENTRY logpalettedata [8]
 

Function Documentation

◆ check_system_palette_entries()

static void check_system_palette_entries ( HDC  hdc)
static

Definition at line 194 of file palette.c.

195 {
196  PALETTEENTRY entries[256];
197  PALETTEENTRY defpal[20];
198  int i, count;
199 
200  memset( defpal, 0xaa, sizeof(defpal) );
202  ok( count == 20, "wrong size %u\n", count );
203 
204  memset( entries, 0x55, sizeof(entries) );
205  count = GetSystemPaletteEntries( hdc, 0, 256, entries );
206  ok( count == 0, "wrong size %u\n", count);
207  for (i = 0; i < 10; i++)
208  {
209  ok( entries[i].peRed == defpal[i].peRed &&
210  entries[i].peGreen == defpal[i].peGreen &&
211  entries[i].peBlue == defpal[i].peBlue &&
212  !entries[i].peFlags,
213  "%u: wrong color %02x,%02x,%02x,%02x instead of %02x,%02x,%02x\n", i,
214  entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags,
215  defpal[i].peRed, defpal[i].peGreen, defpal[i].peBlue );
216  }
217  for (i = 10; i < 246; ++i)
218  {
219  ok( !entries[i].peRed &&
220  !entries[i].peGreen &&
221  !entries[i].peBlue &&
222  !entries[i].peFlags,
223  "%u: wrong color %02x,%02x,%02x,%02x instead of 0,0,0\n", i,
224  entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags);
225  }
226  for (i = 246; i < 256; i++)
227  {
228  int idx = i - 246 + 10;
229  ok( entries[i].peRed == defpal[idx].peRed &&
230  entries[i].peGreen == defpal[idx].peGreen &&
231  entries[i].peBlue == defpal[idx].peBlue &&
232  !entries[i].peFlags,
233  "%u: wrong color %02x,%02x,%02x,%02x instead of %02x,%02x,%02x\n", i,
234  entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags,
235  defpal[idx].peRed, defpal[idx].peGreen, defpal[idx].peBlue );
236  }
237 
238  memset( entries, 0x55, sizeof(entries) );
239  count = GetSystemPaletteEntries( hdc, 0, 10, entries );
240  ok( count == 0, "wrong size %u\n", count);
241  for (i = 0; i < 10; i++)
242  {
243  ok( entries[i].peRed == defpal[i].peRed &&
244  entries[i].peGreen == defpal[i].peGreen &&
245  entries[i].peBlue == defpal[i].peBlue &&
246  !entries[i].peFlags,
247  "%u: wrong color %02x,%02x,%02x,%02x instead of %02x,%02x,%02x\n", i,
248  entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags,
249  defpal[i].peRed, defpal[i].peGreen, defpal[i].peBlue );
250  }
251 
252  memset( entries, 0x55, sizeof(entries) );
253  count = GetSystemPaletteEntries( hdc, 10, 246, entries );
254  ok( count == 0, "wrong size %u\n", count);
255  for (i = 0; i < 236; ++i)
256  {
257  ok( !entries[i].peRed &&
258  !entries[i].peGreen &&
259  !entries[i].peBlue &&
260  !entries[i].peFlags,
261  "%u: wrong color %02x,%02x,%02x,%02x instead of 0,0,0\n", i,
262  entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags);
263  }
264  for (i = 236; i < 246; i++)
265  {
266  int idx = i - 236 + 10;
267  ok( entries[i].peRed == defpal[idx].peRed &&
268  entries[i].peGreen == defpal[idx].peGreen &&
269  entries[i].peBlue == defpal[idx].peBlue &&
270  !entries[i].peFlags,
271  "%u: wrong color %02x,%02x,%02x,%02x instead of %02x,%02x,%02x\n", i,
272  entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags,
273  defpal[idx].peRed, defpal[idx].peGreen, defpal[idx].peBlue );
274  }
275 
276  memset( entries, 0x55, sizeof(entries) );
277  count = GetSystemPaletteEntries( hdc, 246, 10, entries );
278  ok( count == 0, "wrong size %u\n", count);
279  for (i = 0; i < 10; i++)
280  {
281  int idx = i + 10;
282  ok( entries[i].peRed == defpal[idx].peRed &&
283  entries[i].peGreen == defpal[idx].peGreen &&
284  entries[i].peBlue == defpal[idx].peBlue &&
285  !entries[i].peFlags,
286  "%u: wrong color %02x,%02x,%02x,%02x instead of %02x,%02x,%02x\n", i,
287  entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags,
288  defpal[idx].peRed, defpal[idx].peGreen, defpal[idx].peBlue );
289  }
290 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
UINT WINAPI GetPaletteEntries(HPALETTE hpal, UINT iStartIndex, UINT cEntries, LPPALETTEENTRY ppe)
Definition: palette.c:64
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int idx
Definition: utils.c:41
#define DEFAULT_PALETTE
Definition: wingdi.h:912
UINT WINAPI GetSystemPaletteEntries(HDC hDC, UINT iStartIndex, UINT cEntries, LPPALETTEENTRY ppe)
Definition: palette.c:84
HDC hdc
Definition: main.c:9
#define ok(value,...)
Definition: atltest.h:57
#define memset(x, y, z)
Definition: compat.h:39

Referenced by test_system_palette_entries().

◆ START_TEST()

START_TEST ( palette  )

Definition at line 319 of file palette.c.

320 {
325 }
static void test_halftone_palette(void)
Definition: palette.c:147
static void test_palette_entries(void)
Definition: palette.c:122
static void test_DIB_PAL_COLORS(void)
Definition: palette.c:42
static void test_system_palette_entries(void)
Definition: palette.c:292

◆ test_DIB_PAL_COLORS()

static void test_DIB_PAL_COLORS ( void  )
static

Definition at line 42 of file palette.c.

42  {
43  HDC hdc = GetDC( NULL );
44  HDC memhdc = CreateCompatibleDC( hdc );
46  char bmpbuf[sizeof(BITMAPINFO) + 10 * sizeof(WORD)];
47  PBITMAPINFO bmp = (PBITMAPINFO)bmpbuf;
48  WORD * bmpPalPtr;
49  char logpalettebuf[sizeof(LOGPALETTE) + sizeof(logpalettedata)];
50  PLOGPALETTE logpalette = (PLOGPALETTE)logpalettebuf;
51  HPALETTE hpal, hpalOld;
52  COLORREF setColor, chkColor, getColor;
53  int i;
54 
55  /* Initialize the logical palette with a few colours */
56  logpalette->palVersion = 0x300;
58  memcpy( logpalette->palPalEntry, logpalettedata, sizeof(logpalettedata) );
59  hpal = CreatePalette( logpalette );
60  hpalOld = SelectPalette( memhdc, hpal, FALSE );
61  ok( hpalOld != NULL, "error=%d\n", GetLastError() );
62 
63  /* Create a DIB BMP which references colours in the logical palette */
64  memset( bmp, 0x00, sizeof(BITMAPINFO) );
65  bmp->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
66  bmp->bmiHeader.biWidth = 1;
67  bmp->bmiHeader.biHeight = 1;
68  bmp->bmiHeader.biPlanes = 1;
69  bmp->bmiHeader.biBitCount = 8;
70  bmp->bmiHeader.biCompression = BI_RGB;
71  bmp->bmiHeader.biClrUsed = 10;
72  bmp->bmiHeader.biClrImportant = 0;
73  bmpPalPtr = (WORD *)&bmp->bmiColors;
74  for( i = 0; i < 8; i++ ) {
75  *bmpPalPtr++ = i;
76  }
77  *bmpPalPtr++ = 8; /* Pointer to logical palette index just outside range */
78  *bmpPalPtr++ = 19; /* Pointer to bad logical palette index */
79 
80  hbmp = CreateDIBSection( memhdc, bmp, DIB_PAL_COLORS, 0, 0, 0 );
81  ok( hbmp != NULL, "error=%d\n", GetLastError() );
82  hbmpOld = SelectObject( memhdc, hbmp );
83  ok( hbmpOld != NULL, "error=%d\n", GetLastError() );
84 
85  /* Test with a RGB to DIB_PAL_COLORS */
86  setColor = RGB( logpalettedata[1].peRed, logpalettedata[1].peGreen, logpalettedata[1].peBlue );
87  SetPixel( memhdc, 0, 0, setColor );
88  chkColor = RGB( logpalettedata[1].peRed, logpalettedata[1].peGreen, logpalettedata[1].peBlue );
89  getColor = GetPixel( memhdc, 0, 0 );
90  ok( getColor == chkColor, "getColor=%08X\n", (UINT)getColor );
91 
92  /* Test with a valid DIBINDEX to DIB_PAL_COLORS */
93  setColor = DIBINDEX( 2 );
94  SetPixel( memhdc, 0, 0, setColor );
95  chkColor = RGB( logpalettedata[2].peRed, logpalettedata[2].peGreen, logpalettedata[2].peBlue );
96  getColor = GetPixel( memhdc, 0, 0 );
97  ok( getColor == chkColor, "getColor=%08X\n", (UINT)getColor );
98 
99  /* Test with an invalid DIBINDEX to DIB_PAL_COLORS */
100  setColor = DIBINDEX( 12 );
101  SetPixel( memhdc, 0, 0, setColor );
102  chkColor = RGB( 0, 0, 0 );
103  getColor = GetPixel( memhdc, 0, 0 );
104  ok( getColor == chkColor, "getColor=%08X\n", (UINT)getColor );
105 
106  /* Test for double wraparound on logical palette references from */
107  /* DIBINDEX by DIB_PAL_COLORS. */
108  setColor = DIBINDEX( 9 );
109  SetPixel( memhdc, 0, 0, setColor );
110  chkColor = RGB( logpalettedata[3].peRed, logpalettedata[3].peGreen, logpalettedata[3].peBlue );
111  getColor = GetPixel( memhdc, 0, 0 );
112  ok( getColor == chkColor, "getColor=%08X\n", (UINT)getColor );
113 
114  SelectPalette( memhdc, hpalOld, FALSE );
115  DeleteObject( hpal );
116  SelectObject( memhdc, hbmpOld );
117  DeleteObject( hbmp );
118  DeleteDC( memhdc );
119  ReleaseDC( NULL, hdc );
120 }
static const LOGPALETTE logpalette
Definition: clipboard.c:1346
FORCEINLINE VOID SetPixel(_In_ ULONG Left, _In_ ULONG Top, _In_ UCHAR Color)
Definition: arm.h:50
#define RGB(r, g, b)
Definition: precomp.h:62
#define DIB_PAL_COLORS
Definition: wingdi.h:365
HPALETTE WINAPI CreatePalette(CONST LOGPALETTE *plpal)
Definition: palette.c:54
HDC WINAPI GetDC(_In_opt_ HWND)
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)
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
WORD palVersion
Definition: wingdi.h:1832
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HANDLE hbmpOld
Definition: magnifier.c:54
#define DIBINDEX(n)
Definition: mmsystem.h:932
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HPALETTE WINAPI SelectPalette(_In_ HDC, _In_ HPALETTE, _In_ BOOL)
smooth NULL
Definition: ftsmooth.c:416
HBITMAP hbmp
struct tagLOGPALETTE * PLOGPALETTE
DWORD COLORREF
Definition: windef.h:300
unsigned short WORD
Definition: ntddk_ex.h:93
BITMAP bmp
Definition: alphablend.c:62
HDC hdc
Definition: main.c:9
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const PALETTEENTRY logpalettedata[8]
Definition: palette.c:31
BOOL WINAPI DeleteDC(_In_ HDC)
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
struct tagLOGPALETTE LOGPALETTE
unsigned int UINT
Definition: ndis.h:50
struct tagBITMAPINFO * PBITMAPINFO
WORD palNumEntries
Definition: wingdi.h:1833
static HBITMAP
Definition: button.c:44
#define memset(x, y, z)
Definition: compat.h:39
#define BI_RGB
Definition: precomp.h:47
struct tagBITMAPINFO BITMAPINFO

Referenced by START_TEST().

◆ test_halftone_palette()

static void test_halftone_palette ( void  )
static

Definition at line 147 of file palette.c.

148 {
149  HDC hdc;
150  HPALETTE pal;
151  PALETTEENTRY entries[256];
152  PALETTEENTRY defpal[20];
153  int i, count;
154 
155  hdc = GetDC(0);
156 
158  ok( count == 20, "wrong size %u\n", count );
159 
160  pal = CreateHalftonePalette( hdc );
161  count = GetPaletteEntries( pal, 0, 256, entries );
162  ok( count == 256 || broken(count <= 20), /* nt 4 */
163  "wrong size %u\n", count );
164 
165  /* first and last 8 match the default palette */
166  if (count >= 20)
167  {
168  for (i = 0; i < 8; i++)
169  {
170  ok( entries[i].peRed == defpal[i].peRed &&
171  entries[i].peGreen == defpal[i].peGreen &&
172  entries[i].peBlue == defpal[i].peBlue &&
173  !entries[i].peFlags,
174  "%u: wrong color %02x,%02x,%02x,%02x instead of %02x,%02x,%02x\n", i,
175  entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags,
176  defpal[i].peRed, defpal[i].peGreen, defpal[i].peBlue );
177  }
178  for (i = count - 8; i < count; i++)
179  {
180  int idx = i - count + 20;
181  ok( entries[i].peRed == defpal[idx].peRed &&
182  entries[i].peGreen == defpal[idx].peGreen &&
183  entries[i].peBlue == defpal[idx].peBlue &&
184  !entries[i].peFlags,
185  "%u: wrong color %02x,%02x,%02x,%02x instead of %02x,%02x,%02x\n", i,
186  entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags,
187  defpal[idx].peRed, defpal[idx].peGreen, defpal[idx].peBlue );
188  }
189  }
190  DeleteObject( pal );
191  ReleaseDC( 0, hdc );
192 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
UINT WINAPI GetPaletteEntries(HPALETTE hpal, UINT iStartIndex, UINT cEntries, LPPALETTEENTRY ppe)
Definition: palette.c:64
HDC WINAPI GetDC(_In_opt_ HWND)
GLuint GLuint GLsizei count
Definition: gl.h:1545
static HDC
Definition: imagelist.c:92
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
unsigned int idx
Definition: utils.c:41
#define DEFAULT_PALETTE
Definition: wingdi.h:912
HDC hdc
Definition: main.c:9
#define broken(x)
Definition: _sntprintf.h:21
#define ok(value,...)
Definition: atltest.h:57
HPALETTE WINAPI CreateHalftonePalette(_In_opt_ HDC)

Referenced by START_TEST().

◆ test_palette_entries()

static void test_palette_entries ( void  )
static

Definition at line 122 of file palette.c.

123 {
124  char logpalettebuf[sizeof(LOGPALETTE) + sizeof(logpalettedata)];
125  PLOGPALETTE logpalette = (PLOGPALETTE)logpalettebuf;
126  HPALETTE hpal;
127  UINT res=0;
128  PALETTEENTRY palEntry = { 0x1, 0x2, 0x3, 0xff };
129  PALETTEENTRY getEntryResult;
130 
131  /* Initialize the logical palette with a few colours */
132  logpalette->palVersion = 0x300;
134  memcpy( logpalette->palPalEntry, logpalettedata, sizeof(logpalettedata) );
135  hpal = CreatePalette( logpalette );
136 
137  /* Set a new entry with peFlags to 0xff */
138  SetPaletteEntries(hpal, 0, 1, &palEntry);
139 
140  /* Retrieve the entry to see if GDI32 performs any filtering on peFlags */
141  res = GetPaletteEntries(hpal, 0, 1, &getEntryResult);
142  ok(res == 1, "GetPaletteEntries should have returned 1 but returned %d\n", res);
143 
144  ok( palEntry.peFlags == getEntryResult.peFlags, "palEntry.peFlags (%#x) != getEntryResult.peFlags (%#x)\n", palEntry.peFlags, getEntryResult.peFlags );
145 }
static const LOGPALETTE logpalette
Definition: clipboard.c:1346
UINT WINAPI GetPaletteEntries(HPALETTE hpal, UINT iStartIndex, UINT cEntries, LPPALETTEENTRY ppe)
Definition: palette.c:64
HPALETTE WINAPI CreatePalette(CONST LOGPALETTE *plpal)
Definition: palette.c:54
UINT WINAPI SetPaletteEntries(HPALETTE hpal, UINT iStartIndex, UINT cEntries, const PALETTEENTRY *ppe)
Definition: palette.c:74
WORD palVersion
Definition: wingdi.h:1832
struct tagLOGPALETTE * PLOGPALETTE
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const PALETTEENTRY logpalettedata[8]
Definition: palette.c:31
#define ok(value,...)
Definition: atltest.h:57
struct tagLOGPALETTE LOGPALETTE
unsigned int UINT
Definition: ndis.h:50
GLuint res
Definition: glext.h:9613
WORD palNumEntries
Definition: wingdi.h:1833

Referenced by START_TEST().

◆ test_system_palette_entries()

static void test_system_palette_entries ( void  )
static

Definition at line 292 of file palette.c.

293 {
294  HDC hdc;
295  HDC metafile_dc;
296  HMETAFILE metafile;
297 
298  hdc = GetDC(0);
299 
300  if (!(GetDeviceCaps( hdc, RASTERCAPS ) & RC_PALETTE))
301  {
303  }
304  else
305  {
306  skip( "device is palette-based, skipping test\n" );
307  }
308 
309  ReleaseDC( 0, hdc );
310 
311  metafile_dc = CreateMetaFileA(NULL);
312 
313  check_system_palette_entries(metafile_dc);
314 
315  metafile = CloseMetaFile(metafile_dc);
317 }
HDC WINAPI GetDC(_In_opt_ HWND)
HDC WINAPI CreateMetaFileA(_In_opt_ LPCSTR)
static HDC
Definition: imagelist.c:92
#define RASTERCAPS
Definition: wingdi.h:744
static const unsigned char metafile[]
Definition: olepicture.c:138
static void check_system_palette_entries(HDC hdc)
Definition: palette.c:194
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
HMETAFILE WINAPI CloseMetaFile(_In_ HDC hdc)
#define RC_PALETTE
Definition: wingdi.h:789
HDC hdc
Definition: main.c:9
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define skip(...)
Definition: atltest.h:64
BOOL WINAPI DeleteMetaFile(_In_ HMETAFILE)

Referenced by START_TEST().

Variable Documentation

◆ logpalettedata

const PALETTEENTRY logpalettedata[8]
static
Initial value:
= {
{ 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 31 of file palette.c.

Referenced by test_DIB_PAL_COLORS(), and test_palette_entries().