zxing asp.net 4.0 BarcodeReader

时间:2018-04-23 04:12:22

标签: zxing.net

我正在尝试在测试项目中使用zxing.net,这是我的代码:

protected void Button1_Click(object sender, EventArgs e)
    {
        if (Page.IsPostBack)
        {
            Bitmap bitmap = new Bitmap(Server.MapPath(Image1.ImageUrl));
            BarcodeReader reader = new BarcodeReader
            {
                AutoRotate = true,
                TryInverted = true,
                Options = new ZXing.Common.DecodingOptions
                {
                    TryHarder = true,
                    PossibleFormats = new List<BarcodeFormat>
                   {
                      BarcodeFormat.EAN_13
                      //BarcodeFormat.QR_CODE
                   }
                }
            };
            Result result = reader.Decode(bitmap);
            string decoded = "???";
            if (result != null)
            {
                decoded = result.ToString().Trim();
            }
            this.TextBox1.Text = decoded;
        }
    }

此返回始终为null ...为什么? ean.png如下: ean13 sample

非常感谢。

1 个答案:

答案 0 :(得分:0)

您必须在条形码的左侧和右侧提供一个安静的区域。 右侧七像素宽的白色区域就足够了。

相关问题