realbasic-nug
[Top] [All Lists]

Re: Differences in Graphic Formats

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Differences in Graphic Formats
From: Tom Benson <tombenson at mac dot com>
Date: Sun, 01 Jun 2008 09:11:32 +1000
Authentication-results: mx.google.com; spf=pass (google.com: domain of realbasic-nug-bounces at lists dot realsoftware dot com designates 66.116.103.65 as permitted sender) smtp dot mail=realbasic-nug-bounces at lists dot realsoftware dot com
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <E68C62D6-9DDE-4735-988F-41A88A29B9EE at shaw dot ca> <2958CE02-F951-41E1-BB68-7480A205FD0D at declareSub dot com> <20080531223849 dot RRFN4495 dot aarprv04 dot charter dot net at CB56611-W dot chickensys dot com>
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>


<Prev in Thread] Current Thread [Next in Thread>