真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

vb.net樣條線的簡單介紹

在vbnet中,我在picturebox里面畫線,用滾動條拉動picturebox顯示最新畫出的圖

vb.net沒有自動重畫功能,要在Paint事件中寫代碼對圖形重畫。

讓客戶滿意是我們工作的目標,不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價值的長期合作伙伴,公司提供的服務(wù)項目有:主機域名、網(wǎng)頁空間、營銷軟件、網(wǎng)站建設(shè)、龍圩網(wǎng)站維護、網(wǎng)站推廣。

另外一種情況,如果在Image屬性設(shè)置了一幅圖像,圖像能夠保持完整性的。所以你可以把圖形繪在位圖上,把位圖綁定到Image屬性上。

先綁定一幅位圖:

Dim bm as New BitMap(800,600)

PictureBox1.Image=bm

作圖時不是對圖片框,而是在位圖上作圖。

dim gr As Grapthics=Graphics.FromImage(bm) '建立位圖的繪圖設(shè)備

接下來就可用gr 的繪圖方法作圖

作完圖,PictureBox1.Refresh 刷新一下。

vb中樣條曲線問題

不引用的話,VB做不到。這事情要看VB的版本。如果是6.0的話,要去網(wǎng)上下載GDIPLUS的庫文件或者自己聲明GDI+的API。如果是VB.NET的話,VB自帶GDI+,但是也可以下載GDIPLUS庫來用。如果不知道去哪里下載,我下載有,你可以問我要。我使用VB6.0。下載gdiplus以后,在VB里面引用這個庫,注意要選擇“所有文件”才能看到這個庫。gdi+里面的path功能可以實現(xiàn)樣條:Private

TOKEN

As

Long'GDI+對象

Private

Graphics

As

Long'畫板

Private

Sub

InitGDIPlus()

'初始化GDI+

Dim

uInput

As

GdiplusStartupInput

uInput.GdiplusVersion

=

1

If

GdiplusStartup(TOKEN,

uInput)

Ok

Then

'初始化錯誤

MsgBox

"GDI+

初始化錯誤。程序即將關(guān)閉。",

vbCritical,

"InitError"

End

End

If

GdipCreateFromHDC

Me.hDC,

Graphics'創(chuàng)建畫板

GdipSetSmoothingMode

Graphics,

SmoothingModeAntiAlias'設(shè)置為反鋸齒

End

SubPrivate

Sub

TerminateGDIPlus()

GdipDeleteGraphics

Graphics

'釋放graphics占用的內(nèi)存

GdiplusShutdown

TOKEN

'關(guān)閉GDI+

End

SubPrivate

Sub

Form_Load()

InitGDIPlus

'初始化End

SubPrivate

Sub

Command1_Click()

Dim

path

As

Long

Dim

m(3)

As

POINTF

'以下是坐標,你可以自由改變

m(0).x

=

m(0).y

=

m(1).x

=

10

m(1).y

=

100

m(2).x

=

20

m(2).y

=

3

m(3).x

=

500

m(3).y

=

100

Dim

pen

As

Long

GdipCreatePen1

HFF000000,

2,

UnitPixel,

pen

'創(chuàng)建畫筆,用來畫出樣條

GdipCreatePath

FillModeAlternate,

path

'創(chuàng)建path

GdipAddPathBeziers

path,

m(0),

4

'創(chuàng)建樣條'Count是說坐標的個數(shù),points只能傳遞數(shù)組的第一個元素,不能傳遞數(shù)組。

GdipDrawPath

Graphics,

pen,

path

'畫出樣條

GdipDeletePen

pen

'刪除畫筆

GdipDeletePath

path

'刪除樣條End

SubPrivate

Sub

Form_Unload(Cancel

As

Integer)

TerminateGDIPlus

'刪除GDI+

End

Sub

關(guān)于vb.net中繪圖并保存圖片的問題

Imports System.Drawing.Imaging

Public Class Form1

Dim imageName As String = "C:\Documents and Settings\...\1126.jpg "

Dim i As Image = Image.FromFile(imageName)

Dim g As Graphics = Graphics.FromImage(i) '此處從背景圖創(chuàng)建Greaphics

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

'劃線

Dim BluePen As New Pen(Color.Blue, 5)

BluePen.DashStyle = Drawing2D.DashStyle.Solid

g.DrawLine(BluePen, 100.0F, 170, 500.0F, 170)

g.Dispose()

PictureBox1.Image = i

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

'退出

Me.Close()

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

'存盤

i.Save( "C:\testimage.jpg ", ImageFormat.Jpeg)

i.Dispose()

End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

PictureBox1.Image = i

End Sub

End Class

怎么用VB。net 畫直線

dim bmp as new bitmap(width,height)dim g as graphics=graphics.fromimage(bmp)g.drawlines(pen.blue,20,20,100,20)backgroundimage=bmp

vb.net 畫線再畫保留以前畫得

可以把所有畫的線都保存在一個列表中,畫的時候全部畫出即可。如下:

Public?Class?Form1

Class?Line? ? ? '直線類

? Public?Point1,?Point2?As?Point? ? ?'成員,直線的兩個端點

? Sub?New(p1?As?Point,?p2?As?Point)? ?'構(gòu)造方法

? ? ? Point1?=?p1

? ? ? Point2?=?p2

? End?Sub

? Public?Sub?Draw(g?As?Graphics)? ? ? '繪制方法

? ? ? g.DrawLine(Pens.Black,?Point1,?Point2)

? End?Sub

End?Class

Private?Lines?As?New?List(Of?Line)? ? ? '列表用于保存所有畫下的直線

Private?Sub?Form1_Load(sender?As?Object,?e?As?EventArgs)?Handles?MyBase.Load

? BackColor?=?Color.White

? DoubleBuffered?=?True? ? ? ?'開啟雙緩沖可有效避免閃爍

End?Sub

Private?Sub?Form1_MouseDown(sender?As?Object,?e?As?MouseEventArgs)?Handles?Me.MouseDown

? Lines.Add(New?Line(e.Location,?e.Location))? ? ?'在直線列表中添加直線

End?Sub

Private?Sub?Form1_MouseMove(sender?As?Object,?e?As?MouseEventArgs)?Handles?Me.MouseMove

? If?e.Button??Windows.Forms.MouseButtons.Left?Then?Return?'左鍵未按下

? '鼠標拖動時改變列表最后一條直線(也即當前直線的第二個端點)

? Lines(Lines.Count?-?1).Point2?=?e.Location

? Refresh()? ? ? ?'刷新窗體

End?Sub

'在Form的Paint事件中繪制所有直線,每次Form1重繪時都會觸發(fā)Paint事件

'PS:?也可以通過重寫OnPaint方法來達到類似的效果

Private?Sub?Form1_Paint(sender?As?Object,?e?As?PaintEventArgs)?Handles?Me.Paint

? e.Graphics.SmoothingMode?=?Drawing2D.SmoothingMode.AntiAlias? ? '開啟抗鋸齒

? For?Each?l?In?Lines? ? ?'遍歷所有直線

? ? ? l.Draw(e.Graphics)? '調(diào)用繪制方法,傳入的參數(shù)可以理解為畫布

? Next

End?Sub

End?Class

運行效果:

在VB NET中,在Form_Load中創(chuàng)建graphics類,并繪制直線,為什么執(zhí)行程序后發(fā)現(xiàn)直線繪制不出來?

1. 創(chuàng)建一個Graphics對象實例。

繪制圖形必須創(chuàng)建Graphics對象。如果是在窗體上繪圖,要使用下列代碼創(chuàng)建Graphics對象;

Dim MyGraphics As Graphics = Me.CreateGraphics

如果是在PictrueBox里繪圖,要使用下列代碼創(chuàng)建Graphics對象;

Dim MyGraphics As Graphics = PictureBox1.CreateGraphics

2. 定義一個Brush對象,用來填充圖形(如果你需要填充的話)。

如果填充封閉曲線或者多邊形,必須創(chuàng)建Brush對象(或者Brush類的繼承類對象),用來確定填充的顏色。例如下面的代碼,創(chuàng)建了一個填充紅色的畫刷對象。在最后的括號里,用Color結(jié)構(gòu)指定的枚舉值,確定畫刷的顏色。限于篇幅有關(guān)Color結(jié)構(gòu)這里不展開,可能在后續(xù)博文里介紹。

Dim RedBrush As New SolidBrush(Color.Red)


分享標題:vb.net樣條線的簡單介紹
當前鏈接:http://weahome.cn/article/docgchg.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部