1个回答
2013-07-13
展开全部
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);
}
}
{
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);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询