ZXing一维码/二维码 使用文档
样例:
System.IO.Stream stmYiWei = new System.IO.MemoryStream();
BitMatrix byteMatrix = new MultiFormatWriter().encode(sCode, BarcodeFormat.CODE_39, 230, 40);
toBitmap(byteMatrix).Save(stmYiWei, ImageFormat.Bmp);
Byte[] byteYiWei = new byte[stmYiWei.Length];
stmYiWei.Position = 0;
stmYiWei.Read(byteYiWei, 0, (int)stmYiWei.Length); //将图片文件流保存为二进制文件以便保存到数据库中
System.IO.Stream stmErWei = new System.IO.MemoryStream();
IDictionary hints = new Dictionary();
hints.Add(EncodeHintType.CHARACTER_SET, "UTF-8");
byteMatrix = new MultiFormatWriter().encode(sTmp, BarcodeFormat.QR_CODE, 200, 200, hints);
toBitmap(byteMatrix).Save(stmErWei, ImageFormat.Bmp);
Byte[] byteErWei = new byte[stmErWei.Length];
stmErWei.Position = 0;
stmErWei.Read(byteErWei, 0, (int)stmErWei.Length); //将图片文件流保存为二进制文件以便保存到数据库中
strSQL = "insert into gdzc_biaoqian( bq_gd_no,bq_yiweima,bq_erweima,bq_us_no) values(";
strSQL = strSQL + " @bq_gd_no,@bq_yiweima,@bq_erweima,@bq_us_no)";
SqlCommand commandImage = new SqlCommand(strSQL, connectionImage);
commandImage.Parameters.Clear();
commandImage.Parameters.Add("@bq_gd_no", SqlDbType.Int).Value = Convert.ToInt32(sGdzcNo);
commandImage.Parameters.Add("@bq_yiweima", SqlDbType.Image).Value = byteYiWei;
commandImage.Parameters.Add("@bq_erweima", SqlDbType.Image).Value = byteErWei;
commandImage.Parameters.Add("@bq_us_no", SqlDbType.Int).Value = Convert.ToInt32(Session["LoginUserID"]);
commandImage.ExecuteNonQuery();
commandImage.Dispose();
1