Reading barcode from image stream in C# application is an easy work. C# developers can implement fast UPC-A bar code recognition from image string with the help of following APIs. By defining a file path, image source can be quickly loaded and UPC-A barcodes on it will be scanned and decoded within seconds.
public static BarcodeResult[] Scan(string filename); public static BarcodeResult[] Scan(string filename, BarCodeType barType);
The first API is for all barcodes reading and the second one is used to decode UPC-A from loaded image only. And here, we give you a C# sample code for implementing UPC-A barcode scanning. APIs for reading UPC-A from stream or bitmap of image are also illustrated.
public void ScanUPCAFromFile(string filename) { // Recognize UPC-A from image file in C# application. BarcodeResult[] results = BarCodeScanner.Scan(filename, BarCodeType.UPCA); // Recognize UPC-A from Bitmap or Stream of image in C# application. // 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); } }