在vb.net中如何用Graphics画图(

前端之家收集整理的这篇文章主要介绍了在vb.net中如何用Graphics画图(前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

在vb.net中如何用Graphics画图(

下面这段代码是我截取的部分代码,但是从中读者可以清楚在vb.net中如何用Graphics画图了。 用来做统计图之类的,很是方便。 注:下面的代码只是截取了原来程序中的代码,是不能直接运行的。希望这篇简短的文章能够对你有所帮助。 Public Function generateImage()Function generateImage() As String Dim i As Integer Dim k() As Integer bmp = New Bitmap(640,480) '定义Bitmap对象 gra = Graphics.FromImage(bmp) '获取Graphices对象 Me.pic.Image = bmp '让画出来的图片显示在窗体上的pic控件上 '定义画线用的画笔 Dim ppen As Pen = New Pen(Color.Black,1) '定义写字用的刷子 Dim dotUserBrush As SolidBrush = New SolidBrush(Color.Blue) '画线 gra.DrawLine(ppen,30,100,60,100) '最上头的横线 ''''''' Dim FFamily As FontFamily = New FontFamily("宋体") Dim font As Font = New Font(FFamily,"12",FontStyle.Regular,FontStyle.Italic,GraphicsUnit.Pixel) Dim text As String ="你输出文字" Dim solidbrush As SolidBrush = New SolidBrush(Color.Black) Dim pr As PointF '在图片上写字 pr = New PointF(10,50) gra.DrawString(text,font,solidbrush,pr) '画矩形 gra.FillRectangle(solidbrush,300,400,20,20) '打印图片标题 text = "销售操作图" pr = New PointF(10,10) font = New Font(FFamily,"15",FontStyle.Bold,GraphicsUnit.Pixel) gra.DrawString(text,pr) '画椭圆 gra.FillEllipse(solidbrush,200,50,60) '保存图片方法 bmp.Save("c:\genImage.jpg") Return "genImage.jpg" End Function

原文链接:https://www.f2er.com/vb/260511.html

猜你在找的VB相关文章