Simple example of C image with binary conversion
- 2020-05-19 05:36:15
- OfStack
/// Image transfer 2 Into the system
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));
// Change the above two sentences to the next two
byte[] bytes = ms.ToArray();
ms.Close();
return bytes;
}
///2 Base generates a picture
private Image convertImg(byte[] datas)
{
MemoryStream ms = new MemoryStream(datas);
Image img = Image.FromStream(ms, true);
ms.Close();
return img;
}