Dev Center
Table of contents

Thanks for downloading Dynamsoft Barcode Reader Package!

Your download will start shortly. If your download does not begin, click here to retry.

Decode Functions

Function Description
DBR_DecodeFile Decode barcodes from a specified image file.
DBR_DecodeFileInMemory Decode barcodes from an image file in memory.
DBR_DecodeBuffer Decode barcodes from raw buffer.
DBR_DecodeImageData Decode barcodes from source image defined as ImageData.
DBR_DecodeBase64String Decode barcodes from a base64 encoded string.
DBR_DecodeDIB Decode barcode from a handle of device-independent bitmap (DIB).
DBR_InitIntermediateResult Inits an intermediateResult struct with default values.
DBR_DecodeIntermediateResults Decodes barcode from intermediate results.

DBR_DecodeFile

Decode barcodes from a specified image file.

DBR_API int DBR_DecodeFile (void* barcodeReader, const char* pFileName, const char* pTemplateName)	

Parameters
[in] barcodeReader Handle of the barcode reader instance.
[in] pFileName A string defining the file name. It supports BMP, JPEG, PNG, TIFF and PDF files. [in] pTemplateName 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];
DBR_InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
void* barcodeReader = DBR_GetInstance();
if(barcodeReader != NULL)
{
	int errorCode = DBR_DecodeFile(barcodeReader, "C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Images\\AllSupportedBarcodeTypes.tif", "");
    //... more process here
    DBR_RecycleInstance(barcodeReader);
}

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

DBR_DecodeFileInMemory

Decode barcodes from an image file in memory.

DBR_API int DBR_DecodeFileInMemory (void* barcodeReader, const unsigned char* pFileBytes, const int fileSize, const char* pTemplateName)	

Parameters
[in] barcodeReader Handle of the barcode reader instance.
[in] pFileBytes The image file bytes in memory.
[in] fileSize The length of the file bytes in memory.
[in] pTemplateName 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];
DBR_InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
void* barcodeReader = DBR_GetInstance();
if(barcodeReader != NULL)
{
	unsigned char* pFileBytes;
	int nFileSize = 0;
	GetFileStream("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Images\\AllSupportedBarcodeTypes.tif", &pFileBytes, &nFileSize);
	int errorCode = DBR_DecodeFileInMemory(barcodeReader, pFileBytes, nFileSize, "");
    //... more process here
    DBR_RecycleInstance(barcodeReader);
}

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

DBR_DecodeBuffer

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

DBR_API int DBR_DecodeBuffer (void* barcodeReader, const unsigned char* pBufferBytes, const int width, const int height, const int stride, const ImagePixelFormat format, const char* pTemplateName)

Parameters
[in] barcodeReader Handle of the barcode reader instance.
[in] pBufferBytes The array of bytes which contain the image data.
[in] width The width of the image in pixels.
[in] height The height of the image in pixels.
[in] stride The stride (or scan width) of the image.
[in] format The image pixel format used in the image byte array.
[in] pTemplateName 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];
DBR_InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
void* barcodeReader = DBR_GetInstance();
if(barcodeReader != NULL)
{
	unsigned char* pBufferBytes;
	int iWidth = 0;
	int iHeight = 0;
	int iStride = 0;
	ImagePixelFormat format;
	GetBufferFromFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Images\\AllSupportedBarcodeTypes.tif", &pBufferBytes, &iWidth, &iHeight, &iStride, &format);
	int errorCode = DBR_DecodeBuffer(barcodeReader, pBufferBytes, iWidth, iHeight, iStride, format, "");
    //... more process here
    DBR_RecycleInstance(barcodeReader);
}

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

DBR_DecodeImageData

Decode barcodes from source image defined as ImageData.

DBR_API int DBR_DecodeImageData(void* barcodeReader, const ImageData* imageData, const char* templateName)

Parameters
[in] barcodeReader Handle of the barcode reader instance.
[in] imageData The source image defined as ImageData.
[in] templateName 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];
DBR_InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
void* barcodeReader = DBR_GetInstance();
if(barcodeReader != NULL)
{
	//...generate imageData somewhere else
	int errorCode = DBR_DecodeImageData(barcodeReader, imageData, "");
    //... more process here
    DBR_RecycleInstance(barcodeReader);
}

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

DBR_DecodeBase64String

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

DBR_API int DBR_DecodeBase64String (void* barcodeReader, const char* pBase64String, const char* pTemplateName)	

Parameters
[in] barcodeReader Handle of the barcode reader instance.
[in] pBase64String A base64 encoded string that represents an image.
[in] pTemplateName 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];
DBR_InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
void* barcodeReader = DBR_GetInstance();
if(barcodeReader != NULL)
{
	unsigned char* pBufferBytes;
	int nFileSize = 0;
	GetFileStream("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Images\\AllSupportedBarcodeTypes.tif", &pFileBytes, &nFileSize);
	char* strBase64String;
	GetFileBase64String(pBufferBytes, &strBase64String);
	int errorCode = DBR_DecodeBase64String(barcodeReader, strBase64String, "");
    //... more process here
    DBR_RecycleInstance(barcodeReader);
}

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

DBR_DecodeDIB

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

DBR_API int DBR_DecodeDIB (void* barcodeReader, const HANDLE hDIB, const char* pTemplateName)	

Parameters
[in] barcodeReader Handle of the barcode reader instance.
[in] hDIB Handle of the device-independent bitmap.
[in] pTemplateName 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];
DBR_InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
void* barcodeReader = DBR_GetInstance();
if(barcodeReader != NULL)
{
	HANDLE pDIB;
	GetDIBFromImage("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Images\\AllSupportedBarcodeTypes.tif", &pDIB);
	int errorCode = DBR_DecodeDIB(barcodeReader, pDIB, "");
    //... more process here
    DBR_RecycleInstance(barcodeReader);
}

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

DBR_InitIntermediateResult

Inits an intermediateResult struct with default values.

DBR_API int DBR_InitIntermediateResult (IntermediateResultType intermediateResultType, IntermediateResult* pIntermediateResult)	

Parameters
[in] intermediateResultType The type of the intermediate result defined by EnumIntermediateResultType.
[in, out] pIntermediateResult The intermediate result struct of type IntermediateResult.

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;
DBR_InitIntermediateResult(IRT_ORIGINAL_IMAGE, &imResult);

DBR_DecodeIntermediateResults

Decodes barcode from intermediate results.

DBR_API int DBR_DecodeIntermediateResults (void* barcodeReader, const IntermediateResultArray *pIntermediateResultArray, const char* pTemplateName)	

Parameters
[in] barcodeReader Handle of the barcode reader instance.
[in] pIntermediateResultArray The IntermediateResultArray for decoding.
[in] pTemplateName 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];
DBR_InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
void* barcodeReader = DBR_GetInstance();
if(barcodeReader != NULL)
{
	char fileName[] = "Your barcode file";
	PublicRuntimeSettings settings;
	DBR_GetRuntimeSettings(barcodeReader, &settings);
	settings.intermediateResultTypes = IRT_ORIGINAL_IMAGE;
	DBR_UpdateRuntimeSettings(barcodeReader, &settings, errorBuf, 512);
	DBR_DecodeFile(barcodeReader, fileName, "");
	IntermediateResultArray * imResults = NULL;
	DBR_GetIntermediateResults(barcodeReader, &imResults);
	DBR_DecodeIntermediateResults(barcodeReader, imResults, "");
	TextArray * results = NULL;
	DBR_GetAllTextResults(barcodeReader, &results);
    //... more process here
	DBR_FreeTextResults(&results);
    DBR_RecycleInstance(barcodeReader);
}

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.0.20
    • Version 10.0.10
    • Version 10.0.0
  • Version 9.x
    • 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 +