QrCodeEncodingOptions options =
new
QrCodeEncodingOptions();
options.CharacterSet =
"UTF-8"
;
options.DisableECI =
true
;
options.ErrorCorrection = ZXing.QrCode.Internal.ErrorCorrectionLevel.H;
options.Width = 300;
options.Height = 300;
options.Margin = 1;
BarcodeWriter writer =
new
BarcodeWriter();
writer.Format = BarcodeFormat.QR_CODE;
writer.Options = options;
Response.Clear();
using
(Bitmap bmp = writer.Write(
"http://www.cftea.com"
)) // Write 具备生成、写入两个功能
{
MemoryStream ms =
new
MemoryStream();
{
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
Response.ContentType =
"image/png"
;
Response.BinaryWrite(ms.ToArray());
}
}
Response.End();
QrCodeEncodingOptions options =
new
QrCodeEncodingOptions();
options.CharacterSet =
"UTF-8"
;
options.Width = 300;
options.Height = 50;
options.Margin = 1;
options.PureBarcode =
false
;
BarcodeWriter writer =
new
BarcodeWriter();
writer.Format = BarcodeFormat.CODE_128;
writer.Options = options;
Response.Clear();
using
(Bitmap bmp = writer.Write(
"12345678"
))
{
MemoryStream ms =
new
MemoryStream();
{
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
Response.ContentType =
"image/png"
;
Response.BinaryWrite(ms.ToArray());
}
}
Response.End();
BarcodeReader reader =
new
BarcodeReader();
reader.Options.CharacterSet =
"UTF-8"
;
using
(Bitmap bmp =
new
Bitmap(
"D:\\qr.png"
))
{
Result result = reader.Decode(bmp);
Response.Write(result.Text);
}