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.
public static string[] Scan(Bitmap bitmap);
Scan a specified image for all the supported barcodes.
bitmap: The image to scan
public static string[] Scan(Bitmap image, BarCodeType barcodeType);
Scan a specified image for a specified type of barcode.
Scan a specified portion of the image for a specified type of barcode.
- bitmap: The image to scan
- rect: Specify the portion of Bitmap to scan
- barcode type: Specify the type of barcode to detect
Sample Code
In order to evaluate the method Scan, I made an image barcode.jpg. 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.
Here is the result.
Code snippet
datas = BarcodeScanner.Scan(bitmap);
Outcome
Code snippet
datas = BarcodeScanner.Scan(bitmap, BarCodeType.Codabar);
Outcome
Code snippet
datas = BarcodeScanner.Scan(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height / 2), BarCodeType.QRCode);
Outcome
Conclusion
You may try it yourself. I hope this barcode library can do you some help.