不用PictureBoxTest.Image屬性,直接把圖形繪制到PictureBoxTest上面就可以了。

網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)建站!專注于網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、小程序設(shè)計、集團企業(yè)網(wǎng)站建設(shè)等服務(wù)項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了呼蘭免費建站歡迎大家使用!
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
分類: 電腦/網(wǎng)絡(luò) 程序設(shè)計 其他編程語言
問題描述:
VB6中的form1.circle (100,200),rgb(0,255,0)的語句如何在VB中使用啊?
急用啊!!!!!!!!
解析:
VB與VB不同。
VB已經(jīng)有專門繪圖的類。
可以定義筆刷然后用Drawing類中的方法繪制。
Private Sub DrawEllipse()
Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim formGraphics as System.Drawing.Graphics
formGraphics = Me.CreateGraphics()
formGraphics.DrawEllipse(myPen, New Rectangle(0,0,200,300))
myPen.Dispose()
formGraphics.Dispose()
End Sub
Private Sub DrawRectangle()
Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim formGraphics as System.Drawing.Graphics
formGraphics = Me.CreateGraphics()
formGraphics.DrawRectangle(myPen, New Rectangle(0,0,200,300))
myPen.Dispose()
formGraphics.Dispose()
End Sub
參考一下下面這段代碼:
‘?首先picturebox1?加載一張圖像
FolderBrowserDialog1.Description?=?"選擇圖片文件夾導(dǎo)入圖片"
FolderBrowserDialog1.ShowDialog()
path?=?FolderBrowserDialog1.SelectedPath()
If?path?=?""?Then?Return
strSrcFile?=?Dir(path??"\*.tif")
PictureBox1.Image?=?Image.FromFile(path??"\"??strSrcFile)
’??然后再在picturebox1中用graphic畫圖而不清空原圖像
'?建立一個畫圖對象
Dim?g?As?Graphics?=?Me.PictureBox1.CreateGraphics
‘?定義畫筆
Dim?myPen?As?System.Drawing.Pen?=?New?System.Drawing.Pen(Color.Blue)
’?畫出矩形框并且填充顏色(顏色保持50%的透明度,使得下面原來的圖片背景能看得到)
g.DrawRectangle(myPen,?New?System.Drawing.Rectangle(50,?50,?30,?20))
g.FillRectangle(New?SolidBrush(Color.FromArgb(50,?Color.YellowGreen)),?New?System.Drawing.Rectangle(50,?50,?30,?20))
'?最后釋放畫圖對象
g.Dispose()
效果大致如下圖所示:
。net 不用api就行
縮放操作
Function 縮放(ByVal bitmap As Bitmap, ByVal 倍數(shù) As Single) As Bitmap
Dim w As Integer = bitmap.Width * 倍數(shù)
Dim h As Integer = bitmap.Height * 倍數(shù)
Dim tem As New Bitmap(w, h)
Dim g As Graphics = Graphics.FromImage(tem)
g.DrawImage(bitmap, New Rectangle(0, 0, w, h), New Rectangle(0, 0, bitmap.Width, bitmap.Height), GraphicsUnit.Pixel)
g.Dispose()
Return tem
End Function
鼠標滾輪事件 MouseWheel
MouseEventArgs.Delta 值可以判斷滾動方向
名稱欄目:vb.net畫圖代碼 vb畫圖程序
當前URL:http://chinadenli.net/article12/hhghgc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、企業(yè)網(wǎng)站制作、App設(shè)計、虛擬主機、靜態(tài)網(wǎng)站、定制開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)