ZXing生成和读取条形码二维码(C#)
2017-01-10 15:20
1311 查看
程序下载:点击打开链接
http://download.csdn.net/detail/softimite_zifeng/9733790
1. 条形码生成:
//设置条形码规格
EncodingOptions encodeOption = new EncodingOptions();
//设置宽和高
encodeOption.Height = 130;
encodeOption.Width = 240;
BarcodeWriter wr = new BarcodeWriter();
wr.Options = encodeOption;
//条形码:根据自己的需要选择条形码格式
wr.Format = BarcodeFormat.EAN_13;
//生成条形码
Bitmap image = wr.Write(textBox1.Text);
//显示
pictureBox1.Image = image;
2. 条形码读取:
DecodingOptions decodeOption = new DecodingOptions();
decodeOption.PossibleFormats = new List<BarcodeFormat>() { BarcodeFormat.EAN_13 };
//读取条形码
BarcodeReader br = new BarcodeReader();
br.Options = decodeOption;
Result result = br.Decode(pictureBox2.Image as Bitmap);
if (result == null)
{
MessageBox.Show("读取失败");
}
else
{
//读取成功
textBox3.Text = result.Text;
}
3. 二维码生成:
//设置QR二维码的规格
QrCodeEncodingOptions qrEncodeOption = new QrCodeEncodingOptions();
//设置编码格式,否则中文乱码
qrEncodeOption.CharacterSet = "UTF-8";
//设置宽和高
qrEncodeOption.Height = 200;
qrEncodeOption.Width = 200;
//设置周围空白边距
qrEncodeOption.Margin = 1;
BarcodeWriter wr = new BarcodeWriter();
//二维码
wr.Format = BarcodeFormat.QR_CODE;
wr.Options = qrEncodeOption;
//生成二维码
Bitmap image = wr.Write(textBox4.Text);
//显示
pictureBox3.Image = image;
4. 二维码读取:
DecodingOptions decodeOption = new DecodingOptions();
decodeOption.PossibleFormats = new List<BarcodeFormat>() { BarcodeFormat.QR_CODE };
//读取二维码
BarcodeReader br = new BarcodeReader();
br.Options = decodeOption;
Result result = br.Decode(pictureBox4.Image as Bitmap);
if (result == null)
{
MessageBox.Show("读取失败");
}
else
{
//读取成功
textBox7.Text = result.Text;
}
http://download.csdn.net/detail/softimite_zifeng/9733790
1. 条形码生成:
//设置条形码规格
EncodingOptions encodeOption = new EncodingOptions();
//设置宽和高
encodeOption.Height = 130;
encodeOption.Width = 240;
BarcodeWriter wr = new BarcodeWriter();
wr.Options = encodeOption;
//条形码:根据自己的需要选择条形码格式
wr.Format = BarcodeFormat.EAN_13;
//生成条形码
Bitmap image = wr.Write(textBox1.Text);
//显示
pictureBox1.Image = image;
2. 条形码读取:
DecodingOptions decodeOption = new DecodingOptions();
decodeOption.PossibleFormats = new List<BarcodeFormat>() { BarcodeFormat.EAN_13 };
//读取条形码
BarcodeReader br = new BarcodeReader();
br.Options = decodeOption;
Result result = br.Decode(pictureBox2.Image as Bitmap);
if (result == null)
{
MessageBox.Show("读取失败");
}
else
{
//读取成功
textBox3.Text = result.Text;
}
3. 二维码生成:
//设置QR二维码的规格
QrCodeEncodingOptions qrEncodeOption = new QrCodeEncodingOptions();
//设置编码格式,否则中文乱码
qrEncodeOption.CharacterSet = "UTF-8";
//设置宽和高
qrEncodeOption.Height = 200;
qrEncodeOption.Width = 200;
//设置周围空白边距
qrEncodeOption.Margin = 1;
BarcodeWriter wr = new BarcodeWriter();
//二维码
wr.Format = BarcodeFormat.QR_CODE;
wr.Options = qrEncodeOption;
//生成二维码
Bitmap image = wr.Write(textBox4.Text);
//显示
pictureBox3.Image = image;
4. 二维码读取:
DecodingOptions decodeOption = new DecodingOptions();
decodeOption.PossibleFormats = new List<BarcodeFormat>() { BarcodeFormat.QR_CODE };
//读取二维码
BarcodeReader br = new BarcodeReader();
br.Options = decodeOption;
Result result = br.Decode(pictureBox4.Image as Bitmap);
if (result == null)
{
MessageBox.Show("读取失败");
}
else
{
//读取成功
textBox7.Text = result.Text;
}
相关文章推荐
- C# 利用BarcodeLib.dll生成条形码(一维,zxing,QrCodeNet/dll二维码)
- C# 利用BarcodeLib.dll生成条形码(一维,zxing,QrCodeNet/dll二维码)
- .NET C#利用ZXing生成、识别二维码/条形码
- C# .Net 使用zxing.dll生成二维码,条形码
- C#利用Zxing.net生成条形码和二维码并实现打印的功能
- C#利用Zxing.net生成二维码和条形码并实现打印的功能
- C# 利用BarcodeLib.dll生成条形码(一维,zxing,QrCodeNet/dll二维码)
- C# 利用BarcodeLib.dll生成条形码(一维,zxing,QrCodeNet/dll二维码)
- C# 利用BarcodeLib.dll生成条形码(一维,zxing,QrCodeNet/dll二维码)
- C#利用ZXing.Net生成条形码和二维码
- C# 利用ZXing.Net来生成条形码和二维码
- C#利用zxing.net生成二维码和条形码并实现打印的功能
- Google开源项目二维码读取与生成工具ZXing
- C# WPF使用ZXing生成二维码ImageSource
- C#利用zxing.net操作二维码和条形码
- C#使用Zxing2.0生成二维码 带简单中心LOGO
- 使用zxing生成QRCode二维码,在Android的webview中调用条形码扫描(转)
- 使用zxing生成QRCode二维码,在Android的webview中调用条形码扫描
- C# 生成二维码和zxing类库
- Google开源项目二维码读取与生成工具ZXing