Page 1 of 1

Keeping web images in memory

Posted: Mon Nov 30, 2009 6:47 pm
by massung
So, I have an interesting datagrid problem. Each row in my datagrid (form) can have an optional image in it. When that image is present, it's always from an external website. This causes me to have to choose between one of two problems (note: the datagrid can end up having hundreds of rows on it):

Problem A. If I set the datagrid to cache controls, it can take a long time load all the images for the form.

Problem B. If cache controls is false, then as I scroll through the form it's constantly pinging the internet, re-downloading the images over and over again (since fillInData is called repeatedly each time a new row becomes visible).

I'm pretty much between a rock and hard place. I'm hoping that one of few possible solutions exists and someone can point me in the right direction(s).

Solution A. Is it possible to tell Rev to downloading image URLs asynchronously? Right now I'm just doing set the fileName of image X of me to "http://...". If this ran in the background instead of halting the program, then caching controls would be an acceptable solution for me.

Solution B. Is there a way for me to preload or keep images around in memory until I want them gone? That way, as I scroll around the form and each image control gets its fileName property updated, it doesn't have to ping the web over and over again?

Thoughts?

Jeff M.

Re: Keeping web images in memory

Posted: Mon Nov 30, 2009 7:45 pm
by sturgis
Not sure if this is what you're looking for, but you might look at "load" in the dictionary.

Re: Keeping web images in memory

Posted: Mon Nov 30, 2009 8:01 pm
by massung
sturgis wrote:Not sure if this is what you're looking for, but you might look at "load" in the dictionary.
I use load for other URL asynchronous loading. I'm unaware of it working for images, though. I suppose I can give it a try.

Re: Keeping web images in memory

Posted: Mon Nov 30, 2009 8:43 pm
by sturgis
Just did a quick test, seems to work fine. Nothing too complicated, just compared reloading 2 images into an image object a few times, one method using load to preload, the other with the urls unloaded. The caching is definately working for the images. Without the caching while using large pictures, the picture flip is horrendously slow on my connect. Using the load method its downright snappy.