Refactor QRCodeHelper

This commit is contained in:
2dust
2024-08-28 10:20:37 +08:00
parent 54c16cad7d
commit 6721d150e0
4 changed files with 39 additions and 10 deletions

View File

@@ -0,0 +1,15 @@
using QRCoder;
namespace ServiceLib.Common
{
public class QRCodeHelper
{
public static byte[]? GenQRCode(string? url)
{
using QRCodeGenerator qrGenerator = new();
using QRCodeData qrCodeData = qrGenerator.CreateQrCode(url ?? string.Empty, QRCodeGenerator.ECCLevel.Q);
using PngByteQRCode qrCode = new(qrCodeData);
return qrCode.GetGraphic(20);
}
}
}