Alexandre Julliard : comctl32: Only support an alpha channel for 32-bpp DIB-based imagelists.

Alexandre Julliard julliard at winehq.org
Wed Jun 2 11:16:24 CDT 2010


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Jun  2 12:21:41 2010 +0200

comctl32: Only support an alpha channel for 32-bpp DIB-based imagelists.

---

 dlls/comctl32/imagelist.c |   21 +++++++++++----------
 dlls/comctl32/toolbar.c   |    4 ++--
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c
index a73b423..e4249b9 100644
--- a/dlls/comctl32/imagelist.c
+++ b/dlls/comctl32/imagelist.c
@@ -153,8 +153,9 @@ static BOOL add_with_alpha( HIMAGELIST himl, HDC hdc, int pos, int count,
 
     if (!GetObjectW( hbmImage, sizeof(bm), &bm )) return FALSE;
 
-    /* if neither the imagelist nor the source bitmap can have an alpha channel, bail out now */
-    if (himl->uBitsPixel != 32 && bm.bmBitsPixel != 32) return FALSE;
+    /* if either the imagelist or the source bitmap don't have an alpha channel, bail out now */
+    if (!himl->has_alpha) return FALSE;
+    if (bm.bmBitsPixel != 32) return FALSE;
 
     SelectObject( hdc, hbmImage );
     mask_width = (bm.bmWidth + 31) / 32 * 4;
@@ -208,7 +209,7 @@ static BOOL add_with_alpha( HIMAGELIST himl, HDC hdc, int pos, int count,
         }
         else
         {
-            if (himl->has_alpha) himl->has_alpha[pos + n] = 1;
+            himl->has_alpha[pos + n] = 1;
 
             if (mask_info && himl->hbmMask)  /* generate the mask from the alpha channel */
             {
@@ -751,7 +752,7 @@ ImageList_Create (INT cx, INT cy, UINT flags,
     else
         himl->hbmMask = 0;
 
-    if (himl->uBitsPixel == 32)
+    if (ilc == ILC_COLOR32)
         himl->has_alpha = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, himl->cMaxImage );
     else
         himl->has_alpha = NULL;
@@ -1204,7 +1205,7 @@ static BOOL alpha_blend_image( HIMAGELIST himl, HDC dest_dc, int dest_x, int des
         }
     }
 
-    if (himl->uBitsPixel == 32)  /* we already have an alpha channel in this case */
+    if (himl->has_alpha)  /* we already have an alpha channel in this case */
     {
         /* pre-multiply by the alpha channel */
         for (i = 0, ptr = bits; i < cx * cy; i++, ptr++)
@@ -2515,7 +2516,7 @@ ImageList_ReplaceIcon (HIMAGELIST himl, INT nIndex, HICON hIcon)
     if (hdcImage == 0)
 	ERR("invalid hdcImage!\n");
 
-    if (himl->uBitsPixel == 32)
+    if (himl->has_alpha)
     {
         if (!ii.hbmColor)
         {
@@ -2525,13 +2526,13 @@ ImageList_ReplaceIcon (HIMAGELIST himl, INT nIndex, HICON hIcon)
             SelectObject( hdcImage, color );
             SelectObject( hdcMask, ii.hbmMask );
             BitBlt( hdcImage, 0, 0, bmp.bmWidth, height, hdcMask, 0, height, SRCCOPY );
-            add_with_alpha( himl, hdcImage, nIndex, 1, bmp.bmWidth, height, color, ii.hbmMask );
+            ret = add_with_alpha( himl, hdcImage, nIndex, 1, bmp.bmWidth, height, color, ii.hbmMask );
             DeleteDC( hdcMask );
             DeleteObject( color );
+            if (ret) goto done;
         }
-        else add_with_alpha( himl, hdcImage, nIndex, 1, bmp.bmWidth, bmp.bmHeight, ii.hbmColor, ii.hbmMask );
-
-        goto done;
+        else if (add_with_alpha( himl, hdcImage, nIndex, 1, bmp.bmWidth, bmp.bmHeight,
+                                 ii.hbmColor, ii.hbmMask )) goto done;
     }
 
     imagelist_point_from_index(himl, nIndex, &pt);
diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c
index d24b3dc..684406b 100644
--- a/dlls/comctl32/toolbar.c
+++ b/dlls/comctl32/toolbar.c
@@ -2757,7 +2757,7 @@ TOOLBAR_CheckImageListIconSize(TOOLBAR_INFO *infoPtr)
         cx, cy, infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
 
     himlNew = ImageList_Create(infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
-                                ILC_COLORDDB|ILC_MASK, 8, 2);
+                                ILC_COLOR32|ILC_MASK, 8, 2);
     for (i = 0; i < infoPtr->nNumBitmapInfos; i++)
         TOOLBAR_AddBitmapToImageList(infoPtr, himlNew, &infoPtr->bitmaps[i]);
     TOOLBAR_InsertImageList(&infoPtr->himlDef, &infoPtr->cimlDef, himlNew, 0);
@@ -2854,7 +2854,7 @@ TOOLBAR_AddBitmap (TOOLBAR_INFO *infoPtr, INT count, const TBADDBITMAP *lpAddBmp
 	TRACE ("creating default image list!\n");
 
         himlDef = ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
-                                    ILC_COLORDDB | ILC_MASK, info.nButtons, 2);
+                                    ILC_COLOR32 | ILC_MASK, info.nButtons, 2);
 	TOOLBAR_InsertImageList(&infoPtr->himlDef, &infoPtr->cimlDef, himlDef, 0);
         infoPtr->himlInt = himlDef;
     }




More information about the wine-cvs mailing list