二轮冲刺第九天
二轮冲刺第九天
今天我们的任务分配
刘:编写代码
崔:运行调试与修复
编写的代码如下:
//读取条形码-读取
private void button8_Click(object sender, EventArgs e)
{
DecodingOptions decodeOption = new DecodingOptions();
decodeOption.PossibleFormats = new List<BarcodeFormat>() { BarcodeFormat.EAN_13 };
//读取条形码
BarcodeReadr br = new BarcodeReader();
br.Options = decodeOption;
Result result = br.Decode(pictureBox2.Image as Bitmap);
if (result == null)
{
MessageBox.Show("读取失败");
}
else
{
//读取成功
string xs = "";
textBox3.Text = result.Text;
xs = textBox3.Text;
MessageBox.Show("一维码:"+xs+"","读取成功",MesageBoxButtons.OK,MessageBoxIcon.Asterisk);
}
}
private void button8_Click(object sender, EventArgs e)
{
DecodingOptions decodeOption = new DecodingOptions();
decodeOption.PossibleFormats = new List<BarcodeFormat>() { BarcodeFormat.EAN_13 };
//读取条形码
BarcodeReadr br = new BarcodeReader();
br.Options = decodeOption;
Result result = br.Decode(pictureBox2.Image as Bitmap);
if (result == null)
{
MessageBox.Show("读取失败");
}
else
{
//读取成功
string xs = "";
textBox3.Text = result.Text;
xs = textBox3.Text;
MessageBox.Show("一维码:"+xs+"","读取成功",MesageBoxButtons.OK,MessageBoxIcon.Asterisk);
}
}
//生成二维码-生成
private void button3_Click(object sender, EventArgs e)
{
//设置QR二维码的规格
ZXing.QrCode.QrCodeEncodingOptions qrEncodeOption = new ZXing.QrCode.QrCodeEncodingOptions();
//设置编码格式,否则中文乱码
qrEncodeOption.CharacterSet = "UTF-8";
//设置宽和高
qrEncodeOption.Height = 200;
qrEncodeOption.Width = 200;
//设置周围空白边距
qrEncodeOption.Margin = 1;
ZXing.BarcodeWriter wr = new BarcodeWriter();
//二维码
wr.Format = BarcodeFormat.QR_CODE;
wr.Options = qrEncodeOption;
//生成二维码
Bitmap image = wr.Write(textBox4.Text);
//显示
pictureBox3.Image = image;
}
private void button3_Click(object sender, EventArgs e)
{
//设置QR二维码的规格
ZXing.QrCode.QrCodeEncodingOptions qrEncodeOption = new ZXing.QrCode.QrCodeEncodingOptions();
//设置编码格式,否则中文乱码
qrEncodeOption.CharacterSet = "UTF-8";
//设置宽和高
qrEncodeOption.Height = 200;
qrEncodeOption.Width = 200;
//设置周围空白边距
qrEncodeOption.Margin = 1;
ZXing.BarcodeWriter wr = new BarcodeWriter();
//二维码
wr.Format = BarcodeFormat.QR_CODE;
wr.Options = qrEncodeOption;
//生成二维码
Bitmap image = wr.Write(textBox4.Text);
//显示
pictureBox3.Image = image;
}