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

C++ API Reference - CBarcodeReader 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).

DecodeFile

Decode barcodes from a specified image file.

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

Parameters

[in] pFileName A string defining the file name.
[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.

Remark

If no template name is specified, current runtime settings will be used.

Code Snippet

CBarcodeReader* reader = new CBarcodeReader();
reader->InitLicense("t0260NwAAAHV***************");
int errorCode = reader->DecodeFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Images\\AllSupportedBarcodeTypes.tif", "");
delete reader;

 

DecodeFileInMemory

Decode barcodes from an image file in memory.

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

Remark

If no template name is specified, current runtime settings will be used.

Code Snippet

CBarcodeReader* reader = new CBarcodeReader();
reader->InitLicense("t0260NwAAAHV***************");
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, "");
delete reader;

 

DecodeBuffer

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

int CBarcodeReader::DecodeBuffer (const unsigned char* pBufferBytes, const int iWidth, const int iHeight, const int iStride, const ImagePixelFormat format, 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] 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.

Remark

If no template name is specified, current runtime settings will be used.

Code Snippet

CBarcodeReader* reader = new CBarcodeReader();
reader->InitLicense("t0260NwAAAHV***************");
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 = reader->DecodeBuffer(pBufferBytes, iWidth, iHeight, iStride, format, "");
delete reader;

 

DecodeBase64String

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

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

Remark

If no template name is specified, current runtime settings will be used.

Code Snippet

CBarcodeReader* reader = new CBarcodeReader();
reader->InitLicense("t0260NwAAAHV***************");
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, "");
delete reader;

 

DecodeDIB

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

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

Remark

If no template name is specified, current runtime settings will be used.

Code Snippet

CBarcodeReader* reader = new CBarcodeReader();
reader->InitLicense("t0260NwAAAHV***************");
HANDLE pDIB;
GetDIBFromImage("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Images\\AllSupportedBarcodeTypes.tif", &pDIB);
int errorCode = reader->DecodeDIB(pDIB "");
delete reader;

This page is compatible for:

Version 7.5

Is this page helpful?

YesYes NoNo

In this article:

version 7.6

  • Latest version
  • Version 8.4
  • Version 8.2.5
  • Version 8.2.3
  • Version 8.2.1
  • Version 8.2
  • Version 8.1.3
  • Version 8.1.2
  • Version 8.1
  • Version 8.0
  • Version 7.6
  • Version 7.5
Change +
© 2003–2021 Dynamsoft. All rights reserved.
Privacy Statement / Site Map / Home / Purchase / Support