Sign in to follow this  
apocalypse_k40

[.net] I need a trick [help request]

Recommended Posts

apocalypse_k40    122
Hi guys, In my program I want to view thumbnails.. But when the original image size goes up the program starts to freeze.. In my method I directly load the original image to an Image object and then using the GetThumbnail(....) method resize it and pass to another Image object. But it seems this is not an effective way !! Is there ny idea, or trick or something else to increase this performance ? I am open to any advice.. Best regards

Share this post


Link to post
Share on other sites
apocalypse_k40    122
You are right but this will not improve my performance, just make the main form not to freeze (stay inresponsive) but the loading will still take too much time..

By the way, the help I am requesting for is a pattern, a methodology or something like this to improve my performance. I am sure that I am doing something wrong, there must be some other way to make an image's thumbnail and view it.. :S

Share this post


Link to post
Share on other sites
apocalypse_k40    122
Well, the images mainly will directly be loaded from a camera, I guess their format will .bmp,.tiff or .jpeg, but at least I am sure that there will not be only one format because the application will also read from CD/DVD, Removable media or Harddisks.. So any image format will be used >S

Share this post


Link to post
Share on other sites
Wyzfen    288
If you've ever browsed a folder in windows thats full of images (in thumbnail mode) you'll see it takes a long time to load all the images.
The trick is to prioritise which images to thumbnail - based on what images the user is trying to see (ie, where they've scrolled to). Also, show a temporary file.
People are used to it taking a long time to load a lot of images.

Wyzfen

Share this post


Link to post
Share on other sites
nmi    978
So here are some hints:
- use a worker thread as was already suggested to load an image and create a thumbnail of it
- have a queue of jobs for the worker thread for the images that need to be converted to a thumbnail, this way the application can reorder the creation of thumbnails or stop it
- put the images that are currently visible in that queue first
- store the thumbnails in a cache (maybe a hidden file) so that they don't need to be recreated each time, index the files in the cache by the absolute filename or by the basename + hash of file contents (or maybe the first 100 bytes of the file instead of a hash)
- give the worker thread a lower priority then the gui thread, if the worker thread is eating up 100% of its time slices it will get any available cpu cycles while the gui still stays responsive
- you may want two have two worker threads instead of one, so that not only the cpu is better utilized but also the harddisk/cd/dvd/whatever, one thread loads the images while the other one converts them in the meantime
- depending on the image file format you may want to provide different methods for thumbnail creation, for instance a jpeg the is compressed in progressive mode already contains a low-res version

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
One other suggestion: sort your queue smallest to largest, and display results as they are available. This will give a perception of being more responsive.

If you can get status back from your image converter, maybe display that (50% done or whatever). Or estimate it by timing each conversion (so if your 10k file takes 10 sec, you estimate the 100k file at 100 sec and give a % based on how long its been going).

Other than that, all I can think of is use a different image conversion engine.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this