标签:sharp html csharp static enc 技术分享 sla write 获取
先获取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; }
标签:sharp html csharp static enc 技术分享 sla write 获取
原文地址:http://www.cnblogs.com/IWings/p/7274989.html