zoukankan      html  css  js  c++  java
  • ZXing.dll 生成二维码 C# winform net4.5

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using ZXing.QrCode;
    using ZXing;
    using ZXing.Common;
    using ZXing.Rendering;
    
    namespace erweima
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            /// <summary>
              /// 生成二维码图片
              /// </summary>
              /// <param name="strMessage">要生成二维码的字符串</param>
              /// <param name="width">二维码图片宽度</param>
              /// <param name="height">二维码图片高度</param>
             /// <returns></returns>
             private Bitmap GetQRCodeByZXingNet(String strMessage,Int32 width,Int32 height)
              {
                 Bitmap result = null;
                 try
                 {
                     BarcodeWriter barCodeWriter = new BarcodeWriter();
                     barCodeWriter.Format = BarcodeFormat.QR_CODE;
                     barCodeWriter.Options.Hints.Add(EncodeHintType.CHARACTER_SET, "UTF-8");
                     barCodeWriter.Options.Hints.Add(EncodeHintType.ERROR_CORRECTION, ZXing.QrCode.Internal.ErrorCorrectionLevel.H);
                     barCodeWriter.Options.Height = height;
                     barCodeWriter.Options.Width = width;
                     barCodeWriter.Options.Margin = 0;
                     ZXing.Common.BitMatrix bm = barCodeWriter.Encode(strMessage);
                     result = barCodeWriter.Write(bm);
                 }
                 catch (Exception ex)
                 { 
                     //异常输出
                 }
                 return result;
             }
    
             private void button1_Click(object sender, EventArgs e)
             {
                 this.pictureBox1.Image = GetQRCodeByZXingNet("ilikethis", 100, 100);
             }
    
    
    
    
    
    
        }
    }
    

      官网下载的 ZXing.Net-master.zip 里面没找到dll,貌似要自己编译,没有vs2017,放弃了。

    从网站找到别人编译好的。

    ZXing.dll 下载

  • 相关阅读:
    C语言字母频率统计
    C语言文件操作相关函数
    【蓝桥杯】历届试题 回文数字
    【蓝桥杯】历届试题 蚂蚁感冒
    【蓝桥杯】历届试题 地宫取宝
    【蓝桥杯】历届试题 分糖果
    【蓝桥杯】历届试题 兰顿蚂蚁
    JDK的安装和配置
    【蓝桥杯】历届试题 错误票据
    【蓝桥杯】历届试题 带分数
  • 原文地址:https://www.cnblogs.com/pengchenggang/p/10162428.html
Copyright © 2011-2022 走看看