C#中将图片转换成Byte数组,和将数组转换出来
一,将图片转换成Byte数组
byte[] photo; string path = Application.StartupPath + "\\ICMAXR060001_Station1_CH1_HT.jpg";//图片原路径 Image img = new Bitmap(path); MemoryStream stream = new MemoryStream(); img.Save(stream, ImageFormat.Png); photo = stream.ToArray(); stream.Close();
二,将Byte数组转换成图片
MemoryStream ms = new MemoryStream(photo, true); Image img1 = Image.FromStream(ms); pictureBox1.Image = img1;