whats wrong

Blitz3D Forums/Blitz3D Programming/whats wrong

Graphics 1280,960
SaveBuffer FrontBuffer(),fn%
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)

Function size()
Locate 0,60
sx=Input("size x ")
sy=Input("size y ")
End Function

Function colorsel()
Locate 0,60
r=Input("red " )
g=Input("green " )
b=Input("blue " )
End Function 

Function Inser()
Color r,b,g
Locate MouseX(),MouseY()
d1$=Input$("")
End Function



Function save()
Text 0,60,"Saving.."
;fn% = Input$("")
SaveBuffer(ImageBuffer(image%),"moo.bmp")
Delay 100
Text 0,60,"Done"
Delay 100
End Function

Function load()
Cls
Text 0,60,"Loading.."
;imagel% = Input$("")
image% = LoadImage("moo.bmp")
Text 0,80,"Done"
Delay 100
End Function


can somone tell me whats wrong with this code pleasssse. THis isnt the whole code.. just the functions.. it will not load or save..

Your savebuffer command isn't correct. You need to start a location to save too. If you read the docs, you'll see an example of the savebuffer function. The first instance of it anyway. The second one is correct.

I'm afraid i can't help till i see the code your using to call the functions etc

ok, here is my code

AppTitle "Most Awsome Paint Program By Colton Black"
Graphics 1280,960
SaveBuffer FrontBuffer(),fn%
Global sx=50
Global sy=50
Global r=255
Global g=255
Global b=255
Global width=GraphicsWidth():height=GraphicsHeight()
Global image% = CreateImage(width, height)

ClsColor 255,255,255


Function size()
Locate 0,60
sx=Input("size x ")
sy=Input("size y ")
End Function

Function colorselect()
Locate 0,60
r=Input("red " )
g=Input("green " )
b=Input("blue " )
End Function 

Function Insertword()
Color r,b,g
Locate MouseX(),MouseY()
d1$=Input$("")
End Function

Function save()
Text 0,60,"Saving.."
fn% = Input$("save as: ")
SaveBuffer(ImageBuffer(image%),""+fn%+"")
Delay 100
Text 0,60,"Done"
Delay 100
End Function

Function load()
Cls
Text 0,60,"Loading.."
imagel% = Input$("Load: ")
image% = LoadImage(""+imagel%+"")
Delay 100
Text 0,60,"Done"
Delay 100
End Function

Repeat
Cls()
While Not KeyDown(1)
If KeyDown(46) Colorselect
If KeyDown(56) Then r=255:g=255:b=255
If KeyDown(59) Then 
Color r,g,b
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
EndIf
If KeyHit(29) size
If KeyHit(62) save
If KeyHit(61) 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(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) Insertword
If MouseDown(1)
Color r,g,b
Plot MouseX(),MouseY()
Plot MouseX()+1,MouseY()
Plot MouseX(),MouseY()+1
Plot MouseX()-1,MouseY()
Plot MouseX(),MouseY()-1
Plot MouseX(),MouseY()
Plot MouseX()+1,MouseY()
Plot MouseX(),MouseY()+1
Plot MouseX()-1,MouseY()
Plot MouseX(),MouseY()-1
Plot MouseX(),MouseY()
Plot MouseX()+1,MouseY()
Plot MouseX(),MouseY()+1
Plot MouseX()-1,MouseY()
Plot MouseX(),MouseY()-1
Plot MouseX(),MouseY()
Plot MouseX()+1,MouseY()
Plot MouseX(),MouseY()+1
Plot MouseX()-1,MouseY()
Plot MouseX(),MouseY()-1
Plot MouseX(),MouseY()
Plot MouseX()+1,MouseY()
Plot MouseX(),MouseY()+1
Plot MouseX()-1,MouseY()
Plot MouseX(),MouseY()-1
Plot MouseX(),MouseY()
Plot MouseX()+1,MouseY()
Plot MouseX(),MouseY()+1
Plot MouseX()-1,MouseY()
Plot MouseX(),MouseY()-1
Plot MouseX(),MouseY()
Plot MouseX()+1,MouseY()
Plot MouseX(),MouseY()+1
Plot MouseX()-1,MouseY()
Plot MouseX(),MouseY()-1
Plot MouseX(),MouseY()
Plot MouseX()+1,MouseY()
Plot MouseX(),MouseY()+1
Plot MouseX()-1,MouseY()
Plot MouseX(),MouseY()-1
Plot MouseX(),MouseY()
Plot MouseX()+1,MouseY()
Plot MouseX(),MouseY()+1
Plot MouseX()-1,MouseY()
Plot MouseX(),MouseY()-1
Plot MouseX(),MouseY()
Plot MouseX()+1,MouseY()
Plot MouseX(),MouseY()+1
Plot MouseX()-1,MouseY()
Plot MouseX(),MouseY()-1
EndIf
If MouseDown(2)
Color 255,255,255
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)
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)
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)
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
Color 255,255,255
Plot -1+Rnd(100),35+Rnd(100)
Plot -1+Rnd(100),35+Rnd(100)
Plot -1+Rnd(100),35+Rnd(100)
Plot -1+Rnd(100),35+Rnd(100)
Plot -1+Rnd(100),35+Rnd(100)
Plot -1+Rnd(100),35+Rnd(100)
Plot -1+Rnd(100),35+Rnd(100)
Plot -1+Rnd(100),35+Rnd(100)
Color 150,150,150
Text 0,20,"Keys are S,R,G,B,T,Y,O,P,END,INSERT,F1,F4,F5,DELETE,Left CONTROL,left ALT,C"
Flip
Wend
End Forever


what you trying to do buddy?

I still cant get this paint program thing to load and save images can you help me? can you put the right code in the right places please. Im new to this..


Global IMAGE%

Graphics 800,600,32,2 	; FORCE a WINDOWED PANE

image = CreateImage(800,600)
SetBuffer(ImageBuffer(image))
Cls
;-------- DRAW SOME RANDOM STUFF ------------------
For i=0 To 1000
	Color Rnd(255),Rnd(255),Rnd(255)
	Line Rnd(800),Rnd(600),Rnd(800),Rnd(600)
	
Next

; DEMO SAVE IMAGE __ NOTE: IMAGEBUFFER
SaveBuffer(ImageBuffer(image),"c:\temp.bmp")


SetBuffer(BackBuffer())


While Not KeyHit(1)
	Cls
	DrawImage image,0,0
	Flip
Wend
End





; TO LOAD AN IMAGE 
image = LoadImage("c:\temp.bmp")


blitz monkey;

instead of writing code like this:
Plot -1+Rnd(100),35+Rnd(100)
Plot -1+Rnd(100),35+Rnd(100)
Plot -1+Rnd(100),35+Rnd(100)
Plot -1+Rnd(100),35+Rnd(100)
Plot -1+Rnd(100),35+Rnd(100)
Plot -1+Rnd(100),35+Rnd(100)
Plot -1+Rnd(100),35+Rnd(100)
Plot -1+Rnd(100),35+Rnd(100)
Save yourself some time and use loops. What you have above could be written in three lines:
For iter = 1 to 8
  Plot -1+Rnd(100),35+Rnd(100)
Next


BTW, have you seen my programming tutorial (in my sig)?