0

I'm trying to use zxing.net in a test project, this is my code:

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;
        }
    }

This return always null... why? ean.png is the following: ean13 sample

Thank you very much.

S.P.
  • 45
  • 2
  • 7

1 Answers1

0

You have to provide a quiet zone at the left and right of the barcode. A seven pixel wide white area at the right side should be enough.

Michael
  • 2,361
  • 1
  • 15
  • 15