开发者

How to handle 1000+ images in a C# Application?

A winform control for displaying a list of images is currently implemented with a flowlayoutpanel and a collection of pictureboxes. But even at thumbnail scale (64x64) when we when start to approach 1000+ images we get OutOfMemory exceptions - our actual problem lies from the thumbnail generation part and the creation of the Image object.

I haven't been able to find any strategies from the existing image viewing examples on the net regarding a large number of images so does anybody have any links or strategies for solving this problem of displaying a list of 1000+ images?

As a starting point we really only need these image objects around when the thumbnail's picture box is in view. Then we would only have 10 image objects created but is there a smarter way of doing this othe开发者_StackOverflow社区r than loading and destroying image objects?

Thanks, Edward


You should display only one screen of images at a time.

When the user drags the scrollbar, destroy those images and load new ones.


WPF handles this in a great way. If you have turned on Virtualization, the ListBox will create only the control that are visible to the screen.

In your case, keep reference to the images in a list. Put a pictureBox, and based on the Scrollbar, change the image on the pictureBox.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜