Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What do you graphics gurus think?..
#1
If you just have a few small images, approx. 10, would it be better to load each at the top of the program and keep them in memory, or use the _LOAD statement each time they are needed? In my routine, these images overlay each other, so they get exchanged a lot; so the way I'm doing this now is to load them only when needed, and free them once loaded and displayed.

Here is the routine I'm working on: https://qb64phoenix.com/forum/showthread...8#pid23598

Thanks,

Pete
Reply
#2
(03-07-2024, 07:03 PM)Pete Wrote: If you just have a few small images, approx. 10, would it be better to load each at the top of the program and keep them in memory, or use the _LOAD statement each time they are needed? In my routine, these images overlay each other, so they get exchanged a lot; so the way I'm doing this now is to load them only when needed, and free them once loaded and displayed.

Here is the routine I'm working on: https://qb64phoenix.com/forum/showthread...8#pid23598

Thanks,

Pete

If you are going to display those images often (like in the routine, you shared), then it is a good idea to load and cache the images in memory until you are sure you'll not need those anymore. The _LOADIMAGE function adds quite a bit of processing overhead that may not really show until you are calling _LOADIMAGE inside tight loops. My two cents.  Smile
Reply
#3
10 small images?  I'd just load them and then use them.  Forget about freeing them.  What's another 200MB memory usage when today's PCs come with 8-bazillion GB RAM for the cheap bottom-of-the-bin economy PCs?
Reply
#4
Quote:f you are going to display those images often (like in the routine, you shared), then it is a good idea to load and cache the images in memory until you are sure you'll not need those anymore. The _LOADIMAGE function adds quite a bit of processing overhead that may not really show until you are calling _LOADIMAGE inside tight loops. My two cents.  [Image: smile.png]

Good point. If the buttons were used in a form typing routine, the image would need to be loaded each time a key was pressed. I suppose what I can do is try some routines with the images saved in memory, and see how much memory the app uses. There will no doubt be some good balance between CPU and memory usage.

Thanks for the reply,

Pete Smile
Reply
#5
In reply to Professor Steve...

You forget, sir, that I am the proud owner of a laptop signed by Fred Flintstone from the 10,000 BC Comic-Con convention.

Pete Big Grin
Shoot first and shoot people who ask questions, later.
Reply
#6
(03-07-2024, 07:03 PM)Pete Wrote: If you just have a few small images, approx. 10, would it be better to load each at the top of the program and keep them in memory, or use the _LOAD statement each time they are needed? In my routine, these images overlay each other, so they get exchanged a lot; so the way I'm doing this now is to load them only when needed, and free them once loaded and displayed.

Here is the routine I'm working on: https://qb64phoenix.com/forum/showthread...8#pid23598

Thanks,

Pete
Load them all at the beginning. Many of the games I've written have well over 10 images (sometimes in the hundreds) loaded in memory ready for use. The combination of _LOADIMAGE and disk access over and over will slow things down for you.
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply
#7
I'm making a website program to display images for a company that sells diapers. So you're advice is I should load them first? Hmmm, despite faster processing, won't that have a negative effect on sales, gross profit aside?

Pete Confused
Shoot first and shoot people who ask questions, later.
Reply




Users browsing this thread: 5 Guest(s)