From 352b8bc9e89fe45c8026474eeae3df2768f974f9 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Wed, 12 Nov 2003 22:42:26 +0000 Subject: [PATCH] Make sure we create a polychrome bitmap from the dib. CreateDIBitmap doesn't do this when the dib is 1bpp and has a black/white colour table. In such cases this resulted in a monochrome bitmap being StretchBlt'ed which is clearly incorrect since we then start using text and bkgnd colours. --- objects/dib.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/objects/dib.c b/objects/dib.c index 5df8c8ae808..7f3127f48dc 100644 --- a/objects/dib.c +++ b/objects/dib.c @@ -164,7 +164,7 @@ INT WINAPI StretchDIBits(HDC hdc, INT xDst, INT yDst, INT widthDst, dc = DC_GetDCUpdate( hdc ); if(!dc) return FALSE; - + if(dc->funcs->pStretchDIBits) { heightSrc = dc->funcs->pStretchDIBits(dc->physDev, xDst, yDst, widthDst, @@ -179,6 +179,10 @@ INT WINAPI StretchDIBits(HDC hdc, INT xDst, INT yDst, INT widthDst, GDI_ReleaseObj( hdc ); hdcMem = CreateCompatibleDC( hdc ); + hBitmap = CreateCompatibleBitmap(hdc, info->bmiHeader.biWidth, + info->bmiHeader.biHeight); + hOldBitmap = SelectObject( hdcMem, hBitmap ); + if (info->bmiHeader.biCompression == BI_RLE4 || info->bmiHeader.biCompression == BI_RLE8) { @@ -196,22 +200,15 @@ INT WINAPI StretchDIBits(HDC hdc, INT xDst, INT yDst, INT widthDst, * pStretchDIBits function shall be implemented. * ericP (2000/09/09) */ - hBitmap = CreateCompatibleBitmap(hdc, info->bmiHeader.biWidth, - info->bmiHeader.biHeight); - hOldBitmap = SelectObject( hdcMem, hBitmap ); - /* copy existing bitmap from destination dc */ - StretchBlt( hdcMem, xSrc, abs(info->bmiHeader.biHeight) - heightSrc - ySrc, - widthSrc, heightSrc, hdc, xDst, yDst, widthDst, heightDst, - dwRop ); - SetDIBits(hdcMem, hBitmap, 0, info->bmiHeader.biHeight, bits, - info, DIB_RGB_COLORS); + /* copy existing bitmap from destination dc */ + StretchBlt( hdcMem, xSrc, abs(info->bmiHeader.biHeight) - heightSrc - ySrc, + widthSrc, heightSrc, hdc, xDst, yDst, widthDst, heightDst, + dwRop ); + } - } else { - hBitmap = CreateDIBitmap( hdc, &info->bmiHeader, CBM_INIT, - bits, info, wUsage ); - hOldBitmap = SelectObject( hdcMem, hBitmap ); - } + SetDIBits(hdcMem, hBitmap, 0, info->bmiHeader.biHeight, bits, + info, wUsage); /* Origin for DIBitmap may be bottom left (positive biHeight) or top left (negative biHeight) */