GdPicture.NET.14
GdPicture14 Namespace / GdPictureImaging Class / Barcode1DReaderGetBarcodeCount Method
Example





In This Topic
Barcode1DReaderGetBarcodeCount Method (GdPictureImaging)
In This Topic
Returns the number of barcode detected by the Barcode1DReaderDoScan method.
Syntax
'Declaration
 
Public Function Barcode1DReaderGetBarcodeCount() As Integer
public int Barcode1DReaderGetBarcodeCount()
public function Barcode1DReaderGetBarcodeCount(): Integer; 
public function Barcode1DReaderGetBarcodeCount() : int;
public: int Barcode1DReaderGetBarcodeCount(); 
public:
int Barcode1DReaderGetBarcodeCount(); 

Return Value

The number of barcode detected.
Remarks

This method is used in the "Barcode Recognition" Demo.

Example
Finding all 1D barcodes in a given image and saving their information to a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
 
    // Specify 1D barcode search types to be Code39 and Code128.
    Barcode1DReaderType barcodeType = Barcode1DReaderType.Barcode1DReaderCode39 | Barcode1DReaderType.Barcode1DReaderCode128;
 
    // Start the barcode scanning process. The ExpectedCount parameter is 0, all the barcodes should be retrieved.
    gdpictureImaging.Barcode1DReaderDoScan(imageID, Barcode1DReaderScanMode.BestQuality, barcodeType, false, 0);
 
    using (System.IO.StreamWriter file = new System.IO.StreamWriter("barcodes.txt"))
    {
        int barcodesFound = gdpictureImaging.Barcode1DReaderGetBarcodeCount();
        for (int i = 1; i <= barcodesFound; i++)
        {
            file.WriteLine(gdpictureImaging.Barcode1DReaderGetBarcodeValue(i));
        }
    }
 
    // Release used resources.
    gdpictureImaging.Barcode1DReaderClear();
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also