2011-01-01, 01:32 PM
I'm trying to get some directory browsing working for a plugin, but the performance I'm seeing as it loads preview images for the UiList isn't as good as any of the built-in browsers (Videos, Pictures, etc), especially with large images sizes.
I figure it must be related to the caching of images, but I'm not 100% sure how I should be doing it?
- Can I just create a single ImageCache object (via GetInstance) and then reuse it as often as I want?
- At the time I parse the files in the directory and build the UiList, should I fire off a background thread to pre-cache everything? If so, would it be something like the following for each file?
- When I then want the actual image, do I just call GetImage or should I check if it's in the cache again (even though I've already asked for it)? Does the cache have a limit?
If none of that makes sense, does anyone have some other suitable pseudo-code for dealing with this scenario?
Thanks
Iain
I figure it must be related to the caching of images, but I'm not 100% sure how I should be doing it?
- Can I just create a single ImageCache object (via GetInstance) and then reuse it as often as I want?
- At the time I parse the files in the directory and build the UiList, should I fire off a background thread to pre-cache everything? If so, would it be something like the following for each file?
Code:
if (cache.HasCachedImage(path, 150, 225, false) == false)
cache.PreloadImage(path, 150, 225, false, false);
- When I then want the actual image, do I just call GetImage or should I check if it's in the cache again (even though I've already asked for it)? Does the cache have a limit?
If none of that makes sense, does anyone have some other suitable pseudo-code for dealing with this scenario?
Thanks
Iain