If you are a Visual C# or VB.NET programmer, this part will help you a lot. After adding reference to our .NET barcode scanner component in Visual Studio project, you can easily use robust APIs to implement fast Code 128 barcode detecting and scanning.
In details, you are able to load image file (Jpeg/Jpg, Tiff/Tif, Png, Bmp or Gif) in the forms of bitmap, local picture at pc and stream to your Visual Studio C# or VB.NET application. If the Code 128 1d bar code on loaded image source is rotated to 180 degree, it still can be recognized by our barcode reader DLL library for .NET. The following two examples illustrate how to use C# and VB.NET class codes to scan and read Code 128 barcode from an image source.
C# Examples: Detect and Read Code 128 on Image
public void ScanCode128FromFile(string filename) { // Set Code 128 as target barcode type and read from loaded image file. BarcodeResult[] results = BarCodeScanner.Scan(filename, BarCodeType.Code128); // Set Code 128 as target barcode type and read 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); } }
// Used to improve barcode reader accuracy when there's only one Code 128 on your image. Bitmap bmp = new Bitmap("YourImagePath"); BarcodeResult barcode = BarCodeScanner.ScanSingle(bmp); Console.WriteLine("barcode data:{0}.", barcode.Data);
VB Examples: Read All Barcodes & One Code 128 from Image
Public Sub ScanAllFromFile(ByVal filename As String) ' Read all barcode symbols from loaded image file. Dim results() As BarcodeResult = BarCodeScanner.Scan(filename) ' Read all barcode symbols from images in Bitmap and Stream forms. ' 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
' Used to improve barcode reader accuracy when there's only one Code 128 on your image. Dim bmp As Bitmap = New Bitmap("YourImagePath") Dim barcode As BarcodeResult = BarCodeScanner.ScanSingle(bmp) Console.WriteLine("barcode data:{0}.", barcode.Data)
To see related barcode detecting and reading tutorials, please go to .NET Barcode Reading Tutorial - Overview page. Besides .NET solution for C# & VB.NET Code 128 reading, we also provide .NET solution for C# & VB.NET Code 128 generation. Please click to see details.