ARTICLE

Barcode Scanner in C#

Posted by Krishna Garad Articles | .NET 4.5 August 27, 2011
In this article we will discuss about barcode scanner in C#.
Reader Level:
Download Files:
 

Introduction:

In last article we discuss about generating barcode images. In this article we will discuss about to reading those barcode images from C#. For generating barcode Images we used this SDK provided by OnBarcode.com. For reading those barcodei mages or scannig 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 developer need to generate the barcode images and scan those barcode images. You can check how to generating barcode images and scannig those barcode images from our C# application. We will see how to perform the scannig 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.

private String[] ReadBarcodeFromFile(string _Filepath)
        {
           String[] barcodes = BarcodeScanner.Scan(_Filepath, BarcodeType.Code39);
           return barcodes;
        }

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.

private String[] ReadBarcodeFromBitmap(Bitmap _bimapimage)
        {
            System.Drawing.Bitmap objImage = _bimapimage;
            String[] barcodes = BarcodeScanner.Scan(objImage, BarcodeType.Code39);
            return barcodes;
        }

You can call this method by passing barcode image as bitmap.

Conclusion:

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

Login to add your contents and source code to this article
post comment
     

Hi Sir , it is not compatible for windows phone 8 , please kindly help me...

Posted by lavanya geetha Dec 17, 2012

Hi Sir , ReadBarcodeFromFile(string _Filepath)I pass Image url to _filpath like this "~/upload/image/1.gif" and readbarcode return null. plz tell me how to pass image in order to get scan

Posted by mb mb Jun 07, 2012

you can try this one may work for windows phone http://www.codeproject.com/Articles/42852/Reading-Barcodes-from-an-Image-III

Posted by Krishna Garad May 09, 2012

Hi Sir The dLL Onbarcode.Barcode.BarcodeScanner is applicable to only desktop Applications.but I am developing windows phone 7 Application.so if i add reference it shows only windows phone 7 assemblies can add.can u help me. I am waiting for your Assemblies.

Posted by Arun Kumar GK May 08, 2012
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts