diff --git a/reactos/dll/win32/gdi32/objects/bitmap.c b/reactos/dll/win32/gdi32/objects/bitmap.c index 6fcb97fb6ce..a16cc8661d5 100644 --- a/reactos/dll/win32/gdi32/objects/bitmap.c +++ b/reactos/dll/win32/gdi32/objects/bitmap.c @@ -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); diff --git a/reactos/dll/win32/gdi32/objects/palette.c b/reactos/dll/win32/gdi32/objects/palette.c index ac9ea25ffa0..bbfa6e76bc6 100644 --- a/reactos/dll/win32/gdi32/objects/palette.c +++ b/reactos/dll/win32/gdi32/objects/palette.c @@ -3,6 +3,42 @@ #define NDEBUG #include + +#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; } /*