GdPicture.NET.14.API
GdPicture14 Namespace / GdPictureImaging Class / Barcode1DReaderDoScan Method / Barcode1DReaderDoScan(Int32,Barcode1DReaderScanMode,Barcode1DReaderType,Boolean,Int32,Boolean) Method
A unique image identifier of the GdPicture image representing the image in use.
A member of the Barcode1DReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
A member or a combination of members of the Barcode1DReaderType enumeration. Default value is Barcode1DReaderType.Barcode1DReaderNone meaning to search for all known barcode symbologies.
Specifies if the barcode scanner shall returns corrupted barcode. False by default. It is highly recommended to keep this option to False, otherwise invalid detected barcode can override valid barcode. Therefore, you should use it only in a second attempt when the first detection process did not detect any barcode.
Specifies the number of barcodes expected to be detected. Use 0 to find all available barcodes within an image.
If this is set to true and ExpectedCount > 0, the scanning process stops after first ExpectedCount barcodes were found.
Example





In This Topic
Barcode1DReaderDoScan(Int32,Barcode1DReaderScanMode,Barcode1DReaderType,Boolean,Int32,Boolean) Method
In This Topic
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the GdPictureImaging.SetROI method. This method allows you to set the scanning mode parameter as well as to specify the type of barcodes to be searched for. You can also define the required number of barcodes the engine should detect.
Syntax
'Declaration
 
Public Overloads Function Barcode1DReaderDoScan( _
   ByVal ImageID As Integer, _
   ByVal ScanMode As Barcode1DReaderScanMode, _
   ByVal BarcodeType As Barcode1DReaderType, _
   ByVal ReturnCorrupted As Boolean, _
   ByVal ExpectedCount As Integer, _
   ByVal StopOnExpectedCount As Boolean _
) As GdPictureStatus
public function Barcode1DReaderDoScan( 
    ImageID: Integer;
    ScanMode: Barcode1DReaderScanMode;
    BarcodeType: Barcode1DReaderType;
    ReturnCorrupted: Boolean;
    ExpectedCount: Integer;
    StopOnExpectedCount: Boolean
): GdPictureStatus; 
public function Barcode1DReaderDoScan( 
   ImageID : int,
   ScanMode : Barcode1DReaderScanMode,
   BarcodeType : Barcode1DReaderType,
   ReturnCorrupted : boolean,
   ExpectedCount : int,
   StopOnExpectedCount : boolean
) : GdPictureStatus;

Parameters

ImageID
A unique image identifier of the GdPicture image representing the image in use.
ScanMode
A member of the Barcode1DReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
BarcodeType
A member or a combination of members of the Barcode1DReaderType enumeration. Default value is Barcode1DReaderType.Barcode1DReaderNone meaning to search for all known barcode symbologies.
ReturnCorrupted
Specifies if the barcode scanner shall returns corrupted barcode. False by default. It is highly recommended to keep this option to False, otherwise invalid detected barcode can override valid barcode. Therefore, you should use it only in a second attempt when the first detection process did not detect any barcode.
ExpectedCount
Specifies the number of barcodes expected to be detected. Use 0 to find all available barcodes within an image.
StopOnExpectedCount
If this is set to true and ExpectedCount > 0, the scanning process stops after first ExpectedCount barcodes were found.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK. We strongly recommend always checking this status first.
Remarks
Be aware when reading Code128 symbology, if barcode checksum is missing or wrong, the barcode will be recognized as corrupted. To return the value nonetheless, please set ReturnCorrupted to true.

For more details, please refer to our Barcode Recognition Sample included in the installation folder that demonstrates the usage of this method.

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", false);
 
    // 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, false);
 
    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