#include "ltbar.h"
L_LTBAR_API L_INT L_BarCodeGetNextDuplicated(pBarCodeData, nCurIndex)
pBARCODEDATA pBarCodeData; |
pointer to the BARCODEDATA structures |
L_INT nCurIndex; |
current barcode index |
Returns the index of the next barcode in the array that is a duplicate of the barcode at index nCurIndex.
Parameter |
Description |
pBarCodeData | Pointer to an array of BARCODEDATA structures that contain barcode information for a bitmap. This parameter is the same array returned by L_BarCodeRead. |
nCurIndex | Index of the current duplicated barcode. The value returned by L_BarCodeGetNextDuplicated will be greater than this value. This index is zero based. |
>=0 | An index of duplicated barcode. |
< 0 | An error occurred. Refer to Return Codes. |
LEADTOOLS provides a number of functions to let you work with duplicated barcodes. They let you:
To determine whether a barcode is duplicated, use the L_BarCodeIsDuplicated function. If a barcode is duplicated, L_BarCodeGetDuplicated will return the index of the first barcode in the array after the specified barcode, which is a duplicate of the specified barcode.
If you know the index of a barcode within an array, you can get the index of the first duplicate of the specified barcode using L_BarCodeGetFirstDuplicated. Use the L_BarCodeGetNextDuplicated to get the next instance of a duplicated barcode.
Although no function is included to tell you the number of different sets of barcodes that are duplicated, you can easily program this by using the following code:
L_INT i, j, nCount;
L_BOOL * pbVisited = (L_BOOL *)malloc(pBarCodeData->nTotalCount*sizeof(L_BOOL));
memset(pbVisited, 0, pBarCodeData->nTotalCount*sizeof(L_BOOL));
nCount = 0;
for (i=0; i<pBarCodeData->nTotalCount; i++)
{
if(pbVisited[i])
continue;
pbVisited[i] = TRUE;
nCount++;
j = i;
while(pBarCodeData[j].nIndexDuplicate != -1)
{
j = pBarCodeData[j].nIndexDuplicate;
pbVisited[j] = TRUE;
}
}
free(pbVisited);
After this code is executed, nCount will contain the number of different sets of barcodes.
As an example, suppose a call to L_BarCodeRead reads ten barcodes into a BARCODEDATA array. When L_BarCodeIsDuplicated is called for the item at index 3 in the array, TRUE is returned. Therefore one or more barcodes in the array are duplicates of the specified item.
Calling L_BarCodeGetFirstDuplicated returns the index of the first barcode in the array that is a duplicate of the barcode at index 3 in the array. Suppose this value is 0. The barcode present at index three in the array is the first duplicate of the barcode at index 3.
Calling L_BarCodeGetNextDuplicated with nCurIndex set to 3 will return the index of the next barcode in the array that is a duplicate of the barcodes at index 0 and 3. Suppose this value is 9. Therefore the barcodes at index 0, index 3, and index 9 of the array are all duplicates.
Required DLLs and Libraries
LTBAR For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
Win32, x64, Linux.
For an example, refer to L_BarCodeGetDuplicated.