mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 07:46:29 +00:00
[WIN32K/NTGDI]
- Better semi-implementation of CreateHalftonePalette svn path=/trunk/; revision=63677
This commit is contained in:
parent
2bfabe5522
commit
0f7a53e999
2 changed files with 61 additions and 89 deletions
|
@ -65,7 +65,7 @@ InitPaletteImpl()
|
||||||
// Create default palette (20 system colors)
|
// Create default palette (20 system colors)
|
||||||
gppalDefault = PALETTE_AllocPalWithHandle(PAL_INDEXED,
|
gppalDefault = PALETTE_AllocPalWithHandle(PAL_INDEXED,
|
||||||
20,
|
20,
|
||||||
(PULONG)g_sysPalTemplate,
|
g_sysPalTemplate,
|
||||||
0, 0, 0);
|
0, 0, 0);
|
||||||
GDIOBJ_vReferenceObjectByPointer(&gppalDefault->BaseObject);
|
GDIOBJ_vReferenceObjectByPointer(&gppalDefault->BaseObject);
|
||||||
PALETTE_UnlockPalette(gppalDefault);
|
PALETTE_UnlockPalette(gppalDefault);
|
||||||
|
@ -132,7 +132,7 @@ NTAPI
|
||||||
PALETTE_AllocPalette(
|
PALETTE_AllocPalette(
|
||||||
_In_ ULONG iMode,
|
_In_ ULONG iMode,
|
||||||
_In_ ULONG cColors,
|
_In_ ULONG cColors,
|
||||||
_In_opt_ PULONG pulColors,
|
_In_opt_ const PALETTEENTRY* pEntries,
|
||||||
_In_ FLONG flRed,
|
_In_ FLONG flRed,
|
||||||
_In_ FLONG flGreen,
|
_In_ FLONG flGreen,
|
||||||
_In_ FLONG flBlue)
|
_In_ FLONG flBlue)
|
||||||
|
@ -174,12 +174,10 @@ PALETTE_AllocPalette(
|
||||||
if (iMode & PAL_INDEXED)
|
if (iMode & PAL_INDEXED)
|
||||||
{
|
{
|
||||||
/* Check if we got a color array */
|
/* Check if we got a color array */
|
||||||
if (pulColors)
|
if (pEntries)
|
||||||
{
|
{
|
||||||
/* Copy the entries */
|
/* Copy the entries */
|
||||||
RtlCopyMemory(ppal->IndexedColors,
|
RtlCopyMemory(ppal->IndexedColors, pEntries, cColors * sizeof(pEntries[0]));
|
||||||
pulColors,
|
|
||||||
cColors * sizeof(ULONG));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (iMode & PAL_BITFIELDS)
|
else if (iMode & PAL_BITFIELDS)
|
||||||
|
@ -208,7 +206,7 @@ NTAPI
|
||||||
PALETTE_AllocPalWithHandle(
|
PALETTE_AllocPalWithHandle(
|
||||||
_In_ ULONG iMode,
|
_In_ ULONG iMode,
|
||||||
_In_ ULONG cColors,
|
_In_ ULONG cColors,
|
||||||
_In_opt_ PULONG pulColors,
|
_In_opt_ const PALETTEENTRY* pEntries,
|
||||||
_In_ FLONG flRed,
|
_In_ FLONG flRed,
|
||||||
_In_ FLONG flGreen,
|
_In_ FLONG flGreen,
|
||||||
_In_ FLONG flBlue)
|
_In_ FLONG flBlue)
|
||||||
|
@ -216,7 +214,7 @@ PALETTE_AllocPalWithHandle(
|
||||||
PPALETTE ppal;
|
PPALETTE ppal;
|
||||||
|
|
||||||
/* Allocate the palette without a handle */
|
/* Allocate the palette without a handle */
|
||||||
ppal = PALETTE_AllocPalette(iMode, cColors, pulColors, flRed, flGreen, flBlue);
|
ppal = PALETTE_AllocPalette(iMode, cColors, pEntries, flRed, flGreen, flBlue);
|
||||||
if (!ppal) return NULL;
|
if (!ppal) return NULL;
|
||||||
|
|
||||||
/* Insert the palette into the handle table */
|
/* Insert the palette into the handle table */
|
||||||
|
@ -382,7 +380,7 @@ EngCreatePalette(
|
||||||
PPALETTE ppal;
|
PPALETTE ppal;
|
||||||
HPALETTE hpal;
|
HPALETTE hpal;
|
||||||
|
|
||||||
ppal = PALETTE_AllocPalette(iMode, cColors, pulColors, flRed, flGreen, flBlue);
|
ppal = PALETTE_AllocPalette(iMode, cColors, (PPALETTEENTRY)pulColors, flRed, flGreen, flBlue);
|
||||||
if (!ppal) return NULL;
|
if (!ppal) return NULL;
|
||||||
|
|
||||||
hpal = GDIOBJ_hInsertObject(&ppal->BaseObject, GDI_OBJ_HMGR_PUBLIC);
|
hpal = GDIOBJ_hInsertObject(&ppal->BaseObject, GDI_OBJ_HMGR_PUBLIC);
|
||||||
|
@ -454,7 +452,7 @@ GreCreatePaletteInternal(
|
||||||
pLogPal->palNumEntries = cEntries;
|
pLogPal->palNumEntries = cEntries;
|
||||||
ppal = PALETTE_AllocPalWithHandle(PAL_INDEXED,
|
ppal = PALETTE_AllocPalWithHandle(PAL_INDEXED,
|
||||||
cEntries,
|
cEntries,
|
||||||
(PULONG)pLogPal->palPalEntry,
|
pLogPal->palPalEntry,
|
||||||
0, 0, 0);
|
0, 0, 0);
|
||||||
|
|
||||||
if (ppal != NULL)
|
if (ppal != NULL)
|
||||||
|
@ -512,107 +510,81 @@ NtGdiCreatePaletteInternal(
|
||||||
return hpal;
|
return hpal;
|
||||||
}
|
}
|
||||||
|
|
||||||
HPALETTE APIENTRY NtGdiCreateHalftonePalette(HDC hDC)
|
HPALETTE
|
||||||
|
APIENTRY
|
||||||
|
NtGdiCreateHalftonePalette(HDC hDC)
|
||||||
{
|
{
|
||||||
int i, r, g, b;
|
int i, r, g, b;
|
||||||
struct {
|
PALETTEENTRY PalEntries[256];
|
||||||
WORD Version;
|
PPALETTE ppal;
|
||||||
WORD NumberOfEntries;
|
PDC pdc;
|
||||||
PALETTEENTRY aEntries[256];
|
HPALETTE hpal = NULL;
|
||||||
} Palette;
|
|
||||||
|
|
||||||
Palette.Version = 0x300;
|
pdc = DC_LockDc(hDC);
|
||||||
Palette.NumberOfEntries = 256;
|
if (!pdc)
|
||||||
if (IntGetSystemPaletteEntries(hDC, 0, 256, Palette.aEntries) == 0)
|
|
||||||
{
|
{
|
||||||
/* From WINE, more that 256 color math */
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
||||||
Palette.NumberOfEntries = 20;
|
return NULL;
|
||||||
for (i = 0; i < Palette.NumberOfEntries; i++)
|
}
|
||||||
{
|
|
||||||
Palette.aEntries[i].peRed=0xff;
|
|
||||||
Palette.aEntries[i].peGreen=0xff;
|
|
||||||
Palette.aEntries[i].peBlue=0xff;
|
|
||||||
Palette.aEntries[i].peFlags=0x00;
|
|
||||||
}
|
|
||||||
|
|
||||||
Palette.aEntries[0].peRed=0x00;
|
RtlZeroMemory(PalEntries, sizeof(PalEntries));
|
||||||
Palette.aEntries[0].peBlue=0x00;
|
|
||||||
Palette.aEntries[0].peGreen=0x00;
|
|
||||||
|
|
||||||
/* The first 6 */
|
/* First and last ten entries are default ones */
|
||||||
for (i=1; i <= 6; i++)
|
for (i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
Palette.aEntries[i].peRed=(i%2)?0x80:0;
|
PalEntries[i].peRed = g_sysPalTemplate[i].peRed;
|
||||||
Palette.aEntries[i].peGreen=(i==2)?0x80:(i==3)?0x80:(i==6)?0x80:0;
|
PalEntries[i].peGreen = g_sysPalTemplate[i].peGreen;
|
||||||
Palette.aEntries[i].peBlue=(i>3)?0x80:0;
|
PalEntries[i].peBlue = g_sysPalTemplate[i].peBlue;
|
||||||
}
|
|
||||||
|
|
||||||
for (i=7; i <= 12; i++)
|
PalEntries[246 + i].peRed = g_sysPalTemplate[10 + i].peRed;
|
||||||
{
|
PalEntries[246 + i].peGreen = g_sysPalTemplate[10 + i].peGreen;
|
||||||
switch(i)
|
PalEntries[246 + i].peBlue = g_sysPalTemplate[10 + i].peBlue;
|
||||||
{
|
}
|
||||||
case 7:
|
|
||||||
Palette.aEntries[i].peRed=0xc0;
|
|
||||||
Palette.aEntries[i].peBlue=0xc0;
|
|
||||||
Palette.aEntries[i].peGreen=0xc0;
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
Palette.aEntries[i].peRed=0xc0;
|
|
||||||
Palette.aEntries[i].peGreen=0xdc;
|
|
||||||
Palette.aEntries[i].peBlue=0xc0;
|
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
Palette.aEntries[i].peRed=0xa6;
|
|
||||||
Palette.aEntries[i].peGreen=0xca;
|
|
||||||
Palette.aEntries[i].peBlue=0xf0;
|
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
Palette.aEntries[i].peRed=0xff;
|
|
||||||
Palette.aEntries[i].peGreen=0xfb;
|
|
||||||
Palette.aEntries[i].peBlue=0xf0;
|
|
||||||
break;
|
|
||||||
case 11:
|
|
||||||
Palette.aEntries[i].peRed=0xa0;
|
|
||||||
Palette.aEntries[i].peGreen=0xa0;
|
|
||||||
Palette.aEntries[i].peBlue=0xa4;
|
|
||||||
break;
|
|
||||||
case 12:
|
|
||||||
Palette.aEntries[i].peRed=0x80;
|
|
||||||
Palette.aEntries[i].peGreen=0x80;
|
|
||||||
Palette.aEntries[i].peBlue=0x80;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i=13; i <= 18; i++)
|
ppal = PALETTE_ShareLockPalette(pdc->dclevel.hpal);
|
||||||
{
|
if (ppal && (ppal->flFlags & PAL_INDEXED))
|
||||||
Palette.aEntries[i].peRed=(i%2)?0xff:0;
|
{
|
||||||
Palette.aEntries[i].peGreen=(i==14)?0xff:(i==15)?0xff:(i==18)?0xff:0;
|
/* FIXME: optimize the palette for the current palette */
|
||||||
Palette.aEntries[i].peBlue=(i>15)?0xff:0x00;
|
UNIMPLEMENTED
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* 256 color table */
|
|
||||||
for (r = 0; r < 6; r++)
|
for (r = 0; r < 6; r++)
|
||||||
|
{
|
||||||
for (g = 0; g < 6; g++)
|
for (g = 0; g < 6; g++)
|
||||||
|
{
|
||||||
for (b = 0; b < 6; b++)
|
for (b = 0; b < 6; b++)
|
||||||
{
|
{
|
||||||
i = r + g*6 + b*36 + 10;
|
i = r + g*6 + b*36 + 10;
|
||||||
Palette.aEntries[i].peRed = r * 51;
|
PalEntries[i].peRed = r * 51;
|
||||||
Palette.aEntries[i].peGreen = g * 51;
|
PalEntries[i].peGreen = g * 51;
|
||||||
Palette.aEntries[i].peBlue = b * 51;
|
PalEntries[i].peBlue = b * 51;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 216; i < 246; i++)
|
for (i = 216; i < 246; i++)
|
||||||
{
|
{
|
||||||
int v = (i - 216) << 3;
|
int v = (i - 216) << 3;
|
||||||
Palette.aEntries[i].peRed = v;
|
PalEntries[i].peRed = v;
|
||||||
Palette.aEntries[i].peGreen = v;
|
PalEntries[i].peGreen = v;
|
||||||
Palette.aEntries[i].peBlue = v;
|
PalEntries[i].peBlue = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return GreCreatePaletteInternal((LOGPALETTE *)&Palette, Palette.NumberOfEntries);
|
if (ppal)
|
||||||
|
PALETTE_ShareUnlockPalette(ppal);
|
||||||
|
|
||||||
|
DC_UnlockDc(pdc);
|
||||||
|
|
||||||
|
ppal = PALETTE_AllocPalWithHandle(PAL_INDEXED, 256, PalEntries, 0, 0, 0);
|
||||||
|
if (ppal)
|
||||||
|
{
|
||||||
|
hpal = ppal->BaseObject.hHmgr;
|
||||||
|
PALETTE_UnlockPalette(ppal);
|
||||||
|
}
|
||||||
|
|
||||||
|
return hpal;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
|
|
|
@ -65,7 +65,7 @@ NTAPI
|
||||||
PALETTE_AllocPalette(
|
PALETTE_AllocPalette(
|
||||||
_In_ ULONG iMode,
|
_In_ ULONG iMode,
|
||||||
_In_ ULONG cColors,
|
_In_ ULONG cColors,
|
||||||
_In_opt_ PULONG pulColors,
|
_In_opt_ const PALETTEENTRY* pEntries,
|
||||||
_In_ FLONG flRed,
|
_In_ FLONG flRed,
|
||||||
_In_ FLONG flGreen,
|
_In_ FLONG flGreen,
|
||||||
_In_ FLONG flBlue);
|
_In_ FLONG flBlue);
|
||||||
|
@ -75,7 +75,7 @@ NTAPI
|
||||||
PALETTE_AllocPalWithHandle(
|
PALETTE_AllocPalWithHandle(
|
||||||
_In_ ULONG iMode,
|
_In_ ULONG iMode,
|
||||||
_In_ ULONG cColors,
|
_In_ ULONG cColors,
|
||||||
_In_opt_ PULONG pulColors,
|
_In_opt_ const PALETTEENTRY* pEntries,
|
||||||
_In_ FLONG flRed,
|
_In_ FLONG flRed,
|
||||||
_In_ FLONG flGreen,
|
_In_ FLONG flGreen,
|
||||||
_In_ FLONG flBlue);
|
_In_ FLONG flBlue);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue