解析二维码

       public string Recognize(Bitmap image)
        {
            string text = string.Empty;
            var barcodeReader = new BarcodeReader();
            var options = new DecodingOptions();
            options.PureBarcode = false;
            options.TryHarder = true;
            options.PossibleFormats = new List<BarcodeFormat>() { BarcodeFormat.QR_CODE };
            barcodeReader.AutoRotate = true;
            barcodeReader.Options = options;
            //barcodeReader.TryInverted = true;
            var res = barcodeReader.Decode(image);
            if (res == null) return text;
            text = res.Text;
            return text;
        }

 

posted @ 2017-04-13 16:28  雪?  阅读(449)  评论(0编辑  收藏  举报