CR的代码文本

all for learning about the world
  订阅 订阅  :: 管理
// 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();