using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Linq; using System.Text; //using Spire.Barcode; using ThoughtWorks.QRCode.Codec; namespace EMIS.Utility { public class QRCodeHelper { public static Image GenerateQRCode(string code) { QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(); qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE; qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M; qrCodeEncoder.QRCodeVersion = 0; qrCodeEncoder.QRCodeScale = 4; //将字符串生成二维码图片 Bitmap image = qrCodeEncoder.Encode(code, Encoding.Default); return image; ////保存为PNG到内存流 //MemoryStream ms = new MemoryStream(); //image.Save(ms, ImageFormat.Png); //BarcodeSettings barsetting = new BarcodeSettings(); ////set the x dimension //barsetting.X = 0.8f; //barsetting.Unit = GraphicsUnit.Millimeter; //barsetting.HasBorder = true; //barsetting.BorderWidth = 0.5F; ////set the data //barsetting.Data = code; //barsetting.Data2D = code; //barsetting.QRCodeECL = QRCodeECL.H; //barsetting.ShowText = false; //barsetting.ShowTopText = false; //barsetting.ShowCheckSumChar = false; //barsetting.ShowTextOnBottom = false; ////generate UPCA barcode //barsetting.Type = BarCodeType.QRCode; //BarCodeGenerator bargenerator = new BarCodeGenerator(barsetting); //Image barcodeimage = bargenerator.GenerateImage(); //return barcodeimage; } } }