It's possible to select an (indexed) palette into a bitfield (e.g. 16 bit

deep) DC. This palette will be used when calling CreateDIBSection with
DIB_PAL_COLORS usage. Fixes bug 1077.

svn path=/trunk/; revision=19967
This commit is contained in:
Gé van Geldorp 2005-12-08 17:34:48 +00:00
parent d108d4822a
commit 2c2515fd46
4 changed files with 17 additions and 1 deletions

View file

@ -100,6 +100,8 @@ typedef struct _DC
INT saveLevel;
BOOL IsIC;
HPALETTE PalIndexed;
WIN_DC_INFO w;
} DC, *PDC;

View file

@ -509,6 +509,12 @@ HPALETTE STDCALL NtGdiSelectPalette(HDC hDC,
oldPal = dc->w.hPalette;
dc->w.hPalette = hpal;
}
else if (8 < dc->w.bitsPerPixel && PAL_INDEXED == PalGDI->Mode)
{
PALETTE_UnlockPalette(PalGDI);
oldPal = dc->PalIndexed;
dc->PalIndexed = hpal;
}
else
{
PALETTE_UnlockPalette(PalGDI);

View file

@ -222,6 +222,7 @@ NtGdiCreateCompatibleDC(HDC hDC)
NewDC->w.hFirstBitmap = hBitmap;
NewDC->GDIDevice = OrigDC->GDIDevice;
NewDC->PalIndexed = OrigDC->PalIndexed;
NewDC->w.hPalette = OrigDC->w.hPalette;
NewDC->w.textColor = OrigDC->w.textColor;
NewDC->w.textAlign = OrigDC->w.textAlign;
@ -905,6 +906,7 @@ IntGdiCreateDC(PUNICODE_STRING Driver,
if (! CreateAsIC)
{
NewDC->PalIndexed = NtGdiGetStockObject(DEFAULT_PALETTE);
NewDC->w.hPalette = NewDC->DevInfo->hpalDefault;
NewDC->w.ROPmode = R2_COPYPEN;
@ -1315,6 +1317,7 @@ NtGdiGetDCState(HDC hDC)
#if 0
newdc->w.hDevice = dc->w.hDevice;
#endif
newdc->PalIndexed = dc->PalIndexed;
newdc->w.hPalette = dc->w.hPalette;
newdc->w.totalExtent = dc->w.totalExtent;
newdc->w.bitsPerPixel = dc->w.bitsPerPixel;
@ -1440,6 +1443,7 @@ NtGdiSetDCState ( HDC hDC, HDC hDCSave )
dc->vportOrgY = dcs->vportOrgY;
dc->vportExtX = dcs->vportExtX;
dc->vportExtY = dcs->vportExtY;
dc->PalIndexed = dcs->PalIndexed;
if (!(dc->w.flags & DC_MEMORY))
{

View file

@ -1108,7 +1108,11 @@ DIB_MapPaletteColors(PDC dc, CONST BITMAPINFO* lpbmi)
if (palGDI->Mode != PAL_INDEXED)
{
PALETTE_UnlockPalette(palGDI);
return NULL;
palGDI = PALETTE_LockPalette(dc->PalIndexed);
if (palGDI->Mode != PAL_INDEXED)
{
return NULL;
}
}
nNumColors = 1 << lpbmi->bmiHeader.biBitCount;