安装 NuGet 包 TECIT.TBarCode。这个简短的 C# 示例选择 QR Code、设置数据并保存 PNG,使用 Windows 绘图 API。
using System.Drawing;
using TECIT.TBarCode;
var barcode = new Barcode {
BarcodeType = BarcodeType.QRCode,
Data = "https://www.tec-it.com", Dpi = 300
};
var size = barcode.CalculateOptimalBitmapSize(null, 6, 6);
barcode.BoundingRectangle = new Rectangle(Point.Empty, size);
barcode.Draw("barcode.png", ImageType.Png);