Xojo Conferences
MBSOct2019CologneDE

what is the best way to load images once? (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: Listbox sorting numbers
Next thread: How Many Folders in a Folder


Re: Jaguar RB?   -   German Bauer
  what is the best way to load images once?   -   Donald Myers
   Re: what is the best way to load images once?   -   Joseph J. Strout

what is the best way to load images once?
Date: 07.05.02 17:16 (Tue, 07 May 2002 12:16:39 -0400)
From: Donald Myers
I have a REALbasic Program which has an array of objects.

in the object there is a properties of type picture

here is the question:

if I need to have the same picture in the object.picture property numours
time my current code loads the picture each time into the property.

This of course takes more and more memory for the same picture each time I
append a new object to the array which has a duplicate picture (not all are
duplicates).

Is there any way to make the realbasic picture property reference a picture
(in some other dynamic array or something) instead of copying it each time?

Donald Myers

---
Subscribe to the digest:
<mailto:<email address removed>>
Unsubscribe:
<mailto:<email address removed>>

Re: what is the best way to load images once?
Date: 07.05.02 18:14 (Tue, 7 May 2002 10:14:39 -0700)
From: Joseph J. Strout
At 12:16 PM -0400 5/7/02, Donald Myers wrote:

>if I need to have the same picture in the object.picture property numours
>time my current code loads the picture each time into the property.

How do you know when this is the case? Are you loading pictures
based on file name or some such?

>This of course takes more and more memory for the same picture each time I
>append a new object to the array which has a duplicate picture (not all are
>duplicates).
>
>Is there any way to make the realbasic picture property reference a picture
>(in some other dynamic array or something) instead of copying it each time?

Sure. Most likely, you should store your pictures in a Dictionary
based on file name or whatever other unique picture identifier is
handy. Then get your picture references from there. See the
Offworld project for an example; it does exactly this for pictures,
sounds, and 3D objects
(http://www.strout.net/info/coding/rb/spacegame/). (Note that that
code requires 4.5a9 to run, but you can comment out the line the
compiler objects to if you just want to see what it does.)

Cheers,
- Joe