/// <summary> /// /// </summary> /// <param name="url">存储内容</param> /// <param name="pixel">像素大小</param> /// <returns></returns> public Bitmap GetQRCodeB(string url, int pixel, bool hasLogo = false) { QRCodeGenerator generator = new QRCodeGenerator(); QRCodeData codeData = generator.CreateQrCode(url, QRCodeGenerator.ECCLevel.M, true); QRCode qrcode = new QRCode(codeData); Bitmap qrImage = qrcode.GetGraphic(pixel); if (hasLogo) { System.IO.MemoryStream MStream = new System.IO.MemoryStream(); qrImage.Save(MStream, ImageFormat.Png); System.IO.MemoryStream MStream1 = new System.IO.MemoryStream(); var logoPath = _host.WebRootPath + "/images/yh_logo_36.png"; // Path.Combine(AppContext.BaseDirectory, "images/yh_logo.png"); var resultImg = QRCodeHelper.CombinImage(qrImage, logoPath); Bitmap codeImg = new Bitmap(resultImg); return(codeImg); } else { return(qrImage); } }