赞
踩
1、加载函数
private Image LoadPicFromPath(string fileName)
{
Image img = null;
if (System.IO.File.Exists(fileName))
{
Image img = Image.FromFile(fileName);
System.IO.MemoryStream mStream = new System.IO.MemoryStream();
img.Save(mStream, System.Drawing.Imaging.ImageFormat.Png);
byte[] imgByte = mStream.ToArray();
Clipboard.Clear();
img.Dispose();
mStream.Close();
System.IO.MemoryStream mstream = new System.IO.MemoryStream(imgByte);
img = Image.FromStream(mstream);
mstream.Close();
}
return img;
}
2、调用
this.pic.Image = LoadPicFromPath(filepicPath);
其中pic为winform窗体控件名称,filepicPath为图片的路径
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。