Generate Barcode Using Spire.Barcode Library

Background

I surfed the internet one day and found a barcode library. The description of the library says it can scan an image for barcodes. I was interested in it. I wanted to know whether the library is useful or not. So I used its method to scan some images to evaluate the library. It turns out that it is OK.

So I introduce this barcode library to you. You can download it here (Download Spire.Barcode).

Introduction

The library provides a method called Scan to read barcode images. It is an overloaded method. In this part, I list the definitions of the methods. Those methods will be used in the code to test the performance of the library.

publicstaticstring [] Scan (Bitmap bitmap);

Scan a specified image for all the supported barcodes.

bitmap: The image to scan

publicstaticstring[] Scan(Bitmap image, BarCodeType barcodeType);

Scan a specified image for specified type of barcode.

  • bitmap: The image to scan
  • barcodeType: The type of barcode to detect

publicstaticstring[] Scan(Bitmap bitmap, Rectangle rect, BarCodeType barcodeType);

Scan a specified portion of the image for specified type of barcode.

  • bitmap: The image to scan
  • rect: Specify the portion of Bitmap to scan
  • barcodeType: Specify the type of barcode to detect
Sample Code

In order to evaluate the method Scan, I made an image barcode.jpg. And there are three elements in the image: three QR Code barcodes, two Codabar barcodes and one POSTNET barcode. Scan the image with different parameters, we should get different outcomes.

barcode
Here is the result:

Code snippet

datas = BarcodeScanner.Scan(bitmap);

Outcome

TestOne

Code snippet

datas = BarcodeScanner.Scan(bitmap, BarCodeType.Codabar);

Outcome

TestTwo 

Code snippet

datas = BarcodeScanner.Scan(bitmap, newRectangle(0, 0, bitmap.Width, bitmap.Height / 2), BarCodeType.QRCode);

Outcome

TestThree 

Conclusion

You may try it yourself. I hope this barcode library can do you some help.

Up Next
    Ebook Download
    View all
    Learn
    View all