c#,vs2010.在一个picturebox控件中打开了一张本地的图片,做了修改后如何保存下来!
展开全部
public string strFileName = null;
//打开
private void btnOpne_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "打开图片";
ofd.Filter = "jpg图片(*.jpg)|*.jpg";
ofd.ShowDialog();
if (ofd.FileName.Length != 0)
{
this.strFileName = ofd.FileName;
this.pictureBox1.ImageLocation = strFileName;
}
}
//保存
private void btnSave_Click(object sender, EventArgs e)
{
FileInfo fi = new FileInfo(strFileName);
if (fi.Exists)
{
fi.Delete();
this.pictureBox1.Image.Save(strFileName);
}
else
{
this.pictureBox1.Image.Save(strFileName);
}
}
//另存为
private void button1_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "jpg图片(*.jpg)|*.jpg";
saveFileDialog1.FilterIndex = 2;
saveFileDialog1.RestoreDirectory = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
this.pictureBox1.Image.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
//打开
private void btnOpne_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "打开图片";
ofd.Filter = "jpg图片(*.jpg)|*.jpg";
ofd.ShowDialog();
if (ofd.FileName.Length != 0)
{
this.strFileName = ofd.FileName;
this.pictureBox1.ImageLocation = strFileName;
}
}
//保存
private void btnSave_Click(object sender, EventArgs e)
{
FileInfo fi = new FileInfo(strFileName);
if (fi.Exists)
{
fi.Delete();
this.pictureBox1.Image.Save(strFileName);
}
else
{
this.pictureBox1.Image.Save(strFileName);
}
}
//另存为
private void button1_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "jpg图片(*.jpg)|*.jpg";
saveFileDialog1.FilterIndex = 2;
saveFileDialog1.RestoreDirectory = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
this.pictureBox1.Image.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
private void button1_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "jpg图片(*.jpg)|*.jpg";//其他格式也可加上去。
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
this.pictureBox1.Image.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
{
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "jpg图片(*.jpg)|*.jpg";//其他格式也可加上去。
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
this.pictureBox1.Image.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询