Encode and decode two-dimensional codes using Zint and zxing (using Open-source tools to generate and decode Q-r code) 1. Zint generate two-dimensional code
http://sourceforge.net/projects/zint/
"1" Download the Zint tool from the above site
"2" Installation Zint tool
"3" uses the Zint tool to generate the QR code, note the selection type, and enter the text to be generated, here I enter the Hello world,everyone!
"4" Save q-r QR code image
In this way our q-r QR code image is saved successfully "Save as Hello.png".
2. Decoding using the Zxing
Zxing is the famous barcode processing open source project, which provides a variety of standard barcode generation and decoding tools on multiple platforms.
Https://github.com/zxing
Zxing provides the ANDROID,JAVA,IPHONE,OBJECTIVE-C,C++,JRUBY,QT,. NET and other platform libraries, the content is very large, here is not the main introduction. Below, we use the JRuby project provided by Zxing to perform a simple decoding operation, the two-dimensional code image just generated as input, to see if the expected output can be obtained.
"1" Installation JRuby
Since Zxing was originally born in Java, it provided libraries that were JRuby versions, so install JRuby first. (JRuby is chosen because it is relatively lightweight, easy to use)
http://jruby.org/installation JRuby is very simple and takes only 3 steps:
(1) Download JRuby Zip package
(2) Decompression JRuby
(3) Add the path of the JRuby down bin directory to the Paths environment variable
(4) Complete (enter jruby-v in CMD to test if the installation is successful)
"2" Install zxing for Ruby
Https://github.com/ecin/zxing.rb
Open cmd, enter JRuby -S gem install zxing Wait a few seconds, JRuby will install zxing for us. At this point, we can import zxing in Ruby Code!
"3" Write the Decoder program
Decoding program is very simple, in the folder just saved the image of a new Ruby file "1.ruby", the program code only 3 lines:
1 Require ' zxing ' 2 3 result = Zxing.decode ' Hello.png ' 4 5 puts result
Simply put, the Decode method in Zxing is called, the input parameter is the "hello.png" file in the same directory, and the input is saved in result.
"4" Execution decoding program
Open cmd, execute JRuby 1.rb, its output is exactly the same as we entered.
3. Based on. NET is a simple codec tool
"1" Download Zxing.net tool
http://zxingnet.codeplex.com/releases/view/117068
After downloading it, unzip it to any location and we'll use the DLL file later.
"2" Build WinForm application in VS2013
"3" Add reference
When adding references, be aware of the corresponding version!!! Select the corresponding version of the Zxing.dll and add it to the reference.
"4" Design GUI interface
Here is a demonstration, please download the Project Code (accessories)
(1) Enter text, click Generate, Generate Qr-code
(2) Click Save, select Path, save Qr-code
(3) Click Decoding, select the appropriate Qr-code file, decode the Qr-code, and display the text in result!
"5" Encoding
Core Code 1: Generate Qr-code
Core Code 2: decoding Qr-code
"6" function display
(1) Generate Qr-code
Enter Hello world! Click generate!
(2) Save Qr-code
(3) Decoding Qr-code
This time we chose to start by using Zint generated hello.png to see if we could get the same results.
As we can see, the result is the same as the JRuby output.
"7" Last project source sharing, welcome to further explore, Thank you for your support!
Click me to get code.
Reprinted from: http://www.cnblogs.com/Kassadin/p/4534952.html
. NET Two-dimensional code solution