生活随笔
收集整理的這篇文章主要介紹了
图片与二进制流转换
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
#region//圖片轉(zhuǎn)換為二進(jìn)制流??public?void?PictureToBinaryStream()??{??????????string?path?=?Application.StartupPath;??????????string?fullPath?=?path?+?"\\images\\test.png";??????????Bitmap?bmp?=?new?Bitmap(Image.FromFile(fullPath));??????MemoryStream?ms?=?new?MemoryStream();??????bmp.Save(ms,?System.Drawing.Imaging.ImageFormat.Png);??????ms.Flush();??????????byte[]?bmpBytes?=?ms.ToArray();??????????foreach?(var?item?in?bmpBytes)??????{??????????richTextBox1.Text?+=?item;??????}??????pictureBox1.Image?=?Image.FromStream(new?MemoryStream(bmpBytes));??}??#endregion???#region//二進(jìn)制流轉(zhuǎn)換成圖片??public?void?BinaryStreamToPicture()??{??????string?url?=?@"http://php.weather.sina.com.cn/images/yb3/78_78/duoyun_0.png";??????WebClient?client?=?new?WebClient();??????byte[]?pageData?=?client.DownloadData(url);??????????pictureBox1.Image?=?Image.FromStream(new?MemoryStream(pageData));??????Bitmap?bmp?=?new?Bitmap(new?MemoryStream(pageData));??????string?path?=?Application.StartupPath;??????string?fullPath?=?path?+?"\\images\\"+?Guid.NewGuid().ToString()+".png";??????richTextBox1.Text?=?fullPath;??????bmp.Save(fullPath,?System.Drawing.Imaging.ImageFormat.Png);??}??#endregion?
轉(zhuǎn)載于:https://www.cnblogs.com/jimmyLei/p/9037892.html
總結(jié)
以上是生活随笔為你收集整理的图片与二进制流转换的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。