图片二进制存取

图片二进制存取


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);  
posted @ 2010-04-19 10:35  hevily  Views(357)  Comments(0Edit  收藏  举报