Esempio n. 1
0
        /// <summary>
        /// 生成二维码图片
        /// </summary>
        /// <param name="param"></param>
        /// <param name="filePath"></param>
        public static void GetQrCode(QrCodeParam param, string filePath)
        {
            var    wr  = CreateCode(param);
            Bitmap img = wr.Write(param.Content);

            img = DrawLogo(img, param.imgPath);

            img.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);
        }
Esempio n. 2
0
        /// <summary>
        /// 生成二维码图片
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public static MemoryStream GetQrCode(QrCodeParam param)
        {
            var    wr  = CreateCode(param);
            Bitmap img = wr.Write(param.Content);

            img = DrawLogo(img, param.imgPath);

            using (MemoryStream ms = new System.IO.MemoryStream())
            {
                img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                return(ms);
            }
        }
Esempio n. 3
0
        private static BarcodeWriter CreateCode(QrCodeParam param)
        {
            QrCodeEncodingOptions qrEncodeOption = new QrCodeEncodingOptions();

            qrEncodeOption.CharacterSet    = "UTF-8";
            qrEncodeOption.Height          = param.Height;
            qrEncodeOption.Width           = param.Width;
            qrEncodeOption.Margin          = param.Margin;
            qrEncodeOption.ErrorCorrection = ErrorCorrectionLevel.H;
            qrEncodeOption.DisableECI      = true;

            ZXing.BarcodeWriter wr = new BarcodeWriter();
            wr.Format  = BarcodeFormat.QR_CODE;
            wr.Options = qrEncodeOption;
            return(wr);
        }