没试过。也许这样能行:画新图时强制使前一秒的屏幕不刷新重画。具体怎么实现继续探索。
成都创新互联于2013年成立,是专业互联网技术服务公司,拥有项目成都网站建设、网站设计网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元印台做网站,已为上家服务,为印台各地企业和个人服务,联系电话:028-86922220
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click '好处:画的图刷新不会消失
PictureBox1.Image = Nothing
Dim wid As Integer = PictureBox1.ClientSize.Width
Dim hgt As Integer = PictureBox1.ClientSize.Height
Dim bm As New Bitmap(wid, hgt)
Dim g As Graphics = Graphics.FromImage(bm)
'画图代码,比如下面的直线
g.DrawLine(Pens.Red, 10, 10, 500, 10)
'画图代码
PictureBox1.Image = bm
PictureBox1.Refresh()
g.Dispose()
PictureBox1.Image.Save("C:\1.jpg")
End Sub
不用PictureBoxTest.Image属性,直接把图形绘制到PictureBoxTest上面就可以了。
Dim button As Integer = 0
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) _
Handles Button1.Click
Using g As Graphics = Graphics.FromHwnd(PictureBoxTest.Handle)
Dim penRed As Pen = New Pen(Color.Red, 1) '定义红色画笔
Dim penblue As Pen = New Pen(Color.Blue, 1) '定义蓝色画笔
If button = 0 Then
g.DrawLine(penRed, 0, 0, 100, 100)
button = 1
ElseIf button = 1 Then
g.DrawLine(penblue, 100, 100, 200, 200)
button = 0
End If
End Using
End Sub