Use free service to generate QR code

Source: Internet
Author: User

QR codes are increasingly appearing in people's daily lives, such as movie tickets, electronic coupons, and even electronic air tickets.

Can you imagine how much information such an image contains?

Today, smartphones are widely used, and most mobile phones can also read QR code information.

Today, I am bored and write a smallProgramTo generate a QR code. The program is very simple. It does not use any QR technology and does not contain anyAlgorithmOr use third-party components. It simply utilizes the existing free resources of the network. Http://www.qrstuff.com/is a foreign site that provides free QR code generation service.

AnalyzedSource code, Found as long as through http://www.qrstuff.com/generate.generate? Type = text & text = {0} & foreground_color = 000000 this address can generate the QR code parameter Text of the specified content to specify the content you want.

The program is simple.

Just a class

Using system; using system. collections. generic; using system. componentmodel; using system. data; using system. drawing; using system. io; using system. LINQ; using system. net; using system. text; using system. windows. forms; namespace createqr {public partial class form1: FORM {public form1 () {initializecomponent ();} /// <summary> /// address that generates the QR code /// </Summary> readonly string qrcreateurl = "http://www.qrstuff.co M/generate. generate? Type = text & text = {0} & foreground_color = 000000 "; private void btnsave_click (Object sender, eventargs e) {// Save the data savedata (picdata );} /// <summary> // save data /// </Summary> /// <Param name = "data"> </param> private void savedata (byte [] data) {savefiledialog savefiledialog1 = new savefiledialog (); savefiledialog1.filter = "PNG Format Image | *. PNG "; savefiledialog1.title =" save images "; savefiledialog1.showdialog (); If (S Avefiledialog1.filename! = "") {If (file. exists (savefiledialog1.filename) {file. delete (savefiledialog1.filename);} using (filestream FS = file. create (savefiledialog1.filename) {FS. write (data, 0, Data. length) ;}}/// <summary> // temporary image data // </Summary> private byte [] picdata; private void btncreate_click (Object sender, eventargs e) {// download downloaddata (string. format (qrcreateurl, String. isnullorempty (txtqr. text )? "No content": txtqr. text), (_ Send, _ e) =>{ picdata = _ e. result; using (memorystream MS = new system. io. memorystream () {Ms. write (picdata, 0, picdata. length); picturebox. image = image. fromstream (MS );};});} /// <summary> /// download data /// </Summary> /// <Param name = "url"> </param> /// <Param name = "dceh"> </param> private void downloaddata (string URL, downloaddatacompletedeventhandler dceh) {using (WebClient = new WebClient () {WebClient. downloaddataasync (New uri (URL); WebClient. downloaddatacompleted + = dceh ;};}}}

ArticleThe following are all source code and demo

Click here to download the demo

Tang Xiaohua QQ 1881597 MSN tension1990@hotmail.com

2011 05 22

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.