DecodeBufferRect Method

Decodes barcode from a device-independent bitmap (DIB) in buffer by only searching a certain part of the image defined by the parameters top, left, width, height.

Syntax

int DecodeBufferRect(
    unsigned char* pDIBBuffer,
    int iDIBSize,
    int iRectLeft,
    int iRectTop,
    int iRectWidth,
    int iRectHeight
);

Parameters

pDIBBuffer
A buffer data pointer to a DIB.
iDIBSize
An integer that defines the size of buffer data.
iRectLeft
An integer value that defines the left margin coordinate of scanning zone.
iRectTop
An integer value that defines the top margin coordinate of scanning zone.
iRectWidth
An integer that defines the width of scanning zone.
iRectHeight
An integer that defines the height scanning zone.

Return Value

Zero if the function completed successfully; otherwise nonzero.

Remarks

The DecodeBufferRect member method reads an image from DIB buffer by specifying an area, and extract the barcode data.

Example

CBarcodeReader reader;

int iErrorCode = reader.InitLicense("88FFAA09C42D5DE******");

ReaderOptions options;
options.iMaxBarcodeNumPerPage = 1;
options.llBarcodeFormats = (OneD | QR_CODE | PDF417 | DATAMATRIX);

reader.SetReaderOptions(options);
iErrorCode = reader.DecodeBufferRect(pDIBBuffer, iDIBSize, 0, 0, 100, 100);
if(iErrorCode != DBR_OK)
	return;

pBarcodeResultArray pResults = NULL;
reader.GetBarcodes(&pResults);
int iCount = pResults->iBarcodeCount;
for(int i = 0; i < iCount; ++i)
{
	printf("%d: %s\n", i, pResults->ppBarcodes[i]->pBarcodeData);
}

See Also

C++ > Structs > ReaderOptions
C++ > Structs > BarcodeResultArray
C++ > Class > CBarcodeReader > DecodeBuffer
C++ > Constant > BarcodeFormat
C++ > Constant > Error List