picBox.Refresh();
openFileDialog1.InitialDirectory = ".";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string srcFileName = openFileDialog1.FileName;
string fileNameExt = srcFileName.Substring(srcFileName.LastIndexOf(".")).ToLower();
if (fileNameExt == ".jpg" || fileNameExt == ".gif" ||
fileNameExt == ".bmp" || fileNameExt == ".png" ||
fileNameExt == ".tif")
{
bmp = new Bitmap(srcFileName);
picBox.Width = bmp.Width;
picBox.Height = bmp.Height;
picBox.Image = bmp;
}
}
//保存图像模块
picBox.Refresh();
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
string dstFileName =saveFileDialog1.FileName;
string fileNameExt = dstFileName.Substring(dstFileName.LastIndexOf(".")).ToLower();
if (fileNameExt == ".jpg" || fileNameExt == ".gif" ||
fileNameExt == ".bmp" || fileNameExt == ".png" ||
fileNameExt == ".tif")
{
bmp = (Bitmap)picBox.Image;
bmp.Save(dstFileName);
}
}