网上查到的代码,多数的写法使用MemoryStream来实现:
using (var stream = new MemoryStream(File.ReadAllBytes(...))) {
bitmap.StreamSource = stream;
bitmap.CacheOption = BitmapCacheOption.OnLoad;
bitmap.EndInit();
bitmap.Freeze();
}
this.Dispatcher.Invoke((Action)delegate {
Image1.Source = bitmap;
});
})).Start();
image.DecodePixelWidth = 100;
image.CacheOption = BitmapCacheOption.OnLoad;
image.EndInit();
image.Freeze();
}
新闻热点
疑难解答