In all, there are nine APIs are simple to be implemented in C# and VB.NET EAN-8 decoding applications, which enables programmers to not only recognize all barcode types from loaded image file but also choose to read EAN-8 barcode symbology only. Please see detailed APIs and sample coding in the following parts.
C# Demo: Tell Scanner to Scan EAN-8 Only
This Visual C# programming demo is used to direct our barcode decoder library to only read all EAN-8 barcodes from loaded image source. You may also see another two APIs for recognizing EAN-8 from images in Bitmap and Stream values.
public void ScanEAN8FromFile(string filename) { // Detect and read EAN-8 only in C#.NET program. BarcodeResult[] results = BarCodeScanner.Scan(filename, BarCodeType.EAN8); // Used to detect and read EAN-8 from image source in Bitmap or Stream value. // 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); } }
Moreover, we provide the way to improve the accuracy of barcode reading. If your image has only one EAN-8 barcode, please try the following C# sample code.
Bitmap bmp = new Bitmap("YourImagePath"); BarcodeResult barcode = BarCodeScanner.ScanSingle(bmp); Console.WriteLine("barcode data:{0}.", barcode.Data);
VB.NET Demo: Tell Scanner to Decode All Barcode Types
The following .NET APIs and VB.NET class code are designed for reading all barcode types including EAN-8 linear barcode from image file in Visual Basic .NET application.
Public Sub ScanAllFromFile(ByVal filename As String) ' Detect and scan all barcode types from a local image file. Dim results() As BarcodeResult = BarCodeScanner.Scan(filename) ' Used to detect and scan all barcode types from a loaded image in Bitmap or Stream value. ' public static BarcodeResult[] Scan(Bitmap bitmap) ' public static BarcodeResult[] Scan(Stream stream) Dim result As BarcodeResult For Each result In results Console.WriteLine(result.BarType.ToString() + "-" + result.Data) Next End Sub
To read only one EAN-8 barcode from your image in VB.NET project, you can use the following sample code. It helps to improve barcode recognition accuracy.
Dim bmp As Bitmap = New Bitmap("YourImagePath") Dim barcode As BarcodeResult = BarCodeScanner.ScanSingle(bmp) Console.WriteLine("barcode data:{0}.", barcode.Data)
Besides EAN-8 linear bar code, our Barcode Reader Component for .NET also supports other bar codes recognition in Visual Studio C# and VB.NET programs, like EAN-13, Codabar, Code 39, Code 128, UPC-A, UPC-E, ITF-14, QR Code, etc. If you have requests or questions, please contact us via email (support@pqscan.com).