1. Download first
The address is:/releases/view/117068
Then drag the corresponding version .dll into the project and reference it.
Mainly use BarcodeWriter and BarcodeReader.
2. Generate QR code
The code of the .NET platform is always simpler.
QrCodeEncodingOptions options = new QrCodeEncodingOptions(); = "UTF-8"; = true; // Extended Channel Interpretation (ECI) is mainly used for special character sets. Not all scanners support this encoding. = ; // Error correction level = 300; = 300; = 1; // , more properties can also be added here. BarcodeWriter writer = new BarcodeWriter(); = BarcodeFormat.QR_CODE; = options; (); using (Bitmap bmp = ("")) // Write has two functions: Generate and write{ MemoryStream ms = new MemoryStream(); { (ms, ); = "image/png"; (()); } } ();
Error correction level:
- L - Approximately 7% error correction capability.
- M - Approximately 15% error correction capability.
- Q - Approximately 25% error correction capability.
- H - Approximately 30% error correction capability.
3. Generate barcodes
QrCodeEncodingOptions options = new QrCodeEncodingOptions(); = "UTF-8"; = 300; = 50; = 1; = false; // Whether it is pure code, if it is false, the number will be displayed below the picture BarcodeWriter writer = new BarcodeWriter(); = BarcodeFormat.CODE_128; = options; (); using (Bitmap bmp = ("12345678")) { MemoryStream ms = new MemoryStream(); { (ms, ); = "image/png"; (()); } } ();
4. Identify QR codes and barcodes
BarcodeReader reader = new BarcodeReader(); = "UTF-8"; using (Bitmap bmp = new Bitmap("D:\\")) { Result result = (bmp); (); }
Summarize
OK, the above is all about this article. If you want to change the background color and draw avatar, you can draw it directly in Bitmap. I hope the content of this article will be of some help to everyone's study or work.