- Update palette functions and small cleanup in bitmaps.

svn path=/trunk/; revision=37496
This commit is contained in:
James Tabor 2008-11-21 06:50:36 +00:00
parent 62a7ad910e
commit a16c4ab474
2 changed files with 68 additions and 5 deletions

View file

@ -341,8 +341,6 @@ CreateCompatibleBitmap(
}
INT
STDCALL
GetDIBits(
@ -392,7 +390,7 @@ GetDIBits(
uUsage,
cjBmpScanSize,
0);
if ( lpvBits )
if ( lpvBits != pvSafeBits)
{
RtlCopyMemory( lpvBits, pvSafeBits, cjBmpScanSize);
RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits);

View file

@ -3,6 +3,42 @@
#define NDEBUG
#include <debug.h>
#define NB_RESERVED_COLORS 20 /* number of fixed colors in system palette */
static const PALETTEENTRY sys_pal_template[NB_RESERVED_COLORS] =
{
/* first 10 entries in the system palette */
/* red green blue flags */
{ 0x00, 0x00, 0x00, 0 },
{ 0x80, 0x00, 0x00, 0 },
{ 0x00, 0x80, 0x00, 0 },
{ 0x80, 0x80, 0x00, 0 },
{ 0x00, 0x00, 0x80, 0 },
{ 0x80, 0x00, 0x80, 0 },
{ 0x00, 0x80, 0x80, 0 },
{ 0xc0, 0xc0, 0xc0, 0 },
{ 0xc0, 0xdc, 0xc0, 0 },
{ 0xa6, 0xca, 0xf0, 0 },
/* ... c_min/2 dynamic colorcells */
/* ... gap (for sparse palettes) */
/* ... c_min/2 dynamic colorcells */
{ 0xff, 0xfb, 0xf0, 0 },
{ 0xa0, 0xa0, 0xa4, 0 },
{ 0x80, 0x80, 0x80, 0 },
{ 0xff, 0x00, 0x00, 0 },
{ 0x00, 0xff, 0x00, 0 },
{ 0xff, 0xff, 0x00, 0 },
{ 0x00, 0x00, 0xff, 0 },
{ 0xff, 0x00, 0xff, 0 },
{ 0x00, 0xff, 0xff, 0 },
{ 0xff, 0xff, 0xff, 0 } /* last 10 */
};
BOOL
WINAPI
AnimatePalette(HPALETTE hpal,
@ -50,7 +86,34 @@ GetSystemPaletteEntries(HDC hDC,
UINT cEntries,
LPPALETTEENTRY ppe)
{
return NtGdiDoPalette(hDC, iStartIndex, cEntries, ppe, GdiPalGetSystemEntries, FALSE);
PALETTEENTRY ippe[256];
if (cEntries < 0) return 0;
else
{
if ( GetDeviceCaps(hDC, RASTERCAPS) & RC_PALETTE )
return NtGdiDoPalette(hDC, iStartIndex, cEntries, ppe, GdiPalGetSystemEntries, FALSE);
else
{
if (ppe)
{
RtlZeroMemory( &ippe, sizeof(ippe) );
RtlCopyMemory( &ippe, &sys_pal_template, sizeof(sys_pal_template) );
if (iStartIndex < 256)
{
INT Index = 256 - iStartIndex;
if ( Index >= cEntries ) Index = cEntries;
RtlCopyMemory( ppe,
&ippe[iStartIndex],
Index*sizeof(PALETTEENTRY));
}
}
}
}
return 0;
}
UINT
@ -60,7 +123,9 @@ GetDIBColorTable(HDC hDC,
UINT cEntries,
RGBQUAD *pColors)
{
return NtGdiDoPalette(hDC, iStartIndex, cEntries, pColors, GdiPalGetColorTable, FALSE);
if (cEntries)
return NtGdiDoPalette(hDC, iStartIndex, cEntries, pColors, GdiPalGetColorTable, FALSE);
return 0;
}
/*