Many applications on the web are using QR codes to share URLs or other information. Especially in the mobile domain, the QR code is a very large application scenario. Because of the needs of the project, need to add a Web site to generate two-dimensional code analysis of the function of the URL, in the case of large cramps in Google's frustration using Baidu. Baidu N More, find some projects, but the availability is not strong. (There is a project developed with VS2005, debugging in 2010 does not open.) Finally found a "artifact" on the CodePlex, this "artifact" can be very convenient to generate two-dimensional code, speed that is quite fast, and can support Chinese, adhere to the MIT Protocol.
Qrcode.net is a class library written in C # to generate two-dimensional code images, which makes it easy to provide QR code output functionality for WinForm, WebForm, WPF, Silverlight, and Windows Phone 7 applications. You can export two-dimensional code files to EPS format.
The project address is: http://qrcodenet.codeplex.com
The qrcode.net no longer uses the http://code.google.com/p/zxing/ZXing port, and the new version will have better performance.
The test results are as follows (in microseconds):
Input string Length: 74 x
EC Performance tests~ qrcode.net:3929 zxing:5221
At the same time, Qrcode.net can parse the string and decide whether to use UTF-8 encoding. (for example, when using Chinese.) )
1.Graphics
//const string str = "Hello world!"; Const stringstr ="http://www.weilanwu.com"; protected Override voidOnPaint (PaintEventArgs e) {Base. OnPaint (e); ShowCode (E.graphics); } //draw the QR code on the graphics Private voidShowCode (Graphics g) {Qrencoder Qrencoder=NewQrencoder (ErrorCorrectionLevel.H); QRCode QRCode=Qrencoder.encode (str); Fixedmodulesize modulesize=NewFixedmodulesize (2, Quietzonemodules.two); Graphicsrenderer Render=Newgraphicsrenderer (modulesize, Brushes.black, brushes.white); Render. Draw (g, Qrcode.matrix); }
Show Results:
2. Generate to Picture
/** Fixedmodulesize---5-----165*165 * Fixedmodulesize---4-----132*132 * Fixedmodulesize---3---- -99*99 * Fixedmodulesize---2-----66*66 * Fixedmodulesize---1-----33*33*/ //save QR Code directly to file Private voidSavecodefile () {Qrencoder Qrencoder=NewQrencoder (ErrorCorrectionLevel.H); QRCode Code=NewQRCode (); Qrencoder.tryencode (str, outcode); Const intModelsizeinpixels =4; Graphicsrenderer Render=NewGraphicsrenderer (Newfixedmodulesize (Modelsizeinpixels, Quietzonemodules.two), Brushes.black, brushes.white); stringfilename = Localpathhelper.desktoppath +"/one.png"; using(FileStream stream =NewFileStream (filename, filemode.create)) {Render. WriteToStream (code. Matrix, Imageformat.png, stream); } }
Show Results:
C # generates two-dimensional code (QR code) using Qrcode.net