PictureBox loading too slow & too big

SEVI

Well-known member
Joined
Jun 28, 2003
Messages
48
Location
Australia
Im writing a program that works with images and want to have an image preview menu that displays a directory full of images so that the user can see the image and drop and drop the one they want to the main work area.

Ive tested with 20 or 30 images and Ive found loading these images from file to be quite slow and to use a heap of memory. To quote rough figures, for around 20 images, initially the exe gets up to around 250mb then drops down to 150mb and takes around 5 seconds or more to complete. I then used the thumbnail method which showed better results at 150-200mb initially and then down to 40mb, it wasnt much faster at around 5 seconds.

The image res doesnt have to be great as it is only a preview. There has to be a faster way of doing this or is this just a .NET thing?

Any ideas?
 
One suggestion - instead of using picture box arrays (Im assuming), have a single picture box, get the graphics object from it and draw on it directly, using:

graphics.DrawImage(...

This allows you to specify the source, position and size

So load each thumbnail into a memory bitmap and draw it directly onto your single preview picture boxs image.
 
Use an Imagelist control to store the images and display them.

System.Windows.Forms.ImageList myList = System.Windows.Forms.ImageList();

use myList.Images.Add to add an image into the list.

use myList.ImageSize to set the sizes of the images, then use them as thumbnails. :)
 
Should have mentioned initially that the methods Id tried are:

1/ Loading the picbox using Image.FromFile() method
2/ Creating a bitmap using the bitmap() file constructor
Then loading the picbox with the bitmap
3/ Now Im creating the bitmap using file constructor as above
Then using GetThumbnailImage(ltBitmap.Width/15,ltBitmap.Height/15, myCallBack, IntPtr.Zero) to reduce the image size/res and loading that to the picbox

Ive found 3 to be the best for memory usage but about the same speed..

I thought of trying an image list, but guessed it wouldnt be any faster.

Thanx for the sugestions, Ill give them a go and advise what happens.
 
Yeah, i think bitmap object will use up a lot of the memory, so the way i implemented this solution was to Set the Image size of images in the Imagelist and thenload the pics into the Imagelist.
This way the thumbs of the images get creating without a lot of effort.

But i would advice u to implement this ur self cos thats more satisfying. Only use Microsoft controls when u have deadlines to meet :D
 
Back
Top