ref https://jingyan.baidu.com/article/fb48e8bef1ebab6e622e1409.html
1. Visual Studio> right-click the project name> Manage NuGet Packages ...> Search Spire.Barcode and install it. The current version is v3.5.0, VS using a VS Community 2017 Version 15.9.12
Add the following code within the function 2. Program.cs Main, generated QR Code:
. 1 the using Spire.Barcode; 2 the using the System.Drawing; . 3 . 4 static void the Main ( String [] args) . 5 { . 6 . 7 // Create BarcodeSettings objects . 8 BarcodeSettings Settings = new new BarcodeSettings (); . 9 10 // set to two barcode types dimensional code . 11 settings.Type = BarCodeType.QRCode; 12 is 13 is // set two-dimensional code data 14 settings.Data = " 123456789 " ; 15 16 // set the display text . 17 settings.Data2D = " 123456789 " ; 18 is . 19 // Set digital data type 20 is settings.QRCodeDataMode = QRCodeDataMode.Numeric; 21 is 22 is // set the error correction code is a two-dimensional level 23 is settings.QRCodeECL = QRCodeECL .H; 24 25 // set the width 26 is settings.X = 3.0f ; 27 28 // instantiate an object of class BarCodeGenerator 29 BarCodeGenerator = Generator new new BarCodeGenerator (settings); 30 31 is // generate two-dimensional code image and save it as a PNG format 32 Image Image = generator.GenerateImage (); 33 is Image.Save ( " QRCode.png " ); // Not mandatory
3. Form1.cs, the parameters passed to the generated image to be displayed Form
public Form1(Image image) // add args image { InitializeComponent(image); // parse image to form
4. Form1.Designer.cs, for displaying a two-dimensional code added pictureBox
using System.Drawing; // add name space if report error private void InitializeComponent(Image image) // parse image this.pictureBox1.Image = image; // show QRCode the this .pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; // the AutoSize pictureBox automatically extended according to the size of the image