Graphics 800,600,16,1
SetBuffer BackBuffer()
Global temporary=CreateImage(800,600) ;<y2 Then
Cls
drawscaled image,BackBuffer(),0,0,x1,y1
a=a+1
If MilliSecs()-t>1000 Then
fps = a
a = 0
t = MilliSecs()
End If
Color 255,255,255
ms = 100/fps
Text 0,0,fps+" fps / "+ms+" ms"
Flip
EndIf
Wend
WaitKey()
FreeImage temporary
FreeImage image
End
;---------------------------------------------------------------------
Function drawscaled(src,dest,x,y,width,height)
src_width =ImageWidth (src)
src_height =ImageHeight(src)
src_buffer =ImageBuffer(src)
tmp_buffer =ImageBuffer(temporary)
div_x# =Float#(src_width) /Float#(width)
div_y# =Float#(src_height)/Float#(height)
If width=0 Or height=0 Or src_width=0 Or src_height=0 Then Return
For i=0 To width-1
CopyRect i*div_x#,0,1,src_height,i,0,src_buffer,tmp_buffer
Next
For i=0 To height-1
CopyRect 0,i*div_y#,width,1,x,y+i,tmp_buffer,dest
Next
End Function
|