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