Zxing是一个免费的条码处理软件,可生成一维码、二维码并进行读取。注释中有功能介绍

1.下载Zxing的.Net类库,并引用zxing.dll,zxing.presentation.dll
using ZXing;
using ZXing.Common;
using ZXing.QrCode;
2.生成一维码,并保存图片
//定义变量
private int cw=200;
private int ch=200;
//定义路径
private string path=AppDomain.CurrentDomain.BaseDirectory+"\\";
private void btnCreateCode_Click(object sender,EventArgs e)
{
//设置条码的规格
EncodingOptions encoding=new EncodingOptions();
encoding.Width=cw;
encoding.Height=ch;
//生成条码的图片并保存
BarcodeWriter bw=new BarcodeWriter ();
//指定规格
bw.Options=encoding;
bw.Format=BarcodeFormat.CODE_39;
Bitmap btp=bw.Write(txtInfor.Text.Trim());
//将图片转换为字符串数组
MemoryStream ms=new MemoryStream();
btp.Save(ms,ImageFormat.Bmp);
ms.Seek(0,SeekOrigin.Begin);
byte[]

本文介绍了如何使用Zxing.NET库在C#中生成和读取一维码(CODE_39)与二维码(QR_CODE),包括设置规格、保存图片,并演示了二维码字符集设置和读取过程。
最低0.47元/天 解锁文章
1732

被折叠的 条评论
为什么被折叠?



