今天我的任务是进行代码的编写,
今天编写的代码是编写生成二维码
代码如下:
//生成二维码-生成
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;
}
//生成二维码-保存
private void button7_Click(object sender, EventArgs e)
{
//保存图片
saveImage(pictureBox3, textBox4.Text);
}
private void button7_Click(object sender, EventArgs e)
{
//保存图片
saveImage(pictureBox3, textBox4.Text);
}
//读取二维码-选择图片
private void button5_Click(object sender, EventArgs e)
{
//打开图片
openImage(textBox6, pictureBox4);
}
private void button5_Click(object sender, EventArgs e)
{
//打开图片
openImage(textBox6, pictureBox4);
}