- remove duplicate prototype
  - use RGB macro where possible
  - we create BGR palette for RGB DIB sections, let's do the other way around
  - simplify overcomplicated IntGetDIBColorTable
  - Add a first implementation of IntRealizePalette
No, it's not the VLC icons bugfix

svn path=/trunk/; revision=50928
This commit is contained in:
Jérôme Gardou 2011-02-27 21:45:43 +00:00
parent ccebf72731
commit 5de8339cd1
5 changed files with 40 additions and 73 deletions

View file

@ -232,8 +232,6 @@ IntGetSystemPaletteEntries(HDC hDC,
UINT StartIndex,
UINT Entries,
LPPALETTEENTRY pe);
UINT APIENTRY
IntGetDIBColorTable(HDC hDC, UINT StartIndex, UINT Entries, RGBQUAD *Colors);
UINT APIENTRY
IntSetDIBColorTable(HDC hDC, UINT StartIndex, UINT Entries, CONST RGBQUAD *Colors);

View file

@ -562,8 +562,8 @@ NtGdiMaskBlt(
NtGdiBitBlt(hdcBack, 0, 0, nWidth, nHeight, hdcDest, nXDest, nYDest, BKGND_ROP3(dwRop), 0, 0);
/* 2.4 Erase the foreground pixels */
IntGdiSetBkColor(hdcBack, 0xffffffff);
IntGdiSetTextColor(hdcBack, 0);
IntGdiSetBkColor(hdcBack, RGB(0xFF, 0xFF, 0xFF));
IntGdiSetTextColor(hdcBack, RGB(0, 0, 0));
NtGdiBitBlt(hdcBack, 0, 0, nWidth, nHeight, hdcMask, xMask, yMask, SRCAND, 0, 0);
/* 3. Create masked Foreground bitmap */
@ -583,8 +583,8 @@ NtGdiMaskBlt(
NtGdiBitBlt(hdcFore, 0, 0, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, FRGND_ROP3(dwRop), 0,0);
/* 2.4 Erase the background pixels */
IntGdiSetBkColor(hdcFore, 0);
IntGdiSetTextColor(hdcFore, 0xffffffff);
IntGdiSetBkColor(hdcFore, RGB(0, 0, 0));
IntGdiSetTextColor(hdcFore, RGB(0xFF, 0xFF, 0xFF));
NtGdiBitBlt(hdcFore, 0, 0, nWidth, nHeight, hdcMask, xMask, yMask, SRCAND, 0, 0);
/* 3. Combine the fore and background into the background bitmap */

View file

@ -941,7 +941,7 @@ BITMAP_GetObject(SURFACE *psurf, INT Count, LPVOID buffer)
break;
case BMF_32BPP:
if (psurf->ppal->flFlags & PAL_RGB)
if (psurf->ppal->flFlags & (PAL_RGB|PAL_BGR))
pds->dsBmih.biCompression = BI_RGB;
else
pds->dsBmih.biCompression = BI_BITFIELDS;

View file

@ -193,9 +193,8 @@ IntGetDIBColorTable(
{
PDC dc;
PSURFACE psurf;
PPALETTE PalGDI;
PPALETTE ppal;
UINT Index, Count = 0;
ULONG biBitCount;
if (!(dc = DC_LockDc(hDC))) return 0;
if (dc->dctype == DC_TYPE_INFO)
@ -219,33 +218,22 @@ IntGetDIBColorTable(
return 0;
}
biBitCount = BitsPerFormat(psurf->SurfObj.iBitmapFormat);
if (biBitCount <= 8 &&
StartIndex < (1 << biBitCount))
ppal = psurf->ppal;
ASSERT(ppal);
if (ppal->flFlags & PAL_INDEXED)
{
if (StartIndex + Entries > (1 << biBitCount))
Entries = (1 << biBitCount) - StartIndex;
if (psurf->ppal == NULL)
{
DC_UnlockDc(dc);
EngSetLastError(ERROR_INVALID_HANDLE);
return 0;
}
PalGDI = PALETTE_LockPalette(psurf->ppal->BaseObject.hHmgr);
for (Index = StartIndex;
Index < StartIndex + Entries && Index < PalGDI->NumColors;
Index < StartIndex + Entries && Index < ppal->NumColors;
Index++)
{
Colors[Index - StartIndex].rgbRed = PalGDI->IndexedColors[Index].peRed;
Colors[Index - StartIndex].rgbGreen = PalGDI->IndexedColors[Index].peGreen;
Colors[Index - StartIndex].rgbBlue = PalGDI->IndexedColors[Index].peBlue;
Colors[Index - StartIndex].rgbRed = ppal->IndexedColors[Index].peRed;
Colors[Index - StartIndex].rgbGreen = ppal->IndexedColors[Index].peGreen;
Colors[Index - StartIndex].rgbBlue = ppal->IndexedColors[Index].peBlue;
Colors[Index - StartIndex].rgbReserved = 0;
Count++;
}
PALETTE_UnlockPalette(PalGDI);
}
DC_UnlockDc(dc);

View file

@ -725,58 +725,39 @@ UINT
FASTCALL
IntGdiRealizePalette(HDC hDC)
{
/*
* This function doesn't do any real work now and there's plenty
* of bugs in it.
*/
UINT i, realize = 0;
PDC pdc;
PALETTE *ppalSurf, *ppalDC;
PPALETTE palGDI, sysGDI;
int realized = 0;
PDC dc;
HPALETTE systemPalette;
pdc = DC_LockDc(hDC);
if(!pdc)
{
EngSetLastError(ERROR_INVALID_HANDLE);
return 0;
}
dc = DC_LockDc(hDC);
if (!dc) return 0;
ppalSurf = pdc->dclevel.pSurface->ppal;
ppalDC = pdc->dclevel.ppal;
systemPalette = NtGdiGetStockObject(DEFAULT_PALETTE);
palGDI = PALETTE_LockPalette(dc->dclevel.hpal);
if(!(ppalSurf->flFlags & PAL_INDEXED))
{
// FIXME : set error?
goto cleanup;
}
if (palGDI == NULL)
{
DPRINT1("IntGdiRealizePalette(): palGDI is NULL, exiting\n");
DC_UnlockDc(dc);
return 0;
}
ASSERT(ppalDC->flFlags & PAL_INDEXED);
sysGDI = PALETTE_LockPalette(systemPalette);
// FIXME : should we resize ppalSurf if it's too small?
realize = (ppalDC->NumColors < ppalSurf->NumColors) ? ppalDC->NumColors : ppalSurf->NumColors;
if (sysGDI == NULL)
{
DPRINT1("IntGdiRealizePalette(): sysGDI is NULL, exiting\n");
PALETTE_UnlockPalette(palGDI);
DC_UnlockDc(dc);
return 0;
}
for(i=0; i<realize; i++)
{
InterlockedExchange((LONG*)&ppalSurf->IndexedColors[i], *(LONG*)&ppalDC->IndexedColors[i]);
}
// The RealizePalette function modifies the palette for the device associated with the specified device context. If the
// device context is a memory DC, the color table for the bitmap selected into the DC is modified. If the device
// context is a display DC, the physical palette for that device is modified.
if(dc->dctype == DC_TYPE_MEMORY)
{
// Memory managed DC
DPRINT1("RealizePalette unimplemented for memory managed DCs\n");
} else
{
DPRINT1("RealizePalette unimplemented for device DCs\n");
}
// need to pass this to IntEngCreateXlate with palettes unlocked
PALETTE_UnlockPalette(sysGDI);
PALETTE_UnlockPalette(palGDI);
DC_UnlockDc(dc);
return realized;
cleanup:
DC_UnlockDc(pdc);
return realize;
}
UINT APIENTRY