vb.net画直线不消失,将图形保存为bmp文件
发布时间:2020-12-17 08:07:05 所属栏目:百科 来源:网络整理
导读:须创建bitmap,关联到picturebox1.image上。 再在picturebox1.image上创建Graphics,再进行作图。 注意,因picturebox1.image是最初bitmap创建,默认是黑色,故,须用fillrectangle把背景刷成白色。 Imports System.DrawingImports System.Drawing.Drawing2DPu
须创建bitmap,关联到picturebox1.image上。 再在picturebox1.image上创建Graphics,再进行作图。
注意,因picturebox1.image是最初bitmap创建,默认是黑色,故,须用fillrectangle把背景刷成白色。
Imports System.Drawing Imports System.Drawing.Drawing2D Public Class Form1 Private Sub Button1_Click(sender As Object,e As EventArgs) Handles Button1.Click Dim gr As Graphics Dim bp As New Bitmap(PictureBox1.Width,PictureBox1.Height) Dim pen1 As New Pen(Color.Red) pen1.DashStyle = DashStyle.DashDotDot pen1.Width = 2 PictureBox1.Image = bp gr = Graphics.FromImage(PictureBox1.Image) gr.FillRectangle(Brushes.White,New Rectangle(0,PictureBox1.Width,PictureBox1.Height)) gr.DrawLine(pen1,10,70,70) PictureBox1.Image.Save("D:1.bmp",System.Drawing.Imaging.ImageFormat.Bmp) gr.Dispose() End Sub End Class
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |