bmp图片转换成wmf格式

C# 2022-02-11 13:37:26

private void buttonConvert_Click(object sender, EventArgs e)
{
if (comboBox.SelectedItem == null) //如果没有选择项
{
return; //退出本次操作
}
else
{
SaveFileDialog saveFileDialog = new SaveFileDialog(); //实例化SaveFileDialog类
saveFileDialog.Title = "转化为:"; //设置“另存为”对话框的题标
saveFileDialog.OverwritePrompt = true; //如果文件名存在则提示
saveFileDialog.CheckPathExists = true; //如果文件的路径不存在则提示
saveFileDialog.Filter = comboBox.Text "|" comboBox.Text; //设置文件类型
if (saveFileDialog.ShowDialog() == DialogResult.OK) //打开“另存为”对话框
{
string fileName = saveFileDialog.FileName; //获取另存为文件的路径及名称
bitmap.Save(fileName, ImageFormat.Wmf); //调用Save方法将图片保存为wmf格式
FileInfo f = new FileInfo(fileName); //实例化FileInfo类
this.Text = "图像转换:" f.Name; //设置窗体标题栏
label1.Text = f.Name;
}
}
}