private void Button1_Click (object sender, EventArgs e) {if (string. IsNullOrEmpty (This.textBox1.Text.Trim ())) {MessageBox.Show ("Please enter the information you need to convert!") "); Return The string content = TextBox1.Text; Hashtable hints= new Hashtable (); Hints. ADD (Encodehinttype.error_correction, ERRORCORRECTIONLEVEL.L);//error correction level hints. ADD (Encodehinttype.character_set, "UTF-8");//encoding format Bytematrix Bytematrix = new Multiformatwriter (). Encode (Conten T, Barcodeformat.qr_code, +, hints); Bitmap Bitmap = Tobitmap (Bytematrix); pictureBox1.Image = bitmap; SaveFileDialog SFD = new SaveFileDialog (); Sfd.filter = "*.png|*.png"; Sfd.addextension = true; try {if (sfd.showdialog () = = DialogResult.OK) {WriteToFile (b Ytematrix, System.Drawing.Imaging.ImageFormat.Png, sfd.filename); }} catch (Exception ex) {MessageBox.Show (ex). Message); }} public static void WriteToFile (Bytematrix matrix, System.Drawing.Imaging.ImageFormat format, string file ) {System.Drawing.Imaging.EncoderParameters EPS = new System.Drawing.Imaging.EncoderParameters (); Eps. Param[0] = new System.Drawing.Imaging.EncoderParameter (System.Drawing.Imaging.Encoder.Quality, 100L); Bitmap bmap = Tobitmap (matrix); Bmap. Save (file, format); } public static Bitmap Tobitmap (Bytematrix matrix) {int width = matrix. Width; int height = matrix. Height; Bitmap bmap = new Bitmap (width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); for (int x = 0; x < width; + +) {for (int y = 0; y < height; y++) { Bmap. SetPixel (x, Y, Matrix.get_renamEd (x, y)! =-1? Colortranslator.fromhtml ("Purple"): colortranslator.fromhtml ("0xFFFFFFFF"));//can customize color and background colors}} return bmap; }