dibs: fix StretchDIBits when using DIB_PAL_COLORS

Huw D M Davies h.davies1 at physics.ox.ac.uk
Fri Mar 26 06:22:29 CST 2004


        Huw Davies <huw at codeweavers.com>
        When using DIB_PAL_COLORS select the current palette into the
        memory dc so that SetDIBits works correctly.
-- 
Huw Davies
huw at codeweavers.com
Index: objects/dib.c
===================================================================
RCS file: /home/wine/wine/objects/dib.c,v
retrieving revision 1.85
diff -u -r1.85 dib.c
--- objects/dib.c	12 Mar 2004 19:46:12 -0000	1.85
+++ objects/dib.c	26 Mar 2004 12:20:26 -0000
@@ -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 );



More information about the wine-patches mailing list