In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to generate a QR code picture for a web address by C#". In daily operation, I believe many people have doubts about how to generate a QR code picture from the URL by C#. The editor consulted all kinds of materials and sorted out a simple and easy-to-use operation method. I hope it will be helpful for you to answer the question of "how to generate a QR code picture from the web site by C#". Next, please follow the editor to study!
What is the QR code?
The QR code QR Code, whose full name is Quick Response Code, was first used to track parts in the Japanese automobile industry. There are 40 standard versions and 4 micro versions of QR. Compared with the one-dimensional code (that is, the bar code we still use at present), it has a higher density of coding and can store more information. One-dimensional codes can only store letters and numbers, while two-dimensional codes can hold up to 1850 uppercase letters or 2710 numbers or 1108 characters or more than 500 Chinese characters, dozens of times more than bar codes. In addition, the QR code can encode pictures, sounds, text, and other information that can be digitized.
In addition: two-dimensional code than one-dimensional code decoding error rate is much lower (code error rate is not more than 1/1000), better confidentiality, security, low cost, easy to make, so that two-dimensional code is used more widely, more and more popular.
In addition to storing the encoded data, the QR code also contains some patterns predetermined in the basic standards to help scanning software quickly identify and decode them.
This is what the standard (ISO/IEC 18004) says
C # implements using System;using System.Drawing;using System.Text;using ThoughtWorks.QRCode.Codec;namespace ConsoleTest {public class Test {# region to generate QR code / private static string QRCode () {System.Drawing.Bitmap bt String enCodeString = "http://www.baidu.com"; QRCodeEncoder qrCodeEncoder = new QRCodeEncoder (); qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;// encoding method (Note: BYTE can support Chinese, ALPHA_NUMERIC scans are all digits) qrCodeEncoder.QRCodeScale = 4 qrCodeEncoder.QRCodeVersion / size (the higher the value, the higher the pixel of the image generated by the QR code). / / version (Note: set to 0 is mainly to prevent errors when the encoded string is too long) qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;// error validation, error correction (there are 4 levels) qrCodeEncoder.QRCodeBackgroundColor = Color.Yellow;// background color qrCodeEncoder.QRCodeForegroundColor = Color.Green;// foreground color bt = qrCodeEncoder.Encode (enCodeString, Encoding.UTF8) String filename = "code"; string file_path = AppDomain.CurrentDomain.BaseDirectory + "QRCode\\"; string codeUrl = file_path + filename + ".jpg"; / / based on the file name, automatically establish the corresponding directory if (! System.IO.Directory.Exists (file_path)) System.IO.Directory.CreateDirectory (file_path) Bt.Save (codeUrl); / / Save picture return codeUrl;} # endregion}} at this point, the study on "how to generate a QR code picture from a web address in C#" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 275
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.