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.
DecodeBitmap Decodes barcode from a bitmap.
InitIntermediateResult Inits an intermediateResult struct with default values.
DecodeIntermediateResults Decodes barcode from intermediate results.

DecodeFile

Decode barcodes from a specified image file.

TextResult[] Dynamsoft.DBR.BarcodeReader.DecodeFile(string fileName, string templateName)

Parameters
[in] fileName <string> : A string defining the file name. It supports BMP, JPEG, PNG, TIFF and PDF files.
[in] templateName <string> : The template name.

Return Value
TextResult array.

Exception
BarcodeReaderException The exception thrown by Dynamsoft Barcode Reader.

Code Snippet

string errorMsg;
BarcodeReader.InitLicense("YOUR-LICENSE-KEY", out errorMsg);
BarcodeReader reader = BarcodeReader.GetInstance();
if (reader != null)
{
	TextResult[] result = reader.DecodeFile(@"C:\Program Files (x86)\Dynamsoft\{Version number}\Images\AllSupportedBarcodeTypes.tif", "");
	//... add further process
    reader.Recycle();
}

DecodeFileInMemory

Decode barcodes from an image file in memory.

TextResult[] Dynamsoft.DBR.BarcodeReader.DecodeFileInMemory(byte[] fileStream, string templateName)  

Parameters
[in] fileStream <byte[]> : The image file bytes in memory.
[in] templateName <string> : The template name.

Return Value
TextResult array.

Exception
BarcodeReaderException The exception thrown by Dynamsoft Barcode Reader.

Code Snippet

string errorMsg;
BarcodeReader.InitLicense("YOUR-LICENSE-KEY", out errorMsg);
BarcodeReader reader = BarcodeReader.GetInstance();
if (reader != null)
{
	byte[] fileStream = GetFileStream(@"C:\Program Files (x86)\Dynamsoft\{Version number}\Images\AllSupportedBarcodeTypes.tif");
	TextResult[] result = reader.DecodeFileInMemory(fileStream, "");
	//... add further process
    reader.Recycle();
}

DecodeBuffer

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

TextResult[] Dynamsoft.DBR.BarcodeReader.DecodeBuffer(byte[] buffer, int width, int height, int stride, EnumImagePixelFormat imagePixelFormat, string templateName)

TextResult[] Dynamsoft.DBR.BarcodeReader.DecodeBuffer(byte[] buffer, int width, int height, int stride, EnumImagePixelFormat imagePixelFormat, int orientation, string templateName)

Parameters
[in] buffer <byte[]> : The array of bytes which contain the image data.
[in] width <int> : The width of the image in pixels.
[in] height <int> : The height of the image in pixels.
[in] stride <int> : The stride of the image (also called scan width).
[in] imagePixelFormat <EnumImagePixelFormat> : The image pixel format used in the image byte array.
[in] orientation <int> : 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] templateName <string> : The template name.

Return Value
TextResult array.

Exception
BarcodeReaderException The exception thrown by Dynamsoft Barcode Reader.

Code Snippet

string errorMsg;
BarcodeReader.InitLicense("YOUR-LICENSE-KEY", out errorMsg);
BarcodeReader reader = BarcodeReader.GetInstance();
if (reader != null)
{
	Bitmap bBMP = new Bitmap(@"C:\Program Files (x86)\Dynamsoft\{Version number}\Images\AllSupportedBarcodeTypes.tif");
	BitmapData bmdat = bBMP.LockBits(new Rectangle(Point.Empty, bBMP.Size), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
	int width = bBMP.Width;
	int height = bBMP.Height;
	int stride = bmdat.Stride;
	byte[] buffer = new byte[stride * bmdat.Height];
	Marshal.Copy(bmdat.Scan0, buffer, 0, buffer.Length);
	bBMP.UnlockBits(bmdat);
	EnumImagePixelFormat imagePixelFormat = EnumImagePixelFormat.IPF_ARGB_8888;
	TextResult[] result = reader.DecodeBuffer(buffer, width, height, stride, imagePixelFormat, "");
	//TextResult[] result = reader.DecodeBuffer(buffer, width, height, stride, imagePixelFormat, 0, "");
	//... add further process
    reader.Recycle();
}

DecodeBase64String

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

TextResult[] Dynamsoft.DBR.BarcodeReader.DecodeBase64String(string base64, string templateName)	

Parameters
[in] base64 <string> : A base64 encoded string that represents an image.
[in] templateName <string> : The template name.

Return Value
All barcode text results decoded successfully.

Exception
BarcodeReaderException The exception thrown by Dynamsoft Barcode Reader.

Code Snippet

string errorMsg;
BarcodeReader.InitLicense("YOUR-LICENSE-KEY", out errorMsg);
BarcodeReader reader = BarcodeReader.GetInstance();
if (reader != null)
{
	byte[] byteFileStream = GetFileStream(@"C:\Program Files (x86)\Dynamsoft\{Version number}\Images\AllSupportedBarcodeTypes.tif");
	string base64String = GetFileBase64String(byteFileStream);
	TextResult[] result = reader.DecodeBase64String(base64String, "");
	//... add further process
    reader.Recycle();
}

See Also
TextResult

DecodeBitmap

Decodes barcode from a bitmap.

TextResult[] Dynamsoft.DBR.BarcodeReader.DecodeBitmap(Bitmap bitMap, string templateName)

Parameters
[in] bitMap <Bitmap> : The image to be decoded.
[in] templateName <string> : The template name.

Return Value
TextResult array.

Exception
BarcodeReaderException The exception thrown by Dynamsoft Barcode Reader.

Code Snippet

string errorMsg;
BarcodeReader.InitLicense("YOUR-LICENSE-KEY", out errorMsg);
BarcodeReader reader = BarcodeReader.GetInstance();
if (reader != null)
{
	Bitmap bBMP = new Bitmap(@"C:\Program Files (x86)\Dynamsoft\{Version number}\Images\AllSupportedBarcodeTypes.tif");
	TextResult[] result = reader.DecodeBitmap(bBMP, "");
	//... add further process
    reader.Recycle();
}

InitIntermediateResult

Inits an intermediateResult struct with default values.

IntermediateResult Dynamsoft.DBR.BarcodeReader.InitIntermediateResult(EnumIntermediateResultType intermediateResultType) 	

Parameters
intermediateResultType : The type of the intermediate result to init.

Return Value
IntermediateResult with default values

Code Snippet

BarcodeReader reader = BarcodeReader.GetInstance();
if (reader != null)
{
	IntermediateResult imResult = reader.InitIntermediateResult(EnumIntermediateResultType.IRT_ORIGINAL_IMAGE);
	//... add further process
    reader.Recycle();
}

DecodeIntermediateResults

Decodes barcode from intermediate results.

TextResult[] Dynamsoft.DBR.BarcodeReader.DecodeIntermediateResults(IntermediateResult[] intermediateResultArray, string templateName) 	

Parameters
intermediateResultArray : The intermediate result array for decoding.
templateName : The template name.

Return Value
TextResult array.

Exception
BarcodeReaderException The exception thrown by Dynamsoft Barcode Reader.

Code Snippet

string errorMsg;
BarcodeReader.InitLicense("YOUR-LICENSE-KEY", out errorMsg);
BarcodeReader reader = BarcodeReader.GetInstance();
if (reader != null)
{
	PublicRuntimeSettings settings = reader.GetRuntimeSettings();
	settings.IntermediateResultType = (int)EnumIntermediateResultType.IRT_ORIGINAL_IMAGE;
	reader.UpdateRuntimeSettings(settings);
	reader.DecodeFile("Your file path", "");
	IntermediateResult[] IMRs = reader.GetIntermediateResults();
	TextResult[] result = reader.DecodeIntermediateResults(IMRs, "");
	//... add further process
    reader.Recycle();
}

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 +