-2

Iam trying to make IDs reader using C# Winforms application with ZXing.net library.

I found a simple example like this one but it didn't works well both results are always null

Iam trying to figure out what is the proplem !!!

IBarcodeReader reader = new BarcodeReader();
reader.Options.PossibleFormats = new List<BarcodeFormat>();
reader.Options.PossibleFormats.Add(BarcodeFormat.PDF_417);
reader.Options.PossibleFormats.Add(BarcodeFormat.RSS_14);
reader.Options.TryHarder = true;

var barcodeBitmap = (Bitmap)Image.FromFile("d:\\5.png");
var res1 = reader.Decode(barcodeBitmap);
var res2 = reader.DecodeMultiple(barcodeBitmap);

any help !

msh
  • 15
  • 7

1 Answers1

0

When the result is null, it means that the image couldn't be decoded to any of the PossibleFormats. If you're not sure about the format of the barcode/QR code, you can simply remove all the expected format in order to let it accept any format:

IBarcodeReader reader = new BarcodeReader();

using (var barcodeBitmap = (Bitmap)Image.FromFile(@"d:\5.png"))
{
    var result = reader.Decode(barcodeBitmap);
    if (result != null)
    {
        Console.WriteLine(result.Text);
        // You can also use the following to determine the Barcode format.
        Console.WriteLine(result.BarcodeFormat.ToString());
    }
}