This simple question bothered me for nearly two hours, the main is the official document did not find the demo, that can only use search engines, see other programmers to write the program, but found everywhere is a pit, see four or five examples, no one can be normal operation, all the error, after one hours of trial, only to finish. Not much to say, directly on the screenshot and code.
First, add the Zxing.dll reference to the project (zxing.dll download address http://www.jb51.net/dll/zxing.dll.html)
The second is to create an ASPX file, in the background the code is as follows
Copy Code code as follows:
Using Zxing.common;
Using Zxing;
Using Zxing.rendering;
Using System.Drawing;
Using System.Drawing.Imaging;
Using ZXing.QrCode.Internal;
Namespace Zxingtm
{
public partial class Txm:System.Web.UI.Page
{
protected void Page_Load (object sender, EventArgs e)
{
Multiformatwriter mutiwriter = new Multiformatwriter ();
Bitmatrix BM = Mutiwriter.encode ("123456789", barcodeformat.code_39, 363, 150);
Bitmap img = new Barcodewriter (). Write (BM);
Img. Save ("D:/1.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
}
In the code "123456789" in the test I was written dead, use the time can be replaced with a variable. barcodeformat.code_39 and other parameters can be replaced by other, to generate other formats of the barcode
In this case, the output of the 1.JEPG barcode picture in D disk, where the main function has been achieved, the resulting barcode picture is as follows:
With the mobile phone with the scanning barcode function swept down, the result is 123456789