Dev Center
Table of contents

Decode Methods

Method Description
DecodeFile Decode barcodes from a specified image file.
DecodeFileInMemory Decode barcodes from an image file in memory.
DecodeBuffer Decode barcodes from raw buffer.
DecodeBase64String Decode barcodes from a base64 encoded string.
DecodeDIB Decode barcode from a handle of device-independent bitmap (DIB).
InitIntermediateResult Inits an intermediateResult struct with default values.
DecodeIntermediateResults Decodes barcode from intermediate results.

DecodeFile

Decode barcodes from a specified image file.

int dynamsoft::dbr::CBarcodeReader::DecodeFile (const char* pFileName, const char* pTemplateName = "")	

Parameters
[in] pFileName A string defining the file name. It supports BMP, JPEG, PNG, TIFF and PDF files.
[in] pTemplateNameOptional The template name.

Return Value
Returns error code (returns 0 if the function operates successfully).
You can call GetErrorString to get detailed error message.

Code Snippet

char errorBuf[512];
dynamsoft::dbr::CBarcodeReader::InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
CBarcodeReader* reader = CBarcodeReader::GetInstance();
if(reader != NULL)
{
    int errorCode = reader->DecodeFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Images\\AllSupportedBarcodeTypes.tif", "");
    // add further process
    reader->Recycle();
}

Remarks
If no template name is specified, current runtime settings will be used. To get the actual text results, please refer to GetAllTextResults.

DecodeFileInMemory

Decode barcodes from an image file in memory.

int dynamsoft::dbr::CBarcodeReader::DecodeFileInMemory (const unsigned char* pFileBytes, int fileSize, const char* pTemplateName = "")	

Parameters
[in] pFileBytes The image file bytes in memory.
[in] fileSize The length of the file bytes in memory.
[in] pTemplateNameOptional The template name.

Return Value
Returns error code (returns 0 if the function operates successfully).
You can call GetErrorString() to get detailed error message.

Code Snippet

char errorBuf[512];
dynamsoft::dbr::CBarcodeReader::InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
CBarcodeReader* reader = CBarcodeReader::GetInstance();
if(reader != NULL)
{
	unsigned char* pFileBytes;
	int nFileSize = 0;
	GetFileStream("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Images\\AllSupportedBarcodeTypes.tif", &pFileBytes, &nFileSize);
	int errorCode = reader->DecodeFileInMemory(pFileBytes, nFileSize, "");
    // add further process
    reader->Recycle();
}

Remarks
If no template name is specified, current runtime settings will be used. To get the actual text results, please refer to GetAllTextResults.

DecodeBuffer

Decode barcodes from the memory buffer containing image pixels in defined format.

int dynamsoft::dbr::CBarcodeReader::DecodeBuffer (const unsigned char* pBufferBytes, const int iWidth, const int iHeight, const int iStride, const ImagePixelFormat format, const char* pszTemplateName = "")

int dynamsoft::dbr::CBarcodeReader::DecodeBuffer (const unsigned char* pBufferBytes, const int iWidth, const int iHeight, const int iStride, const ImagePixelFormat format, const int orientation, const char* pszTemplateName = "")

Parameters
[in] pBufferBytes The array of bytes which contain the image data.
[in] iWidth The width of the image in pixels.
[in] iHeight The height of the image in pixels.
[in] iStride The stride (or scan width) of the image.
[in] format The image pixel format used in the image byte array.
[in] orientation The orientation of the image data. The value is the angle that the image needs to be rotated clockwise so it shows correctly on the display in its natural orientation. It can be 0, 90, 180, or 270.
[in] pTemplateNameOptional The template name.

Return Value
Returns error code (returns 0 if the function operates successfully).
You can call GetErrorString to get detailed error message.

Code Snippet

char errorBuf[512];
dynamsoft::dbr::CBarcodeReader::InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
CBarcodeReader* reader = CBarcodeReader::GetInstance();
if(reader != NULL)
{
	unsigned char* pBufferBytes;
	int iWidth = 0;
	int iHeight = 0;
	int iStride = 0;
	ImagePixelFormat format;
	int iOrientation = 0;
	//get image data (pBufferBytes, iWidth, iHeight, iStride, format, iOrientation) somewhere else
	int errorCode = reader->DecodeBuffer(pBufferBytes, iWidth, iHeight, iStride, format, "");
	//int errorCode = reader->DecodeBuffer(pBufferBytes, iWidth, iHeight, iStride, format, iOrientation, "");
    // add further process
    reader->Recycle();
}

Remarks
If no template name is specified, current runtime settings will be used. To get the actual text results, please refer to GetAllTextResults.

DecodeBase64String

Decode barcode from an image file encoded as a base64 string.

int dynamsoft::dbr::CBarcodeReader::DecodeBase64String (const char* pBase64String, const char* pTemplateName = "")	

Parameters
[in] pBase64String A base64 encoded string that represents an image.
[in] pTemplateNameOptional The template name.

Return Value
Returns error code (returns 0 if the function operates successfully).
You can call GetErrorString to get detailed error message.

Code Snippet

char errorBuf[512];
dynamsoft::dbr::CBarcodeReader::InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
CBarcodeReader* reader = CBarcodeReader::GetInstance();
if(reader != NULL)
{
	unsigned char* pFileBytes;
	int nFileSize = 0;
	GetFileStream("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Images\\AllSupportedBarcodeTypes.tif", &pFileBytes, &nFileSize);
	char* strBase64String;
	GetFileBase64String(pBufferBytes, &strBase64String);
	int errorCode = reader->DecodeBase64String(strBase64String, "");
    // add further process
    reader->Recycle();
}

Remarks
If no template name is specified, current runtime settings will be used. To get the actual text results, please refer to GetAllTextResults.

DecodeDIB

Decode barcode from a handle of device-independent bitmap (DIB).

int dynamsoft::dbr::CBarcodeReader::DecodeDIB (const HANDLE hDIB, const char* pszTemplateName = "")	

Parameters
[in] hDIB Handle of the device-independent bitmap.
[in] pTemplateNameOptional The template name.

Return Value
Returns error code (returns 0 if the function operates successfully).
You can call GetErrorString to get detailed error message.

Code Snippet

char errorBuf[512];
dynamsoft::dbr::CBarcodeReader::InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
CBarcodeReader* reader = CBarcodeReader::GetInstance();
if(reader != NULL)
{
    HANDLE pDIB;
    GetDIBFromImage("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Images\\AllSupportedBarcodeTypes.tif", &pDIB);
    int errorCode = reader->DecodeDIB(pDIB, "");
    // add further process
    reader->Recycle();
}

Remarks
If no template name is specified, current runtime settings will be used. To get the actual text results, please refer to GetAllTextResults.

InitIntermediateResult

Inits an intermediateResult struct with default values.

int dynamsoft::dbr::CBarcodeReader::InitIntermediateResult(IntermediateResultType intermediateResultType, IntermediateResult* pIntermediateResult)	

Parameters
[in] intermediateResultType The type of the intermediate result to init. Please see EnumIntermediateResultType.
[in, out] pIntermediateResult The resulting IntermediateResult struct.

Return Value
Returns error code (returns 0 if the function operates successfully).
You can call DBR_GetErrorString to get detailed error message.

Code Snippet

IntermediateResult imResult;
dynamsoft::dbr::CBarcodeReader::InitIntermediateResult(IRT_ORIGINAL_IMAGE, &imResult);

DecodeIntermediateResults

Decodes barcode from intermediate results.

int dynamsoft::dbr::CBarcodeReader::DecodeIntermediateResults(const IntermediateResultArray *pIntermediateResultArray, const char* pTemplateName = "")	

Parameters
[in] pIntermediateResultArray The IntermediateResult array for decoding. [in] pTemplateNameOptional The template name.

Return Value
Returns error code (returns 0 if the function operates successfully).
You can call DBR_GetErrorString to get detailed error message.

Code Snippet

char errorBuf[512];
dynamsoft::dbr::CBarcodeReader::InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
CBarcodeReader* reader = CBarcodeReader::GetInstance();
if(reader != NULL)
{
    char fileName[] = "Your barcode file";
    PublicRuntimeSettings settings;
    reader->GetRuntimeSettings(&settings);
    settings.intermediateResultTypes = IRT_ORIGINAL_IMAGE;
    reader->UpdateRuntimeSettings(&settings);
    reader->DecodeFile(fileName, "");
    IntermediateResultArray * imResults = NULL;
    reader->GetIntermediateResults(&imResults);
    reader->DecodeIntermediateResults(imResults, "");
    TextArray * results = NULL;
    reader->GetAllTextResults(&results);
    // add further process
    reader->Recycle();
}

Remarks If no template name is specified, current runtime settings will be used. To get the actual text results, please refer to GetAllTextResults.

This page is compatible for:

Version 7.5.0

Is this page helpful?

YesYes NoNo

In this article:

latest version

  • Latest version
  • Version 10.x
    • Version 10.2.0
    • Version 10.0.20
    • Version 10.0.10
    • Version 10.0.0
  • Version 9.x
    • Version 9.6.40
    • Version 9.6.30
    • Version 9.6.20
    • Version 9.6.10
    • Version 9.6.0
    • Version 9.4.0
    • Version 9.2.0
    • Version 9.0.0
  • Version 8.x
    • Version 8.8.0
    • Version 8.6.0
    • Version 8.4.0
    • Version 8.2.0
    • Version 8.1.2
    • Version 8.1.0
    • Version 8.0.0
  • Version 7.x
    • Version 7.6.0
    • Version 7.5.0
Change +