QB64 Phoenix Edition
What do you graphics gurus think?.. - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11)
+--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2)
+--- Thread: What do you graphics gurus think?.. (/showthread.php?tid=2492)



What do you graphics gurus think?.. - Pete - 03-07-2024

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.php?tid=2483&pid=23598#pid23598

Thanks,

Pete


RE: What do you graphics gurus think?.. - a740g - 03-07-2024

(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.php?tid=2483&pid=23598#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


RE: What do you graphics gurus think?.. - SMcNeill - 03-07-2024

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?


RE: What do you graphics gurus think?.. - Pete - 03-07-2024

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


RE: What do you graphics gurus think?.. - Pete - 03-07-2024

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


RE: What do you graphics gurus think?.. - TerryRitchie - 03-07-2024

(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.php?tid=2483&pid=23598#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.


RE: What do you graphics gurus think?.. - Pete - 03-07-2024

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