vb.net图形显示的简单介绍-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

vb.net图形显示的简单介绍

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 图片显示问题,图片显示不出来

可能的原因是图片路径问题,路径用的相对路径,不要用绝对路径.

VB.net可以开发小型3D图形显示软件吗?

可以借助DirectX来编程。免费3D引擎可不好找,一般来说速度比不上硬件加速后的DX,尤其令人头疼的是一般都没有针对VB的文档,LZ有这方面理想的话,自己写一个吧……

我不得不承认在VB上写DirectX的教程相当难找!如果LZ想深入研究三维图形问题,C++一定要学,就算不能用C++编程,起码要能把C++程序翻译成VB程序。

我自己学会DX编程花了两三个月(很浅)。编这样一个程序难度是有点大的。

工具:DirectX9和其针对VB的库(项目-添加引用。.NET库里DX库一般都有),VB不知道现在支不支持DX10以上的版本,不过9绝对够用了。

思路:一切3D图形都是由三角形拼成的。矩形挖掉一个圆孔可不是一个方便画的图形,我估计至少得有24个三角形。你需要记录这些点的坐标,或者干脆把它们写在文件里,到时读出来。

这是我的一个老DX程序的不完全的代码(显示一个黑乎乎的平面),不一定能编译,可以参考一下。

Imports Microsoft.DirectX '一定要~

Public Class FormMain

'Direct3D Startup

Dim d3dpp As New Direct3D.PresentParameters 'DX基本参数,例如全屏还是窗口等

Public MyDevice As Direct3D.Device ‘DX基本设备,画图就靠它。

'Matrices

Dim matWorld, matView, matProj As Matrix '世界位置矩阵,摄像机位置矩阵和透视矩阵,数学要学好啊。

'mesh

Public MyPlane as Direct3D.Mesh ’我们的物体

Public VBPlane(3) As Direct3D.CustomVertex.PositionNormalTextured '存放顶点位置的数组

#Region "DX Core"

Public Sub InitDeviceObjects()

With d3dpp ‘以下请照抄。

.Windowed = True ‘不全屏。

.SwapEffect = Direct3D.SwapEffect.Discard ’双缓冲交换效果。请百度“双缓冲”

.BackBufferFormat = Direct3D.Format.Unknown

.EnableAutoDepthStencil = True ’让DX自动管理深度缓冲

.AutoDepthStencilFormat = Direct3D.DepthFormat.D16

End With

MyDevice = New Direct3D.Device(0, Direct3D.DeviceType.Hardware, Me.Handle, Direct3D.CreateFlags.HardwareVertexProcessing, d3dpp) '创建DX设备啦!以下两句请照抄。

MyDevice.SetRenderState(Direct3D.RenderStates.ZEnable, True) ‘Z缓冲

MyDevice.SetRenderState(Direct3D.RenderStates.NormalizeNormals, True)'法线归一化,请看相关数学书籍。

End Sub

Public Sub RestoreDeviceObjects()

Dim PlaneIB() As Short = {0, 1, 3, 0, 2, 3} ’顶点索引信息。

Dim AttrTable(1) As Direct3D.AttributeRange ‘顶点分组属性表

AttrTable(0).AttributeId = 0

AttrTable(0).FaceStart = 0

AttrTable(0).FaceCount = 2 ’有两个三角形

AttrTable(0).VertexStart = 0

AttrTable(0).VertexCount = 4 ‘四个点

‘顶点坐标信息。

VBPlane(0) = New Direct3D.CustomVertex.PositionNormalTextured(-500, -500, 0, 0, 0, 1, 0, 0)

VBPlane(1) = New Direct3D.CustomVertex.PositionNormalTextured(500, -500, 0, 0, 0, 1, 1, 0)

VBPlane(2) = New Direct3D.CustomVertex.PositionNormalTextured(-500, 500, 0, 0, 0, 1, 0, 1)

VBPlane(3) = New Direct3D.CustomVertex.PositionNormalTextured(500, 500, 0, 0, 0, 1, 1, 1)

MyPlane = New Direct3D.Mesh(2, 4, Direct3D.MeshFlags.Managed, Direct3D.VertexFormats.Position + Direct3D.VertexFormats.Normal + Direct3D.VertexFormats.Texture1, MyDevice) ’创建物体

MyPlane.SetVertexBufferData(VBPlane, Direct3D.LockFlags.None) ‘输入顶点坐标数据

MyPlane.SetIndexBufferData(PlaneIB, Direct3D.LockFlags.None) ‘输入索引数据

MyPlane.SetAttributeTable(AttrTable) ‘输入顶点分组属性表

End Sub

Public Sub Render() ‘调用它画图

Dim vlook As New Vector3(1, 0, 0)

Dim vPos As New Vector3(0,0,0)

Dim vUp As New Vector3(0, 0, 1)

MatView = Matrix.LookAtLH(vPos, vlook, vUp) ‘计算摄像机位置矩阵

Device.SetTransform(Direct3D.TransformType.View, MatView) ‘设置当前摄像机位置矩阵为MatView。

Dim fAspect As Single = Me.Width / Me.Height ’窗口长宽比

matProj = Matrix.PerspectiveFovLH(Math.PI / 4, fAspect, 1.0F, 10001) ‘计算透视矩阵MatProj。

MyDevice.SetTransform(Direct3D.TransformType.Projection, matProj) ‘设置当前透视矩阵为MatProj。

MyDevice.Clear(Direct3D.ClearFlags.Target + Direct3D.ClearFlags.ZBuffer, Color.Blue, 1.0F, 0) ’先刷蓝屏

MyDevice.BeginScene() ‘开始画

MatWorld = Matrix.Identity ’物体位于原点,不旋转

Device.SetTransform(Direct3D.TransformType.World, MatWorld) ’设置物体位置

Me.Mesh.DrawSubset(0) ‘画物体

MyDevice.EndScene() ’结束

MyDevice.Present() ‘显示在屏幕上

End Sub

Public Sub DeleteDeviceObjects() ’结束程序时放掉资源

MyPlane.Dispose()

MyDevice.Dispose()

End Sub

#End Region

Private Sub FormMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

DeleteDeviceObjects()

Windows.Forms.Cursor.Show()

End Sub

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

InitDeviceObjects()

RestoreDeviceObjects()

Windows.Forms.Cursor.Hide()

Render()

End Sub

End Class

vb.net 从数据库读取图片循环显示

假如b窗体是form2,在a窗体中调用B窗体,直接dim frm as new form2,然后frm.show()就OK

VB.net该如何将图片圆形显示?

新建一个Winform,拖两个图片框。图片框1在设计器中选择一个图片(尺寸在图片框容纳为佳)。如下代码测试通过:

private void button1_Click(object sender, EventArgs e)

{

Image img1 = this.pictureBox1.Image;

Image img2 = CropToCircle(img1);

this.pictureBox2.Image = img2;

}

public Image CropToCircle(Image img1)

{

Image img2 = new Bitmap(img1.Width, img1.Height, 

img1.PixelFormat);

Graphics g = Graphics.FromImage(img2);

using (Brush br = 

new SolidBrush(SystemColors.Control))//背景色

{

g.FillRectangle(br, 0, 0, 

img2.Width, img2.Height);

}

GraphicsPath path = new GraphicsPath();

path.AddEllipse(0, 0, img2.Width, img2.Height);

g.SetClip(path);

g.DrawImage(img1, 0, 0);

return img2;

}

如何正确掌握VB.NET操作缩放图像

在VB.NET操作缩放图像中的显示和保存缩放图像,用到Image和Graphics类,在VSDotNet2K3下面Reference里自动添加了引用System.Drawing,直接用就行。

实现VB.NET操作缩放图像代码如下:DimimgAsImageImage=Image.FromFile

(D:\Image\tstImage.jpg)

''tstImage是原先的图片DimgrfxAsGraphics=Me

.CreateGraphics

grfx.DrawImage(img,0,0,img.Width*

3,img.Height*3)''在Form里显示

DimimgnewAsNewSystem.Drawing.Bitmap

(img,img.Height*3,img.Width*3)

''新建一个放大的图片

imgnew.Save(D:\Image\tstNewImage.jpg,

System.Drawing.Imaging.ImageFormat.Jpeg)

''保存放大后图片

你可以建一个Form,然后在Form里拖进一个Button,把上面的代码放在Button_Click事件里面源码天空

,执行就行了。

对上面VB.NET操作缩放图像代码的解释:

1.要获取Graphics对象只能从某一事件的参数中获取或者使用窗体和控件对象的CreateGraphics方法来获取-----上面代码使用Me.CreateGraphics来引用这个对象。

2.加载一个图片用Image类的FromFile或者FromStream方法

3.用DrawImage来显示一个图片,该方法有30多个重载方法,可以查MSDN了解细节。

4.保存时的一个问题:我们必须先建一个对象,用于存缩放图像。


本文题目:vb.net图形显示的简单介绍
链接URL:http://kswsj.cn/article/hchhsj.html

其他资讯