在c#中如何通过已知的位图数据文件bmp.bin创建位图Bitmap对象?
即设备发送上来位图文件的数据部分,byte[]存储,通过数据创建位图。

解决方案 »

  1.   

    可以先吧byte[]转成stream 然后从stream创建位图
      

  2.   

    使用反序列化byte[]   bytes ; //图片byte数组;   
    MemoryStream   ms=new   MemoryStream(bytes,0,bytes.Length);   
    BinaryFormatter bf   =  new  BinaryFormatter();   
    object obj=bf.Deserialize(ms);   
    ms.Close();   Bitmap bm = (Bitmap)obj;
      

  3.   

    MemoryStream stream = new MemoryStream(byteArray);
    Bitmap bmp = new Bitmap(stream);
      

  4.   

    我没有说清楚,byte[]数组存的不是整个位图的文件,而是位图的数据部分,去掉了位图头信息等。