Skip to content

Commit

Permalink
Use CreateDIBSection() to make transparent bitmap for open drop-dow…
Browse files Browse the repository at this point in the history
…n menu, issue #740.

Patch by @Sergy2001
  • Loading branch information
zufuliu committed Dec 14, 2023
1 parent 7ea3149 commit 67eba8e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 67eba8e

Please sign in to comment.