I asked this same question a while back (Application Resources, to
cache or not to cache?)
In the end it was suggested that anything under about 100k should be
cached if you plan on accessing it more than once.
I ended up with this function.
> Function LoadPictureResource(filename as string) as picture
>
> if PictureResources.HasKey(fileName) then
> return PictureResource.Value(fileName)
> else
> dim f as folderitem = app.resources.child(fileName+".png")
> if f <> nil then
> if f.length>app.kMaxCachedResourceSize then
> return PNGu.openAsPictureWithMask(f)
> else
> PictureResource.Value(fileName) =
> PNGu.openAsPictureWithMask(f)
> return PictureResource.Value(fileName)
> end
> else
> return nil
> end
> end
>
> End Function
All my Image resources are in PNG format
app.kMaxCacheResourced size is a constant (in bytes) of the maximum
file size you want invoiced)
app.Resources is a function that points to the folderitem (directory)
containing your application resources.
Cheers,
Tom
On 01/06/2008, at 8:38 AM, Rubber Chicken Software Co. wrote:
> If I have an ordinary .png (or whatever) file in my project, and I
> refer to it several times in code, is that efficient?
>
> Does "loading it" and drawing it into a Picture object make it
> faster/efficient to work with? Or does RB automatically make it a
> Picture object, in memory, already?
>
> * * * * * * * * * * * * * * * * * * * * * * * * * * *
> | Garth Hjelte |
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|