I have the following image:
I read it from resources by putting it in an ImageList and then read it from an ImageList to draw on my control surface. But when I do this, the image seems to lose alpha channel information:
Here are all the relevant code snippets:
Program.cs
Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false);
MainForm.cs
ilFilters = new ImageList() { ColorDepth = ColorDepth.Depth32Bit, ImageSize = new Size(16, 16) }; // (...) if (info.Icon != null) { if (info.Icon.Width == 16 && info.Icon.Height == 16) { ilFilters.Images.Add(info.Icon); index = ilFilters.Images.Count - 1; } }
I actually saved the image before ( info.Icon
) and after ( ilFilters.Images[0]
) put it in the list of images. The first version was correct, the second was damaged. ImageList seems to have damaged the image.
I also tried converting PNG to a 32-bit BMP image. No success.
On the system, I am running Windows 7..NET 4.5.1, the Visual Studio 2013 community.
How can I save the alpha channel of an image when added to an imagelist?
Edit: Proof of conceptual application .
source share