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;

 

posted @ 2023-01-31 14:44  田宏伟_thw  阅读(1321)  评论(0编辑  收藏  举报