Form1.cs 997 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using ZXing;
  10. using ZXing.QrCode;
  11. namespace Test.Qrcode
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19. private void button1_Click(object sender, EventArgs e)
  20. {
  21. BarcodeWriter writer = new BarcodeWriter();
  22. writer.Format = BarcodeFormat.QR_CODE;
  23. QrCodeEncodingOptions options = new QrCodeEncodingOptions()
  24. {
  25. DisableECI = true,
  26. CharacterSet = "UTF-8",
  27. Width = pictureBox1.Width,
  28. Height = pictureBox1.Height,
  29. Margin = 1
  30. };
  31. writer.Options = options;
  32. Bitmap map = writer.Write("生成二维码测试");
  33. pictureBox1.Image = map;
  34. }
  35. }
  36. }