编程语言
首页 > 编程语言> > C#生成二维码

C#生成二维码

作者:互联网

namespace Common.QRCode
{
    using System.Drawing;
    using QRCoder;

    /// <summary>
    /// 二维码帮助类
    /// </summary>
    public class QRCodeHelper
    {
        /// <summary>
        /// 普通二维码
        /// </summary>
        /// <param name="url">存储内容</param>
        /// <param name="pixel">像素大小</param>
        /// <returns>图片</returns>
        public static Bitmap GetPTQRCode(string url, int pixel = 5)
        {
            QRCodeGenerator generator = new QRCodeGenerator();
            QRCodeData codeData = generator.CreateQrCode(url, QRCodeGenerator.ECCLevel.M, true);
            QRCoder.QRCode qrcode = new QRCoder.QRCode(codeData);
            Bitmap image = qrcode.GetGraphic(pixel, Color.Black, Color.White, true);
            return image;
        }
    }
}

  

标签:C#,image,QRCodeGenerator,QRCoder,qrcode,二维码,QRCode,生成
来源: https://www.cnblogs.com/lsgControl/p/16378472.html