<summary>
To add a picture to a binary stream
</summary>
<param name= "Path" ></param>
<returns></returns>
public string 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
Encoding myencoding = encoding.getencoding ("Utf-8");
String stimagebyte = Convert.tobase64string (Imgbytesin);
return stimagebyte;
}
<summary>
Picture of realistic binary stream representation
</summary>
<param name= "Imgbytesin" ></param>
public void Showimgbybyte (string stimagebyte)
{
String newimagename = "AAAA";//imagename (Centerid);//Get the name of the picture
String ImagePath = @ "f:/aqpximageurl/" + newimagename.tostring () + ". jpg";
byte[] Imgbytesin = convert.frombase64string (stimagebyte);
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)
{
String bys = SaveImage ("e:/lyx/safetrainall_aqpx/safetrainall_aqpx/defaultmodule/exam/examimage/2015-08-10#2/ 00000052x1.jpg ");
Showimgbybyte (bys);
}
Convert a picture to a binary string in a C # program and convert a binary string to a picture