saveFileDialog1.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif|PnG Image|*.png|Wmf Image|*.wmf";
saveFileDialog1.FilterIndex = 0;
if (pictureBox1.Image == null)
{
MessageBox.Show("没有预览图片");
}
else if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
if (pictureBox1.Image != null)
{
pictureBox1.Image.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
C# winform 另存为picturebox里的图片
最新推荐文章于 2023-09-12 13:32:18 发布
该博客介绍了如何在C# WinForm应用中实现将PictureBox中的图片另存为不同格式。首先,通过设置saveFileDialog1的过滤器允许用户选择不同的图片格式。接着,检查pictureBox1是否已加载图片,如果没有则提示用户。如果用户确认保存,程序将使用pictureBox1中的图片并以JPEG格式保存到用户指定的路径。
摘要由CSDN通过智能技术生成