在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

相关文章

Format[$] ( expr [ , fmt ] ) format 返回变体型 format$ 强...
VB6或者ASP 格式化时间为 MM/dd/yyyy 格式,竟然没有好的办...
在项目中添加如下代码:新建窗口来显示异常信息。 Namespace...
转了这一篇文章,原来一直想用C#做k3的插件开发,vb没有C#用...
Sub 分列() ‘以空格为分隔符,连续空格只算1个。对所选...
  窗体代码 1 Private Sub Text1_OLEDragDrop(Data As Dat...