public static byte [] ReadPicture(DevExpress.XtraEditors.PictureEdit picture) { byte [] mybyte = new byte [0]; string filePath = string.Empty; OpenFileDialog old = new OpenFileDialog( ); old.Filter = "图片文件|*.bmp;*.jpg;*.jpeg;*.gif;*.png;*.emf"; if (old.ShowDialog( ) == DialogResult.OK) { filePath = old.FileName; //获取图片路径 //Bitmap bitmap = new Bitmap ( filePath ); //Point pt = new Point ( bitmap . Size ); //if ( pt . X > picture . Size . Width || pt . Y > picture . Size . Height ) //{ // //图像充满图像框 并且图像维持比例 // picture . BackgroundImageLayout = ImageLayout . Stretch; //} //else //{ // //图像在图像框中 // picture . BackgroundImageLayout = ImageLayout . Stretch; //} // LoadAsync:非同步转入图像 picture.LoadAsync(filePath); FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); mybyte = br.ReadBytes(( int )fs.Length); //图片转换成二进制流 } else { mybyte = new byte [0]; } return(mybyte); }