基本信息
源码名称:C# 二维码生成工具源码下载(zxing.dll)
源码大小:0.42M
文件格式:.zip
开发语言:C#
更新时间:2017-10-09
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

一个二维码生成工具

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ZXing;
using ZXing.Common;
using ZXing.QrCode.Internal;

namespace QRCode
{
    public partial class FrmQR : Form
    {
        public FrmQR()
        {
            InitializeComponent();
        }

        private void btn_Start_Click(object sender, EventArgs e)
        {
            string qRInfo = txt_QRInfo.Text.Trim();
            if(qRInfo=="")
            {
                string errorInfo = "输入内容空,不能生成二维码!";
                MessageBox.Show(errorInfo, "this");
                //Bitmap bmp = new Bitmap(200, 200);
                //Graphics g = Graphics.FromImage(bmp);
                //Point point = new Point(260,51);
                //g.DrawString(errorInfo, new Font("微软雅黑", 15, FontStyle.Bold), new SolidBrush(Color.Black), point);
                //this.picBox_QR.Image = bmp;
                return;
            }
            GenByZXingNet(qRInfo);
        }

        private void GenByZXingNet(string qRInfo)
        {
            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, ErrorCorrectionLevel.H);
            writer.Options.Height = 200;
            writer.Options.Width = 200;
            writer.Options.Margin = 1;
            BitMatrix bm = writer.Encode(qRInfo);
            Bitmap img = writer.Write(bm);
            this.picBox_QR.Image = img;
        }

        private void FrmQR_Load(object sender, EventArgs e)
        {
            GenByZXingNet("欢迎使用HWQ二维码生成器!");
        }

    }
}