编程问题 如何用c#实现图片格式转换成png格式
将图片转换成png格式,默认将背景修改成透明
补充:用其他语言也行
将图片转换成png格式,默认将背景修改成透明
补充:用其他语言也行
答案: private void button1_Click(object sender, EventArgs e)//打开一个图片
{
this.openFileDialog1.ShowDialog();
if (this.openFileDialog1.FileName == "")
{
MessageBox.Show("请选择一个文件");
return;
}
this.pictureBox1.Image = Bitmap.FromFile(this.openFileDialog1.FileName);
private void button2_Click(object sender, EventArgs e)//以另一种格式保存图片
{
this.saveFileDialog1.ShowDialog();
string name = this.saveFileDialog1.FileName;
if (this.saveFileDialog1.FileName == "")
{
MessageBox.Show("请选择一个文件");
}
MessageBox.Show(this.saveFileDialog1.FileName);
if (this.radioButton1.Checked)
{
this.pictureBox1.Image.Save(name + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
}
if (this.radioButton2.Checked)
{
this.pictureBox1.Image.Save(name + ".tif", System.Drawing.Imaging.ImageFormat.Tiff);
}
if (this.radioButton3.Checked)
{
this.pictureBox1.Image.Save(name + ".Gif", System.Drawing.Imaging.ImageFormat.Gif);
}
if (this.radioButton4.Checked)
{
this.pictureBox1.Image.Save(name + ".Jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
} if (this.radioButton5.Checked)
{
this.pictureBox1.Image.Save(name + ".Png", System.Drawing.Imaging.ImageFormat.Png);
}
if (this.radioButton6.Checked)
{
this.pictureBox1.Image.Save(name + ".Wmf", System.Drawing.Imaging.ImageFormat.Wmf);
}
}
上一个:请推荐一本C#的关于windows核心编程的书
下一个:我想用C#编程实现连续画线功能,现在能画一条一条的线,怎么能把第一条线的终点作为第二条线的起点呢?