Open source C # QR code generation Parsing tool to add a custom logo

Source: Internet
Author: User

Original: [Open source]c# QR code generation Parsing tool, can add custom logo

QR Code, also known as CODE,QR Universal Quick Response, is a very popular coding method in mobile devices in recent years, it can save more information than the traditional bar code barcode, but also can represent more data types: characters, numbers, Chinese and so on. Today to share with you my two-dimensional code generation parsing tool, the main function is to generate two-dimensional code, and can add a custom logo. Of course, the network above the generation of two-dimensional code tools abound, the generation of two-dimensional code is no longer fresh. One of the highlights of this tool is to identify two-dimensional code, the following to see the specific, but first to supplement the knowledge of 1.2-dimensional code.

one or two dimensional code basics

One or two-dimensional code version

First of all, let's talk about the QR code a total of 40 sizes. The official name is version versions. Version 1 is a matrix of x 21, version 2 is a matrix of x 25, version 3 is the size of 29, each additional Version will increase the size of 4, the formula is: (V-1) + (V is the version number) Max Ver Sion 40, (40-1) *4+21 = 177, so the highest is a square of 177 x 177.

Let's look at an example of a two-dimensional code:

Second, the fault-tolerant processing of QR code

Two-dimensional code to support error correction processing, error correction processing is relatively complex, according to the QR Code standard document description, QR Code error correction is divided into 4 levels, namely:

    • Level L: A maximum of 7% errors can be corrected;
    • Level M: A maximum of 15% errors can be corrected;
    • Level Q: A maximum of 25% errors can be corrected;
    • Level H: The maximum error of 30% can be corrected;

Capacity of three or two-D code (QR code)

  For different versions of the QR code, the capacity is also different. In theory, the content can be compressed to save 7,089 digits, 4,296 letters and numbers of mixed characters, 2,953 8-bit bytes of data, 1817 Chinese characters; In the above we see that the QR code of different versions is a different matrix, the version is over, It means the larger the capacity. About capacity calculation I did not find the more authoritative algorithm, here in the first version of the calculation, the first version (21X21) format is as follows:

Only yellow is the content of the stored data, in the first version only 217 (21X21-8*9*3-8) The number of space to store data, and the useful data is 217-1 end of data flag = 216, in 216bit

216BIT/8 = 27Byte can only store 27Byte of data in the QR Code of version one (less if there is more fault tolerance), of course, at different levels of fault tolerance, there is also a change in capacity.

Therefore, the QR Code of version 1 will probably be able to tolerate more than 10 characters.

Four or two-dimensional code encoding

The QR code supports the following encodings:

  Numeric mode digital code, from 0 to 9. If the number of numbers that need to be encoded is not a multiple of 3, then the last remaining 1 or 2 digits will be converted to 4 or 7bits, then each of the other 3 digits will be 10,12,14bits, how long it takes to look at the size of the two-dimensional Code (table 3 below illustrates this)

  alphanumeric mode character encoding. Includes 0-9, uppercase A to Z (no lowercase), and the symbol $% * +–. /: Include spaces. These characters are mapped into a single character index table. As shown below: (where the SP is a space, Char is a character, value is its index value) encoding the process is to group the character 22, and then turn to the following table of 45, and then into the binary of the 11bits, if there is a single, then turn into 6bits binary. The number of encoding modes and characters needs to be 9, 11, or 13 binary according to different Version sizes (table 3 in the tables below)

Byte mode, byte-encoded, can be 0-255 iso-8859-1 characters. Some QR code scanners can automatically detect if a UTF-8 is encoded.

Ii. Introduction to QRCode generation parsing tools

This tool is developed using WPF based on open source project ThoughtWorks.QRCode.dll, without complex algorithms for generating QR codes, whether you are a novice or a Daniel, you can read it. See here some used ThoughtWorks.QRCode.dll of the Daniel may be disappointed, but the study of the two-dimensional code generation algorithm really need to learn a lot of things, but also to refer to a lot of information, we are interested to study the source of Thoughtworks.qrcode, the following gives a Some references. Let's take a look at the tools below:

Thoughtworks.qrcode Source Address:http://www.codeproject.com/Articles/20574/Open-Source-QRCode-Library

thoughtworks.qrcodeGitHub address : Https://github.com/aaronogan/QR.NET

The interface is simple, and the following is a simple example:

Two-dimensional code content: generated QR code content, you can enter any string, such as the URL, support Chinese.

Two-dimensional code size : Generate two-dimensional code size, the default value is 4, the larger the number, the larger the generated QR code, can be filled according to demand.

Two-dimensional code version : two-dimensional code versions, the higher the value of 1~40,version, the larger the two-dimensional code information capacity. But more than 30 of the current version of the two-dimensional code, due to mobile phone cameras and other reasons will cause the phone is not recognized.

generate: generates a QR code for the specified content and then displays it in the lower-left picture box.

Save: save QR Code and save QR Code as PNG format.

Open the QR code: Open the QR code image, displayed in the bottom left of the picture box.

Parse: Parse the two-dimensional code in the picture box at the bottom left, and the analytic result will be displayed behind the QR code content.

Custom Logo: Click Add image as logo, do not add the resulting QR code does not have a logo.

below to generate a QR code to see it,

Then we add a logo to look at it, such as:

As the size of the logo can be freely adjusted, sometimes the logo is too large, will cover the two-dimensional code part of the information, resulting in unrecognized. At this point, we can click the Parse button to test whether our QR code is valid,

We see the parsing out of the contents of the garbled, this is because our logo size is too large, we can reduce the size of the logo or increase the size of the two-dimensional code, here I modified the size of the QR Code 6, and then can be normal recognition. Then we click on the Save button, open the Save As dialog box, will be saved as PNG format picture, the actual production of the QR code size

Let us look at the resolution of two-dimensional code, we from Baidu above casually download a QR code image, see what is stored inside,

Here we can copy the text with the mouse, or copy the contents of the QR code directly by clicking on the Clipboard.

Here are some bug processing, the first thing to say is the size of the two-dimensional code, version 1 of the QR code capacity of about more than 10 characters, beyond the capacity of the following error occurs,

Of course, if you randomly open an invalid QR code image as a two-dimensional code to resolve, the following error will appear,

Of course, if the image contains two-dimensional code can be resolved successfully,

Third, GitHub open source address

GitHub Address: Https://github.com/yunfeifei/QRCodeTools

Of course, there are a lot of things to optimize the software, there are many unknown bugs, and will continue to modify the update. You are welcome to review and point out bugs and deficiencies. After testing, if the QR code is too large or the version is too high will be unable to identify the situation, of course, choose the appropriate size and version is normal use.

Reference Links

The details and principles of the generation of two-dimensional codes

QR code generation principle (i)

Cloud drizzling

QQ Exchange Group: 243633526

Blog Address: http://www.cnblogs.com/yunfeifei/

Disclaimer: The original text of this blog only represents my work in a certain time to summarize the views or conclusions, and my unit does not have a direct interest in the relationship. Non-commercial, unauthorized, post please keep the status quo, reprint must retain this paragraph statement, and in the article page obvious location to the original connection.

If you feel that my blog is helpful to everyone, please recommend supporting one, give me the motivation to write.

Open source C # QR code generation Parsing tool to add a custom logo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.