你好,我想实现在picturebox里面画线保存,但是画完线不能保存,因为画完之后不是image格式,我看见你说过
在picturebox里可以把线画在bitmap里然后可以把bitmap保存成图片格式对吗??这个过程我想在vb.net2008中实现,看您能不能给我点提示呢???谢谢?...
在picturebox里可以把线画在bitmap里然后可以把bitmap保存成图片格式对吗??这个过程我想在vb.net2008中实现,看您能不能给我点提示呢???谢谢???
展开
1个回答
展开全部
Private Sub PictureBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick
Dim myBitmap As New Bitmap(640, 480)
Dim myGraphic As Graphics = Graphics.FromImage(myBitmap)
Dim mypen As New Pen(Color.Red, 1)
myGraphic.DrawEllipse(mypen, e.X, e.Y, 8, 8)
myGraphic.DrawLine(mypen, New Point(10, 10), New Point(100, 100))
PictureBox1.Image = myBitmap
mypen.Dispose()
myGraphic.Dispose()
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
PictureBox1.Image.Save("c:\1.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
End Sub
Dim myBitmap As New Bitmap(640, 480)
Dim myGraphic As Graphics = Graphics.FromImage(myBitmap)
Dim mypen As New Pen(Color.Red, 1)
myGraphic.DrawEllipse(mypen, e.X, e.Y, 8, 8)
myGraphic.DrawLine(mypen, New Point(10, 10), New Point(100, 100))
PictureBox1.Image = myBitmap
mypen.Dispose()
myGraphic.Dispose()
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
PictureBox1.Image.Save("c:\1.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
End Sub
更多追问追答
追问
您的这个过程我大概明白,可是我画曲线,是在运行代码之后,通过鼠标移动事件来实现,得到曲线之后,我想把它保存成图片格式可以吗???
追答
可以啊,注意这两句:
Dim myBitmap As New Bitmap(640, 480)
Dim myGraphic As Graphics = Graphics.FromImage(myBitmap)
以后的绘画都在myGraphic里面完成,这样就可以保存了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询