二輪衝刺第二天
阿新 • • 發佈:2018-12-09
今天我的任務是進行程式碼的編寫,
今天編寫的程式碼是編寫生成二維碼
程式碼如下:
//生成二維碼-生成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 button5_Click(object sender, EventArgs e)
{
//開啟圖片
openImage(textBox6, pictureBox4);
}