. NET C # leverages zxing to generate, identify QR codes/barcodes

Source: Internet
Author: User
First, download zxing.net

Address is: http://zxingnet.codeplex.com/releases/view/117068

The corresponding version of the. dll is then dragged into the project and then referenced.

Mainly with Barcodewriter, Barcodereader.

Second, generate two-dimensional code

The code for the. NET platform is always simpler.

Qrcodeencodingoptions options = new Qrcodeencodingoptions (); options. CharacterSet = "UTF-8"; options. Disableeci = true; Extended Channel Interpretation (ECI) is used primarily for special character sets. Not all scanners support this encoding. Options. Errorcorrection = zxing.qrcode.internal.errorcorrectionlevel.h; Error correction level options. Width = 300;options. Height = 300;options. Margin = 1;//options. Hints, more properties, can also be added here. Barcodewriter writer = new Barcodewriter (); writer. Format = Barcodeformat.qr_code;writer. options = options; Response.Clear (); using (Bitmap bmp = writer. Write ("http://www.cftea.com"))//write has a build, write two functions {MemoryStream ms = new MemoryStream (); {  bmp. Save (MS, System.Drawing.Imaging.ImageFormat.Png);   Response.ContentType = "Image/png";  Response.BinaryWrite (Ms. ToArray ()); }}response.end ();

Error correction level:

L-About 7% error correction capability.

M-About 15% error correction capability.

Q-About 25% error correction capability.

H-About 30% error correction capability.

Third, generate barcodes

Qrcodeencodingoptions options = new Qrcodeencodingoptions (); options. CharacterSet = "UTF-8"; options. Width = 300;options. Height = 50;options. Margin = 1;options. Purebarcode = false; Whether it is a pure code, or FALSE, the number is displayed below the picture barcodewriter writer = new Barcodewriter (); writer. Format = Barcodeformat.code_128;writer. options = options; Response.Clear (); using (Bitmap bmp = writer. Write ("12345678")) {MemoryStream ms = new MemoryStream (); {  bmp. Save (MS, System.Drawing.Imaging.ImageFormat.Png);   Response.ContentType = "Image/png";  Response.BinaryWrite (Ms. ToArray ()); }}response.end ();

Iv. identification of two-dimensional code, barcode

Barcodereader reader = new Barcodereader (); reader. Options.characterset = "UTF-8"; using (Bitmap bmp = new Bitmap ("D:\\qr.png")) {result result = reader. Decode (BMP); Response.Write (Result. Text);}

Summarize

Well, the above is the whole content of this article, if you want to change the background color, picture, you can directly in the Bitmap painting, I hope the content of this article to everyone's study or work can bring some help

Related Article

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.