您的位置:首页 > 其它

System.Windows.Media.Imageing.BItmapImage 这么用才不会占用文件

2013-11-25 15:32 423 查看
// Read byte[] from png file
BinaryReader binReader = new BinaryReader(File.Open(filepath, FileMode.Open));
FileInfo fileInfo = new FileInfo(filepath);
byte[] bytes = binReader.ReadBytes((int)fileInfo.Length);
binReader.Close();

// Init bitmap
BitmapImage bitmap = new BitmapImage();
bitmap.BeginInit();
//bitmap.DecodePixelWidth = Convert.ToInt32(w);
//bitmap.DecodePixelHeight = Convert.ToInt32(h);
//bitmap.CacheOption = System.Windows.Media.Imaging.BitmapCacheOption.OnLoad;
//bitmap.CreateOptions = System.Windows.Media.Imaging.BitmapCreateOptions.IgnoreImageCache;
bitmap.StreamSource = new MemoryStream(bytes);
bitmap.EndInit();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: