Barcode Scanner in C#

Introduction

 
In the last article, we discussed about generating barcode images. In this article, we will discuss to reading those barcode images from C#. For generating barcode Images we used this SDK provided by OnBarcode.com. For reading those barcodes mages or scanning those barcode images OnBarcode.com provide the BarCodeReader SDK which is available here. You can download it and use it as usual.
 
Background:
 
In some cases, the developer needs to generate the barcode images and scan those barcode images. You can check how to generating barcode images and scanning those barcode images from our C# application. We will see how to perform the scanning task in this article step-by-step.
 
Step 1:
Download barcode reader dll from here and add the reference to Onbarcode.Barcode.BarcodeScanner to your application.
 
Step 2:
This BarcodeScanner dll contain so many methods to scan the barcode image and retrive the data present in those images. Write this two methods to scan the barcode images.
 
1)  ReadBarcodeFromFile:
This method is very simple method to scan the barcode image which will take the filenpath as argument where barcode image is present and retrive String[] as data.
  1. private String[] ReadBarcodeFromFile(string _Filepath) {  
  2.     String[] barcodes = BarcodeScanner.Scan(_Filepath, BarcodeType.Code39);  
  3.     return barcodes;  
  4. }  
2)  Read BarcodeFromBitmap:
This one other method is provided by BarcodeScanner dll which will take Bitmap image as input and returns same String[] as output.
  1. private String[] ReadBarcodeFromBitmap(Bitmap _bimapimage) {  
  2.     System.Drawing.Bitmap objImage = _bimapimage;  
  3.     String[] barcodes = BarcodeScanner.Scan(objImage, BarcodeType.Code39);  
  4.     return barcodes;  
  5. }  
You can call this method by passing barcode image as bitmap.
 

Conclusion

 
In this way, we can scan the barcode images using C#.