Ziqing Hui : comctl32/imagelist: Support flag ILS_SATURATE for ImageList_DrawIndirect().

Alexandre Julliard julliard at winehq.org
Mon Mar 9 17:42:34 CDT 2020


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

Author: Ziqing Hui <zhui at codeweavers.com>
Date:   Fri Mar  6 18:00:39 2020 +0800

comctl32/imagelist: Support flag ILS_SATURATE for ImageList_DrawIndirect().

Signed-off-by: Ziqing Hui <zhui at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/comctl32/imagelist.c       | 24 ++++++++++++++++++------
 dlls/comctl32/tests/imagelist.c |  1 -
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c
index 3cf7cc8c7f..14a17c2717 100644
--- a/dlls/comctl32/imagelist.c
+++ b/dlls/comctl32/imagelist.c
@@ -1242,7 +1242,7 @@ ImageList_DrawEx (HIMAGELIST himl, INT i, HDC hdc, INT x, INT y,
 
 static BOOL alpha_blend_image( HIMAGELIST himl, HDC dest_dc, int dest_x, int dest_y,
                                int src_x, int src_y, int cx, int cy, BLENDFUNCTION func,
-                               UINT style, COLORREF blend_col, BOOL has_alpha )
+                               UINT style, COLORREF blend_col, BOOL has_alpha, BOOL grayscale )
 {
     BOOL ret = FALSE;
     HDC hdc;
@@ -1293,6 +1293,18 @@ static BOOL alpha_blend_image( HIMAGELIST himl, HDC dest_dc, int dest_x, int des
         }
     }
 
+    if (grayscale)
+    {
+        for (i = 0, ptr = bits; i < cx * cy; i++, ptr++)
+        {
+            DWORD gray = (((*ptr & 0x00ff0000) >> 16) * 299 +
+                          ((*ptr & 0x0000ff00) >>  8) * 587 +
+                          ((*ptr & 0x000000ff) >>  0) * 114 + 500) / 1000;
+            if (has_alpha) gray = gray * (*ptr >> 24) / 255;
+            *ptr = (*ptr & 0xff000000)| (gray << 16) | (gray << 8) | gray;
+        }
+    }
+
     if (has_alpha)  /* we already have an alpha channel in this case */
     {
         /* pre-multiply by the alpha channel */
@@ -1422,7 +1434,7 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp)
     oldImageBk = SetBkColor( hImageDC, RGB( 0xff, 0xff, 0xff ) );
 
     has_alpha = (himl->has_alpha && himl->has_alpha[pimldp->i]);
-    if (!bMask && (has_alpha || (fState & ILS_ALPHA)))
+    if (!bMask && (has_alpha || (fState & ILS_ALPHA) || (fState & ILS_SATURATE)))
     {
         COLORREF colour, blend_col = CLR_NONE;
         BLENDFUNCTION func;
@@ -1441,8 +1453,8 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp)
 
         if (bIsTransparent)
         {
-            bResult = alpha_blend_image( himl, pimldp->hdcDst, pimldp->x, pimldp->y,
-                                         pt.x, pt.y, cx, cy, func, fStyle, blend_col, has_alpha );
+            bResult = alpha_blend_image( himl, pimldp->hdcDst, pimldp->x, pimldp->y, pt.x, pt.y, cx, cy,
+                                         func, fStyle, blend_col, has_alpha, fState & ILS_SATURATE );
             goto end;
         }
         colour = pimldp->rgbBk;
@@ -1451,7 +1463,8 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp)
 
         hOldBrush = SelectObject (hImageDC, CreateSolidBrush (colour));
         PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY );
-        alpha_blend_image( himl, hImageDC, 0, 0, pt.x, pt.y, cx, cy, func, fStyle, blend_col, has_alpha );
+        alpha_blend_image( himl, hImageDC, 0, 0, pt.x, pt.y, cx, cy, func,
+                           fStyle, blend_col, has_alpha, fState & ILS_SATURATE );
         DeleteObject (SelectObject (hImageDC, hOldBrush));
         bResult = BitBlt( pimldp->hdcDst, pimldp->x,  pimldp->y, cx, cy, hImageDC, 0, 0, SRCCOPY );
         goto end;
@@ -1545,7 +1558,6 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp)
 	}
     }
 
-    if (fState & ILS_SATURATE) FIXME("ILS_SATURATE: unimplemented!\n");
     if (fState & ILS_GLOW) FIXME("ILS_GLOW: unimplemented!\n");
     if (fState & ILS_SHADOW) FIXME("ILS_SHADOW: unimplemented!\n");
 
diff --git a/dlls/comctl32/tests/imagelist.c b/dlls/comctl32/tests/imagelist.c
index 106ae92ffd..984ca053c8 100644
--- a/dlls/comctl32/tests/imagelist.c
+++ b/dlls/comctl32/tests/imagelist.c
@@ -1475,7 +1475,6 @@ static void check_ImageList_DrawIndirect_grayscale(HDC hdc, HIMAGELIST himl, UIN
         expected = (gray << 16) | (gray << 8) | gray;
         expected_winxp = (gray_winxp << 16) | (gray_winxp << 8) | gray_winxp;
 
-        todo_wine_if(expected != 0 && expected != 0x00FFFFFF)
         ok(colour_match(dst_bits[i], expected) || broken(colour_match(dst_bits[i], expected_winxp)),
            "ImageList_DrawIndirect: got Pixel(%d,%d) %08X, Expected a close match to %08X from line %d\n",
            i % width, i / width, dst_bits[i] & 0x00FFFFFF, expected, line);




More information about the wine-cvs mailing list