/// <summary> /// 生成二维码,保存成图片 /// </summary> static void Generate1(string text) { BarcodeWriter writer = new BarcodeWriter(); writer.Format = BarcodeFormat.QR_CODE; QrCodeEncodingOptions options = new QrCodeEncodingOptions(); options.DisableECI = true; //设置内容编码 options.CharacterSet = "UTF-8"; //设置二维码的宽度和高度 options.Width = 500; options.Height = 500; //设置二维码的边距,单位不是固定像素 options.Margin = 1; writer.Options = options; Bitmap map = writer.Write(text); string filename = @"H:桌面截图generate1.png"; map.Save(filename, ImageFormat.Png); map.Dispose(); }