如何将jpg格式图像文件转化成一系列二进制数据,又如何将此二进制数据转化成jpg格式的文件?
Image image = Image.FromFile("C:\\1.jpg");
MemoryStream ms = new MemoryStream();
image.Save(ms,ImageFormat.Jpeg);
ms.Flush();
ms.Seek(0,SeekOrigin.Begin);
byte [] buffer = new byte[ms.Length];
ms.Read(buffer,0,(int)ms.Length);//这里已经转成了字节
MemoryStream ms2 = new MemoryStream(buffer,0,buffer.Length);
ms2.Seek(0,SeekOrigin.Begin);
Image image2 = Image.FromStream(ms2);
image2.Save("C:\\2.jpg",ImageFormat.Jpeg);