When using DIB_PAL_COLORS select the current palette into the memory

dc so that SetDIBits works correctly.
This commit is contained in:
Huw Davies 2004-03-27 01:36:47 +00:00 committed by Alexandre Julliard
parent 7afb399802
commit 89b6080152
1 changed files with 8 additions and 0 deletions

View File

@ -173,6 +173,7 @@ INT WINAPI StretchDIBits(HDC hdc, INT xDst, INT yDst, INT widthDst,
else /* use StretchBlt */ else /* use StretchBlt */
{ {
HBITMAP hBitmap, hOldBitmap; HBITMAP hBitmap, hOldBitmap;
HPALETTE hpal = NULL;
HDC hdcMem; HDC hdcMem;
GDI_ReleaseObj( hdc ); GDI_ReleaseObj( hdc );
@ -180,6 +181,11 @@ INT WINAPI StretchDIBits(HDC hdc, INT xDst, INT yDst, INT widthDst,
hBitmap = CreateCompatibleBitmap(hdc, info->bmiHeader.biWidth, hBitmap = CreateCompatibleBitmap(hdc, info->bmiHeader.biWidth,
info->bmiHeader.biHeight); info->bmiHeader.biHeight);
hOldBitmap = SelectObject( hdcMem, hBitmap ); hOldBitmap = SelectObject( hdcMem, hBitmap );
if(wUsage == DIB_PAL_COLORS)
{
hpal = GetCurrentObject(hdc, OBJ_PAL);
hpal = SelectPalette(hdcMem, hpal, FALSE);
}
if (info->bmiHeader.biCompression == BI_RLE4 || if (info->bmiHeader.biCompression == BI_RLE4 ||
info->bmiHeader.biCompression == BI_RLE8) { info->bmiHeader.biCompression == BI_RLE8) {
@ -213,6 +219,8 @@ INT WINAPI StretchDIBits(HDC hdc, INT xDst, INT yDst, INT widthDst,
StretchBlt( hdc, xDst, yDst, widthDst, heightDst, StretchBlt( hdc, xDst, yDst, widthDst, heightDst,
hdcMem, xSrc, abs(info->bmiHeader.biHeight) - heightSrc - ySrc, hdcMem, xSrc, abs(info->bmiHeader.biHeight) - heightSrc - ySrc,
widthSrc, heightSrc, dwRop ); widthSrc, heightSrc, dwRop );
if(hpal)
SelectPalette(hdcMem, hpal, FALSE);
SelectObject( hdcMem, hOldBitmap ); SelectObject( hdcMem, hOldBitmap );
DeleteDC( hdcMem ); DeleteDC( hdcMem );
DeleteObject( hBitmap ); DeleteObject( hBitmap );