vb.net作图优化的简单介绍

VB.net中如何画图?

VB.net与VB不同。

创新互联是一家专业提供仙游企业网站建设,专注与成都网站制作、做网站、H5网站设计、小程序制作等业务。10年已为仙游众多企业、政府机构等服务。创新互联专业网站建设公司优惠进行中。

VB.net已经有专门绘图的类。

可以定义笔刷然后用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怎么实现图像的处理

这问题有点笼统,软糖来说说把:

图像处理由System.Drawing命名空间负责。

主要是Bitmap类和Graphics类。

Bitmap表示一个位图,可以是BMP,JPG,PNG等文件。

装载位图

Dim 位图 As Bitmap = Bitmap.FromFile("C:\Image1.PNG")

Graphics表示一张画纸,能够进行绘制操作。

它可以被窗体、控件、位图调用CreateGraphics()方法来创建。

然后调用Graphics.Draw开头的一系列函数来绘制图像和图形,Fill开头的填充图形。

创建画纸并绘制位图

Dim 画纸 As Graphics = Me.CreateGraphics()

画纸.DrawImage(位图, 100, 100, 256, 256)

可以将上面三行放到Form1_Load中测试,把路径改一下,

还可以把Me改为能在上面绘图的控件的名称。

更多内容请看MSDN的System.Drawing命名空间。

如满意,请采纳,谢谢。

[VB.NET]怎样让移动图像显示更快一些...

***怎样让移动图像显示更快一些*** Hide Controls When Setting Properties to Avoid Multiple Repaints Every repaint is expensive. The fewer repaints Visual Basic must perform, the faster your application will appear. One way to reduce the number of repaints is to make controls invisible while you are manipulating them. For example, suppose you want to resize several list boxes in the Resize event for the form: Sub Form_Resize () Dim i As Integer, sHeight As Integer sHeight = ScaleHeight / 4 For i = 0 To 3 lstDisplay(i).Move 0, i * sHeight, _ ScaleWidth, sHeight Next End Sub This creates four separate repaints, one for each list box. You can reduce the number of repaints by placing all the list boxes within a picture box, and hiding the picture box before you move and size the list boxes. Then, when you make the picture box visible again, all of the list boxes are painted in a single pass: 在vb中用move方法移动图片时,速度有些慢,当图片很大时,这时可以用下面的方法: Sub Form_Resize () Dim i As Integer, sHeight As Integer picContainer.Visible = False picContainer.Move 0, 0, ScaleWidth, ScaleHeight sHeight = ScaleHeight / 4 For i = 0 To 3 lstDisplay(i).Move 0, i * sHeight, _ ScaleWidth, sHeight Next picContainer.Visible = True End Sub Note that this example uses the Move method instead of setting the Top and Left properties. The Move method sets both properties in a single operation, saving additional repaints.

VB.net绘图具体如何设置双缓冲

VB.NET画图是不能设置双缓冲的,双缓冲是指窗体,从来没说是针对控件。

不用graphic.clear清理重画就不会闪烁。你可以先把容器删了再重新建立一个再去画。

简单举例:

Graphics g;

Pen p;

Panel pl;

构造函数初始化:

p=new Pen(Color.Red,2);

pl=panel1;

造成闪烁的画法:

g=pl.CreateGraphics();

g.Clear(SystemColor.ButtonFace);

//.....画新的

不会闪烁的办法:

this.Controls.ReMoveAt(panel1);

pl=new Panel();

pl.Name="panel1";

//....创建容器控件

this.Controls.Add(pl);

//继续画

vb.net读取txt的数据作图问题

一、分析:

1,这一类随时间而变化的曲线图,通常把横轴作为时间,把纵轴作为相应的值,在这里就是密度值。

2,点的集合就是线;一组时间、密度值,对应一个点,把点连接起来就构成了线。

二、在VB.NET中作图,需要知道并解决几个问题:

1,与VB6一样,VB.NET中默认的坐标系统,左上角为坐标原点,X轴的正向为从左向右,Y轴的正向是从上向下。

为了使得它与数学中的坐标系统相一致,可以使用VB.NET中Graphics类的两个方法;

1、TranslateTransform----平移变换

格式:Graphics.TranslateTransform(dx,dy)

其中:dx 和 dy分别是Single数据类型

2、ScaleTransform----缩放变换

格式:Graphics.ScaleTransform(sx,sy)

其中:sx 和 sy分别是Single数据类型;

例如:为了符合数学中的一般格式,可以使用下述代码:

Graphics.ScaleTransform(1, -1)

这样就把Y轴的正方向给翻过来了。

三、VB.NET中绘制图形

1,绘制圆或椭圆

'绘制图形的三步曲

'1,获得一个Graphics对象

Dim MyGraphics As Graphics

MyGraphics = Me.CreateGraphics

'2,定义一个Pen对象,用于绘制图形(轮廓线)

Dim MyPen As New Pen(Color.Black)

'3,定义一个Brush对象,用于填充图形(如果需要填充的话)

Dim MyBrush As New SolidBrush(Color.Orange)

'绘制一个实心圆,该圆在:直线x=200,y=200,x=200+100,y=200+100所划的矩形区域内

MyGraphics.FillEllipse(Brush, 200, 200, 100, 100)

'绘制一个空心圆,该圆在:直线x=200,y=200,x=200+100,y=200+100所划的矩形区域内

MyGraphics.DrawEllipse(Pen, 200, 200, 100, 100)

注意:最后两个数值如果不等,就是绘制椭圆

当圆足够小,就是点了。

2,绘制直线

'1,获得一个Graphics对象

Dim MyGraphics As Graphics

MyGraphics = Me.CreateGraphics

'2,定义一个Pen对象,用于绘制图形(轮廓线)

Dim MyPen As New Pen(Color.Black)

MyGraphics.DrawLine(MyPen, 200, 200, 100, 100)

'或者直接用

Me.CreateGraphics.DrawLine(New Pen(Color.Black), 50, 50, 200, 200)


分享标题:vb.net作图优化的简单介绍
网站网址:http://myzitong.com/article/hshdhp.html