ZXing一维码/二维码使用文档样例:System.IO.StreamstmYiWei=newSystem.IO.MemoryStream();BitMatrixbyteMatrix=newMultiFormatWriter().encode(sCode,BarcodeFormat.CODE_39,230,40);toBitmap(byteMatrix).Save(stmYiWei,ImageFormat.Bmp);Byte[]byteYiWei=newbyte[stmYiWei.Length];stmYiWei.Position=0;stmYiWei.Read(byteYiWei,0,(int)stmYiWei.Length);//将图片文件流保存为二进制文件以便保存到数据库中System.IO.StreamstmErWei=newSystem.IO.MemoryStream();IDictionaryhints=newDictionary();hints.Add(EncodeHintType.CHARACTER_SET,"UTF-8");byteMatrix=newMultiFormatWriter().encode(sTmp,BarcodeFormat.QR_CODE,200,200,hints);toBitmap(byteMatrix).Save(stmErWei,ImageFormat.Bmp);Byte[]byteErWei=newbyte[stmErWei.Length];stmErWei.Position=0;stmErWei.Read(byteErWei,0,(int)stmErWei.Length);//将图片文件流保存为二进制文件以便保存到数据库中strSQL="insertintogdzc_biaoqian(bq_gd_no,bq_yiweima,bq_erweima,bq_us_no)values(";strSQL=strSQL+"@bq_gd_no,@bq_yiweima,@bq_erweima,@bq_us_no)";SqlCommandcommandImage=newSqlCommand(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