C # using Third-party components to generate a two-dimensional code rollup _c# tutorial

Source: Internet
Author: User

How to generate two-dimensional code in C #, which we can implement directly from existing Third-party DLLs, lists several different build methods:

1. Through Qrcodenet (Gma.QrCodeNet.Encoding.dll) to achieve

1.1): First download the corresponding Third-party components through the VS2015 NuGet, as shown in the following figure:

1.2): The concrete generation of two-dimensional code method is as follows

    private void Generateqrbyqrcodenet ()
    {
      Qrencoder qrencoder = new Qrencoder (ErrorCorrectionLevel.H);
      QRCode QRCode = new QRCode ();
      Qrencoder.tryencode ("Hello World.") This is Eric Sun testing ... ", out qrcode);

      Graphicsrenderer renderer = new Graphicsrenderer (New Fixedmodulesize (5, Quietzonemodules.two), Brushes.black, Brushes.white);

      using (MemoryStream ms = new MemoryStream ())
      {
        renderer. WriteToStream (Qrcode.matrix, Imageformat.png, MS);
        Image img = image.fromstream (ms);
        Img. Save ("E:/csharp-qrcode-net.png");
      }
    

For more details, please refer to the following links:

http://qrcodenet.codeplex.com/

Http://stackoverflow.com/questions/7020136/free-c-sharp-qr-code-generator

2. Through Thoughtworks.qrcode (ThoughtWorks.QRCode.dll) to achieve

1.1): First download the corresponding Third-party components through the VS2015 NuGet, as shown in the following figure:

1.2): The concrete generation of two-dimensional code method is as follows

    private void Generateqrbythoughtworks ()
    {
      Qrcodeencoder encoder = new Qrcodeencoder ();
      Encoder. Qrcodeencodemode = Qrcodeencoder.encode_mode. byte;//encoding Method (Note: Byte can support Chinese, alpha_numeric scan is the number)
      encoder. Qrcodescale = 4;//size (the larger the value generated two-dimensional code picture pixels higher)
      encoder. Qrcodeversion = 0;//Version (note: setting to 0 is primarily to prevent errors that occur when the encoded string is too long)
      encoder. Qrcodeerrorcorrect = qrcodeencoder.error_correction. m;//error parity, error correction (with 4 levels)
      encoder. Qrcodebackgroundcolor = Color.yellow;
      Encoder. Qrcodeforegroundcolor = Color.green;
      String qrdata = "Hello world!" This is Eric Sun testing ... ";

      Bitmap Bcodebitmap = encoder. Encode (Qrdata. ToString ());
      Bcodebitmap.save (@ "E:\HelloWorld.png", imageformat.png);
      Bcodebitmap.dispose ();
    }

3): Through Spire.barcode (Spire.BarCode.dll) to achieve

1.1): First download the corresponding Third-party components through the VS2015 NuGet, as shown in the following figure:

1.2): The concrete generation of two-dimensional code method is as follows

    private void Generateqrbyspire ()
    {
      barcodesettings bs = new barcodesettings ()
      {
        Data = "This is QR code." ,
        Type = Barcodetype.qrcode,
        toptextcolor = color.red,
        Showchecksumchar = False,
        Showtext = False
      };
      Generate the barcode based on the this.barcodecontrol1
      barcodegenerator generator = new Barcodegenerator (BS); 
  image barcode = Generator. Generateimage ();

      Save the barcode as an image
      barcode. Save (@ "E:\barcode-2d.png");
    }

1.3): Additional specific generated barcode method is as follows

    private void Generatebarcodebyspire ()
    {
      barcodesettings bs = new barcodesettings ()
      {
        Data = "This is Barcode. ",
        Showchecksumchar = False,
        Toptextcolor = color.red,
        Showtoptext = False,
        Showtextonbottom = True
      };
      Generate the barcode based on the this.barcodecontrol1
      barcodegenerator generator = new Barcodegenerator (BS); 
  image barcode = Generator. Generateimage ();

      Save the barcode as an image
      barcode. Save (@ "E:\barcode.png");
    }

For more details, please refer to the following links:

http://freebarcode.codeplex.com/

Http://www.e-iceblue.com/Knowledgebase/Spire.BarCode/Program-Guide/Programme-Guide-for-Spire.BarCode.html

3. Through Barcodelib (BarcodeLib.Barcode.ASP.NET.dll) to achieve

Download the corresponding DLL connection for http://www.barcodelib.com/asp_net/

4.1): The concrete generation of two-dimensional code method is as follows

    private void Generateqrbybarcodelib ()
    {
      QRCode qrbarcode = new QRCode ();
      Qrbarcode. Encoding = Qrcodeencoding.auto;
      Qrbarcode. Data = "336699885522 This is Eric Sun testing.";

      Qrbarcode. Modulesize = ten;
      Qrbarcode. LeftMargin = 8;
      Qrbarcode. RightMargin = 8;
      Qrbarcode. TopMargin = 8;
      Qrbarcode. BottomMargin = 8;
      Qrbarcode. imageformat = System.Drawing.Imaging.ImageFormat.Gif;

      Save QR Code Barcode image into your system
      Qrbarcode.drawbarcode ("E:/csharp-qrcode-lib.gif");
    

4.2): Additional specific generated barcode method is as follows

    private void Generatelinearbybarcodelib ()
    {
      Linear barcode = new Linear ();
      Barcode. Type = barcodetype.code128;
      Barcode. Data = "CODE128";
      Other barcode settings.

      Save barcode image into your system
      Barcode.drawbarcode ("E:/barcode.png");
    }

We are using the trial version (with watermark ...). , as well as paid genuine, please refer to the following links:

http://www.barcodelib.com/asp_net/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.