#region 保存从身份证上读到的头像
private void saveImageFromIDCard(){
//判断是否读到该图像,标准是读到了身份证头像的base64值(PhotoBuffer)和身份证号码(txt_card_cert_no)有值
if (PhotoBuffer.Text != "" && txt_card_cert_no.Text!="") {
string serverPath = System.AppDomain.CurrentDomain.BaseDirectory;//得到当前页面在服务端的绝对位置
serverPath = serverPath.Substring(0, serverPath.LastIndexOf("\\"));
string picSavePath = serverPath+"\\photo\\" + txt_card_cert_no.Text.Trim()+".jpg";
Byte[] streamByte = Convert.FromBase64String(PhotoBuffer.Text);
System.IO.File.WriteAllBytes(picSavePath, streamByte);
}
}
#endregion
#region base64字符串转换为图片
private System.Drawing.Image base64TOImg(String stream) {
Byte[] streamByte = Convert.FromBase64String(stream);
System.IO.MemoryStream ms = new System.IO.MemoryStream(streamByte);
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
return img;
}
#endregion