dotnet / dotnet/winforms

Do not create image masks in `ImageList` when using 32-bit color depth (or provide a way to disable it)

Open
#14,171 2 comments 3 reactions 0 assignees View on GitHub
area-System.Drawing untriaged
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
20h 23m
Merged PRs (30d)
103

Description

### .NET version

10.0

### Did it work in .NET Framework?

Not tested/verified

### Did it work in any of the earlier releases of .NET Core or .NET 5+?

No

### Issue description

See this article from 2004 with a fix: https://www.codeproject.com/articles/Adding-and-using-32-bit-alphablended-images-and-ic

Specifically, when using `ImageList = new ImageList { ColorDepth = ColorDepth.Depth32Bit };` the image list still creates a mask which causes poor anti aliasing on transparent pixels in the bitmap.

The fix in that article is to manually call windows ImageList_Add without the mask. I've tested this in .NET 10 and the fix works and fixes icons having bad transparency in trees/lists/tabs.

before:

Image

after:

Image

look closely, you can see gray pixels when not using the fix

### Steps to reproduce

Create a imagelist, add it to a treeview, and add a bitmap image that has transparent pixels (not fully transparent)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.