大家好,有人能告诉我
怎么能把pictureBox.image直接转换为byte[]格式吗
如果不能直接转化,间接转换也可以的
谢谢

解决方案 »

  1.   

                    MemoryStream imgStream = new MemoryStream();
                    pic.Save(imgStream, System.Drawing.Imaging.ImageFormat.Bmp);//pic为bitmap类型的对象
                    byte[] imageb ={ };
                    imageb = imgStream.ToArray();
      

  2.   

    谢谢你,我一直以为picture.image是个image对象呢,结果试了好几种转换也没有成功
      

  3.   

    保存到文件里再读出来
    this.pictureBox.Image.Save("file");
      

  4.   

    pic.Save(imgStream, System.Drawing.Imaging.ImageFormat.Bmp);
    改为
    pic.Save(imgStream, System.Drawing.Imaging.ImageFormat.gif);
    也可以吧
      

  5.   

     System.Drawing.Image img = this.pictureBox1.Image;
                System.IO.MemoryStream ms = new System.IO.MemoryStream();
                img.Save(ms, img.RawFormat);
                byte[] by = new byte[ms.Length ];
                ms.Position = 0;
                ms.Read(by, 0, (int)ms.Length);