<summary>
To add a picture to a binary stream
</summary>
<param name= "Path" ></param>
<returns></returns>
Public byte[] SaveImage (String path)
{
FileStream fs = new FileStream (path, FileMode.Open, FileAccess.Read); Save a picture as a file stream
BinaryReader br = new BinaryReader (FS);
byte[] Imgbytesin = br. Readbytes ((int) fs. Length); Reads a stream into a byte array
return imgbytesin;
}
<summary>
Picture of realistic binary stream representation
</summary>
<param name= "Imgbytesin" ></param>
public void Showimgbybyte (byte[] imgbytesin)
{
String newimagename = "AAAA";//imagename (Centerid);//Get the name of the picture
String ImagePath = @ "f:/aqpximageurl/" + newimagename.tostring () + ". jpg";
MemoryStream ms = new MemoryStream (imgbytesin);
Bitmap bmp = new Bitmap (MS);
Bmp. Save (ImagePath, imageformat.bmp);
Ms. Close ();
return newimagename;
pictureBox1.Image = Image.fromstream (ms);
}
<summary>
This is for testing
</summary>
<param name= "Sender" ></param>
<param name= "E" ></param>
protected void Btn_jituan_click (object sender, EventArgs e)
{
byte[] bys = SaveImage ("e:/lyx/safetrainall_aqpx/safetrainall_aqpx/defaultmodule/exam/examimage/2015-08-10#2/ 00000052x1.jpg ");
Showimgbybyte (bys);
}
Convert a picture to a byte array in a C # program and convert a byte array to a picture