VB系統(tǒng)的坐標(biāo)原點(diǎn)在左上角,X軸的正方向是水平向右,而Y軸的正方向是垂直向下。所以,要繪制三角函數(shù)的曲線,自己可以通過改變點(diǎn)坐標(biāo)的方法來實(shí)現(xiàn),當(dāng)然,VB.NET提供了相應(yīng)的方法可以來實(shí)現(xiàn)坐標(biāo)變換,也可以通過VB.Net的Graphics類提供的平移、旋轉(zhuǎn)等轉(zhuǎn)換來實(shí)現(xiàn)。
創(chuàng)新互聯(lián)成立10余年來,這條路我們正越走越好,積累了技術(shù)與客戶資源,形成了良好的口碑。為客戶提供做網(wǎng)站、成都網(wǎng)站建設(shè)、網(wǎng)站策劃、網(wǎng)頁設(shè)計(jì)、域名與空間、網(wǎng)絡(luò)營銷、VI設(shè)計(jì)、網(wǎng)站改版、漏洞修補(bǔ)等服務(wù)。網(wǎng)站是否美觀、功能強(qiáng)大、用戶體驗(yàn)好、性價(jià)比高、打開快等等,這些對于網(wǎng)站建設(shè)都非常重要,創(chuàng)新互聯(lián)通過對建站技術(shù)性的掌握、對創(chuàng)意設(shè)計(jì)的研究為客戶提供一站式互聯(lián)網(wǎng)解決方案,攜手廣大客戶,共同發(fā)展進(jìn)步。
下面是我通過自己變換實(shí)現(xiàn)的示例,提供參考;我的環(huán)境是VB.NET 2010
Imports System.Math
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
? '1,獲得一個(gè)Graphics對象
? Dim MyGraphics As Graphics
? MyGraphics = PictureBox1.CreateGraphics
? '2,定義一個(gè)Pen對象,用于繪制圖形(輪廓線)
? Dim MyPen As New Pen(Color.Black, 1)
? '3,定義一個(gè)Brush對象,用于填充圖形(如果需要填充的話)
? Dim MyBrush As New SolidBrush(Color.Orange)
? MyGraphics.DrawLine(MyPen, 0, 200, 700, 200)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
? '1,獲得一個(gè)Graphics對象
? Dim MyGraphics As Graphics
? MyGraphics = PictureBox1.CreateGraphics
? '2,定義一個(gè)Pen對象,用于繪制圖形(輪廓線)
? Dim MyPen As New Pen(Color.Black, 1)
? '3,定義一個(gè)Brush對象,用于填充圖形(如果需要填充的話)
? Dim MyBrush As New SolidBrush(Color.Orange)
? '聲明橫向和縱向比例變量
? Dim Heng As Integer = 20
? Dim Zong As Integer = 50
? '先獲得正弦值,保存到點(diǎn)坐標(biāo)數(shù)組
? Dim MyPoints(700) As Point
? Dim i As Integer
? For i = 0 To 700
? ? ? MyPoints(i) = New Point(i * Heng, 200 + Sin(i) * Zong)
? Next
? '采用繪制光滑線連接點(diǎn)的方式繪制曲線
? MyGraphics.DrawCurve(MyPen, MyPoints)
End Sub
End Class
顯示的效果圖:
這問題有點(diǎn)籠統(tǒng),軟糖來說說把:
圖像處理由System.Drawing命名空間負(fù)責(zé)。
主要是Bitmap類和Graphics類。
Bitmap表示一個(gè)位圖,可以是BMP,JPG,PNG等文件。
裝載位圖
Dim?位圖?As?Bitmap?=?Bitmap.FromFile("C:\Image1.PNG")
Graphics表示一張畫紙,能夠進(jìn)行繪制操作。
它可以被窗體、控件、位圖調(diào)用CreateGraphics()方法來創(chuàng)建。
然后調(diào)用Graphics.Draw開頭的一系列函數(shù)來繪制圖像和圖形,F(xiàn)ill開頭的填充圖形。
創(chuàng)建畫紙并繪制位圖
Dim?畫紙?As?Graphics?=?Me.CreateGraphics()
畫紙.DrawImage(位圖,?100,?100,?256,?256)
可以將上面三行放到Form1_Load中測試,把路徑改一下,
還可以把Me改為能在上面繪圖的控件的名稱。
更多內(nèi)容請看MSDN的System.Drawing命名空間。
如滿意,請采納,謝謝。
下面的例子通過重載Form 窗體的OnPaint()方法繪制GDI圖形Protected Overrides Sub onpaint(ByVal e As System Windows Forms PaintEventArgs)注釋 /////////////繪制任意直線Dim g As Graphics = e GraphicsDim mypen As Pen = New Pen(Color Red )g DrawLine(mypen )注釋 /////////////繪制矩形(任意直線構(gòu)成的封閉圖形)Dim point As PointF = New PointF( F F)Dim point As PointF = New PointF( F F)Dim point As PointF = New PointF( F F)Dim point As PointF = New PointF( F F)Dim curvepoints As PointF() = {point point point point }g DrawPolygon(New Pen(Color Blue ) curvepoints)注釋 ////////////文本表示Dim FFamily As FontFamily = New FontFamily( Arial )Dim font As Font = New Font(FFamily FontStyle Bold FontStyle Italic GraphicsUnit Pixel)Dim text As String = I love you! Dim solidbrush As SolidBrush = New SolidBrush(Color Red)Dim pr As PointF = New PointF( )e Graphics DrawString(text font solidbrush pr)注釋 ////////////平面繪制Dim rec As RectangleF = New RectangleF( )g DrawPie(mypen rec )注釋 ///////////封閉圖形 應(yīng)該是個(gè)圓g DrawClosedCurve(mypen curvepoints Drawing Drawing D FillMode Alternate)注釋 ///////////大家自己試試看吧g DrawArc(mypen )g DrawCurve(mypen curvepoints)g DrawBezier(mypen )g DrawBeziers(mypen curvepoints)注釋 //////////這可是一個(gè)圓Dim rec As RectangleF = New RectangleF( )g DrawEllipse(mypen rec )注釋 //////////這是一個(gè)橢圓Dim rec As RectangleF = New RectangleF( )g DrawEllipse(mypen rec )End Sub 這些是我自己試驗(yàn)出來的 當(dāng)然了 還有好多 我只是開了一個(gè)頭 大家要是發(fā)現(xiàn)什么好東東 別忘了通知一下 ) lishixinzhi/Article/program/net/201311/11800
不用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)?'定義藍(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
。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)方向
分類: 電腦/網(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