Java programming question

Associate
Joined
18 Feb 2010
Posts
940
Hi,

I have a quick question, I'm not sure if there is a positive answer.

Is there a way to get a list of thumbnails for a directory, that doesn't use lots of memory? Currently my application pulls in all the files, then resizes them, then shows them. It's heavy on the CPU and causes some load time.

I'm wondering if it's possible to pull in these images in some way which doesn't have to read each and every file. A little like in windows explorer when you select a folder with images, and it may show you the large icons on the right, is there a less costly way to do this?
Currently I use the path to create an ImageIcon, then get a scaled instance of it, surely this isn't the most efficient way?

Thanks!
 
If the thumbnails are not auto generated by the OS's your developing on then your going to have to generate the thumbs yourself from the actual files. There is no way around this.

A way to shrink the amount of work your code needs to do is to shrink your view of the folder.

For example. Assume there ar 40 pictures in the folder. Do you need to show all the thumbs all the time? If you could manage with just 4 this would reduce your memory overheads greatly.

So your window onto the thumbs is 4. Keep a buffer of 2 more thumbs in either direction ready to use, but not displayed. Then when the user moves in either direction you have some of the thumb images ready. Your algorithms then clean up your lists. Delete the thumbs you no longer need and process the images that are still needed to be decoded so your buffer is ready for the next user interaction. Of course you need to design and implement this thumbnailing system yourself.


If all the above makes no sense, or isnt applicable then there are still some tricks you could try. Would making the thumbs grayscale or reducing the colour depth hurt the user experience as this will reduce memory a lot.
 
Back
Top Bottom