ImageList performance problem

  • Thread starter =?iso-8859-1?B?Sm9oYW4gU2r2c3Ry9m0=?=
  • Start date
?

=?iso-8859-1?B?Sm9oYW4gU2r2c3Ry9m0=?=

Hi all,

I'm experiencing performance problems when adding a large set of
bitmaps to an ImageList. The bitmaps are 55x55 pixels in size, which
matches the ImageList's ImageSize property. Adding approx. 5000 bitmaps
takes about 1,5 minutes. The bitmaps are generated from scratch,
resized and other things much faster than that (in just a few seconds)
so why should adding them to an imagelist be so slow?

The imagelist is also the source for a ListView, which displays the
results. I've tried adding the bitmaps to the ImageList via Add(),
AddRange() and using the async. virtual mode. The latter sounded
promising, but didn't help.

Any ideas, hints?

Cheers,
Johan Sjöström
MSc, MCAD, MCTS, MCITP
 
J

Jared \(Home\)

could try to disconnect listview if connected and also look at lowering
bitdepth wich is just a property of the image list
 
?

=?iso-8859-1?B?Sm9oYW4gU2r2c3Ry9m0=?=

Thanks Jared, I've tried that with no great impact on performance. :(

Cheers,
Johan Sjöström
MSc, MCAD, MCTS, MCITP

Jared (Home) skrev:
 
?

=?iso-8859-1?B?Sm9oYW4gU2r2c3Ry9m0=?=

Actually, I tried disconnecting the ListView from the ImageList by
setting the ListView's LargeImageList property to null, but to improve
performance I had to remove the connection from the designer as well.
Now the adding of images is very fast, but as soon as I connect the
ListView the computer really goes to work..

This example proves my point. It's a simple form with a Button,
ImageList and ListView. It's Part 2 that locks up the CPU for a good
minute or so.



private void button1_Click(object sender, EventArgs e)
{

// Part 1, add images to imagelist
imageList1.Images.Clear();
label1.Text = "Adding..";
label1.Update();
for (int i = 0; i < 5000; i++)
{
imageList1.Images.Add(new Bitmap(1, 1));
}

// Part 2, connect listview to imagelist
label1.Text = "Connecting listview..";
label1.Update();
listView1.LargeImageList = imageList1;
label1.Text = "Finished.";
label1.Update();

}

Cheers,
Johan Sjöström
MSc, MCAD, MCTS, MCITP
 
?

=?iso-8859-1?B?Sm9oYW4gU2r2c3Ry9m0=?=

Looks like I'm forced to go with the really fast DataGridView instead.
Adding bitmaps to an ImageColumn and binding it that way only takes a
second or so.

Guess ListView + ImageList isn't meant for heavy duty use..

Cheers
Johan Sjöström
MSc, MCAD, MCTS, MCITP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top