public void ScanCodabarFromFile(string filename) { // C# class code for reading Codabar from image string. Only this barcode type will be decoded. BarcodeResult[] results = BarCodeScanner.Scan(filename, BarCodeType.Codabar); // Choose to read Codabar and other barcode types from images in Bitmap and Stream forms. // public static BarcodeResult[] Scan(Bitmap bitmap, BarCodeType barType); // public static BarcodeResult[] Scan(Stream stream, BarCodeType barType); foreach (BarcodeResult result in results) { Console.WriteLine(result.BarType.ToString() + "-" + result.Data); } }
We also provide the method to improve the accuracy of barcode scanning. If your image source has only one Codabar barcode, you can directly use the following C# sample code for more accurate barcode recognition.
Bitmap bmp = new Bitmap("YourImagePath"); BarcodeResult barcode = BarCodeScanner.ScanSingle(bmp); Console.WriteLine("barcode data:{0}.", barcode.Data);
In the above code, three APIs are provided which enable C# programmers to read and decode Codabar from image file in string, stream and bitmap values. As you see, Codabar is the only barcode type that will be decoded by our Barcode Reader DLL for .NET. More related barcode recognition tutorials can be found here: Online Barcode Recognition Tutorial for .NET.