用C#实现图片二进制转化
代码
System.Drawing.Image img = System.Drawing.Image.FromFile("C:\\1.jpg");
MemoryStream ms = new MemoryStream();
img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
ms.Flush();
ms.Seek(0, SeekOrigin.Begin);
byte[] buffer = new byte[ms.Length];
ms.Read(buffer, 0, (int)ms.Length);
Response.BinaryWrite(buffer);
MemoryStream ms2 = new MemoryStream(buffer,0,buffer.Length);
ms2.Seek(0, SeekOrigin.Begin);
System.Drawing.Image img2 = System.Drawing.Image.FromStream(ms2);
img2.Save("C:\\2.jpg", System.Drawing.Imaging.ImageFormat.Icon);
MemoryStream ms = new MemoryStream();
img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
ms.Flush();
ms.Seek(0, SeekOrigin.Begin);
byte[] buffer = new byte[ms.Length];
ms.Read(buffer, 0, (int)ms.Length);
Response.BinaryWrite(buffer);
MemoryStream ms2 = new MemoryStream(buffer,0,buffer.Length);
ms2.Seek(0, SeekOrigin.Begin);
System.Drawing.Image img2 = System.Drawing.Image.FromStream(ms2);
img2.Save("C:\\2.jpg", System.Drawing.Imaging.ImageFormat.Icon);