16,555
社区成员
发帖
与我相关
我的任务
分享
Public Class Form1
Private bufImage As Bitmap = Nothing '缓冲区'
Private isNewDraw As Boolean = False
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
bufImage = New Bitmap(PictureBox1.Width, PictureBox1.Height) '假定输出控件为PictureBox1。'
Timer1.Interval = CInt(1000 / 18) '18帧/秒'
'Timer1.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim g As Graphics = Graphics.FromImage(bufImage)
For i As Long = 1 To XXX
'通过 g 在缓冲区中画图'
Next
isNewDraw = True '无论绘图多么频繁,只设置更新标志,一个周期内的绘图最终只刷新一帧。'
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If isNewDraw Then
PictureBox1.Image = New Bitmap(bufImage)
isNewDraw = False '清除标志,后面的帧如果没有绘图就不用刷新了。'
End If
End Sub
End Class