如果是簡單的移動,先把圖形繪制到大小和PictureBox的Bitmap上,然后再繪制到PictureBox就行。
成都創(chuàng)新互聯(lián)公司長期為數(shù)千家客戶提供的網(wǎng)站建設(shè)服務(wù),團隊從業(yè)經(jīng)驗10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為千陽企業(yè)提供專業(yè)的網(wǎng)站制作、成都網(wǎng)站建設(shè),千陽網(wǎng)站改版等技術(shù)服務(wù)。擁有十載豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。
不過在VB.NET中用GDI繪制最好用BufferedGraphics圖形緩沖區(qū),速度馬馬虎虎(VB就這樣了),但是不閃爍,不存在背景擦除的問題。
123456789101112Dim picX, picY, x1, y1, x2, y2, a href=";tn=44039180_cprfenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YLPhmknAcvPjNhnvRYPAF90ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHb3rjbkrjc3rHc4nHn1rj0vPs" target="_blank" class="baidu-highlight"gdi/aX, a href=";tn=44039180_cprfenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YLPhmknAcvPjNhnvRYPAF90ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHb3rjbkrjc3rHc4nHn1rj0vPs" target="_blank" class="baidu-highlight"gdi/aYpicX = 0 '要轉(zhuǎn)換的Picture1坐標(biāo)XpicY = 0 '要轉(zhuǎn)換的Picture1坐標(biāo)Yx1 = Picture1.ScaleLefty1 = Picture1.ScaleTopx2 = Picture1.ScaleLeft + Picture1.ScaleWidthy2 = Picture1.ScaleTop + Picture1.ScaleHeight '記錄原先的坐標(biāo)系統(tǒng)Picture1.ScaleMode = 3 '坐標(biāo)系統(tǒng)設(shè)為像素a href=";tn=44039180_cprfenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YLPhmknAcvPjNhnvRYPAF90ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHb3rjbkrjc3rHc4nHn1rj0vPs" target="_blank" class="baidu-highlight"gdi/aX = Round((picX - x1) / (x2 - x1) * Picture1.ScaleWidth)gdiY = Round((picY - y1) / (y2 - y1) * Picture1.ScaleHeight)MsgBox "Picture1的坐標(biāo)(" picX "," picY ")轉(zhuǎn)為GDI坐標(biāo)是(" gdiX "," gdiY ")"Picture1.Scale (x1, y1)-(x2, y2) '改回原先的坐標(biāo)系統(tǒng)
當(dāng)然是全部重畫。
層只不過是制圖軟件弄出來的一個方便的東西而已。
就像你畫畫,畫上去如果你要擦掉當(dāng)然是擦到底色咯。(當(dāng)然GDI+也可以像你畫畫一樣只擦一部分)
GDI+時鐘我寫過一個VB6的。代碼詳見我博客。地址顯然百度不讓貼上= =。所以你可以看下我的資料。
你可以模擬層,就是把所有繪制信息都保存起來。你的流程應(yīng)當(dāng)是:
如果要繪制了,更新繪制信息(可以是數(shù)組啥的。),交給一個Draw過程
Draw過程:根據(jù)繪制信息,全部繪制。
By vIstaswx ,before junior school graduation exam.
GDI繪圖用字體必須安裝才能使用
在客戶機部署應(yīng)用程序時,安裝該字體就行
繪圖代碼寫在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()