protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { var generator = new QRCodeNetAdapter(); var options = new Options(); options.ErrorCorrectionLevel = ErrorCorrectionLevel.L; options.ModuleSize = 5; options.Brush = System.Drawing.Brushes.GreenYellow; options.BackgroundBrush = System.Drawing.Brushes.White; var stream = generator.Generate(Request["content"], options) as MemoryStream; Response.ContentType = Options.DefaultImageFormatContentType; Response.OutputStream.Write(stream.GetBuffer(), 0, (int)stream.Length); } }
public static Stream Generate(string content, Options options = null) { if (string.IsNullOrEmpty(content)) { throw new ArgumentException("content值不能为空"); } if (options != null) { options.Validate(); } var generator = new QRCodeNetAdapter(); return(generator.Generate(content, options)); }