Author: jimtabor Date: Fri Nov 21 00:50:36 2008 New Revision: 37496
URL: http://svn.reactos.org/svn/reactos?rev=37496&view=rev Log: - Update palette functions and small cleanup in bitmaps.
Modified: trunk/reactos/dll/win32/gdi32/objects/bitmap.c trunk/reactos/dll/win32/gdi32/objects/palette.c
Modified: trunk/reactos/dll/win32/gdi32/objects/bitmap.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/objects/bit... ============================================================================== --- trunk/reactos/dll/win32/gdi32/objects/bitmap.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/gdi32/objects/bitmap.c [iso-8859-1] Fri Nov 21 00:50:36 2008 @@ -341,8 +341,6 @@ }
- - INT STDCALL GetDIBits( @@ -392,7 +390,7 @@ uUsage, cjBmpScanSize, 0); - if ( lpvBits ) + if ( lpvBits != pvSafeBits) { RtlCopyMemory( lpvBits, pvSafeBits, cjBmpScanSize); RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits);
Modified: trunk/reactos/dll/win32/gdi32/objects/palette.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/objects/pal... ============================================================================== --- trunk/reactos/dll/win32/gdi32/objects/palette.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/gdi32/objects/palette.c [iso-8859-1] Fri Nov 21 00:50:36 2008 @@ -2,6 +2,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 @@ -50,7 +86,34 @@ 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 @@ UINT cEntries, RGBQUAD *pColors) { - return NtGdiDoPalette(hDC, iStartIndex, cEntries, pColors, GdiPalGetColorTable, FALSE); + if (cEntries) + return NtGdiDoPalette(hDC, iStartIndex, cEntries, pColors, GdiPalGetColorTable, FALSE); + return 0; }
/*