Herd Software Development
DaVinci Graphics Library
DaVinci Documentation
Scans a DIB for for bar codes.
BOOL API DIBDetectBarCode(
HDIB hDIB,
BARDETECTEDPROC fnProc,
LPARAM lParam,
LPSTR szBarCodeList,
UINT cchBarCodeList,
DWORD dwBarCodeTypes,
DWORD dwReserved);
hDIB HDIB Handle of the DIB to scan for barcode data.
fnProc BARDETECTPROC Application defined callback function to be called when a barcode is discovered, or NULL if no callback is usedif application uses no callback function, the bar code can into szBarCodeList back given be-
lParam LPARAM Application defined 32 bit value which is passed to the callback function when called.
szBarCodeList LPSTR Pointer to an array of characters to receive the barcodes found in the DIB. The codes are stored as a series of zero-terminated strings. The last string is terminated by an additional zero byte. The parameter can be set to NULL if fnProc is being used.
cchBarCodeList UINT Size of the szBarCodeList character array.
dwBarCodeTypes DWORD Specifies the types of barcodes to find. Valid values include:
BARCODE_TYPE_39 Addiction to 3-aus-9 bar codes
BARCODE_TYPE_25 It searches for interleaved bar codes after 2-aus-5
BARCODE_TYPE_EAN13 Searches for codes EAN 13
BARCODE_TYPE_EAN8 Searches for to bar codes EAN 8
BARCODE_TYPE_EAN5 Searches for EAN5 AddOn codes to EAN13 bar codes
BARCODE_TYPE_EAN2 Searches for EAN2 AddOn codes to EAN13 bar codes
BARCODE_DIR_HORZ Searches for barcodes in horizontal direction
BARCODE_DIR_VERT Searches for barcodes in vertical direction
BARCODE_ONCE It transfers every found code only once to the callback even if it was recognized repeatedly in different Rows/Columns of the DIB.
BARCODE_ALL Searches for all known bar code types in all directions.
))))))))))))))
The return value is TRUE if at least one barcode was found, otherwise it is FALSE.
BOOL CALLBACK BARDETECTEDPROC(
UINT uMsg,
int iCurrentPos,
LPCSTR pszBarCode,
DWORD dwBarCodeType,
LPARAM lParam,
DWORD dummy);
uMsg UINT It specifies the reason for the call of the callback function.
MSG_BARDETECT_PEEK: A line or column was processed; the application can use this to update progress indicators.
MSG_BARDETECT_FOUND: A barcode matching the specified type(s) was found. The pszBarCode parameter points to the decoded code.
iCurrentPos int Current x or y coordinate of the search.
pszBarCode LPCSTR Pointer to the found barcode.
dwBarCodeType DWORD Type of barcode recognized. More than one Flag of the BARCODE_xxxx list can be set combined with OR.
lParam LPARAM 32 bit application-defined value specified for passing to the callback.
dummies DWORD Reserved for future use. Applications should specify this value as 0.
The function always searches for barcodes both forward and downward i.e. when searching horizontally it seaches from left to right and from right to left.
EAN barcodes are only transferred to application if the standard checksum value is correct. In the case of 3-of-9 and 2-of-5 codes, a checksum is not defined, so applications will be responsible for checksum calculations on these barcode types.
While several barcodes can be recognized from a single bitmap, there must be sufficient whitespace between the barcodes for proper recognition. A good rule of thumb for whitespace is a proportionate whitespace margin around each barcode comparable to the whitespace around adhesive barcode stickers.
Duplicate barcodes in a single bitmap are ignored. But since the callback can be used to enumerate hits, a tally of identical barcodes can be made if needed. The function will not execute the callback if the BARCODE_ONCE flag is set, signalling the function not to perform any action when encountering a duplicate.
The scan is made from occurs from top to bottom and left to right. Recognized bar codes are transferred to the callback function and added to the character array in this order.
It may be necessary for the DIB to be "aligned" using RotateDIB or a similar function in order to perform an accurate scan.
Barcode recognition is a relatively slow process. If the application knows the approximate position of the bar code in advance, time can be saved by copying a section of the DIB to a new DIB and scanning the copied section rather than the whole image.
This function evaluates only the green components of the DIB when distinguishing bars from white fields.
Do not use dithered Bitmaps for barcode detection. Some scanners support a "Halftone" setting, it is not recommended for barcode detection. Using color DIBs in calls to DIBDetectBarCode does not slow down processing.
This function is provided only as a supplementary function in Leonardo. For more sophisticated barcode processing, BarVision offers considerably more power. (BarVision was available in German only at presstime; inquire to the publisher about English-language versions if required.)