.net core里用ZXing生成二维码
先获取Nuget包
static void Main(string[] args) { string content = "二维码信息"; BitMatrix byteMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, 300, 300); System.Drawing.Bitmap bitmap = toBitmap(byteMatrix); } public static System.Drawing.Bitmap toBitmap(BitMatrix matrix) { int width = matrix.Width; int height = matrix.Height; var white = System.Drawing.ColorTranslator.FromHtml("0xFFFFFFFF"); var black = System.Drawing.ColorTranslator.FromHtml("0xFF000000"); System.Drawing.Bitmap bmap = new System.Drawing.Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { bmap.SetPixel(x, y, matrix[x, y] ? black : white); } } return bmap; }