C#保存winform中显示的图片
作者:互联网
C#,保存winform中pictureBox中的图片
SaveFileDialog savedialog = new SaveFileDialog();
savedialog.Title = "附件另存";
savedialog.Filter = "jpg图片|*.JPG|png图片|Bmp 图片|*.bmp|*.PNG|jpeg图片|*.JPEG";
savedialog.FilterIndex = 3;//设置默认文件类型显示顺序
savedialog.RestoreDirectory = true; //点了保存按钮进入
if (pictureBox1.Image != null)
{
if (savedialog.ShowDialog() == DialogResult.OK)
{
string pictureName = savedialog.FileName;
//照片另存
using (MemoryStream mem = new MemoryStream())
{
Bitmap bmp = new Bitmap(pictureBox1.Image);
//保存到磁盘文件
bmp.Save(@pictureName, pictureBox1.Image.RawFormat);
bmp.Dispose();
MessageBox.Show("附件另存成功!", "注意", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
else
{
MessageBox.Show("没有附件信息!", "注意", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
标签:savedialog,C#,保存,另存,bmp,pictureBox1,new,winform,图片 来源: https://blog.csdn.net/wcx1293296315/article/details/112850723