Image does not exist???

Blitz3D Forums/Blitz3D Programming/Image does not exist???

fall_x(Posted 2005) [#1]
Ok, I have a function generateTexture that returns an image handle. This code works :
newimg%=generateTexture(1,1,1,"000255255","255000255","000255255","255000255","000255255","255000255")
setbuffer frontbuffer()
saveimage(newimg,"c:\temp\texture_test.bmp")


However, this doesn't :

newimg%=generateTexture(1,1,1,"000255255","255000255","000255255","255000255","000255255","255000255")
setbuffer frontbuffer()
print "something"
saveimage(newimg,"c:\temp\texture_test.bmp")


The saveimage line throws a "Image does not exist" error. The only difference between the two pieces of code is that the second one has a print statement before I save the image. Isn't that odd? I really don't understand this. Any ideas?


fall_x(Posted 2005) [#2]
Hmmm... how come I always find what I'm looking for right after posting?
Apparantly, the print command sets the graphics mode since it hasn't been set yet, clearing all images (or at least, that's what I think is happening).
Since this was just a test program, I didn't have a Graphics or Graphics3D command, but if I put it on top of the program, it does seem to work.


GfK(Posted 2005) [#3]
Its hard to say, as you haven't included the code for the two functions that make up 66% of the code above.

One things for sure though - 'Print' definititely does *not* set any graphics mode. Your default graphics mode (unless you specify otherwise) is a 400x300 2D window.


RiverRatt(Posted 2005) [#4]
Try using the Text comand rather than print.


fall_x(Posted 2005) [#5]
Try for yourself. You don't need that 66% of the code, just try these two :

This one should give an "image does not exist" :
a=CreateImage(500,600)
Print "test"
DrawImage a,0,0


The second is the same but I commented out the print statement. It should work fine.
a=CreateImage(500,600)
;Print "test"
DrawImage a,0,0



RiverRatt(Posted 2005) [#6]
I am not sure what you are trying to do here, but it looks like you want to create an image with a statement in it. Someone will hopefully correct me if I am wrong but I believe print is a console command and text is a directx command, so if you are using directx for an image wouldn't it make sense to use text?


Sledge(Posted 2005) [#7]

I didn't have a Graphics or Graphics3D command, but if I put it on top of the program, it does seem to work



Yes, it's fairly logical - graphical commands should be used after the graphics/graphics3D command and before endgraphics, otherwise you're just asking for unnecessary problems.


wizzlefish(Posted 2005) [#8]
Who doesn't make a program without Graphics/Graphics3D at the top?!?


fall_x(Posted 2005) [#9]
I am not sure what you are trying to do here, but it looks like you want to create an image with a statement in it. Someone will hopefully correct me if I am wrong but I believe print is a console command and text is a directx command, so if you are using directx for an image wouldn't it make sense to use text?
Firstly, the "just try it yourself" post was meant as a reply to GfK's post. You just happened to post while I was typing this :)
but to answer your question : I'm not trying to print to the image, I was creating some images with a function, this function returned the image handle, but if I printed something (to the screen, not the image) before saving the image, it didn't work and I found this rather odd.

Calling graphics or graphics3D will clear all open images (I believe), but if you don't call these, a print-command apparantly does the same.