From 33e7d0282b926106957c358e000fb566556ba5dd Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 14 May 2010 13:44:20 +0200 Subject: [PATCH] comctl32: Store an alpha channel present flag for each image in an imagelist. --- dlls/comctl32/imagelist.c | 23 ++++++++++++++++++++++- dlls/comctl32/imagelist.h | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c index 1eb3bc60010..2083d3981f8 100644 --- a/dlls/comctl32/imagelist.c +++ b/dlls/comctl32/imagelist.c @@ -207,6 +207,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; StretchBlt( himl->hdcImage, pt.x, pt.y, himl->cx, himl->cy, hdc, n * width, 0, width, height, SRCCOPY ); } @@ -294,6 +295,18 @@ IMAGELIST_InternalExpandBitmaps(HIMAGELIST himl, INT nImageCount) himl->hbmMask = hbmNewBitmap; } + if (himl->has_alpha) + { + char *new_alpha = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, + himl->has_alpha, himl->cMaxImage ); + if (new_alpha) himl->has_alpha = new_alpha; + else + { + HeapFree( GetProcessHeap(), 0, himl->has_alpha ); + himl->has_alpha = NULL; + } + } + himl->cMaxImage = nNewCount; DeleteDC (hdcBitmap); @@ -728,6 +741,11 @@ ImageList_Create (INT cx, INT cy, UINT flags, else himl->hbmMask = 0; + if (himl->uBitsPixel == 32) + himl->has_alpha = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, himl->cMaxImage ); + else + himl->has_alpha = NULL; + /* create blending brushes */ hbmTemp = CreateBitmap (8, 8, 1, 1, aBitBlend25); himl->hbrBlend25 = CreatePatternBrush (hbmTemp); @@ -1430,7 +1448,7 @@ ImageList_Duplicate (HIMAGELIST himlSrc) } himlDst = ImageList_Create (himlSrc->cx, himlSrc->cy, himlSrc->flags, - himlSrc->cInitial, himlSrc->cGrow); + himlSrc->cCurImage, himlSrc->cGrow); if (himlDst) { @@ -1446,6 +1464,8 @@ ImageList_Duplicate (HIMAGELIST himlSrc) himlDst->cCurImage = himlSrc->cCurImage; himlDst->cMaxImage = himlSrc->cMaxImage; + if (himlSrc->has_alpha && himlDst->has_alpha) + memcpy( himlDst->has_alpha, himlSrc->has_alpha, himlDst->cCurImage ); } return himlDst; } @@ -3132,6 +3152,7 @@ static ULONG WINAPI ImageListImpl_Release(IImageList *iface) if (This->hbrBlend50) DeleteObject (This->hbrBlend50); This->lpVtbl = NULL; + HeapFree(GetProcessHeap(), 0, This->has_alpha); HeapFree(GetProcessHeap(), 0, This); } diff --git a/dlls/comctl32/imagelist.h b/dlls/comctl32/imagelist.h index a979ebf3de9..f6f1d1b9e71 100644 --- a/dlls/comctl32/imagelist.h +++ b/dlls/comctl32/imagelist.h @@ -53,6 +53,7 @@ struct _IMAGELIST HBRUSH hbrBlend50; INT cInitial; UINT uBitsPixel; + char *has_alpha; LONG ref; /* reference count */ };