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();
相关文章推荐
- 保存图片控件上的图片到本地 出现错误:无法将类型为“System.Windows.Media.Imaging.BitmapFrameDecode”的对象强制转换为类型“System.Windows.Media.Imaging.BitmapImage”。
- System.Drawing.Image data to System.Windows.Media.ImageSource (WPF)
- windows system.exe占用文件
- System.Drawing.Bitmap 转换为 System.Windows.Media.Imaging.BitmapSource
- .Net那点事儿系列:System.IO之windows文件操作
- C# using System.Windows.Media.Imaging;该引用哪个dll
- Windows平台下80端口被System占用解决办法
- 微软windows Bitmap文件概述
- 删除Windows 7系统中被占用的文件
- Windows下80端口被pid为4的System进程占用解决方法
- .Net那点事儿系列:System.IO之windows文件操作
- AxWindowsMediaPlayer媒体文件主要方法属性 (转)
- AxWindowsMediaPlayer媒体文件主要方法属性
- Windows下80端口被pid为4的System进程占用解决方法
- 关于Windows Media Player 不能播放 动态VBR编码的mp3文件
- Windows下80端口被进程System&PID=4占用的解决方法
- 解决WPF BitmapImage图片资源无法删除,文件正在被另一个进程使用
- Windows下80端口被pid为4的System进程占用解决方法
- system.badimageformatexception 未能加载文件或程序集
- WPF的Image控件BitmapImage以及Uri的资源占用问题