ReactOS  r75385
palette.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _PALETTE
 

Macros

#define PALETTE_UnlockPalette(pPalette)   GDIOBJ_vUnlockObject((POBJ)pPalette)
 
#define PALETTE_ShareLockPalette(hpal)   ((PPALETTE)GDIOBJ_ShareLockObj((HGDIOBJ)hpal, GDI_OBJECT_TYPE_PALETTE))
 
#define PALETTE_ShareUnlockPalette(ppal)   GDIOBJ_vDereferenceObject(&ppal->BaseObject)
 

Typedefs

typedef struct _PALETTE PALETTE
 
typedef struct _PALETTEPPALETTE
 

Enumerations

enum  _PALFLAGS {
  PAL_INDEXED = 0x00000001, PAL_BITFIELDS = 0x00000002, PAL_RGB = 0x00000004, PAL_BGR = 0x00000008,
  PAL_CMYK = 0x00000010, PAL_DC = 0x00000100, PAL_FIXED = 0x00000200, PAL_FREE = 0x00000400,
  PAL_MANAGED = 0x00000800, PAL_NOSTATIC = 0x00001000, PAL_MONOCHROME = 0x00002000, PAL_BRUSHHACK = 0x00004000,
  PAL_DIBSECTION = 0x00008000, PAL_NOSTATIC256 = 0x00010000, PAL_HT = 0x00100000, PAL_RGB16_555 = 0x00200000,
  PAL_RGB16_565 = 0x00400000, PAL_GAMMACORRECTION = 0x00800000
}
 

Functions

INIT_FUNCTION NTSTATUS NTAPI InitPaletteImpl (VOID)
 
PPALETTE NTAPI PALETTE_AllocPalette (_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
 
PPALETTE NTAPI PALETTE_AllocPalWithHandle (_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
 
VOID FASTCALL PALETTE_ValidateFlags (PALETTEENTRY *lpPalE, INT size)
 
INT FASTCALL PALETTE_GetObject (PPALETTE pGdiObject, INT cbCount, LPLOGBRUSH lpBuffer)
 
ULONG NTAPI PALETTE_ulGetNearestPaletteIndex (PPALETTE ppal, ULONG iColor)
 
ULONG NTAPI PALETTE_ulGetNearestIndex (PPALETTE ppal, ULONG iColor)
 
ULONG NTAPI PALETTE_ulGetNearestBitFieldsIndex (PPALETTE ppal, ULONG ulColor)
 
VOID NTAPI PALETTE_vGetBitMasks (PPALETTE ppal, PULONG pulColors)
 
VOID NTAPI PALETTE_vCleanup (PVOID ObjectBody)
 
FORCEINLINE ULONG CalculateShift (ULONG ulMask1, ULONG ulMask2)
 
FORCEINLINE ULONG PALETTE_ulGetRGBColorFromIndex (PPALETTE ppal, ULONG ulIndex)
 
FORCEINLINE VOID PALETTE_vSetRGBColorForIndex (PPALETTE ppal, ULONG ulIndex, COLORREF crColor)
 
HPALETTE NTAPI GreCreatePaletteInternal (IN LPLOGPALETTE pLogPal, IN UINT cEntries)
 

Variables

PALETTE gpalRGB
 
PALETTE gpalBGR
 
PALETTE gpalRGB555
 
PALETTE gpalRGB565
 
PALETTEgppalMono
 
PALETTEgppalDefault
 
PPALETTE appalSurfaceDefault []
 

Macro Definition Documentation

Typedef Documentation

Enumeration Type Documentation

Enumerator
PAL_INDEXED 
PAL_BITFIELDS 
PAL_RGB 
PAL_BGR 
PAL_CMYK 
PAL_DC 
PAL_FIXED 
PAL_FREE 
PAL_MANAGED 
PAL_NOSTATIC 
PAL_MONOCHROME 
PAL_BRUSHHACK 
PAL_DIBSECTION 
PAL_NOSTATIC256 
PAL_HT 
PAL_RGB16_555 
PAL_RGB16_565 
PAL_GAMMACORRECTION 

Definition at line 8 of file palette.h.

9 {
10 #ifndef _WINDDI_ // Defined in ddk/winddi.h
11  PAL_INDEXED = 0x00000001, // Indexed palette
12  PAL_BITFIELDS = 0x00000002, // Bit fields used for DIB, DIB section
13  PAL_RGB = 0x00000004, // Red, green, blue
14  PAL_BGR = 0x00000008, // Blue, green, red
15  PAL_CMYK = 0x00000010, // Cyan, magenta, yellow, black
16 #endif
17  PAL_DC = 0x00000100,
18  PAL_FIXED = 0x00000200, // Can't be changed
19  PAL_FREE = 0x00000400,
20  PAL_MANAGED = 0x00000800,
21  PAL_NOSTATIC = 0x00001000,
22  PAL_MONOCHROME = 0x00002000, // Two colors only
23  PAL_BRUSHHACK = 0x00004000,
24  PAL_DIBSECTION = 0x00008000, // Used for a DIB section
25  PAL_NOSTATIC256 = 0x00010000,
26  PAL_HT = 0x00100000, // Halftone palette
27  PAL_RGB16_555 = 0x00200000, // 16-bit RGB in 555 format
28  PAL_RGB16_565 = 0x00400000, // 16-bit RGB in 565 format
29  PAL_GAMMACORRECTION = 0x00800000, // Correct colors
30 };
Definition: palette.h:26
Definition: palette.h:17

Function Documentation

FORCEINLINE ULONG CalculateShift ( ULONG  ulMask1,
ULONG  ulMask2 
)

Definition at line 130 of file palette.h.

Referenced by EXLATEOBJ_vInitialize(), and PALETTE_ulGetNearestBitFieldsIndex().

131 {
132  ULONG ulShift1, ulShift2;
133  BitScanReverse(&ulShift1, ulMask1);
134  BitScanReverse(&ulShift2, ulMask2);
135  ulShift2 -= ulShift1;
136  if ((INT)ulShift2 < 0) ulShift2 += 32;
137  return ulShift2;
138 }
int32_t INT
Definition: typedefs.h:57
#define BitScanReverse
Definition: interlocked.h:6
unsigned int ULONG
Definition: retypes.h:1
HPALETTE NTAPI GreCreatePaletteInternal ( IN LPLOGPALETTE  pLogPal,
IN UINT  cEntries 
)

Systemcall Interface

Definition at line 445 of file palette.c.

448 {
449  HPALETTE hpal = NULL;
450  PPALETTE ppal;
451 
452  pLogPal->palNumEntries = cEntries;
454  cEntries,
455  pLogPal->palPalEntry,
456  0, 0, 0);
457 
458  if (ppal != NULL)
459  {
461 
462  hpal = ppal->BaseObject.hHmgr;
463  PALETTE_UnlockPalette(ppal);
464  }
465 
466  return hpal;
467 }
PALETTEENTRY * IndexedColors
Definition: palette.h:42
VOID FASTCALL PALETTE_ValidateFlags(PALETTEENTRY *lpPalE, INT size)
Definition: palette.c:122
#define PALETTE_UnlockPalette(pPalette)
Definition: palette.h:56
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
smooth NULL
Definition: ftsmooth.c:513
PPALETTE NTAPI PALETTE_AllocPalWithHandle(_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
Definition: palette.c:206
_In_ UINT _In_ UINT cEntries
Definition: wingdi.h:3597
BASEOBJECT BaseObject
Definition: palette.h:36
ULONG NumColors
Definition: palette.h:41
INIT_FUNCTION NTSTATUS NTAPI InitPaletteImpl ( VOID  )

Definition at line 63 of file palette.c.

Referenced by DriverEntry().

64 {
65  // Create default palette (20 system colors)
67  20,
69  0, 0, 0);
72 
73  /* palette_size = visual->map_entries; */
74 
76  gpalRGB.RedMask = RGB(0xFF, 0x00, 0x00);
77  gpalRGB.GreenMask = RGB(0x00, 0xFF, 0x00);
78  gpalRGB.BlueMask = RGB(0x00, 0x00, 0xFF);
81 
83  gpalBGR.RedMask = RGB(0x00, 0x00, 0xFF);
84  gpalBGR.GreenMask = RGB(0x00, 0xFF, 0x00);
85  gpalBGR.BlueMask = RGB(0xFF, 0x00, 0x00);
88 
90  gpalRGB555.RedMask = 0x7C00;
91  gpalRGB555.GreenMask = 0x3E0;
92  gpalRGB555.BlueMask = 0x1F;
95 
97  gpalRGB565.RedMask = 0xF800;
98  gpalRGB565.GreenMask = 0x7E0;
99  gpalRGB565.BlueMask = 0x1F;
102 
106 
107  /* Initialize default surface palettes */
118 
119  return STATUS_SUCCESS;
120 }
#define BMF_24BPP
Definition: winddi.h:359
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
PALETTE gpalRGB565
Definition: palette.c:17
PALETTE gpalBGR
Definition: palette.c:17
ULONG ulShareCount
Definition: gdiobj.h:42
#define BMF_32BPP
Definition: winddi.h:360
PALETTE * gppalMono
Definition: palette.c:17
#define BMF_8RLE
Definition: winddi.h:362
Definition: xlate.c:9
PALETTE * gppalDefault
Definition: palette.c:17
USHORT BaseFlags
Definition: gdiobj.h:46
FORCEINLINE VOID PALETTE_vSetRGBColorForIndex(PPALETTE ppal, ULONG ulIndex, COLORREF crColor)
Definition: palette.h:152
PPALETTE NTAPI PALETTE_AllocPalette(_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
Definition: palette.c:132
#define BMF_PNG
Definition: winddi.h:364
ULONG RedMask
Definition: palette.h:43
#define PALETTE_UnlockPalette(pPalette)
Definition: palette.h:56
#define BMF_4RLE
Definition: winddi.h:361
smooth NULL
Definition: ftsmooth.c:513
#define BMF_16BPP
Definition: winddi.h:358
ULONG BlueMask
Definition: palette.h:45
ULONG GreenMask
Definition: palette.h:44
#define RGB(r, g, b)
Definition: wingdi.h:2917
Definition: xlate.c:8
PPALETTE NTAPI PALETTE_AllocPalWithHandle(_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
Definition: palette.c:206
BASEOBJECT BaseObject
Definition: palette.h:36
FLONG flFlags
Definition: palette.h:40
Definition: xlate.c:10
VOID NTAPI GDIOBJ_vReferenceObjectByPointer(POBJ pobj)
Definition: gdiobj.c:729
PPALETTE appalSurfaceDefault[11]
Definition: palette.c:18
PALETTE gpalRGB
Definition: palette.c:17
PALETTE gpalRGB555
Definition: palette.c:17
#define BMF_JPEG
Definition: winddi.h:363
const PALETTEENTRY g_sysPalTemplate[NB_RESERVED_COLORS]
Definition: palette.c:20
PPALETTE NTAPI PALETTE_AllocPalette ( _In_ ULONG  iMode,
_In_ ULONG  cColors,
_In_opt_ const PALETTEENTRY pEntries,
_In_ FLONG  flRed,
_In_ FLONG  flGreen,
_In_ FLONG  flBlue 
)

Definition at line 132 of file palette.c.

Referenced by CreateDIBPalette(), EngCreatePalette(), FixupDIBBrushPalette(), InitPaletteImpl(), and PALETTE_AllocPalWithHandle().

139 {
140  PPALETTE ppal;
141  ULONG fl = 0, cjSize = sizeof(PALETTE);
142 
143  /* Check if the palette has entries */
144  if (iMode & PAL_INDEXED)
145  {
146  /* Check color count */
147  if ((cColors == 0) || (cColors > 1024)) return NULL;
148 
149  /* Allocate enough space for the palete entries */
150  cjSize += cColors * sizeof(PALETTEENTRY);
151  }
152  else
153  {
154  /* There are no palette entries */
155  cColors = 0;
156 
157  /* We can use the lookaside list */
158  fl |= BASEFLAG_LOOKASIDE;
159  }
160 
161  /* Allocate the object (without a handle!) */
163  if (!ppal)
164  {
165  return NULL;
166  }
167 
168  /* Set mode, color count and entry pointer */
169  ppal->flFlags = iMode;
170  ppal->NumColors = cColors;
171  ppal->IndexedColors = ppal->apalColors;
172 
173  /* Check what kind of palette this is */
174  if (iMode & PAL_INDEXED)
175  {
176  /* Check if we got a color array */
177  if (pEntries)
178  {
179  /* Copy the entries */
180  RtlCopyMemory(ppal->IndexedColors, pEntries, cColors * sizeof(pEntries[0]));
181  }
182  }
183  else if (iMode & PAL_BITFIELDS)
184  {
185  /* Copy the color masks */
186  ppal->RedMask = flRed;
187  ppal->GreenMask = flGreen;
188  ppal->BlueMask = flBlue;
189 
190  /* Check what masks we have and set optimization flags */
191  if ((flRed == 0x7c00) && (flGreen == 0x3E0) && (flBlue == 0x1F))
192  ppal->flFlags |= PAL_RGB16_555;
193  else if ((flRed == 0xF800) && (flGreen == 0x7E0) && (flBlue == 0x1F))
194  ppal->flFlags |= PAL_RGB16_565;
195  else if ((flRed == 0xFF0000) && (flGreen == 0xFF00) && (flBlue == 0xFF))
196  ppal->flFlags |= PAL_BGR;
197  else if ((flRed == 0xFF) && (flGreen == 0xFF00) && (flBlue == 0xFF0000))
198  ppal->flFlags |= PAL_RGB;
199  }
200 
201  return ppal;
202 }
struct _PALETTE * PPALETTE
PALETTEENTRY apalColors[0]
Definition: palette.h:50
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
struct _PALETTE PALETTE
_In_ ULONG iMode
Definition: winddi.h:3520
PALETTEENTRY * IndexedColors
Definition: palette.h:42
_In_ FLONG fl
Definition: winddi.h:1279
ULONG RedMask
Definition: palette.h:43
smooth NULL
Definition: ftsmooth.c:513
ULONG BlueMask
Definition: palette.h:45
ULONG GreenMask
Definition: palette.h:44
ULONG NumColors
Definition: palette.h:41
FLONG flFlags
Definition: palette.h:40
unsigned int ULONG
Definition: retypes.h:1
_In_ ULONG cjSize
Definition: winddi.h:3634
struct tagPALETTEENTRY PALETTEENTRY
POBJ NTAPI GDIOBJ_AllocateObject(UCHAR objt, ULONG cjSize, FLONG fl)
Definition: gdiobj.c:557
PPALETTE NTAPI PALETTE_AllocPalWithHandle ( _In_ ULONG  iMode,
_In_ ULONG  cColors,
_In_opt_ const PALETTEENTRY pEntries,
_In_ FLONG  flRed,
_In_ FLONG  flGreen,
_In_ FLONG  flBlue 
)

Definition at line 206 of file palette.c.

Referenced by DIB_MapPaletteColors(), GreCreatePaletteInternal(), InitPaletteImpl(), NtGdiCreateHalftonePalette(), and NtGdiCreatePaletteInternal().

213 {
214  PPALETTE ppal;
215 
216  /* Allocate the palette without a handle */
217  ppal = PALETTE_AllocPalette(iMode, cColors, pEntries, flRed, flGreen, flBlue);
218  if (!ppal) return NULL;
219 
220  /* Insert the palette into the handle table */
222  {
223  DPRINT1("Could not insert palette into handle table.\n");
225  return NULL;
226  }
227 
228  return ppal;
229 }
_In_ ULONG iMode
Definition: winddi.h:3520
PPALETTE NTAPI PALETTE_AllocPalette(_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
Definition: palette.c:132
smooth NULL
Definition: ftsmooth.c:513
BASEOBJECT BaseObject
Definition: palette.h:36
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
#define DPRINT1
Definition: precomp.h:8
VOID NTAPI GDIOBJ_vFreeObject(POBJ pobj)
Definition: gdiobj.c:591
HGDIOBJ NTAPI GDIOBJ_hInsertObject(POBJ pobj, ULONG ulOwner)
Definition: gdiobj.c:907
INT FASTCALL PALETTE_GetObject ( PPALETTE  pGdiObject,
INT  cbCount,
LPLOGBRUSH  lpBuffer 
)

Definition at line 244 of file palette.c.

Referenced by GreGetObject().

245 {
246  if (!lpBuffer)
247  {
248  return sizeof(WORD);
249  }
250 
251  if ((UINT)cbCount < sizeof(WORD)) return 0;
252  *((WORD*)lpBuffer) = (WORD)ppal->NumColors;
253  return sizeof(WORD);
254 }
unsigned short WORD
Definition: ntddk_ex.h:93
static int cbCount
Definition: fiber.c:42
unsigned int UINT
Definition: ndis.h:50
ULONG NTAPI PALETTE_ulGetNearestBitFieldsIndex ( PPALETTE  ppal,
ULONG  ulColor 
)
ULONG NTAPI PALETTE_ulGetNearestIndex ( PPALETTE  ppal,
ULONG  iColor 
)
ULONG NTAPI PALETTE_ulGetNearestPaletteIndex ( PPALETTE  ppal,
ULONG  iColor 
)
FORCEINLINE ULONG PALETTE_ulGetRGBColorFromIndex ( PPALETTE  ppal,
ULONG  ulIndex 
)

Definition at line 142 of file palette.h.

Referenced by CreateDIBPalette(), FixupDIBBrushPalette(), and TranslateCOLORREF().

143 {
144  if (ulIndex >= ppal->NumColors) return 0;
145  return RGB(ppal->IndexedColors[ulIndex].peRed,
147  ppal->IndexedColors[ulIndex].peBlue);
148 }
PALETTEENTRY * IndexedColors
Definition: palette.h:42
#define RGB(r, g, b)
Definition: wingdi.h:2917
ULONG NumColors
Definition: palette.h:41
ULONG ulIndex
Definition: symbols.c:92
VOID FASTCALL PALETTE_ValidateFlags ( PALETTEENTRY lpPalE,
INT  size 
)

Definition at line 122 of file palette.c.

Referenced by GreCreatePaletteInternal(), IntAnimatePalette(), and NtGdiCreatePaletteInternal().

123 {
124  int i = 0;
125  for (; i<size ; i++)
126  lpPalE[i].peFlags = PC_SYS_USED | (lpPalE[i].peFlags & 0x07);
127 }
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define PC_SYS_USED
Definition: color.h:3
GLsizeiptr size
Definition: glext.h:5919
VOID NTAPI PALETTE_vCleanup ( PVOID  ObjectBody)

Definition at line 233 of file palette.c.

234 {
235  PPALETTE pPal = (PPALETTE)ObjectBody;
236  if (pPal->IndexedColors && pPal->IndexedColors != pPal->apalColors)
237  {
239  }
240 }
struct _PALETTE * PPALETTE
PALETTEENTRY apalColors[0]
Definition: palette.h:50
PALETTEENTRY * IndexedColors
Definition: palette.h:42
#define TAG_PALETTE
Definition: tags.h:26
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1097
VOID NTAPI PALETTE_vGetBitMasks ( PPALETTE  ppal,
PULONG  pulColors 
)

Definition at line 319 of file palette.c.

Referenced by EXLATEOBJ_vInitialize().

320 {
321  ASSERT(pulColors);
322 
323  if (ppal->flFlags & PAL_INDEXED || ppal->flFlags & PAL_RGB)
324  {
325  pulColors[0] = RGB(0xFF, 0x00, 0x00);
326  pulColors[1] = RGB(0x00, 0xFF, 0x00);
327  pulColors[2] = RGB(0x00, 0x00, 0xFF);
328  }
329  else if (ppal->flFlags & PAL_BGR)
330  {
331  pulColors[0] = RGB(0x00, 0x00, 0xFF);
332  pulColors[1] = RGB(0x00, 0xFF, 0x00);
333  pulColors[2] = RGB(0xFF, 0x00, 0x00);
334  }
335  else if (ppal->flFlags & PAL_BITFIELDS)
336  {
337  pulColors[0] = ppal->RedMask;
338  pulColors[1] = ppal->GreenMask;
339  pulColors[2] = ppal->BlueMask;
340  }
341 }
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
ULONG RedMask
Definition: palette.h:43
ULONG BlueMask
Definition: palette.h:45
ULONG GreenMask
Definition: palette.h:44
#define RGB(r, g, b)
Definition: wingdi.h:2917
FLONG flFlags
Definition: palette.h:40
FORCEINLINE VOID PALETTE_vSetRGBColorForIndex ( PPALETTE  ppal,
ULONG  ulIndex,
COLORREF  crColor 
)

Definition at line 152 of file palette.h.

Referenced by CreateDIBPalette(), FixupDIBBrushPalette(), and InitPaletteImpl().

153 {
154  if (ulIndex >= ppal->NumColors) return;
155  ppal->IndexedColors[ulIndex].peRed = GetRValue(crColor);
156  ppal->IndexedColors[ulIndex].peGreen = GetGValue(crColor);
157  ppal->IndexedColors[ulIndex].peBlue = GetBValue(crColor);
158 }
#define GetRValue(rgb)
Definition: wingdi.h:2912
PALETTEENTRY * IndexedColors
Definition: palette.h:42
#define GetGValue(rgb)
Definition: wingdi.h:2913
ULONG NumColors
Definition: palette.h:41
ULONG ulIndex
Definition: symbols.c:92
#define GetBValue(rgb)
Definition: wingdi.h:2914

Variable Documentation

PPALETTE appalSurfaceDefault[]

Definition at line 18 of file palette.c.

Referenced by SURFACE_AllocSurface().

PALETTE gpalBGR

Definition at line 17 of file palette.c.

Referenced by InitPaletteImpl().

PALETTE gpalRGB555

Definition at line 17 of file palette.c.

PALETTE gpalRGB565

Definition at line 17 of file palette.c.

Referenced by InitPaletteImpl().

PALETTE * gppalDefault

Definition at line 17 of file palette.c.

Referenced by CreateDIBPalette(), CreateStockObjects(), EBRUSHOBJ_vInit(), and InitPaletteImpl().