欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C# winform點擊生成二維碼實例代碼

 更新時間:2017年04月27日 15:00:43   作者:zhaoyu_m69  
這篇文章主要介紹了 C# winform點擊生成二維碼實例代碼,需要的朋友可以參考下

C# winform 新手實例:點擊生成二維碼

效果圖如下:

打開exe默認界面

打開exe默認界面

部分代碼:

//button點擊事件
private void button1_Click(object sender, EventArgs e)
{
  if (string.IsNullOrEmpty(textBox1.Text))
  {
   MessageBox.Show("請輸入要生成的二維碼!");
   return;
  }
  GenByZXingNet(textBox1.Text);
}
//生成二維碼圖片的函數(shù)
private Bitmap GenByZXingNet(string msg)
 {
  BarcodeWriter writer = new BarcodeWriter();
  writer.Format = BarcodeFormat.QR_CODE;
  writer.Options.Hints.Add(EncodeHintType.CHARACTER_SET, "UTF-8");//編碼問題
  writer.Options.Hints.Add(EncodeHintType.ERROR_CORRECTION, ZXing.QrCode.Internal.ErrorCorrectionLevel.H);
  const int codeSizeInPixels = 240; //設(shè)置圖片長寬
  writer.Options.Height = writer.Options.Width = codeSizeInPixels;
  writer.Options.Margin = 1;//設(shè)置邊框
  ZXing.Common.BitMatrix bm = writer.Encode(msg);
  Bitmap img = writer.Write(bm);
  pictureBox1.Image = img;
  return img;
 }
//若需要打開exe默認出現(xiàn)一張二維碼,先給textbox初始值,然后添加函數(shù)
private void Form1_Load(object sender, EventArgs e)
 {
  button1_Click(null,null);
 }

以上所述是小編給大家介紹的 C# winform點擊生成二維碼實例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評論