hey everyone. i am trying to get a save and load function into my paint program.
but whenever i load the image that was saved. it appears HUGE and it doesent fit on my screen.
does anyone know how to make a loaded image fit the screen perfectly?
here is my code:
Rem Project: PaintSplash V1
Rem Created: 1/25/2006 6:23:20 PM
Rem ***** Main Source File *****
remstart
I shall put in blue gui commands for GUI once i get it
remend
`======paint program======
`=========================
`---Author: ME!----
`=========================
`Main Source File
rem this is history >>>>> SAVE BITMAP "output.bmp", 0 <<<<<<<<<<
`setup
sync on
sync rate 100
size=5
DrawColour as Dword
Rem Project: Paint Program
Rem Created: 2/2/2005 8:07:04 PM
Rem ***** Main Source File *****
`Set backroud color
color backdrop 0,500
`Font
SET TEXT FONT "Arial"
`Set default color
DrawColour = rgb(255,255,255)
set display mode 640,480,16
`Start The Loop
do
if controlkey()=1 and image exist(1)=0
load image "output.bmp",1
paste image 1,0,0
endif
if spacekey()=1
get image 1,0,0,640,480 : save image "output.bmp",1
endif
`print the frame around work area
line screen width() - screen width(),screen height(),0,0
line screen width(),screen height()-screen height(),0,0
line screen width() + screen width(),screen height(),0,479
line screen width() - screen width() + screen width(),screen height() + screen height(),639,0
MX# = mousex()
MY# = mousey()
`Start Button clicking/keystates
if mouseclick()=1
ink DrawColour,0
LineTo(MX#, MY#)
endif
if mouseclick()=0
MoveTo(MX#,MY#)
endif
if escapekey()=1 then end
sync
loop
remstart
AVAILABLE FUNCTIONS*********************************************************************
MoveTo()
Moves the line origin point
LineTo()
Draws a line from the origin to the named position. That position then becomes the
next origin.
FilledCircle()
Draws a filled circle
BoxOutline()
Draws an unfilled box
SaveBitmap()
Saves the bitmap in windows bitmap format
****************************************************************************************
remend
type _2D_LineTo_t
X as integer
Y as integer
endtype
global _2D_LastPoint as _2D_LineTo_t
function MoveTo(X as integer, Y as integer)
_2D_LastPoint.X = X
_2D_LastPoint.Y = Y
endfunction
function LineTo(X as integer, Y as integer)
line _2D_LastPoint.X, _2D_LastPoint.Y, X, Y
MoveTo(X,Y)
endfunction
` This one works out the largest square that can fit inside the circle and draws it.
` It then fills out the top, sides and bottom in the normal way.
function FilledCircle( CX as integer, CY as integer, R as integer )
local x as integer
local y as integer
local i as integer
local s as integer
` Precalculate the square of the radius - this is the hypotenuse
i=R*R
` Calculate the size of the central square
s=R*0.70710678 : ` this number is sin(45)
` Draw it
box CX-s, CY-s, CX+s+1, CY+s+1
s=s+1
` Loop through the bit we have not yet drawn
for y=s to R
x=sqrt( i-(y*y) )
` Draw top and bottom
box CX-x, CY-y, CX+x+1, CY-y+1
box CX-x, CY+y, CX+x+1, CY+y+1
` Draw left and right
box CX-y, CY-x, CX-y+1, CY+x+1
box CX+y, CY-x, CX+y+1, CY+x+1
next y
endfunction
function BoxOutline(x1 as integer, y1 as integer, x2 as integer, y2 as integer)
box x1,y1,x2+1,y1+1
box x2,y1,x2+1,y2+1
box x1,y2,x2+1,y2+1
box x1,y1,x1+1,y2+1
endfunction