C # generates two-dimensional code (QR code) and barcodes (bar code) from third-party components

Source: Internet
Author: User

Many methods, you can refer to the following scenarios, do not expand, the address is as follows:

Https://www.cnblogs.com/mingmingruyuedlut/p/6120671.html

What is described here is a project requirement, which is exported as a picture and displayed in the Web page, with the following code:

Using ThoughtWorks.QRCode.Codec;

public void ProcessRequest (HttpContext context)
{

Context. Response.ContentType = "Text/plain";
String OrderNo = context. request.params["OrderNo"];
Qrcodeencoder encoder = new Qrcodeencoder ();
Encoder. Qrcodeencodemode = Qrcodeencoder.encode_mode. byte;//encoding Method (Note: Byte can support Chinese, alpha_numeric scan out is the number)
Encoder. Qrcodescale = 6;//size (the larger the value, the higher the image pixel of the resulting QR code)
Encoder. Qrcodeversion = 0;//Version (note: setting to 0 is primarily to prevent an error when the encoded string is too long)
Encoder. Qrcodeerrorcorrect = qrcodeencoder.error_correction. m;//error validation, error correction (4 levels)
Encoder. Qrcodebackgroundcolor = Color.yellow;
Encoder. Qrcodeforegroundcolor = Color.green;
System.Drawing.Image _codeimage = encoder. Encode (OrderNo);
System.IO.MemoryStream _stream = new System.IO.MemoryStream ();
_codeimage.save (_stream, System.Drawing.Imaging.ImageFormat.Jpeg);
Context. Response.ContentType = "Image/tiff";
Context. Response.Clear ();
Context. Response.bufferoutput = true;
Context. Response.BinaryWrite (_stream.getbuffer ());
Context. Response.Flush ();

39 yards generating section, shielding
/*context. Response.ContentType = "Text/plain";
String OrderNo = context. request.params["OrderNo"];
Webapplication1.code39 _code39 = new Code39 ();
_code39.height = 60;
_code39.magnify = 0;
_code39.viewfont = new Font ("Arial", 12);
System.Drawing.Image _codeimage = _code39.getcodeimage (OrderNo, Code39.Code39Model.Code39Normal, true);
System.IO.MemoryStream _stream = new System.IO.MemoryStream ();
_codeimage.save (_stream, System.Drawing.Imaging.ImageFormat.Jpeg);
Context. Response.ContentType = "Image/tiff";
Context. Response.Clear ();
Context. Response.bufferoutput = true;
Context. Response.BinaryWrite (_stream.getbuffer ());
Context. Response.Flush (); */

}

This. Image1.imageurl = "/textbuilder.ashx?" orderno= "+ ti_no;

Attach this method of QRCode use

C # generates two-dimensional code (QR code) and barcodes (bar code) from third-party components

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.