When using DIB_PAL_COLORS select the current palette into the memory
dc so that SetDIBits works correctly.
diff --git a/objects/dib.c b/objects/dib.c
index 9e60a7e..83a6a1e 100644
--- a/objects/dib.c
+++ b/objects/dib.c
@@ -173,6 +173,7 @@
else /* use StretchBlt */
{
HBITMAP hBitmap, hOldBitmap;
+ HPALETTE hpal = NULL;
HDC hdcMem;
GDI_ReleaseObj( hdc );
@@ -180,6 +181,11 @@
hBitmap = CreateCompatibleBitmap(hdc, info->bmiHeader.biWidth,
info->bmiHeader.biHeight);
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 ||
info->bmiHeader.biCompression == BI_RLE8) {
@@ -213,6 +219,8 @@
StretchBlt( hdc, xDst, yDst, widthDst, heightDst,
hdcMem, xSrc, abs(info->bmiHeader.biHeight) - heightSrc - ySrc,
widthSrc, heightSrc, dwRop );
+ if(hpal)
+ SelectPalette(hdcMem, hpal, FALSE);
SelectObject( hdcMem, hOldBitmap );
DeleteDC( hdcMem );
DeleteObject( hBitmap );