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
Saving image
BlitzPlus Forums/BlitzPlus Programming/Saving image If its a drawing program, I'd recommend drawing straight onto a blank image created by CreateImage()
Then save the image using SaveBuffer()
pcode:-
Something like that! ;)
Then save the image using SaveBuffer()
pcode:-
image = CreateImage(width, height) if save SaveBuffer(ImageBuffer(image),"imageFile.bmp") end if if load image = LoadImage("imageFile.bmp") end if
Something like that! ;)
THanks Dabhand!
ok.. its not working
it says image does not exist
?
it says image does not exist
?
this is my prgram(dont make fun of it)
Graphics 1028,960
SetBuffer ImageBuffer()
Global r=255
Global g=255
Global b=255
Global save=0
Global load=0
Global width=GraphicsWidth:height=GraphicsHeight
Global a$="Yo mamas so fat that she is fat"
Global b1$="Yo mamas fat"
Global c$="Yo mamas so fat...oh! I can't breath!"
Global image = CreateImage(width, height)
Goto main
.m
Locate 0,40
Global d1$=Input$("What do you want to say? ")
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
Cls
Text 0,80,"Done"
Delay 100
Cls
End If
Goto main
.main
While Not KeyDown(1)
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(79)d$=a$
If KeyHit(80)d$=b1$
If KeyHit(81)d$=c$
If KeyHit(82)d$=d1$
If KeyHit(210) Goto m
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(40),MouseY()+Rnd(40)
EndIf
If KeyHit(211)
Cls
EndIf
If MouseDown(3)
Color r,g,b
Plot MouseX()+Rnd(50),MouseY()+Rnd(50)
Plot MouseX()+Rnd(50),MouseY()+Rnd(50)
Plot MouseX()+Rnd(50),MouseY()+Rnd(50)
Plot MouseX()+Rnd(50),MouseY()+Rnd(50)
EndIf
If KeyDown(50)
Color r,g,b
Text MouseX(),MouseY(),""+d$+""
EndIf
Text 0,20,"Keys are S,R,G,B,T,Y,O,P,NUM=1,2,3,0,END"
Wend
Graphics 1028,960
SetBuffer ImageBuffer()
Global r=255
Global g=255
Global b=255
Global save=0
Global load=0
Global width=GraphicsWidth:height=GraphicsHeight
Global a$="Yo mamas so fat that she is fat"
Global b1$="Yo mamas fat"
Global c$="Yo mamas so fat...oh! I can't breath!"
Global image = CreateImage(width, height)
Goto main
.m
Locate 0,40
Global d1$=Input$("What do you want to say? ")
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
Cls
Text 0,80,"Done"
Delay 100
Cls
End If
Goto main
.main
While Not KeyDown(1)
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(79)d$=a$
If KeyHit(80)d$=b1$
If KeyHit(81)d$=c$
If KeyHit(82)d$=d1$
If KeyHit(210) Goto m
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(40),MouseY()+Rnd(40)
EndIf
If KeyHit(211)
Cls
EndIf
If MouseDown(3)
Color r,g,b
Plot MouseX()+Rnd(50),MouseY()+Rnd(50)
Plot MouseX()+Rnd(50),MouseY()+Rnd(50)
Plot MouseX()+Rnd(50),MouseY()+Rnd(50)
Plot MouseX()+Rnd(50),MouseY()+Rnd(50)
EndIf
If KeyDown(50)
Color r,g,b
Text MouseX(),MouseY(),""+d$+""
EndIf
Text 0,20,"Keys are S,R,G,B,T,Y,O,P,NUM=1,2,3,0,END"
Wend
Couple of things, first off, SetBuffer ImageBuffer() at the top wont work as you dont specify an image in the parameters. (eg SetBuffer ImageBuffer(image) ) And in this case, your calling it before you have created one single image.
Secondly, GraphicsWidth and GraphicsHeight requires opening and closing brackets after each command, that should correctly set up the image and it will exist
GraphicsWidth()
GraphicsHeight()
I've also noticed that you are'nt drawing it in your main loop, you need to SetBuffer ImageBuffer(image) before drawing on it, then after that, SetBuffer BackBuffer() then draw your image/flip etc etc. e.g.
Hope that helps
Secondly, GraphicsWidth and GraphicsHeight requires opening and closing brackets after each command, that should correctly set up the image and it will exist
GraphicsWidth()
GraphicsHeight()
I've also noticed that you are'nt drawing it in your main loop, you need to SetBuffer ImageBuffer(image) before drawing on it, then after that, SetBuffer BackBuffer() then draw your image/flip etc etc. e.g.
SetBuffer ImageBuffer(image) //Draw stuff SetBuffer BackBuffer() DrawImage image,0,0 Flip
Hope that helps
and please place your code inside the
[code] and [/code] tags so the formatting is preserved