189 8069 5689

vb.net画曲线控件 vb实时曲线绘制

vb.net中,我用picturebox控件画曲线。使用picturebox.CreateGraphics()画线,请教保存问题??

首先你要建一个 Bitmap

网站建设哪家好,找创新互联!专注于网页设计、网站建设、微信开发、小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了巴楚免费建站欢迎大家使用!

再将picture控件的image属性与之相关联

再到 picture的image上画线

保存image到文件

/////////////////////////////////

Dim mybitmap As Bitmap

mybitmap = New Bitmap(300, 150)

PictureBox0.Image = mybitmap

Dim Graph As Graphics

Graph =Graphics.FromImage(PictureBox0.image)

Graph .drawline(Pens.Blue,0,0,111,111)

picturebox0.image.save("c:\aaa.jpg")

/////////////////////////////////////

存成的文件绝对有你画的线..我一直在用这种方法

VB.NET 实时曲线

拖一个PictureBox1控件 创建一个Paint事件。在事件中加入 Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint ' Create pens. Dim redPen As New Pen(Color.Red, 3) Dim greenPen As New Pen(Color.Green, 3) ' Create points that define curve. Dim point1 As New Point(50, 50) Dim point2 As New Point(100, 25) Dim point3 As New Point(200, 5) Dim point4 As New Point(250, 50) Dim point5 As New Point(300, 100) Dim point6 As New Point(350, 200) Dim point7 As New Point(250, 250) Dim curvePoints As Point() = {point1, point2, point3, point4, _ point5, point6, point7} ' Draw lines between original points to screen. e.Graphics.DrawLines(redPen, curvePoints) ' Draw curve to screen. e.Graphics.DrawCurve(greenPen, curvePoints) End Sub 得到数据后,改point的数据。然后PictureBox1.Refresh()就行了

VB中,将从下位机读取的数据,用控件的方式画出以时间为横轴的曲线

1.用picturebox 控件可以实现

2.可以使用Scale方法移动坐标原始位置和改变坐标轴方向,以下该方法:

Scale(x1,y1)-(x2,y2)

X1和y1为对象左上角的新坐标位置;

X2和y2为对象右下角的新坐标位置;

现在让我们看看一些范例。这一方法将使原点处于左上角,但将坐标系统单位改变为窗体大小的1/100:

Picture1.Scale(0,0)-(100,100)

以下调用将移动原点到窗体的左下角,并旋转Y轴:

Picture1.Scale(0,100)-(100, 0)

以下调用将移动原点到窗体的正中心,并旋转Y轴,然后将坐标单位转换为窗体大小的1/5000:

Picture1.Scale(-2500,2500)-(2500,2500)

用Picture1.Line (x1,y1)-(x2,y2)

如果不指定(x1,y1)则line方法默认为上次line方法的(x2,y2)为当前line方法(x1,y1)

For i = 1 To 100

j = i + 10

Me.Picture1.Line -(i, j), vbRed '可以指定画线的颜色

Next

3.如果画到最右边的时候,可以清掉picturebox 的内容,从头再画。

给段代码,供参考:

Private Sub Form_Load()

Dim i, j As Integer

Me.Picture1.Scale (0, Me.Picture1.Height)-(Me.Picture1.Width, 0)

Me.Picture1.AutoRedraw = True

Me.Picture1.Line (0, 0)-(0, 0), vbRed

For i = 1 To 1000

j = i + 10

Me.Picture1.Line -(i, j), vbRed

Next

End Sub

我这样画过曲线,大概思路就是这样吧,希望能帮到你


文章标题:vb.net画曲线控件 vb实时曲线绘制
网页地址:http://jkwzsj.com/article/hgpsdc.html

其他资讯