LBarCode::WriteExt

#include "ltwrappr.h"

L_INT LBarCode::WriteExt (pBarCodeData, ulFlags = 0, pBarColor = NULL, pBarCode1D = NULL, pBarCodePDF = NULL, pBarCodeDM = NULL, lprcSize = NULL)

pBARCODEDATA pBarCodeData;

/* pointer to a BARCODEDATA structure */

L_UINT32 ulFlags;

/* flags that determine the function behavior */

pBARCODECOLOR pBarColor;

/* pointer to the BARCODECOLOR structure */

pBARCODE1D pBarCode1D;

/* pointer to a BARCODE1D structure */

pBARCODEWRITEPDF pBarCodePDF;

/* pointer to the BARCODEWRITEPDF structure */

pBARCODEWRITEDM pBarCodeDM;

/* pointer to a BARCODEWRITEDM structure */

LPRECT lprcSize;

/* pointer to a RECT structure to be updated */

Writes a linear, PDF or Data Matrix barcode over the bitmap.

Parameter

Description

pBarCodeData

Pointer to a BARCODEDATA structure that contains the barcode information to be written over the image.

pBarColor

Pointer to the BARCODECOLOR structure. Pass NULL to search for barcode using the default colors.

ulFlags

Flags that determine 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 PDF4167 symbol version.

BARCODE_MSGAPPEND

[0x0020] Write the barcode symbol in group mode. Used for PDF.

BARCODE_INITREADER

[0x0040] Write the reader initialization flags for Data Matrix & PDF.

BARCODE_DISABLE_COMPRESSOPN

[0x0100] Write a Data Matrix symbol without compression.

BARCODE_COLROWASLIMITS

[0x0080] Use column and row values as limits when a PDF 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 barcode with a transparent background. This is not recommended.

BARCODE_JUSTIFYRIGHT

[0x0010] Justify the linear barcode symbol to the right side of the window described by BARCODEDATA.rcBarLocation

BARCODE_JUSTIFYHCENTER

[0x0020] Justify the linear barcode symbol to the horizontal center of the window described by BARCODEDATA.rcBarLocation

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 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.

lprcSize

Pointer to a Windows 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 just write the barcode.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

The LBarCode::WriteExt function will write a linear, PDF or Data Matrix barcode symbol over the bitmap using the rectangle defined by the rcBarLocation member in pBarCodeData. 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.

When the BARCODE_USECOLORS flag is set, 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 are used.

Using colors does not apply for 1 bit per pixel images.

The BARCODE_USECOLORS and BARCODE_TRANSPARENT are used with all barcode types.

Note:

This function does not support BARCODE_1D_UCCEAN_128.

The Linear barcodes are not supported in UNICODE.

To write QR barcodes, use LBarCode::WriteExt2.

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:

LBarCode::LBarCode, LBarCode::Read, LBarCode::WriteExt2, Class Members

Topics:

Programming with LEADTOOLS Barcode

Barcode Function Functions: Writing BarCodes

Example

For complete sample code, refer to the BarCode demo.

L_VOID TestBarCodeWrite(LBitmapBase L_FAR *pLeadBitmap)
{
   LBase::LoadLibraries(LT_ALL_LEADLIB);   //make sure all libraries are loaded

   LBarCode MyBarCode(pLeadBitmap);

   if (MyBarCode.IsValid())
   {
      BARCODEDATA BarCodeData;
      BARCODE1D   Bar1D;
      BARCODECOLOR BarColor;

      memset(&BarCodeData, 0, sizeof(BARCODEDATA));
      memset(&Bar1D, 0, sizeof(BARCODE1D));
      memset(&BarColor, 0, sizeof(BARCODECOLOR));
      BarCodeData.uStructSize = sizeof(BARCODEDATA);
      Bar1D.uStructSize = sizeof(BARCODE1D);
      BarColor.uStructSize = sizeof(BARCODECOLOR);

      BarCodeData.rcBarLocation.left = 50; // 1/2 inch
      BarCodeData.rcBarLocation.top = 50; // 1/2 inch
      BarCodeData.rcBarLocation.right = 200; // 2.0 inch (width = 1.5 inch)
      BarCodeData.rcBarLocation.bottom = 100; // 1 inch (height = ½ inch)
      BarCodeData.nUnits = BARCODE_SCANLINES_PER_PIXELS;
      BarCodeData.ulType = BARCODE_1D_EAN_13;
      BarCodeData.pszBarCodeData = "123456789012";   
      BarCodeData.nSizeofBarCodeData = strlen(BarCodeData.pszBarCodeData);

      Bar1D.bErrorCheck = TRUE;
      Bar1D.bOutShowText= TRUE;

      BarColor.dwColorBar = RGB(0, 0, 255);

      BarColor.dwColorSpace = RGB(255, 0, 0);

      MyBarCode.WriteExt(&BarCodeData, BARCODE_USECOLORS, &BarColor, &Bar1D, NULL, NULL, NULL);
   }
}