vb.net picture 保存图片
visualstitdo2010。vb,在picturexbox中使用graphicsdrawline画线。想把画好的线保存成图片,如何操作????...
visual stitdo 2010。vb,在picturexbox中使用graphics drawline画线。想把画好的线保存成图片,如何操作????
展开
3个回答
展开全部
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click '好处:画的图刷新不会消失
PictureBox1.Image = Nothing
Dim wid As Integer = PictureBox1.ClientSize.Width
Dim hgt As Integer = PictureBox1.ClientSize.Height
Dim bm As New Bitmap(wid, hgt)
Dim g As Graphics = Graphics.FromImage(bm)
'画图代码,比如下面的直线
g.DrawLine(Pens.Red, 10, 10, 500, 10)
'画图代码
PictureBox1.Image = bm
PictureBox1.Refresh()
g.Dispose()
PictureBox1.Image.Save("C:\1.jpg")
End Sub
PictureBox1.Image = Nothing
Dim wid As Integer = PictureBox1.ClientSize.Width
Dim hgt As Integer = PictureBox1.ClientSize.Height
Dim bm As New Bitmap(wid, hgt)
Dim g As Graphics = Graphics.FromImage(bm)
'画图代码,比如下面的直线
g.DrawLine(Pens.Red, 10, 10, 500, 10)
'画图代码
PictureBox1.Image = bm
PictureBox1.Refresh()
g.Dispose()
PictureBox1.Image.Save("C:\1.jpg")
End Sub
追问
如何指定保存文件的名字,就是弹出那个另存为的对话框啊?
追答
Dim fbd As New FolderBrowserDialog
fbd.ShowDialog()
' MsgBox(fbd.SelectedPath) 'fbd.SelectedPath表示选择路径,如果是根目录,会带“\”,如“D:\”,否则末尾不带"\",如:“D:\TDDOWNLOAD”
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
先要建立bitmap,使它与PictureBox1关联
Dim mybitmap As Bitmap
Dim Graph As Graphics
下面的可以放在new里面
mybitmap = New Bitmap(300, 150)
PictureBox1.Image = mybitmap
Graph = Graphics.FromImage(PictureBox1.Image)
下面的放在事件处理过程中
...
PictureBox1.Image.Save("D:/1.jpg")
...
Dim mybitmap As Bitmap
Dim Graph As Graphics
下面的可以放在new里面
mybitmap = New Bitmap(300, 150)
PictureBox1.Image = mybitmap
Graph = Graphics.FromImage(PictureBox1.Image)
下面的放在事件处理过程中
...
PictureBox1.Image.Save("D:/1.jpg")
...
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
6.0 有 savepicture 函数 net 有吗
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询