saving image

Blitz3D Forums/Blitz3D Programming/saving image

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

How can i save a screenshot of the program window by pressing a key? i have made a paint program and i need to save and load images. When i load them i need to be able to edit them.please help
'
Graphics 1028,960
Global sx=50
Global sy=50
Global r=255
Global g=255
Global b=255
Global save=0
Global load=0
Global width=GraphicsWidth:height=GraphicsHeight
Global image = CreateImage(width, height)
Goto main

.size
Locate 0,60
sx=Input("size x")
sy=Input("size y")
Goto main

.i
Locate MouseX(),MouseY()
Global d1$=Input$("")
Goto main



.save
If save=1
Text 0,60,"Saving.."
SaveBuffer(ImageBuffer(image),"imageFile.bmp")
Delay 100
Cls
Text 0,60,"Done"
Delay 100
Cls
End If
Goto main

.load
If load=1
Text 0,60,"Loading.."
image = LoadImage("imagefile.bmp")
Delay 100
Text 0,80,"Done"
Delay 100
End If
Goto main



.main
While Not KeyDown(1)
If KeyHit(29) Then Goto size
If KeyHit (62) Then save=1:Goto save
If KeyHit (61) Then load=1:Goto load
If KeyHit(19)r=255:g=0:b=0
If KeyHit(34)r=0:g=255:b=0
If KeyHit(48)r=0:g=0:b=255
If KeyHit(17)r=255:g=255:b=255
If KeyHit(25)r=111:g=0:b=111
If KeyHit(21)r=255:g=255:b=0
If KeyHit(20)r=0:g=255:b=255
If KeyHit(24)r=249:g=81:b=0
If KeyHit(31)r=98:g=98:b=0
If KeyHit(210) Goto i
If MouseDown(1)
Color r,g,b
Plot MouseX(),MouseY()
Plot MouseX()+1,MouseY()
Plot MouseX(),MouseY()+1
EndIf
If MouseDown(2)
Color 0,0,0
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
EndIf
If KeyHit(211)
Cls
EndIf
If MouseDown(3)
Color r,g,b
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
EndIf
Text 0,20,"Keys are S,R,G,B,T,Y,O,P,NUM=1,2,3,0,END"
Wend