新聞中心
vb.net 畫圖 如何保持圖形
不用PictureBoxTest.Image屬性,直接把圖形繪制到PictureBoxTest上面就可以了。
網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)建站!專注于網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、小程序設(shè)計(jì)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了呼蘭免費(fèi)建站歡迎大家使用!
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)?'定義藍(lán)色畫筆?
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
VB.net中如何畫圖?
分類: 電腦/網(wǎng)絡(luò) 程序設(shè)計(jì) 其他編程語言
問題描述:
VB6中的form1.circle (100,200),rgb(0,255,0)的語句如何在VB中使用?。?/p>
急用?。。。。。。。?!
解析:
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
vb.net 畫圖對(duì)象問題
參考一下下面這段代碼:
‘?首先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畫圖而不清空原圖像
'?建立一個(gè)畫圖對(duì)象
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))
'?最后釋放畫圖對(duì)象
g.Dispose()
效果大致如下圖所示:
VB.NET picturebox 內(nèi)繪圖完圖形放大縮小移動(dòng) 鼠標(biāo)控制 。比較笨看了VB的代碼不明白 求解
。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
鼠標(biāo)滾輪事件 MouseWheel
MouseEventArgs.Delta 值可以判斷滾動(dòng)方向
分享名稱:vb.net畫圖代碼 vb畫圖程序
網(wǎng)站地址:http://www.dlmjj.cn/article/hhghgc.html