this code is supposed to get an image from a screen then put it into a memblock, read the bytes from the memblock into a file, then remove all the old data, reload a new memblock with the image data, make an image from it then use it as sprite and save the image to disk.
`%ProjectTitle%
`======================
`©%Author%
`======================
`Main Source File
sync on
sync rate 40
for i=1 to 4
make object cube i,1
rotate object i,rnd(360),rnd(360),rnd(360)
next i
sync:sync:sync
wait 5000
get image 1,0,0,639,479,1
make memblock from image 1,1
delete image 1
for i=1 to 4
delete object i
next i
open to write 1,"custom.sav"
memblocksize=get memblock size(1)
write word 1,memblocksize
for i=0 to memblocksize-1
write byte 1,memblock byte(1,i)
next i
close file 1
delete memblock 1
open to read 1,"custom.sav"
read word 1,filesize
make memblock 1,filesize
for i=0 to filesize-1
read byte 1,dat
write memblock byte 1,i,dat
next i
close file 1
make image from memblock 1,1
save image "image.bmp",1
cls
do
sprite 1,200,200,1
sync
loop
the only trouble is that it doesnt work, this isn`t actualy my problem, this was actualy going to be the example code that would demonstrate the problem, but it crashes with an internal error 12002 according to the crash report, it doesn`t like the line where you make the image from the memblock, I assume that the data is getting corrupted in some manner, but I can`t work out how, anyway, here is a description of the actual problem I am having and was trying to describe with the help of this code.
(if anyone is wondering why this post gradualy gets bigger with every edit??...well..you recall the forum didn`t like me trying to post?...well it`s at it again, I have to add a bit at a time or it just eats it
)
in my full program I create some DBPro rendered images, grab em to an image number, make a memblock from that number, read the numbers byte by byte from the memblock, write em to a file, close the file, delete all previous objects, images and media, open the file, make a memblock, read the data back byte by byte, close the file, make an image from the memblock, and this is where my problems start, I get a image that has magical properties, you can paste it to the screen and it looks ok, you can use "save image" to save it to a hard drive and it looks ok in preview or inside paint etc, but if I try to use the image for a sprite it just turns into about 12 or so pixels that take up the same area as the sprite, have the right color for parts of the sprite, but its obviously wrong, and I can`t work it out
it isn`t some code error to do with using the right image number, I defined a variable called uniqueimagenumber and used that, I had a bit of code that was just the loader and the lines that made and displayed the image, if I use paste image or save the image to disk it looks ok, if I try to use it as a sprite it just goes La-La, I just subsituted the lines that saved/pasted or tried to display the sprite, same result, it will paste or save, but it refuses to be a sprite
(I have done editing...feel free to comment...and someone ought to fix up these forum bugs, they are getting silly)
Tyger software