bmp转二进制:

1
2
3
FileStream fs = File.OpenRead(filepath); //filepath文件路径
Byte[] tempBuff = new Byte[fs.Length];
fs.Read(tempBuff, 0, tempBuff.Length);

二进制还原bmp:

1
2
3
4
5
BitmapImage BI = new BitmapImage();
BI.BeginInit();
BI.StreamSource = new MemoryStream(bufPic); //bufPic是图片二进制,byte类型
BI.EndInit();
image_emp.Source = BI;//image_emp是图片控件