随笔 - 712  文章 - 1  评论 - 96  阅读 - 34万

将图片读到二进制

FileStream FStream = new FileStream(strImage, FileMode.Open, FileAccess.Read);
BinaryReader BReader = new BinaryReader(FStream);
byte[] byteImage = BReader.ReadBytes((int)FStream.Length);

 

将图片读到二进制

 

MemoryStream MStream = new MemoryStream((byte[])myds.Tables[0].Rows[0][2]);
pictureBox1.Image = Image.FromStream(MStream); //显示用户头像

 

从二进制读回图片

 

转自:https://www.cnblogs.com/spymaster/archive/2008/07/26/1251952.html

转自:http://t.zoukankan.com/jackrebel-p-3964495.html

pic1.Image = null;

var img = Image.FromFile("img.bmp");
var ms = new MemoryStream();
img.Save(ms, ImageFormat.Bmp);
pic1.Image = Image.FromStream(ms);
img.Dispose();

 

posted on   z5337  阅读(247)  评论(0编辑  收藏  举报

点击右上角即可分享
微信分享提示