• 大小: 849KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-08
  • 语言: C#
  • 标签:

资源简介

C#利用ThoughtWorks.QRCode.dll创建和解析二维码

资源截图

代码片段和文件信息

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;
using ThoughtWorks.QRCode;
using ThoughtWorks.QRCode.Codec;
using ThoughtWorks.QRCode.Codec.Data;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender EventArgs e)
        {
            if (!string.IsNullOrEmpty(textBox1.Text.Trim()))
            {
                string enCodeString = textBox1.Text.Trim();
                QRCodeEncoder codeEncoder = new QRCodeEncoder();
                pictureBox1.Image = codeEncoder.Encode(enCodeString Encoding.UTF8);
            }
        }

        private void 二维码另存为ToolStripMenuItem_Click(object sender EventArgs e)
        {
            if (pictureBox1 .Image!=null)
            {
                SaveFileDialog s = new SaveFileDialog();
                s.title = “保存二维码图片“;
                s.Filter = “图片文件(*.jpg)|*.jpg“;
                if (s.ShowDialog()==DialogResult.OK)
                {
                    pictureBox1.Image.Save(s.FileName System.Drawing.Imaging.ImageFormat.Jpeg);
                    MessageBox.Show(“保存成功“);
                }
            }
        }

        string filename = string.Empty;
        private void button1_Click(object sender EventArgs e)
        {
            OpenFileDialog p = new OpenFileDialog();
            p.title = “请选择二维码图片“;
            p.Filter = “图片格式(*.jpg)|*.jpg“;
            p.Multiselect = false;
            if (p.ShowDialog()==DialogResult.OK)
            {
                filename = p.FileName;
                ss();
            }
        }

        private void ss()
        {
            pictureBox1.Image = new Bitmap(filename);
            QRCodeDecoder qrDecoder = new QRCodeDecoder();
          string msg= qrDecoder.decode(new QRCodeBitmapImage(new Bitmap(pictureBox1.Image)) Encoding.UTF8);
          textBox1.Text = msg;
          MessageBox.Show(“解析完成“);
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件    6205440  2012-06-09 11:05  二维码\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\ThoughtWorks.QRCode.dll

     文件      11776  2013-10-10 14:46  二维码\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe

     文件      26112  2013-10-10 14:46  二维码\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb

     文件      11600  2013-10-10 14:46  二维码\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe

     文件        490  2010-03-17 22:39  二维码\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.manifest

     文件       2286  2013-10-10 14:46  二维码\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs

     文件       5340  2013-10-10 14:38  二维码\WindowsFormsApplication1\WindowsFormsApplication1\Form1.Designer.cs

     文件       6022  2013-10-10 14:38  二维码\WindowsFormsApplication1\WindowsFormsApplication1\Form1.resx

     文件       2152  2013-10-10 14:12  二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6388  2013-10-10 14:46  二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        312  2013-10-10 14:44  二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\GenerateResource.read.1.tlog

     文件        790  2013-10-10 14:44  二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\GenerateResource.write.1.tlog

     文件      12276  2013-10-10 14:27  二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\ResolveAssemblyReference.cache

     文件        997  2013-10-10 14:46  二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.csproj.FileListAbsolute.txt

     文件      11776  2013-10-10 14:46  二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.exe

     文件        180  2013-10-10 14:44  二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.Form1.resources

     文件      26112  2013-10-10 14:46  二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.pdb

     文件        180  2013-10-10 14:27  二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.Properties.Resources.resources

     文件        505  2013-10-10 14:12  二维码\WindowsFormsApplication1\WindowsFormsApplication1\Program.cs

     文件       1398  2013-10-10 14:12  二维码\WindowsFormsApplication1\WindowsFormsApplication1\Properties\AssemblyInfo.cs

     文件       2896  2013-10-10 14:12  二维码\WindowsFormsApplication1\WindowsFormsApplication1\Properties\Resources.Designer.cs

     文件       5612  2013-10-10 14:12  二维码\WindowsFormsApplication1\WindowsFormsApplication1\Properties\Resources.resx

     文件       1107  2013-10-10 14:12  二维码\WindowsFormsApplication1\WindowsFormsApplication1\Properties\Settings.Designer.cs

     文件        249  2013-10-10 14:12  二维码\WindowsFormsApplication1\WindowsFormsApplication1\Properties\Settings.settings

     文件       3951  2013-10-10 14:27  二维码\WindowsFormsApplication1\WindowsFormsApplication1\WindowsFormsApplication1.csproj

     文件        914  2013-10-10 14:12  二维码\WindowsFormsApplication1\WindowsFormsApplication1.sln

    ..A..H.     19968  2013-10-10 14:51  二维码\WindowsFormsApplication1\WindowsFormsApplication1.suo

     目录          0  2013-10-10 14:12  二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\TempPE

     目录          0  2013-10-10 14:46  二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug

     目录          0  2013-10-10 14:27  二维码\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug

............此处省略10个文件信息

评论

共有 条评论