From 67eba8ea1a9c1bf4e863091f5aa3485ec3d5cde5 Mon Sep 17 00:00:00 2001 From: zufuliu Date: Thu, 14 Dec 2023 19:03:38 +0800 Subject: [PATCH] Use `CreateDIBSection()` to make transparent bitmap for open drop-down menu, issue #740. Patch by @Sergy2001 --- src/Helpers.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Helpers.c b/src/Helpers.c index 8585c5e0ee..9a35147b7f 100644 --- a/src/Helpers.c +++ b/src/Helpers.c @@ -2571,7 +2571,7 @@ HBITMAP BitmapCache_Get(BitmapCache *cache, LPCWSTR path) { cache->count += 1; } else { // find first zero bit in used, omitted zero check as used can't be UINT32_MAX - // index = __builtin_stdc_first_trailing_one(cache->used); + // index = __builtin_stdc_trailing_ones(cache->used); index = np2_ctz(~cache->used); DeleteObject(cache->items[index]); cache->items[index] = NULL; @@ -2586,9 +2586,9 @@ HBITMAP BitmapCache_Get(BitmapCache *cache, LPCWSTR path) { HDC bitmapDC = CreateCompatibleDC(hDC); RECT rect = { 0, 0, 0, 0 }; ImageList_GetIconSize(imageList, (int *)(&rect.right), (int *)(&rect.bottom)); - hbmp = CreateCompatibleBitmap(hDC, rect.right, rect.bottom); + const BITMAPINFO bmi = { {sizeof(BITMAPINFOHEADER), rect.right, rect.bottom, 1, 32, BI_RGB, 0, 0, 0, 0, 0}, {{ 0, 0, 0, 0 }} }; + hbmp = CreateDIBSection(NULL, &bmi, DIB_RGB_COLORS, NULL, NULL, 0); HBITMAP oldBitmap = (HBITMAP)SelectObject(bitmapDC, hbmp); - FillRect(bitmapDC, &rect, (HBRUSH)(COLOR_MENU + 1)); ImageList_Draw(imageList, iIcon, bitmapDC, 0, 0, ILD_TRANSPARENT); SelectBitmap(bitmapDC, oldBitmap); DeleteDC(bitmapDC);