mirror of
https://github.com/reactos/reactos.git
synced 2025-07-29 15:02:03 +00:00
Bug : 1452 : patch from w3seek, some xlate obj fixes for indexed palettes, should fix a hack introduced in r21292
svn path=/trunk/; revision=21794
This commit is contained in:
parent
6da2349338
commit
bb9e90f468
2 changed files with 33 additions and 32 deletions
|
@ -158,9 +158,6 @@ typedef struct _XLATEGDI {
|
||||||
INT GreenShift;
|
INT GreenShift;
|
||||||
INT BlueShift;
|
INT BlueShift;
|
||||||
// };
|
// };
|
||||||
// struct { /* For Table Translations */
|
|
||||||
ULONG *translationTable;
|
|
||||||
// };
|
|
||||||
// struct { /* For Color -> Mono Translations */
|
// struct { /* For Color -> Mono Translations */
|
||||||
ULONG BackgroundColor;
|
ULONG BackgroundColor;
|
||||||
// };
|
// };
|
||||||
|
|
|
@ -181,6 +181,7 @@ IntEngCreateXlate(USHORT DestPalType, USHORT SourcePalType,
|
||||||
XlateObj->iSrcType = SourcePalType;
|
XlateObj->iSrcType = SourcePalType;
|
||||||
XlateObj->iDstType = DestPalType;
|
XlateObj->iDstType = DestPalType;
|
||||||
XlateObj->flXlate = 0;
|
XlateObj->flXlate = 0;
|
||||||
|
XlateObj->cEntries = 0;
|
||||||
|
|
||||||
/* Store handles of palettes in internal Xlate GDI object (or NULLs) */
|
/* Store handles of palettes in internal Xlate GDI object (or NULLs) */
|
||||||
XlateGDI->SourcePal = PaletteSource;
|
XlateGDI->SourcePal = PaletteSource;
|
||||||
|
@ -237,34 +238,34 @@ IntEngCreateXlate(USHORT DestPalType, USHORT SourcePalType,
|
||||||
/* Indexed -> Indexed */
|
/* Indexed -> Indexed */
|
||||||
if (SourcePalType == PAL_INDEXED && DestPalType == PAL_INDEXED)
|
if (SourcePalType == PAL_INDEXED && DestPalType == PAL_INDEXED)
|
||||||
{
|
{
|
||||||
XlateGDI->translationTable =
|
XlateObj->cEntries = SourcePalGDI->NumColors;
|
||||||
EngAllocMem(0, sizeof(ULONG) * SourcePalGDI->NumColors, 0);
|
XlateObj->pulXlate =
|
||||||
|
EngAllocMem(0, sizeof(ULONG) * XlateObj->cEntries, 0);
|
||||||
|
|
||||||
XlateObj->flXlate |= XO_TRIVIAL;
|
XlateObj->flXlate |= XO_TRIVIAL;
|
||||||
for (i = 0; i < SourcePalGDI->NumColors; i++)
|
for (i = 0; i < XlateObj->cEntries; i++)
|
||||||
{
|
{
|
||||||
XlateGDI->translationTable[i] = ClosestColorMatch(
|
XlateObj->pulXlate[i] = ClosestColorMatch(
|
||||||
XlateGDI, SourcePalGDI->IndexedColors + i,
|
XlateGDI, SourcePalGDI->IndexedColors + i,
|
||||||
DestPalGDI->IndexedColors, DestPalGDI->NumColors);
|
DestPalGDI->IndexedColors, XlateObj->cEntries);
|
||||||
if (XlateGDI->translationTable[i] != i)
|
if (XlateObj->pulXlate[i] != i)
|
||||||
XlateObj->flXlate &= ~XO_TRIVIAL;
|
XlateObj->flXlate &= ~XO_TRIVIAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
XlateObj->flXlate |= XO_TABLE;
|
XlateObj->flXlate |= XO_TABLE;
|
||||||
XlateObj->pulXlate = XlateGDI->translationTable;
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Indexed -> Bitfields/RGB/BGR */
|
/* Indexed -> Bitfields/RGB/BGR */
|
||||||
if (SourcePalType == PAL_INDEXED)
|
if (SourcePalType == PAL_INDEXED)
|
||||||
{
|
{
|
||||||
XlateGDI->translationTable =
|
XlateObj->cEntries = SourcePalGDI->NumColors;
|
||||||
EngAllocMem(0, sizeof(ULONG) * SourcePalGDI->NumColors, 0);
|
XlateObj->pulXlate =
|
||||||
for (i = 0; i < SourcePalGDI->NumColors; i++)
|
EngAllocMem(0, sizeof(ULONG) * XlateObj->cEntries, 0);
|
||||||
XlateGDI->translationTable[i] =
|
for (i = 0; i < XlateObj->cEntries; i++)
|
||||||
|
XlateObj->pulXlate[i] =
|
||||||
ShiftAndMask(XlateGDI, *((ULONG *)&SourcePalGDI->IndexedColors[i]));
|
ShiftAndMask(XlateGDI, *((ULONG *)&SourcePalGDI->IndexedColors[i]));
|
||||||
XlateObj->flXlate |= XO_TABLE;
|
XlateObj->flXlate |= XO_TABLE;
|
||||||
XlateObj->pulXlate = XlateGDI->translationTable;
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,6 +314,7 @@ IntEngCreateMonoXlate(
|
||||||
XlateGDI->SourcePal = PaletteSource;
|
XlateGDI->SourcePal = PaletteSource;
|
||||||
|
|
||||||
XlateObj->flXlate = XO_TO_MONO;
|
XlateObj->flXlate = XO_TO_MONO;
|
||||||
|
XlateObj->cEntries = 1;
|
||||||
XlateObj->pulXlate = &XlateGDI->BackgroundColor;
|
XlateObj->pulXlate = &XlateGDI->BackgroundColor;
|
||||||
switch (SourcePalType)
|
switch (SourcePalType)
|
||||||
{
|
{
|
||||||
|
@ -368,16 +370,15 @@ IntEngCreateSrcMonoXlate(HPALETTE PaletteDest,
|
||||||
}
|
}
|
||||||
XlateObj = GDIToObj(XlateGDI, XLATE);
|
XlateObj = GDIToObj(XlateGDI, XLATE);
|
||||||
|
|
||||||
XlateGDI->translationTable = EngAllocMem(0, sizeof(ULONG) * 2, 0);
|
XlateObj->cEntries = 2;
|
||||||
if (XlateGDI->translationTable == NULL)
|
XlateObj->pulXlate = EngAllocMem(0, sizeof(ULONG) * XlateObj->cEntries, 0);
|
||||||
|
if (XlateObj->pulXlate == NULL)
|
||||||
{
|
{
|
||||||
PALETTE_UnlockPalette(DestPalGDI);
|
PALETTE_UnlockPalette(DestPalGDI);
|
||||||
EngFreeMem(XlateGDI);
|
EngFreeMem(XlateGDI);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
XlateObj->pulXlate = XlateGDI->translationTable;
|
|
||||||
|
|
||||||
XlateObj->iSrcType = PAL_INDEXED;
|
XlateObj->iSrcType = PAL_INDEXED;
|
||||||
XlateObj->iDstType = DestPalGDI->Mode;
|
XlateObj->iDstType = DestPalGDI->Mode;
|
||||||
|
|
||||||
|
@ -394,19 +395,19 @@ IntEngCreateSrcMonoXlate(HPALETTE PaletteDest,
|
||||||
XlateGDI->GreenShift = CalculateShift(RGB(0x00, 0xFF, 0x00)) - CalculateShift(XlateGDI->GreenMask);
|
XlateGDI->GreenShift = CalculateShift(RGB(0x00, 0xFF, 0x00)) - CalculateShift(XlateGDI->GreenMask);
|
||||||
XlateGDI->BlueShift = CalculateShift(RGB(0x00, 0x00, 0xFF)) - CalculateShift(XlateGDI->BlueMask);
|
XlateGDI->BlueShift = CalculateShift(RGB(0x00, 0x00, 0xFF)) - CalculateShift(XlateGDI->BlueMask);
|
||||||
|
|
||||||
XlateGDI->translationTable[0] = ShiftAndMask(XlateGDI, BackgroundColor);
|
XlateObj->pulXlate[0] = ShiftAndMask(XlateGDI, BackgroundColor);
|
||||||
XlateGDI->translationTable[1] = ShiftAndMask(XlateGDI, ForegroundColor);
|
XlateObj->pulXlate[1] = ShiftAndMask(XlateGDI, ForegroundColor);
|
||||||
|
|
||||||
if (XlateObj->iDstType == PAL_INDEXED)
|
if (XlateObj->iDstType == PAL_INDEXED)
|
||||||
{
|
{
|
||||||
XlateGDI->translationTable[0] =
|
XlateObj->pulXlate[0] =
|
||||||
ClosestColorMatch(XlateGDI,
|
ClosestColorMatch(XlateGDI,
|
||||||
(LPPALETTEENTRY)&XlateGDI->translationTable[0],
|
(LPPALETTEENTRY)&XlateObj->pulXlate[0],
|
||||||
DestPalGDI->IndexedColors,
|
DestPalGDI->IndexedColors,
|
||||||
DestPalGDI->NumColors);
|
DestPalGDI->NumColors);
|
||||||
XlateGDI->translationTable[1] =
|
XlateObj->pulXlate[1] =
|
||||||
ClosestColorMatch(XlateGDI,
|
ClosestColorMatch(XlateGDI,
|
||||||
(LPPALETTEENTRY)&XlateGDI->translationTable[1],
|
(LPPALETTEENTRY)&XlateObj->pulXlate[1],
|
||||||
DestPalGDI->IndexedColors,
|
DestPalGDI->IndexedColors,
|
||||||
DestPalGDI->NumColors);
|
DestPalGDI->NumColors);
|
||||||
}
|
}
|
||||||
|
@ -453,9 +454,9 @@ EngDeleteXlate(XLATEOBJ *XlateObj)
|
||||||
XlateGDI = ObjToGDI(XlateObj, XLATE);
|
XlateGDI = ObjToGDI(XlateObj, XLATE);
|
||||||
|
|
||||||
if ((XlateObj->flXlate & XO_TABLE) &&
|
if ((XlateObj->flXlate & XO_TABLE) &&
|
||||||
XlateGDI->translationTable != NULL)
|
XlateObj->pulXlate != NULL)
|
||||||
{
|
{
|
||||||
EngFreeMem(XlateGDI->translationTable);
|
EngFreeMem(XlateObj->pulXlate);
|
||||||
}
|
}
|
||||||
|
|
||||||
EngFreeMem(XlateGDI);
|
EngFreeMem(XlateGDI);
|
||||||
|
@ -467,11 +468,9 @@ EngDeleteXlate(XLATEOBJ *XlateObj)
|
||||||
PULONG STDCALL
|
PULONG STDCALL
|
||||||
XLATEOBJ_piVector(XLATEOBJ *XlateObj)
|
XLATEOBJ_piVector(XLATEOBJ *XlateObj)
|
||||||
{
|
{
|
||||||
XLATEGDI *XlateGDI = ObjToGDI(XlateObj, XLATE);
|
|
||||||
|
|
||||||
if (XlateObj->iSrcType == PAL_INDEXED)
|
if (XlateObj->iSrcType == PAL_INDEXED)
|
||||||
{
|
{
|
||||||
return XlateGDI->translationTable;
|
return XlateObj->pulXlate;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -494,8 +493,13 @@ XLATEOBJ_iXlate(XLATEOBJ *XlateObj, ULONG Color)
|
||||||
if (XlateObj->flXlate & XO_TRIVIAL)
|
if (XlateObj->flXlate & XO_TRIVIAL)
|
||||||
return Color;
|
return Color;
|
||||||
|
|
||||||
if ((XlateObj->flXlate & XO_TABLE))
|
if (XlateObj->flXlate & XO_TABLE)
|
||||||
return XlateObj->pulXlate[Color & 0xff];
|
{
|
||||||
|
if (Color >= XlateObj->cEntries)
|
||||||
|
Color %= XlateObj->cEntries;
|
||||||
|
|
||||||
|
return XlateObj->pulXlate[Color];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (XlateObj->flXlate & XO_TO_MONO)
|
if (XlateObj->flXlate & XO_TO_MONO)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue