拖一個PictureBox1控件
成都創(chuàng)新互聯(lián)公司主營夏邑網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,app軟件定制開發(fā),夏邑h5小程序設(shè)計搭建,夏邑網(wǎng)站營銷推廣歡迎夏邑等地區(qū)企業(yè)咨詢
創(chuàng)建一個Paint事件。在事件中加入
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
' Create pens.
Dim redPen As New Pen(Color.Red, 3)
Dim greenPen As New Pen(Color.Green, 3)
' Create points that define curve.
Dim point1 As New Point(50, 50)
Dim point2 As New Point(100, 25)
Dim point3 As New Point(200, 5)
Dim point4 As New Point(250, 50)
Dim point5 As New Point(300, 100)
Dim point6 As New Point(350, 200)
Dim point7 As New Point(250, 250)
Dim curvePoints As Point() = {point1, point2, point3, point4, _
point5, point6, point7}
' Draw lines between original points to screen.
e.Graphics.DrawLines(redPen, curvePoints)
' Draw curve to screen.
e.Graphics.DrawCurve(greenPen, curvePoints)
End Sub
得到數(shù)據(jù)后,改point的數(shù)據(jù)。然后PictureBox1.Refresh()就行了
GDI繪圖用字體必須安裝才能使用
在客戶機部署應(yīng)用程序時,安裝該字體就行
如果是簡單的移動,先把圖形繪制到大小和PictureBox的Bitmap上,然后再繪制到PictureBox就行。
不過在VB.NET中用GDI繪制最好用BufferedGraphics圖形緩沖區(qū),速度馬馬虎虎(VB就這樣了),但是不閃爍,不存在背景擦除的問題。
繪圖代碼寫在Paint事件中,如
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim g As Graphics = Me.CreateGraphics
g.DrawLine(Pens.Red, 100, 100, 200, 100)
End Sub
'方法二:在 PictureBox1上顯示圖像----圖畫在Bitmap
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)
'畫圖代碼
'畫圖代碼
PictureBox1.Image = bm
PictureBox1.Refresh()
g.Dispose()
當然是全部重畫。
層只不過是制圖軟件弄出來的一個方便的東西而已。
就像你畫畫,畫上去如果你要擦掉當然是擦到底色咯。(當然GDI+也可以像你畫畫一樣只擦一部分)
GDI+時鐘我寫過一個VB6的。代碼詳見我博客。地址顯然百度不讓貼上= =。所以你可以看下我的資料。
你可以模擬層,就是把所有繪制信息都保存起來。你的流程應(yīng)當是:
如果要繪制了,更新繪制信息(可以是數(shù)組啥的。),交給一個Draw過程
Draw過程:根據(jù)繪制信息,全部繪制。
By vIstaswx ,before junior school graduation exam.