基本信息
源码名称:C# 生成二维码 例子源码(DotNetBarcode)
源码大小:0.23M
文件格式:.7z
开发语言:C#
更新时间:2016-11-03
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

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

本次赞助数额为: 2 元 
   源码介绍
输入随便文字或数字可生成二维码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QRCode
{
    public partial class Form1 : Form
    {
        DotNetBarcode bc = new DotNetBarcode();
        Image printImage;
        public Form1()
        {
            InitializeComponent();
        }

        private void btnCreate_Click(object sender, EventArgs e)
        {
            this.ptQRCode.Refresh();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            bc.Type = DotNetBarcode.Types.QRCode;
            bc.PrintCheckDigitChar = true;
        }

        private void ptQRCode_Paint(object sender, PaintEventArgs e)
        {
            bc.WriteBar(this.txtContent.Text.Trim(), 0, 0, this.ptQRCode.Width, this.ptQRCode.Height, e.Graphics);
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            string url = null;
            Bitmap b = new Bitmap(ptQRCode.Width, ptQRCode.Height);
            ptQRCode.DrawToBitmap(b,new Rectangle(0,0,ptQRCode.Width,ptQRCode.Height));
            SaveFileDialog sfd=new SaveFileDialog ();
            sfd.InitialDirectory=Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            sfd.Filter="jpg图片|*.jpg|bmp图片|*.bmp";
            sfd.RestoreDirectory=true;
            sfd.Title="请选择要保存的位置";
            if(sfd.ShowDialog()==DialogResult.OK)
            {
            url=sfd.FileName;
            }
            printImage=b;
            if(url!=null)
            {
            b.Save(url);
            }



        }
    }
}