///图片转二进制
private byte[] convertByte(Image img)
{
MemoryStream ms = new MemoryStream();
img.Save(ms, img.RawFormat);
//byte[] bytes = new byte[ms.Length];
//ms.Read(bytes, 0, Convert.ToInt32(ms.Length));
//以上两句改成下面两句
byte[] bytes = ms.ToArray();
ms.Close();
return bytes;
}
///二进制生成图片
private Image convertImg(byte[] datas)
{
MemoryStream ms = new MemoryStream(datas);
Image img = Image.FromStream(ms, true);
ms.Close();
return img;
}