将base64转为图片

void Base64StringToImage(string imgCode)
{
try
{
String inputStr = imgCode;
byte[] arr = Convert.FromBase64String(inputStr);
MemoryStream ms = new MemoryStream(arr);
Bitmap bmp = new Bitmap(ms); //bmp.Save(txtFileName + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
//bmp.Save(txtFileName + ".bmp", ImageFormat.Bmp);
//bmp.Save(txtFileName + ".gif", ImageFormat.Gif);
//bmp.Save(txtFileName + ".png", ImageFormat.Png);
ms.Close();
this.pictureBox1.Image = bmp;
//MessageBox.Show("转换成功!");
}
catch (Exception ex)
{
MessageBox.Show("Base64StringToImage 转换失败\nException:" + ex.Message);
}
}
上一篇:[CSS3] CSS Display Property: Block, Inline-Block, and Inline


下一篇:[转]动态添加Fragments