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:
- L-About 7% error correction capability.
- M-About 15% error correction capabilities.
- Q-About 25% error correction capabilities.
- 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