I have a winforms ImageList
which contains 200 256x256 images.
When I add the images, 1 by one, half of the programs time spent on the Add
method according to ANTS .NET profiler.
So the program takes 10 secs to launch and 5 is spent there. That is very slow in my opinion.
I implemented the same thing using ImageList.Images.AddRange
. The result did not change.
Does anyone know any alternatives or optimizations to solve this? Is the WPF ImageList
any faster? Is there a faster winforms ImageList
?
EDIT:
foreach (string imageFile in images)
{
imageList.Images.Add(Image.FromFile(imageFile)); // takes pretty much all of program's execution time.
}