数据空中的image同过dataTable 直接转成byte[] 再把Base64保存为图片,这里把byte装成流再转图片当然也可以,只是那样略显麻烦
private void button1_Click(object sender, EventArgs e) { using (SqlConnection con = new SqlConnection("server=.;uid=sa;pwd=123;database=Sys")) { using (SqlDataAdapter adp = new SqlDataAdapter("select * from usertable where code ='0008'", con)) { DataTable dt = new DataTable(); adp.Fill(dt); byte[] mybyte = null; mybyte = (byte[])dt.Rows[0]["U_Signature"]; string s = Convert.ToBase64String(mybyte); GetImageFromBase64(s).Save(@"D:\test.bmp", System.Drawing.Imaging.ImageFormat.Bmp); } } }
base64转图片方法
public Bitmap GetImageFromBase64(string base64string) { byte[] b = Convert.FromBase64String(base64string); MemoryStream ms = new MemoryStream(b); Bitmap bitmap = new Bitmap(ms); return bitmap; }View Code
标签:C#,Image,Bitmap,mybyte,bitmap,new,byte,Server,dt From: https://www.cnblogs.com/SoftWareIe/p/16648740.html