17,740
社区成员
发帖
与我相关
我的任务
分享
private BitmapImage ChangeImage(string path)
{
byte[] bytes = null;
using (BinaryReader br = new BinaryReader(File.Open(path, FileMode.Open)))
{
FileInfo fileInfo = new FileInfo(path);
bytes = br.ReadBytes((int)fileInfo.Length);
}
BitmapImage bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.StreamSource = new MemoryStream(bytes);
bitmap.EndInit();
return bitmap;
}
//调用
this.pic.Source = null;
this.pic.Source = ChangeImage("...");