ZXing.Net 解析二维码图片

netcore3.1 ZXing.Net 解析二维码图片

  1. nuget 添加 ZXing.Net.Bindings.SkiaSharp
  2. 使用
var txt = string.Empty;
string path = "xxx.jpg";
var stream = System.IO.File.Open(path, System.IO.FileMode.Open);
using (var skiaImage = SkiaSharp.SKBitmap.Decode(stream))
{
    var skiaReader = new ZXing.SkiaSharp.BarcodeReader();
    var skiaResult = skiaReader.Decode(skiaImage);
    txt = skiaResult?.Text ?? imgUrl;
}

参考:https://github.com/micjahn/ZXing.Net/blob/master/Clients/ASP.NetCoreDemo/Controllers/HomeController.cs

posted @ 2021-09-23 14:33  pizisu  阅读(268)  评论(0编辑  收藏  举报