mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 13:26:17 +00:00
- Palette fixes.
svn path=/trunk/; revision=7130
This commit is contained in:
parent
e437baff45
commit
57af3eb9c8
8 changed files with 119 additions and 204 deletions
|
@ -721,7 +721,6 @@ typedef struct _PALOBJ
|
||||||
ULONG ulReserved;
|
ULONG ulReserved;
|
||||||
PXLATEOBJ logicalToSystem;
|
PXLATEOBJ logicalToSystem;
|
||||||
int *mapping;
|
int *mapping;
|
||||||
PLOGPALETTE logpalette; /* _MUST_ be the last field */
|
|
||||||
} PALOBJ, *PPALOBJ;
|
} PALOBJ, *PPALOBJ;
|
||||||
|
|
||||||
typedef struct _PATHOBJ
|
typedef struct _PATHOBJ
|
||||||
|
|
|
@ -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 2003/11/26 22:24:04 gvg Exp $
|
/* $Id: palette.c,v 1.20 2003/12/20 10:31:32 navaraf Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -85,7 +85,10 @@ PALOBJ_cGetColors(PALOBJ *PalObj,
|
||||||
|
|
||||||
for(i=Start; i<Colors; i++)
|
for(i=Start; i<Colors; i++)
|
||||||
{
|
{
|
||||||
PaletteEntry[i] = PalGDI->IndexedColors[i];
|
PaletteEntry[i] = RGB(
|
||||||
|
PalGDI->IndexedColors[i].peRed,
|
||||||
|
PalGDI->IndexedColors[i].peGreen,
|
||||||
|
PalGDI->IndexedColors[i].peBlue);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Colors;
|
return Colors;
|
||||||
|
|
|
@ -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: xlate.c,v 1.26 2003/12/19 22:58:47 navaraf Exp $
|
/* $Id: xlate.c,v 1.27 2003/12/20 10:31:32 navaraf Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -83,11 +83,10 @@ static ULONG FASTCALL ShiftAndMask(XLATEGDI *XlateGDI, ULONG Color)
|
||||||
|
|
||||||
// Takes indexed palette and a
|
// Takes indexed palette and a
|
||||||
ULONG STDCALL
|
ULONG STDCALL
|
||||||
ClosestColorMatch(XLATEGDI *XlateGDI, ULONG SourceColor, ULONG *DestColors,
|
ClosestColorMatch(XLATEGDI *XlateGDI, ULONG SourceColor,
|
||||||
ULONG NumColors)
|
PALETTEENTRY *DestColors, ULONG NumColors)
|
||||||
{
|
{
|
||||||
PVIDEO_CLUTDATA cSourceColor;
|
LPPALETTEENTRY cSourceColor;
|
||||||
PVIDEO_CLUTDATA cDestColors;
|
|
||||||
LONG idx = 0;
|
LONG idx = 0;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
ULONG SourceRGB;
|
ULONG SourceRGB;
|
||||||
|
@ -106,25 +105,23 @@ ClosestColorMatch(XLATEGDI *XlateGDI, ULONG SourceColor, ULONG *DestColors,
|
||||||
{
|
{
|
||||||
/* FIXME: must use bitfields */
|
/* FIXME: must use bitfields */
|
||||||
SourceRGB = ShiftAndMask(XlateGDI, SourceColor);
|
SourceRGB = ShiftAndMask(XlateGDI, SourceColor);
|
||||||
cSourceColor = (PVIDEO_CLUTDATA) &SourceRGB;
|
cSourceColor = (LPPALETTEENTRY) &SourceRGB;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cSourceColor = (PVIDEO_CLUTDATA)&SourceColor;
|
cSourceColor = (LPPALETTEENTRY)&SourceColor;
|
||||||
}
|
}
|
||||||
SourceRed = cSourceColor->Red;
|
SourceRed = cSourceColor->peRed;
|
||||||
SourceGreen = cSourceColor->Green;
|
SourceGreen = cSourceColor->peGreen;
|
||||||
SourceBlue = cSourceColor->Blue;
|
SourceBlue = cSourceColor->peBlue;
|
||||||
|
|
||||||
for (i=0; i<NumColors; i++)
|
for (i=0; i<NumColors; i++)
|
||||||
{
|
{
|
||||||
cDestColors = (PVIDEO_CLUTDATA)&DestColors[i];
|
cxRed = (SourceRed - DestColors[i].peRed);
|
||||||
|
|
||||||
cxRed = (SourceRed - cDestColors->Red);
|
|
||||||
cxRed *= cxRed; //compute cxRed squared
|
cxRed *= cxRed; //compute cxRed squared
|
||||||
cxGreen = (SourceGreen - cDestColors->Green);
|
cxGreen = (SourceGreen - DestColors[i].peGreen);
|
||||||
cxGreen *= cxGreen;
|
cxGreen *= cxGreen;
|
||||||
cxBlue = (SourceBlue - cDestColors->Blue);
|
cxBlue = (SourceBlue - DestColors[i].peBlue);
|
||||||
cxBlue *= cxBlue;
|
cxBlue *= cxBlue;
|
||||||
|
|
||||||
rt = /* sqrt */ (cxRed + cxGreen + cxBlue);
|
rt = /* sqrt */ (cxRed + cxGreen + cxBlue);
|
||||||
|
@ -152,7 +149,7 @@ IndexedToIndexedTranslationTable(XLATEGDI *XlateGDI, ULONG *TranslationTable,
|
||||||
Trivial = TRUE;
|
Trivial = TRUE;
|
||||||
for(i=0; i<PalSource->NumColors; i++)
|
for(i=0; i<PalSource->NumColors; i++)
|
||||||
{
|
{
|
||||||
TranslationTable[i] = ClosestColorMatch(XlateGDI, PalSource->IndexedColors[i], PalDest->IndexedColors, PalDest->NumColors);
|
TranslationTable[i] = ClosestColorMatch(XlateGDI, *((ULONG*)&PalSource->IndexedColors[i]), PalDest->IndexedColors, PalDest->NumColors);
|
||||||
Trivial = Trivial && (TranslationTable[i] == i);
|
Trivial = Trivial && (TranslationTable[i] == i);
|
||||||
}
|
}
|
||||||
if (Trivial)
|
if (Trivial)
|
||||||
|
|
|
@ -5,7 +5,6 @@ const PALETTEENTRY* FASTCALL COLOR_GetSystemPaletteTemplate (VOID);
|
||||||
COLORREF STDCALL COLOR_LookupNearestColor (PALETTEENTRY* palPalEntry, INT size, COLORREF color);
|
COLORREF STDCALL COLOR_LookupNearestColor (PALETTEENTRY* palPalEntry, INT size, COLORREF color);
|
||||||
INT STDCALL COLOR_PaletteLookupExactIndex (PALETTEENTRY* palPalEntry, INT size, COLORREF col);
|
INT STDCALL COLOR_PaletteLookupExactIndex (PALETTEENTRY* palPalEntry, INT size, COLORREF col);
|
||||||
INT STDCALL COLOR_PaletteLookupPixel(PALETTEENTRY *palPalEntry, INT size, PXLATEOBJ XlateObj, COLORREF col, BOOL skipReserved);
|
INT STDCALL COLOR_PaletteLookupPixel(PALETTEENTRY *palPalEntry, INT size, PXLATEOBJ XlateObj, COLORREF col, BOOL skipReserved);
|
||||||
ULONG FASTCALL NtGdiGetSysColor(int nIndex);
|
|
||||||
HBRUSH STDCALL NtGdiGetSysColorBrush(int nIndex);
|
HBRUSH STDCALL NtGdiGetSysColorBrush(int nIndex);
|
||||||
|
|
||||||
#endif /* _WIN32K_COLOR_H */
|
#endif /* _WIN32K_COLOR_H */
|
||||||
|
|
|
@ -19,7 +19,7 @@ typedef struct _PALGDI {
|
||||||
HPALETTE Self;
|
HPALETTE Self;
|
||||||
ULONG Mode; // PAL_INDEXED, PAL_BITFIELDS, PAL_RGB, PAL_BGR
|
ULONG Mode; // PAL_INDEXED, PAL_BITFIELDS, PAL_RGB, PAL_BGR
|
||||||
ULONG NumColors;
|
ULONG NumColors;
|
||||||
ULONG *IndexedColors;
|
PALETTEENTRY *IndexedColors;
|
||||||
ULONG RedMask;
|
ULONG RedMask;
|
||||||
ULONG GreenMask;
|
ULONG GreenMask;
|
||||||
ULONG BlueMask;
|
ULONG BlueMask;
|
||||||
|
|
|
@ -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: color.c,v 1.30 2003/12/19 22:58:47 navaraf Exp $ */
|
/* $Id: color.c,v 1.31 2003/12/20 10:31:32 navaraf Exp $ */
|
||||||
|
|
||||||
// FIXME: Use PXLATEOBJ logicalToSystem instead of int *mapping
|
// FIXME: Use PXLATEOBJ logicalToSystem instead of int *mapping
|
||||||
|
|
||||||
|
@ -28,11 +28,13 @@
|
||||||
#include <win32k/dc.h>
|
#include <win32k/dc.h>
|
||||||
#include <win32k/color.h>
|
#include <win32k/color.h>
|
||||||
#include <win32k/pen.h>
|
#include <win32k/pen.h>
|
||||||
|
#include <win32k/ntuser.h>
|
||||||
#include "../eng/handle.h"
|
#include "../eng/handle.h"
|
||||||
#include <include/inteng.h>
|
#include <include/inteng.h>
|
||||||
#include <include/color.h>
|
#include <include/color.h>
|
||||||
#include <include/palette.h>
|
#include <include/palette.h>
|
||||||
#include <include/error.h>
|
#include <include/error.h>
|
||||||
|
#include <include/dce.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <win32k/debug1.h>
|
#include <win32k/debug1.h>
|
||||||
|
@ -109,48 +111,6 @@ const COLORREF SysColours[] =
|
||||||
RGB(181, 181, 181) /* COLOR_GRADIENTINACTIVECAPTION */,
|
RGB(181, 181, 181) /* COLOR_GRADIENTINACTIVECAPTION */,
|
||||||
};
|
};
|
||||||
|
|
||||||
ULONG FASTCALL NtGdiGetSysColor(int nIndex)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
const PALETTEENTRY *p = COLOR_sysPalTemplate + (nIndex * sizeof(PALETTEENTRY));
|
|
||||||
return RGB(p->peRed, p->peGreen, p->peBlue);
|
|
||||||
#else
|
|
||||||
if (nIndex < 0 || sizeof(SysColours) / sizeof(SysColours[0]) < nIndex)
|
|
||||||
{
|
|
||||||
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SysColours[nIndex];
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
HPEN STDCALL NtGdiGetSysColorPen(int nIndex)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
COLORREF Col;
|
|
||||||
memcpy(&Col, COLOR_sysPalTemplate + nIndex, sizeof(COLORREF));
|
|
||||||
return(NtGdiCreatePen(PS_SOLID, 1, Col));
|
|
||||||
#else
|
|
||||||
static HPEN SysPens[sizeof(SysColours) / sizeof(SysColours[0])];
|
|
||||||
|
|
||||||
if (nIndex < 0 || sizeof(SysColours) / sizeof(SysColours[0]) < nIndex)
|
|
||||||
{
|
|
||||||
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXME should register this object with DeleteObject() so it
|
|
||||||
can't be deleted */
|
|
||||||
if (NULL == SysPens[nIndex])
|
|
||||||
{
|
|
||||||
SysPens[nIndex] = (HPEN)((DWORD)NtGdiCreatePen(PS_SOLID, 0, SysColours[nIndex]) | 0x00800000);
|
|
||||||
}
|
|
||||||
|
|
||||||
return SysPens[nIndex];
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
HBRUSH STDCALL NtGdiGetSysColorBrush(int nIndex)
|
HBRUSH STDCALL NtGdiGetSysColorBrush(int nIndex)
|
||||||
{
|
{
|
||||||
static HBRUSH SysBrushes[sizeof(SysColours) / sizeof(SysColours[0])];
|
static HBRUSH SysBrushes[sizeof(SysColours) / sizeof(SysColours[0])];
|
||||||
|
@ -174,92 +134,70 @@ HBRUSH STDCALL NtGdiGetSysColorBrush(int nIndex)
|
||||||
return SysBrushes[nIndex];
|
return SysBrushes[nIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const PALETTEENTRY* FASTCALL COLOR_GetSystemPaletteTemplate(void)
|
const PALETTEENTRY* FASTCALL COLOR_GetSystemPaletteTemplate(void)
|
||||||
{
|
{
|
||||||
return (const PALETTEENTRY*)&COLOR_sysPalTemplate;
|
return (const PALETTEENTRY*)&COLOR_sysPalTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL STDCALL NtGdiAnimatePalette(HPALETTE hpal,
|
BOOL STDCALL NtGdiAnimatePalette(HPALETTE hPalette, UINT uStartIndex,
|
||||||
UINT StartIndex,
|
UINT uEntries, CONST PPALETTEENTRY ppe)
|
||||||
UINT Entries,
|
|
||||||
CONST PPALETTEENTRY ppe)
|
|
||||||
{
|
{
|
||||||
/*
|
UNIMPLEMENTED;
|
||||||
if( hPal != NtGdiGetStockObject(DEFAULT_PALETTE) )
|
SetLastWin32Error(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
{
|
return FALSE;
|
||||||
PALETTEOBJ* palPtr = (PALETTEOBJ *)GDI_GetObjPtr(hPal, PALETTE_MAGIC);
|
|
||||||
if (!palPtr) return FALSE;
|
|
||||||
|
|
||||||
if( (StartIndex + NumEntries) <= palPtr->logpalette->palNumEntries )
|
|
||||||
{
|
|
||||||
UINT u;
|
|
||||||
for( u = 0; u < NumEntries; u++ )
|
|
||||||
palPtr->logpalette->palPalEntry[u + StartIndex] = PaletteColors[u];
|
|
||||||
PALETTE_Driver->pSetMapping(palPtr, StartIndex, NumEntries, hPal != hPrimaryPalette );
|
|
||||||
GDI_ReleaseObj(hPal);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
GDI_ReleaseObj(hPal);
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
*/
|
|
||||||
UNIMPLEMENTED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HPALETTE STDCALL NtGdiCreateHalftonePalette(HDC hDC)
|
HPALETTE STDCALL NtGdiCreateHalftonePalette(HDC hDC)
|
||||||
{
|
{
|
||||||
int i, r, g, b;
|
int i, r, g, b;
|
||||||
struct {
|
struct {
|
||||||
WORD Version;
|
WORD Version;
|
||||||
WORD NumberOfEntries;
|
WORD NumberOfEntries;
|
||||||
PALETTEENTRY aEntries[256];
|
PALETTEENTRY aEntries[256];
|
||||||
} Palette;
|
} Palette;
|
||||||
|
|
||||||
Palette.Version = 0x300;
|
Palette.Version = 0x300;
|
||||||
Palette.NumberOfEntries = 256;
|
Palette.NumberOfEntries = 256;
|
||||||
NtGdiGetSystemPaletteEntries(hDC, 0, 256, Palette.aEntries);
|
if (NtGdiGetSystemPaletteEntries(hDC, 0, 256, Palette.aEntries) == 0)
|
||||||
|
{
|
||||||
for (r = 0; r < 6; r++) {
|
return 0;
|
||||||
for (g = 0; g < 6; g++) {
|
|
||||||
for (b = 0; b < 6; b++) {
|
|
||||||
i = r + g*6 + b*36 + 10;
|
|
||||||
Palette.aEntries[i].peRed = r * 51;
|
|
||||||
Palette.aEntries[i].peGreen = g * 51;
|
|
||||||
Palette.aEntries[i].peBlue = b * 51;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 216; i < 246; i++) {
|
for (r = 0; r < 6; r++)
|
||||||
int v = (i - 216) * 8;
|
for (g = 0; g < 6; g++)
|
||||||
Palette.aEntries[i].peRed = v;
|
for (b = 0; b < 6; b++)
|
||||||
Palette.aEntries[i].peGreen = v;
|
{
|
||||||
Palette.aEntries[i].peBlue = v;
|
i = r + g*6 + b*36 + 10;
|
||||||
}
|
Palette.aEntries[i].peRed = r * 51;
|
||||||
|
Palette.aEntries[i].peGreen = g * 51;
|
||||||
|
Palette.aEntries[i].peBlue = b * 51;
|
||||||
|
}
|
||||||
|
|
||||||
return NtGdiCreatePalette((LOGPALETTE *)&Palette);
|
for (i = 216; i < 246; i++)
|
||||||
|
{
|
||||||
|
int v = (i - 216) * 8;
|
||||||
|
Palette.aEntries[i].peRed = v;
|
||||||
|
Palette.aEntries[i].peGreen = v;
|
||||||
|
Palette.aEntries[i].peBlue = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NtGdiCreatePalette((LOGPALETTE *)&Palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
HPALETTE STDCALL NtGdiCreatePalette(CONST PLOGPALETTE palette)
|
HPALETTE STDCALL NtGdiCreatePalette(CONST PLOGPALETTE palette)
|
||||||
{
|
{
|
||||||
PPALOBJ PalObj;
|
PPALGDI PalGDI;
|
||||||
|
|
||||||
HPALETTE NewPalette = PALETTE_AllocPalette(
|
HPALETTE NewPalette = PALETTE_AllocPalette(
|
||||||
PAL_INDEXED,
|
PAL_INDEXED,
|
||||||
palette->palNumEntries,
|
palette->palNumEntries,
|
||||||
(PULONG)palette->palPalEntry,
|
(PULONG)palette->palPalEntry,
|
||||||
0, 0, 0);
|
0, 0, 0);
|
||||||
ULONG size;
|
|
||||||
|
|
||||||
PalObj = (PPALOBJ) PALETTE_LockPalette(NewPalette);
|
PalGDI = (PPALGDI) PALETTE_LockPalette(NewPalette);
|
||||||
|
|
||||||
size = sizeof(LOGPALETTE) + (palette->palNumEntries * sizeof(PALETTEENTRY));
|
PALETTE_ValidateFlags(PalGDI->IndexedColors, PalGDI->NumColors);
|
||||||
PalObj->logpalette = ExAllocatePool(NonPagedPool, size);
|
PalGDI->PalObj.logicalToSystem = NULL;
|
||||||
memcpy(PalObj->logpalette, palette, size);
|
|
||||||
PALETTE_ValidateFlags(PalObj->logpalette->palPalEntry, PalObj->logpalette->palNumEntries);
|
|
||||||
PalObj->logicalToSystem = NULL;
|
|
||||||
|
|
||||||
PALETTE_UnlockPalette(NewPalette);
|
PALETTE_UnlockPalette(NewPalette);
|
||||||
|
|
||||||
|
@ -277,21 +215,21 @@ COLORREF STDCALL NtGdiGetNearestColor(HDC hDC,
|
||||||
{
|
{
|
||||||
COLORREF nearest = CLR_INVALID;
|
COLORREF nearest = CLR_INVALID;
|
||||||
PDC dc;
|
PDC dc;
|
||||||
PPALOBJ palObj;
|
PPALGDI palGDI;
|
||||||
|
|
||||||
dc = DC_LockDc(hDC);
|
dc = DC_LockDc(hDC);
|
||||||
if (NULL != dc)
|
if (NULL != dc)
|
||||||
{
|
{
|
||||||
HPALETTE hpal = (dc->w.hPalette) ? dc->w.hPalette : NtGdiGetStockObject(DEFAULT_PALETTE);
|
HPALETTE hpal = (dc->w.hPalette) ? dc->w.hPalette : NtGdiGetStockObject(DEFAULT_PALETTE);
|
||||||
palObj = (PPALOBJ) PALETTE_LockPalette(hpal);
|
palGDI = (PPALGDI) PALETTE_LockPalette(hpal);
|
||||||
if (!palObj)
|
if (!palGDI)
|
||||||
{
|
{
|
||||||
DC_UnlockDc(hDC);
|
DC_UnlockDc(hDC);
|
||||||
return nearest;
|
return nearest;
|
||||||
}
|
}
|
||||||
|
|
||||||
nearest = COLOR_LookupNearestColor(palObj->logpalette->palPalEntry,
|
nearest = COLOR_LookupNearestColor(palGDI->IndexedColors,
|
||||||
palObj->logpalette->palNumEntries, Color);
|
palGDI->NumColors, Color);
|
||||||
PALETTE_UnlockPalette(hpal);
|
PALETTE_UnlockPalette(hpal);
|
||||||
DC_UnlockDc( hDC );
|
DC_UnlockDc( hDC );
|
||||||
}
|
}
|
||||||
|
@ -302,7 +240,6 @@ COLORREF STDCALL NtGdiGetNearestColor(HDC hDC,
|
||||||
UINT STDCALL NtGdiGetNearestPaletteIndex(HPALETTE hpal,
|
UINT STDCALL NtGdiGetNearestPaletteIndex(HPALETTE hpal,
|
||||||
COLORREF Color)
|
COLORREF Color)
|
||||||
{
|
{
|
||||||
#if 1
|
|
||||||
PPALGDI palGDI = (PPALGDI) PALETTE_LockPalette(hpal);
|
PPALGDI palGDI = (PPALGDI) PALETTE_LockPalette(hpal);
|
||||||
UINT index = 0;
|
UINT index = 0;
|
||||||
|
|
||||||
|
@ -314,20 +251,6 @@ UINT STDCALL NtGdiGetNearestPaletteIndex(HPALETTE hpal,
|
||||||
}
|
}
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
#else
|
|
||||||
PPALOBJ palObj = (PPALOBJ) PALETTE_LockPalette(hpal);
|
|
||||||
UINT index = 0;
|
|
||||||
|
|
||||||
if (NULL != palObj)
|
|
||||||
{
|
|
||||||
/* Return closest match for the given RGB color */
|
|
||||||
ASSERT(palObj->logpalette != NULL);
|
|
||||||
index = COLOR_PaletteLookupPixel(palObj->logpalette->palPalEntry, palObj->logpalette->palNumEntries, NULL, Color, FALSE);
|
|
||||||
PALETTE_UnlockPalette(hpal);
|
|
||||||
}
|
|
||||||
|
|
||||||
return index;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT STDCALL NtGdiGetPaletteEntries(HPALETTE hpal,
|
UINT STDCALL NtGdiGetPaletteEntries(HPALETTE hpal,
|
||||||
|
@ -335,16 +258,16 @@ UINT STDCALL NtGdiGetPaletteEntries(HPALETTE hpal,
|
||||||
UINT Entries,
|
UINT Entries,
|
||||||
LPPALETTEENTRY pe)
|
LPPALETTEENTRY pe)
|
||||||
{
|
{
|
||||||
PPALOBJ palPtr;
|
PPALGDI palGDI;
|
||||||
UINT numEntries;
|
UINT numEntries;
|
||||||
|
|
||||||
palPtr = (PPALOBJ) PALETTE_LockPalette(hpal);
|
palGDI = (PPALGDI) PALETTE_LockPalette(hpal);
|
||||||
if (NULL == palPtr)
|
if (NULL == palGDI)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
numEntries = palPtr->logpalette->palNumEntries;
|
numEntries = palGDI->NumColors;
|
||||||
if (numEntries < StartIndex + Entries)
|
if (numEntries < StartIndex + Entries)
|
||||||
{
|
{
|
||||||
Entries = numEntries - StartIndex;
|
Entries = numEntries - StartIndex;
|
||||||
|
@ -356,7 +279,7 @@ UINT STDCALL NtGdiGetPaletteEntries(HPALETTE hpal,
|
||||||
PALETTE_UnlockPalette(hpal);
|
PALETTE_UnlockPalette(hpal);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
memcpy(pe, &palPtr->logpalette->palPalEntry[StartIndex], Entries * sizeof(PALETTEENTRY));
|
memcpy(pe, &palGDI->IndexedColors[StartIndex], Entries * sizeof(PALETTEENTRY));
|
||||||
for (numEntries = 0; numEntries < Entries; numEntries++)
|
for (numEntries = 0; numEntries < Entries; numEntries++)
|
||||||
{
|
{
|
||||||
if (pe[numEntries].peFlags & 0xF0)
|
if (pe[numEntries].peFlags & 0xF0)
|
||||||
|
@ -448,7 +371,7 @@ UINT STDCALL NtGdiRealizePalette(HDC hDC)
|
||||||
palPtr = (PPALOBJ) palGDI;
|
palPtr = (PPALOBJ) palGDI;
|
||||||
|
|
||||||
// Step 1: Create mapping of system palette\DC palette
|
// Step 1: Create mapping of system palette\DC palette
|
||||||
realized = PALETTE_SetMapping(palPtr, 0, palPtr->logpalette->palNumEntries,
|
realized = PALETTE_SetMapping(palPtr, 0, palGDI->NumColors,
|
||||||
(dc->w.hPalette != hPrimaryPalette) ||
|
(dc->w.hPalette != hPrimaryPalette) ||
|
||||||
(dc->w.hPalette == NtGdiGetStockObject(DEFAULT_PALETTE)));
|
(dc->w.hPalette == NtGdiGetStockObject(DEFAULT_PALETTE)));
|
||||||
|
|
||||||
|
@ -466,7 +389,7 @@ UINT STDCALL NtGdiRealizePalette(HDC hDC)
|
||||||
} else {
|
} else {
|
||||||
if(SurfGDI->SetPalette)
|
if(SurfGDI->SetPalette)
|
||||||
{
|
{
|
||||||
success = SurfGDI->SetPalette(dc->PDev, sysPtr, 0, 0, sysPtr->logpalette->palNumEntries);
|
success = SurfGDI->SetPalette(dc->PDev, sysPtr, 0, 0, sysGDI->NumColors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -583,13 +506,13 @@ UINT STDCALL NtGdiSetPaletteEntries(HPALETTE hpal,
|
||||||
UINT Entries,
|
UINT Entries,
|
||||||
CONST LPPALETTEENTRY pe)
|
CONST LPPALETTEENTRY pe)
|
||||||
{
|
{
|
||||||
PPALOBJ palPtr;
|
PPALGDI palGDI;
|
||||||
WORD numEntries;
|
WORD numEntries;
|
||||||
|
|
||||||
palPtr = (PPALOBJ)PALETTE_LockPalette(hpal);
|
palGDI = PALETTE_LockPalette(hpal);
|
||||||
if (!palPtr) return 0;
|
if (!palGDI) return 0;
|
||||||
|
|
||||||
numEntries = palPtr->logpalette->palNumEntries;
|
numEntries = palGDI->NumColors;
|
||||||
if (Start >= numEntries)
|
if (Start >= numEntries)
|
||||||
{
|
{
|
||||||
PALETTE_UnlockPalette(hpal);
|
PALETTE_UnlockPalette(hpal);
|
||||||
|
@ -599,46 +522,39 @@ UINT STDCALL NtGdiSetPaletteEntries(HPALETTE hpal,
|
||||||
{
|
{
|
||||||
Entries = numEntries - Start;
|
Entries = numEntries - Start;
|
||||||
}
|
}
|
||||||
memcpy(&palPtr->logpalette->palPalEntry[Start], pe, Entries * sizeof(PALETTEENTRY));
|
memcpy(&palGDI->IndexedColors[Start], pe, Entries * sizeof(PALETTEENTRY));
|
||||||
PALETTE_ValidateFlags(palPtr->logpalette->palPalEntry, palPtr->logpalette->palNumEntries);
|
PALETTE_ValidateFlags(palGDI->IndexedColors, palGDI->NumColors);
|
||||||
ExFreePool(palPtr->logicalToSystem);
|
ExFreePool(palGDI->PalObj.logicalToSystem);
|
||||||
palPtr->logicalToSystem = NULL;
|
palGDI->PalObj.logicalToSystem = NULL;
|
||||||
PALETTE_UnlockPalette(hpal);
|
PALETTE_UnlockPalette(hpal);
|
||||||
|
|
||||||
return Entries;
|
return Entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT STDCALL NtGdiSetSystemPaletteUse(HDC hDC,
|
UINT STDCALL
|
||||||
UINT Usage)
|
NtGdiSetSystemPaletteUse(HDC hDC, UINT Usage)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL STDCALL NtGdiUnrealizeObject(HGDIOBJ hgdiobj)
|
BOOL STDCALL
|
||||||
|
NtGdiUnrealizeObject(HGDIOBJ hgdiobj)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL STDCALL NtGdiUpdateColors(HDC hDC)
|
BOOL STDCALL
|
||||||
|
NtGdiUpdateColors(HDC hDC)
|
||||||
{
|
{
|
||||||
//PDC dc;
|
HWND hWnd;
|
||||||
//HWND hWnd;
|
|
||||||
//int size;
|
|
||||||
/*
|
|
||||||
if (!(dc = AccessUserObject(hDC))) return 0;
|
|
||||||
size = dc->GDIInfo->ulNumPalReg;
|
|
||||||
// GDI_ReleaseObj( hDC );
|
|
||||||
|
|
||||||
if (Callout.WindowFromDC)
|
hWnd = IntWindowFromDC(hDC);
|
||||||
{
|
if (hWnd == NULL)
|
||||||
hWnd = Callout.WindowFromDC( hDC );
|
{
|
||||||
|
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
|
||||||
// Docs say that we have to remap current drawable pixel by pixel
|
return FALSE;
|
||||||
// but it would take forever given the speed of XGet/PutPixel.
|
}
|
||||||
if (hWnd && size) Callout.RedrawWindow( hWnd, NULL, 0, RDW_INVALIDATE );
|
return NtUserRedrawWindow(hWnd, NULL, 0, RDW_INVALIDATE);
|
||||||
} */
|
|
||||||
// FIXME UNIMPLEMENTED
|
|
||||||
return 0x666;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
INT STDCALL COLOR_PaletteLookupPixel(PALETTEENTRY *palPalEntry, INT size,
|
INT STDCALL COLOR_PaletteLookupPixel(PALETTEENTRY *palPalEntry, INT size,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $Id: dib.c,v 1.37 2003/12/07 10:31:56 navaraf Exp $
|
* $Id: dib.c,v 1.38 2003/12/20 10:31:32 navaraf 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
|
||||||
|
@ -44,12 +44,12 @@ UINT STDCALL NtGdiSetDIBColorTable(HDC hDC,
|
||||||
{
|
{
|
||||||
PDC dc;
|
PDC dc;
|
||||||
PALETTEENTRY * palEntry;
|
PALETTEENTRY * palEntry;
|
||||||
PPALOBJ palette;
|
PPALGDI palette;
|
||||||
const RGBQUAD *end;
|
const RGBQUAD *end;
|
||||||
|
|
||||||
if (!(dc = (PDC)AccessUserObject((ULONG)hDC))) return 0;
|
if (!(dc = (PDC)AccessUserObject((ULONG)hDC))) return 0;
|
||||||
|
|
||||||
if (!(palette = (PPALOBJ)PALETTE_LockPalette((ULONG)dc->DevInfo->hpalDefault)))
|
if (!(palette = PALETTE_LockPalette((ULONG)dc->DevInfo->hpalDefault)))
|
||||||
{
|
{
|
||||||
// GDI_ReleaseObj( hdc );
|
// GDI_ReleaseObj( hdc );
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -59,12 +59,12 @@ UINT STDCALL NtGdiSetDIBColorTable(HDC hDC,
|
||||||
|
|
||||||
if (dc->w.bitsPerPixel <= 8)
|
if (dc->w.bitsPerPixel <= 8)
|
||||||
{
|
{
|
||||||
palEntry = palette->logpalette->palPalEntry + StartIndex;
|
palEntry = palette->IndexedColors + StartIndex;
|
||||||
if (StartIndex + Entries > (UINT) (1 << dc->w.bitsPerPixel))
|
if (StartIndex + Entries > (UINT) (1 << dc->w.bitsPerPixel))
|
||||||
Entries = (1 << dc->w.bitsPerPixel) - StartIndex;
|
Entries = (1 << dc->w.bitsPerPixel) - StartIndex;
|
||||||
|
|
||||||
if (StartIndex + Entries > palette->logpalette->palNumEntries)
|
if (StartIndex + Entries > palette->NumColors)
|
||||||
Entries = palette->logpalette->palNumEntries - StartIndex;
|
Entries = palette->NumColors - StartIndex;
|
||||||
|
|
||||||
for (end = Colors + Entries; Colors < end; palEntry++, Colors++)
|
for (end = Colors + Entries; Colors < end; palEntry++, Colors++)
|
||||||
{
|
{
|
||||||
|
@ -892,11 +892,11 @@ DIB_MapPaletteColors(PDC dc, CONST BITMAPINFO* lpbmi)
|
||||||
RGBQUAD *lpRGB;
|
RGBQUAD *lpRGB;
|
||||||
ULONG nNumColors,i;
|
ULONG nNumColors,i;
|
||||||
DWORD *lpIndex;
|
DWORD *lpIndex;
|
||||||
PPALOBJ palObj;
|
PPALGDI palGDI;
|
||||||
|
|
||||||
palObj = (PPALOBJ) PALETTE_LockPalette(dc->DevInfo->hpalDefault);
|
palGDI = PALETTE_LockPalette(dc->DevInfo->hpalDefault);
|
||||||
|
|
||||||
if (NULL == palObj)
|
if (NULL == palGDI)
|
||||||
{
|
{
|
||||||
// RELEASEDCINFO(hDC);
|
// RELEASEDCINFO(hDC);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -913,9 +913,9 @@ DIB_MapPaletteColors(PDC dc, CONST BITMAPINFO* lpbmi)
|
||||||
|
|
||||||
for (i = 0; i < nNumColors; i++)
|
for (i = 0; i < nNumColors; i++)
|
||||||
{
|
{
|
||||||
lpRGB[i].rgbRed = palObj->logpalette->palPalEntry[*lpIndex].peRed;
|
lpRGB[i].rgbRed = palGDI->IndexedColors[*lpIndex].peRed;
|
||||||
lpRGB[i].rgbGreen = palObj->logpalette->palPalEntry[*lpIndex].peGreen;
|
lpRGB[i].rgbGreen = palGDI->IndexedColors[*lpIndex].peGreen;
|
||||||
lpRGB[i].rgbBlue = palObj->logpalette->palPalEntry[*lpIndex].peBlue;
|
lpRGB[i].rgbBlue = palGDI->IndexedColors[*lpIndex].peBlue;
|
||||||
lpIndex++;
|
lpIndex++;
|
||||||
}
|
}
|
||||||
// RELEASEDCINFO(hDC);
|
// RELEASEDCINFO(hDC);
|
||||||
|
|
|
@ -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.13 2003/09/25 15:15:03 fireball Exp $ */
|
/* $Id: palette.c,v 1.14 2003/12/20 10:31:32 navaraf Exp $ */
|
||||||
|
|
||||||
#undef WIN32_LEAN_AND_MEAN
|
#undef WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -185,9 +185,10 @@ INT STDCALL PALETTE_SetMapping(PPALOBJ palPtr, UINT uStart, UINT uNum, BOOL mapO
|
||||||
int index, iRemapped = 0;
|
int index, iRemapped = 0;
|
||||||
int *mapping;
|
int *mapping;
|
||||||
HPALETTE hSysPal = NtGdiGetStockObject(DEFAULT_PALETTE);
|
HPALETTE hSysPal = NtGdiGetStockObject(DEFAULT_PALETTE);
|
||||||
PPALOBJ pSysPal = (PPALOBJ)PALETTE_LockPalette(hSysPal);
|
PPALGDI pSysPal = PALETTE_LockPalette(hSysPal);
|
||||||
|
PPALGDI palGDI = (PPALGDI) palPtr;
|
||||||
|
|
||||||
COLOR_sysPal = pSysPal->logpalette->palPalEntry;
|
COLOR_sysPal = pSysPal->IndexedColors;
|
||||||
PALETTE_UnlockPalette(hSysPal); // FIXME: Is this a right way to obtain pointer to the system palette?
|
PALETTE_UnlockPalette(hSysPal); // FIXME: Is this a right way to obtain pointer to the system palette?
|
||||||
|
|
||||||
|
|
||||||
|
@ -200,7 +201,7 @@ INT STDCALL PALETTE_SetMapping(PPALOBJ palPtr, UINT uStart, UINT uNum, BOOL mapO
|
||||||
//mapping = HeapReAlloc( GetProcessHeap(), 0, palPtr->mapping,
|
//mapping = HeapReAlloc( GetProcessHeap(), 0, palPtr->mapping,
|
||||||
// sizeof(int)*palPtr->logpalette->palNumEntries);
|
// sizeof(int)*palPtr->logpalette->palNumEntries);
|
||||||
ExFreePool(palPtr->mapping);
|
ExFreePool(palPtr->mapping);
|
||||||
mapping = ExAllocatePool(NonPagedPool, sizeof(int)*palPtr->logpalette->palNumEntries);
|
mapping = ExAllocatePool(NonPagedPool, sizeof(int)*palGDI->NumColors);
|
||||||
|
|
||||||
palPtr->mapping = mapping;
|
palPtr->mapping = mapping;
|
||||||
|
|
||||||
|
@ -209,11 +210,11 @@ INT STDCALL PALETTE_SetMapping(PPALOBJ palPtr, UINT uStart, UINT uNum, BOOL mapO
|
||||||
index = -1;
|
index = -1;
|
||||||
flag = PC_SYS_USED;
|
flag = PC_SYS_USED;
|
||||||
|
|
||||||
switch( palPtr->logpalette->palPalEntry[uStart].peFlags & 0x07 )
|
switch( palGDI->IndexedColors[uStart].peFlags & 0x07 )
|
||||||
{
|
{
|
||||||
case PC_EXPLICIT: // palette entries are indices into system palette
|
case PC_EXPLICIT: // palette entries are indices into system palette
|
||||||
// The PC_EXPLICIT flag is used to copy an entry from the system palette into the logical palette
|
// The PC_EXPLICIT flag is used to copy an entry from the system palette into the logical palette
|
||||||
index = *(WORD*)(palPtr->logpalette->palPalEntry + uStart);
|
index = *(WORD*)(palGDI->IndexedColors + uStart);
|
||||||
if(index > 255 || (index >= COLOR_gapStart && index <= COLOR_gapEnd))
|
if(index > 255 || (index >= COLOR_gapStart && index <= COLOR_gapEnd))
|
||||||
{
|
{
|
||||||
DbgPrint("Win32k: PC_EXPLICIT: idx %d out of system palette, assuming black.\n", index);
|
DbgPrint("Win32k: PC_EXPLICIT: idx %d out of system palette, assuming black.\n", index);
|
||||||
|
@ -228,7 +229,7 @@ INT STDCALL PALETTE_SetMapping(PPALOBJ palPtr, UINT uStart, UINT uNum, BOOL mapO
|
||||||
// fall through
|
// fall through
|
||||||
default: // try to collapse identical colors
|
default: // try to collapse identical colors
|
||||||
index = COLOR_PaletteLookupExactIndex(COLOR_sysPal, 256,
|
index = COLOR_PaletteLookupExactIndex(COLOR_sysPal, 256,
|
||||||
*(COLORREF*)(palPtr->logpalette->palPalEntry + uStart));
|
*(COLORREF*)(palGDI->IndexedColors + uStart));
|
||||||
// fall through
|
// fall through
|
||||||
|
|
||||||
case PC_NOCOLLAPSE:
|
case PC_NOCOLLAPSE:
|
||||||
|
@ -271,9 +272,9 @@ INT STDCALL PALETTE_SetMapping(PPALOBJ palPtr, UINT uStart, UINT uNum, BOOL mapO
|
||||||
// we have to map to existing entry in the system palette
|
// we have to map to existing entry in the system palette
|
||||||
|
|
||||||
index = COLOR_PaletteLookupPixel(COLOR_sysPal, 256, NULL,
|
index = COLOR_PaletteLookupPixel(COLOR_sysPal, 256, NULL,
|
||||||
*(COLORREF*)(palPtr->logpalette->palPalEntry + uStart), TRUE);
|
*(COLORREF*)(palGDI->IndexedColors + uStart), TRUE);
|
||||||
}
|
}
|
||||||
palPtr->logpalette->palPalEntry[uStart].peFlags |= PC_SYS_USED;
|
palGDI->IndexedColors[uStart].peFlags |= PC_SYS_USED;
|
||||||
|
|
||||||
/* if(PALETTE_PaletteToXPixel) index = PALETTE_PaletteToXPixel[index]; FIXME */
|
/* if(PALETTE_PaletteToXPixel) index = PALETTE_PaletteToXPixel[index]; FIXME */
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue