Alexandre Julliard : gdi32: Fix StretchDIBits color mapping for monochrome bitmaps without a color table.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Dec 4 08:19:27 CST 2015


Module: wine
Branch: master
Commit: eddc4609eca7589c021e181b1701ec25b1ee0e8e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=eddc4609eca7589c021e181b1701ec25b1ee0e8e

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Dec  4 21:40:14 2015 +0900

gdi32: Fix StretchDIBits color mapping for monochrome bitmaps without a color table.

This is the equivalent of df924f6a8ca6d4835c579141d16d866a574b380a for
the StretchDIBits case.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdi32/dib.c | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c
index 2817ede..cf1ebe4 100644
--- a/dlls/gdi32/dib.c
+++ b/dlls/gdi32/dib.c
@@ -567,22 +567,33 @@ INT nulldrv_StretchDIBits( PHYSDEV dev, INT xDst, INT yDst, INT widthDst, INT he
     err = dev->funcs->pPutImage( dev, clip, dst_info, &src_bits, &src, &dst, rop );
     if (err == ERROR_BAD_FORMAT)
     {
+        DWORD dst_colors = dst_info->bmiHeader.biClrUsed;
+
         /* 1-bpp destination without a color table requires a fake 1-entry table
-         * that contains only the background color */
-        if (dst_info->bmiHeader.biBitCount == 1 && !dst_info->bmiHeader.biClrUsed)
+         * that contains only the background color; except with a 1-bpp source,
+         * in which case it uses the source colors */
+        if (dst_info->bmiHeader.biBitCount == 1 && !dst_colors)
         {
-            COLORREF color = GetBkColor( dev->hdc );
-            dst_info->bmiColors[0].rgbRed      = GetRValue( color );
-            dst_info->bmiColors[0].rgbGreen    = GetGValue( color );
-            dst_info->bmiColors[0].rgbBlue     = GetBValue( color );
-            dst_info->bmiColors[0].rgbReserved = 0;
-            dst_info->bmiHeader.biClrUsed = 1;
+            if (src_info->bmiHeader.biBitCount > 1)
+            {
+                COLORREF color = GetBkColor( dev->hdc );
+                dst_info->bmiColors[0].rgbRed      = GetRValue( color );
+                dst_info->bmiColors[0].rgbGreen    = GetGValue( color );
+                dst_info->bmiColors[0].rgbBlue     = GetBValue( color );
+                dst_info->bmiColors[0].rgbReserved = 0;
+                dst_info->bmiHeader.biClrUsed = 1;
+            }
+            else
+            {
+                memcpy( dst_info->bmiColors, src_info->bmiColors, 2 * sizeof(dst_info->bmiColors[0]) );
+                dst_info->bmiHeader.biClrUsed = 2;
+            }
         }
 
         if (!(err = convert_bits( src_info, &src, dst_info, &src_bits )))
         {
             /* get rid of the fake 1-bpp table */
-            if (dst_info->bmiHeader.biClrUsed == 1) dst_info->bmiHeader.biClrUsed = 0;
+            dst_info->bmiHeader.biClrUsed = dst_colors;
             err = dev->funcs->pPutImage( dev, clip, dst_info, &src_bits, &src, &dst, rop );
         }
     }




More information about the wine-cvs mailing list