C # generates two-dimensional code (QR code) and barcode (bar code) _c# tutorials through Third-party components

Source: Internet
Author: User
Tags generator

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://www.jb51.net/article/99215.htm

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:h 2amk-z3v69-rtjzd-c7jau-will4 ",
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:h2amk-z3v69-rtjzd-c7jau-will4 ",
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");
}

1.3): Appeal code We found that the generated barcode and two-dimensional code with watermark [E-iceblue], how to remove the watermark? Please see the following code

Barcodesettings.applykey ("...");

Please send mail to sales@e-iceblue.com for free to get the corresponding key value

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

Http://www.jb51.net/article/99222.htm

4): Through the Barcode Rendering Framework (Zen.Barcode.Rendering.Framework.dll) to achieve

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

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

private void Generatebarcodebyzen ()
{
Code128barcodedraw barcode128 = Barcodedrawfactory.code128withchecksum;
Image img = barcode128. Draw ("Hello World");
Img. Save ("E:/zenbarcode.gif");
}

4.3): Additional specific generated barcode method is as follows

private void Generateqrbyzen ()
{
Codeqrbarcodedraw qrcode = BARCODEDRAWFACTORY.CODEQR;
Image img = qrcode. Draw ("Hello world!", QRCode.) Getdefaultmetrics ());
Img. Save ("E:/zenqrcode.gif");
}

For more details, please refer to the following links:

http://barcoderender.codeplex.com/

5): Through Barcodelib (BarcodeLib.Barcode.ASP.NET.dll) to implement, download the corresponding DLL connection for http://www.barcodelib.com/asp_net/

5.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");

5.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/

The above is a small series to introduce C # through Third-party components to generate two-dimensional code (QR code) and bar code (bar code), I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.