Store tons of small pixmaps in ram for later use?
BlitzMax Forums/MaxGUI Module/Store tons of small pixmaps in ram for later use?
| ||
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 |
| ||
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??? |
| ||
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 |
| ||
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 |
| ||
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 |
| ||
ohhhhhhhhhhhhhhhhhhhhhh *slaps head* :D |