Convert between RGBQUAD and PALETTEENTRY

svn path=/trunk/; revision=9814
This commit is contained in:
Gé van Geldorp 2004-06-22 20:08:17 +00:00
parent a8b5ba5a72
commit 47e5aeceab
3 changed files with 48 additions and 5 deletions

View file

@ -33,6 +33,8 @@ HPALETTE FASTCALL PALETTE_AllocPalette(ULONG Mode,
ULONG Red, ULONG Red,
ULONG Green, ULONG Green,
ULONG Blue); ULONG Blue);
HPALETTE FASTCALL PALETTE_AllocPaletteIndexedRGB(ULONG NumColors,
CONST RGBQUAD *Colors);
#define PALETTE_FreePalette(hPalette) GDIOBJ_FreeObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE, GDIOBJFLAG_DEFAULT) #define PALETTE_FreePalette(hPalette) GDIOBJ_FreeObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE, GDIOBJFLAG_DEFAULT)
#define PALETTE_LockPalette(hPalette) ((PPALGDI)GDIOBJ_LockObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE)) #define PALETTE_LockPalette(hPalette) ((PPALGDI)GDIOBJ_LockObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE))
#define PALETTE_UnlockPalette(hPalette) GDIOBJ_UnlockObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE) #define PALETTE_UnlockPalette(hPalette) GDIOBJ_UnlockObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE)

View file

@ -1,5 +1,5 @@
/* /*
* $Id: dib.c,v 1.51 2004/06/20 00:45:37 navaraf Exp $ * $Id: dib.c,v 1.52 2004/06/22 20:08:17 gvg Exp $
* *
* ReactOS W32 Subsystem * ReactOS W32 Subsystem
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
@ -54,9 +54,8 @@ NtGdiSetDIBColorTable(HDC hDC, UINT StartIndex, UINT Entries, CONST RGBQUAD *Col
/* Rebuild the palette. */ /* Rebuild the palette. */
NtGdiDeleteObject(dc->w.hPalette); NtGdiDeleteObject(dc->w.hPalette);
dc->w.hPalette = PALETTE_AllocPalette(PAL_INDEXED, dc->w.hPalette = PALETTE_AllocPaletteIndexedRGB(1 << BitmapObj->dib->dsBmih.biBitCount,
1 << BitmapObj->dib->dsBmih.biBitCount, BitmapObj->ColorMap);
(PULONG)BitmapObj->ColorMap, 0, 0, 0);
} }
else else
Entries = 0; Entries = 0;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: palette.c,v 1.19 2004/06/20 00:45:37 navaraf Exp $ */ /* $Id: palette.c,v 1.20 2004/06/22 20:08:17 gvg Exp $ */
#include <w32k.h> #include <w32k.h>
#ifndef NO_MAPPING #ifndef NO_MAPPING
@ -98,6 +98,48 @@ PALETTE_AllocPalette(ULONG Mode,
return NewPalette; return NewPalette;
} }
HPALETTE FASTCALL
PALETTE_AllocPaletteIndexedRGB(ULONG NumColors,
CONST RGBQUAD *Colors)
{
HPALETTE NewPalette;
PPALGDI PalGDI;
unsigned i;
NewPalette = (HPALETTE) GDIOBJ_AllocObj(sizeof(PALGDI), GDI_OBJECT_TYPE_PALETTE, (GDICLEANUPPROC) PALETTE_InternalDelete);
if (NULL == NewPalette)
{
return NULL;
}
PalGDI = PALETTE_LockPalette(NewPalette);
ASSERT( PalGDI );
PalGDI->Self = NewPalette;
PalGDI->Mode = PAL_INDEXED;
PalGDI->IndexedColors = ExAllocatePoolWithTag(PagedPool, sizeof(PALETTEENTRY) * NumColors, TAG_PALETTE);
if (NULL == PalGDI->IndexedColors)
{
PALETTE_UnlockPalette(NewPalette);
PALETTE_FreePalette(NewPalette);
return NULL;
}
for (i = 0; i < NumColors; i++)
{
PalGDI->IndexedColors[i].peRed = Colors[i].rgbRed;
PalGDI->IndexedColors[i].peGreen = Colors[i].rgbGreen;
PalGDI->IndexedColors[i].peBlue = Colors[i].rgbBlue;
PalGDI->IndexedColors[i].peFlags = 0;
}
PalGDI->NumColors = NumColors;
PALETTE_UnlockPalette(NewPalette);
return NewPalette;
}
// Create the system palette // Create the system palette
HPALETTE FASTCALL PALETTE_Init(VOID) HPALETTE FASTCALL PALETTE_Init(VOID)
{ {