. NET C # _c# Tutorials with zxing generation, identification of two-dimensional code/barcode

Source: Internet
Author: User

First, download zxing.net

The address is: http://zxingnet.codeplex.com/releases/view/117068

Then drag the corresponding version. dll into the project, and then refer to it.

Mainly used Barcodewriter, Barcodereader.

Two, generate two dimensional code

The. NET Platform's code is always simpler.

Qrcodeencodingoptions options = new Qrcodeencodingoptions ();
Options. CharacterSet = "UTF-8";
Options. Disableeci = true; Extended Channel Interpretation (ECI) is mainly used for special character sets. Not all scanners support this encoding.
options. Errorcorrection = zxing.qrcode.internal.errorcorrectionlevel.h; Error correction level
options. Width =;
Options. Height =;
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 with build, write two features
{
 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:

    1. L-About 7% error correction capability.
    2. M-About 15% error correction capabilities.
    3. Q-About 25% error correction capabilities.
    4. H-About 30% error correction capabilities.

Third, the production of barcode

Qrcodeencodingoptions options = new Qrcodeencodingoptions ();
Options. CharacterSet = "UTF-8";
Options. Width =;
Options. Height = m;
Options. Margin = 1;
Options. Purebarcode = false; is a pure code, if False, the digital

barcodewriter writer = new Barcodewriter () is displayed below the picture;
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 ();

Four, the identification of two-dimensional code, bar code

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 entire content of this article, if you want to change the background color, picture portrait, you can directly in the Bitmap painting, I hope the content of this article for everyone's study or work can bring certain help

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.