L_BarCodeWrite
#include "ltbar.h"
L_LTBAR_API L_INT L_BarCodeWrite(pBitmap, pBarCodeData, pBarCodeColor, ulFlags, pBarCode1D, pBarCodePDF, pBarCodeDM, pBarCodeQR, lprcSize)
pBITMAPHANDLE pBitmap; |
/* pointer to the bitmap handle */ |
pBARCODEDATA pBarCodeData; |
/* pointer to the BARCODEDATA structure */ |
pBARCODECOLOR pBarCodeColor; |
/* pointer to the BARCODECOLOR structure */ |
L_UINT32 ulFlags; |
/* flags that indicate the function behavior */ |
pBARCODE1D pBarCode1D; |
/* pointer to the BARCODE1D structure */ |
pBARCODEWRITEPDF pBarCodePDF; |
/* pointer to the BARCODEWRITEPDF structure */ |
pBARCODEWRITEDM pBarCodeDM; |
/* pointer to the BARCODEWRITEDM structure */ |
pBARCODEWRITEQR pBarCodeQR; |
/* pointer to the BARCODEWRITEQR structure */ |
LPRECT lprcSize; |
/* pointer to the RECT structure to be updated */ |
Writes linear, PDF417, MicroPDF417, Data Matrix, and QR barcode symbols over the bitmap.
Parameter |
Description |
|
pBitmap |
Pointer to the bitmap handle referencing the bitmap on which the barcode will be written. |
|
pBarCodeData |
Pointer to a BARCODEDATA structure that contains the barcode information to be written over the image. |
|
pBarCodeColor |
Pointer to the BARCODECOLOR structure that contains the color information to be written over the image. Pass NULL to write barcode using the default colors. |
|
ulFlags |
Flags that indicate the function behavior. You can combine values when appropriate, by using a bitwise OR ( | ). The following values are used only when you want to write Data Matrix or PDF barcodes. Pass 0 to use the default values, based on the type of barcode being written. Possible values are: |
|
|
Value |
Meaning |
|
BARCODE_TRUNCATE |
[0x0010] Write Truncated PDF417 symbols. |
|
BARCODE_MSGAPPEND |
[0x0020] Write the barcode symbol in the group mode. Used for PDF and MicroPDF. |
|
BARCODE_INITREADER |
[0x0040] Write the reader initialization flags for Data Matrix, PDF, and MicroPDF barcodes. |
|
BARCODE_DISABLE_COMPRESSOPN |
[0x0100] Write Data Matrix symbols without compression. |
|
BARCODE_COLROWASLIMITS |
[0x0080] Use column and row values as limits when a PDF or MicroPDF symbol is written. |
|
BARCODE_USECOLORS |
[0x0200] Write color barcode. The colors are used as the exact bar and space colors for searching for the barcode. |
|
BARCODE_TRANSPARENT |
[0x0400] Write barcodes with a transparent background. This is not recommended. |
|
BARCODE_JUSTIFYRIGHT |
[0x0010] Justify linear barcode symbols to the right side of the window described by BARCODEDATA.rcBarLocation. |
|
BARCODE_JUSTIFYHCENTER |
[0x0020] Justify linear barcode symbols to the horizontal center of the window described by BARCODEDATA.rcBarLocation. |
|
BARCODE_MICRO_PDF417_MODE128 |
[0x0200]If set, use the Function Code word for Code 128 emulation. Only used for MicroPDF417. |
|
BARCODE_MICRO_PDF417_LINKED |
[0x0400]If set, the MicroPDF417 barcode is linked to a linear symbol that is printed below it. Only used for MicroPDF417. |
pBarCode1D |
Pointer to the BARCODE1D structure that contains the information related to linear barcodes. Pass NULL to use the default or if you don't want to write a linear barcode. |
|
pBarCodePDF |
Pointer to the BARCODEWRITEPDF structure that contains the information related to PDF417 and MicroPDF417 barcodes. Pass NULL to use the default or if you don't want to write a PDF417 barcode. |
|
pBarCodeDM |
Pointer to the BARCODEWRITEDM structure that contains the information related to Data Matrix barcodes. Pass NULL to use the default or if you don't want to write a Data Matrix barcode. |
|
pBarCodeQR |
Pointer to the BARCODEWRITEQR structure that contains the information related to QR barcodes. Pass NULL to use the default or if you don't want to write a Data QR barcode. |
|
lprcSize |
Pointer to the RECT structure to be updated with the barcode size before writing the barcode over the bitmap. If the user passes a valid pointer, then the function will calculate the size of the barcode and will update this parameter with the barcode size. Pass NULL to write the barcode. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
The L_BarCodeWrite function writes linear, PDF, MicroPDF, QR and Data Matrix barcodes.
This function supports all bitmaps currently supported by LEADTOOLS.
You must pass an allocated bitmap to this function. If you do not pass an allocated bitmap, the function wil return an error code.
The L_BarCodeWrite function will write the barcode symbol over the bitmap using the rectangle defined by the rcBarLocation member in the BARCODEDATA structure. However, if the bitmap has a region, this function will write the barcode using the region boundaries.
If the region is non-rectangular, the barcode will be written to the rectangle bounding the region and subsequently clipped to the given region. This might cause the resulting barcode to be unreadable.
If you set the ulFlags parameter to BARCODE_USECOLORS, then this function will use the pBarCodeColor parameter, otherwise the function will ignore it and use the default colors of black for bars and white for spaces.
Using colors does not apply for 1 bit per pixel images.
The BARCODE_USECOLORS and BARCODE_TRANSPARENT are used with all barcode types.
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. |
See Also
Functions: |
L_BarCodeRead, L_BarCodeFree, L_BarCodeIsDuplicated, L_BarCodeGetDuplicated, L_BarCodeGetNextDuplicated, L_BarCodeVersionInfo, L_BarCodeGetFirstDuplicated |
Topics: |
Example
For complete sample code refer to: \Examples\API\Barcode. The related demo executable is: \Bin\API\Win32\Barcode_Original.exe.
L_INT BarCodeWriteExample(HWND hWnd, pBITMAPHANDLE pBitmap) { L_TCHAR szBuffer[256]; BARCODEDATA BarCodeData; BARCODECOLOR BarColor; BARCODE1D Bar1D; L_INT nRet; RECT rcBarSize; ZeroMemory(&szBuffer, sizeof(szBuffer)); ZeroMemory(&BarCodeData, sizeof(BARCODEDATA)); ZeroMemory(&Bar1D, sizeof(BARCODE1D)); BarColor.uStructSize = sizeof(BARCODECOLOR); BarColor.dwColorBar = RGB(0, 0, 255); BarColor.dwColorSpace = RGB(255, 0, 0); BarCodeData.uStructSize = sizeof(BarCodeData); BarCodeData.rcBarLocation.left = 50; BarCodeData.rcBarLocation.top = 50; BarCodeData.rcBarLocation.right = 250; BarCodeData.rcBarLocation.bottom = 100; BarCodeData.nUnits = BARCODE_SCANLINES_PER_PIXELS; BarCodeData.ulType = BARCODE_1D_EAN_13; BarCodeData.pszBarCodeData = "123456789012"; BarCodeData.nSizeofBarCodeData = (L_INT) strlen(BarCodeData.pszBarCodeData); Bar1D.uStructSize = sizeof(BARCODE1D); Bar1D.bErrorCheck = TRUE; Bar1D.bOutShowText= TRUE; nRet = L_BarCodeWrite(pBitmap, &BarCodeData, &BarColor, BARCODE_USECOLORS, &Bar1D, NULL, NULL, NULL, &rcBarSize); if (nRet == SUCCESS) { wsprintf(szBuffer, TEXT("A Barcode is written ...")); MessageBox(hWnd, szBuffer, TEXT("Notice!"), MB_OK); } else { wsprintf(szBuffer, TEXT("An error occurred in L_BarCodeWrite,\nError No. = %d\n"), nRet); MessageBox(hWnd, szBuffer, TEXT("Error!"), MB_OK); return nRet; } return SUCCESS; }