Store tons of small pixmaps in ram for later use?

BlitzMax Forums/MaxGUI Module/Store tons of small pixmaps in ram for later use?

Grisu(Posted 2011) [#1]
Hi!

I'm looking for a decent way to store lots of pixmaps into ram so I don't need to access the hdd when they are drawn on a panel.

1. Currently, I extract the image data from a zip to a TRamStream:
-> logo:TRamstream=zrObject.ExtractFile("station_ico.png",False)
(I could transform the data into pixmaps directly but this will raise memory usage by far too much.)

2. When the image is needed I put it on a panel via:
-> SetGadgetPixmap(Canvas,LoadPixmap(logo),PANELPIXMAP_STRETCH)

The issue I have is that image is not displayed on the panel the second time the same pixmap is called?

I might be missing something. - Any alternatives welcome.

Grisu


skn3(Posted 2011) [#2]
What if you had a cache and disk combo... So set a limit for number of images that can be loaded in ram... and then keep the rest on disk. So the most popular/used ones will remain in cache and the unused ones are loaded on demand.

Apart from that I'm not sure why your method wouldn't work???


Grisu(Posted 2011) [#3]
It should, but it doesn't! - I did code a simple example last night. You need GMan's Zip module for this and the included test.zip. See download link at bottom.

Code:


Example source with test zip.file:
-

The second time one tries to put the data from RAM to the panel, it fails. Each time!

OS: Win7 64 Bit

Last edited 2011


jsp(Posted 2011) [#4]
Hi,
you forgot to reset the pointer of the RamStream.

Function Add_Logo_From_RAM()
	SetGadgetPixmap(RadioStationCanvas, Null)
	_logo.seek 0
	If _logo Print "logo" Else Print "Nothing"
	SetGadgetPixmap(RadioStationCanvas, LoadPixmap(_logo), PANELPIXMAP_FIT)
End Function 



Grisu(Posted 2011) [#5]
Didn't know one had to do this. Blame the docs! ;)

With this issue solved the next version of PRP isn't too far away


skn3(Posted 2011) [#6]
ohhhhhhhhhhhhhhhhhhhhhh *slaps head* :D