Here's the code to save images into one file using memblocks.
rem Example of storing multiple images inside a memblock, saving it then opening it
rem David Tattersall
` Make 3 images for us to store
cls rgb(255,0,0)
get image 1,0,0,100,100
cls rgb(0,255,0)
get image 2,0,0,100,100
cls rgb(0,0,255)
get image 3,0,0,100,100
` Make 3 memblocks from these images
make memblock from image 1,1
make memblock from image 2,2
make memblock from image 3,3
` Open a file to save these to
if file exist("c:/saved.dat") then delete file "c:/saved.dat"
open to write 1,"c:/saved.dat"
` Save the image memblocks to the file
write memblock 1,1
write memblock 1,2
write memblock 1,3
` Close the file
close file 1
` User prompt
cls 0
center text 320,240,"File saved. Check C:/saved.dat then press any key to open file...."
sync
wait key
` Delete all the images + memblocks
for i = 1 to 3
delete image i
delete memblock i
next i
`Open file + images inside
open to read 1,"c:/saved.dat"
read memblock 1,1 : make image from memblock 1,1
read memblock 1,2 : make image from memblock 2,2
read memblock 1,3 : make image from memblock 3,3
close file 1
` Now display the images
for i = 1 to 3
cls
paste image i,0,0
center text 320,440,"Image "+str$(i)+"... any key the continue"
sync
wait key
next i
This code will make 3 images, then save them to c:/saved.dat. It will then load them back from the file an show them in turn.
For your presentation you will want to write the number of images first into your file, then write all the memblocks. When you come to loading them, read the number of images first then use a for loop to load them back again:
NumImages = 11
open to write 1,file$
write string 1,str$(NumImages)
for i = 1 to NumImages
write memblock 1,i
next i
close file 1
`Load
open to write 1,file$
read string 1,NumImages$:NumImages = val(NumImages$)
for i = 1 to NumImages
read memblock 1,i
next i
close file 1
The reason why I write the NumImages var to the file as a string is that I'm not sure about all the other write commands, and I know that one works
You are the
th person to view this signature.
Programmers don't die, they just
Gosub without
return....