22 lines
668 B
C#
22 lines
668 B
C#
using AMREZ.EOP.Abstractions.Applications.UseCases.Payments.SlipVerification.QrDecode;
|
|
using SkiaSharp;
|
|
using ZXing.SkiaSharp;
|
|
|
|
namespace AMREZ.EOP.Application.UseCases.Payments.SlipVerification.QrDecode;
|
|
|
|
public sealed class ZxingQrDecoder : IQrDecoder
|
|
{
|
|
public string? TryDecodeText(byte[] imageBytes)
|
|
{
|
|
using var bmp = SKBitmap.Decode(imageBytes);
|
|
if (bmp is null) return null;
|
|
|
|
var reader = new BarcodeReader
|
|
{
|
|
AutoRotate = true,
|
|
Options = { TryHarder = true, PossibleFormats = new[] { ZXing.BarcodeFormat.QR_CODE } }
|
|
};
|
|
var res = reader.Decode(bmp);
|
|
return res?.Text;
|
|
}
|
|
} |