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 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.
decodeBufferedImage Decodes barcode from a buffered imag (bitmap).
initIntermediateResult Inits an intermediateResult struct with default values.
decodeIntermediateResults Decodes barcode from intermediate results.

DecodeFile

Decode barcodes from a specified image file.

TextResult[] com.dynamsoft.dbr.BarcodeReader.decodeFile(String fileFullPath, String templateName)	throws BarcodeReaderException	

Parameters
fileFullPath A string defining the file path. It supports BMP, TIFF, JPG, PNG and PDF files. templateName The template name.

Return Value
An array of TextResult

Exception
BarcodeReaderException

Code Snippet

BarcodeReader.initLicense("YOUR-LICENSE-KEY");
BarcodeReader reader = BarcodeReader.getInstance();
if(reader != null)
{
	TextResult[] result = reader.decodeFile("your file path", "");
    // add further process
    reader.recycle();
}

DecodeFileInMemory

Decode barcodes from an image file in memory.

TextResult[] com.dynamsoft.dbr.BarcodeReader.decodeFileInMemory(byte[] fileBytes, String templateName) throws BarcodeReaderException

Parameters
fileBytes The image file bytes in memory.
templateName The template name.

Return Value
An array of TextResult

Exception
BarcodeReaderException

Code Snippet

BarcodeReader.initLicense("YOUR-LICENSE-KEY");
BarcodeReader reader = BarcodeReader.getInstance();
if(reader != null)
{
	//get bufferBytes from other component
	TextResult[] result = reader.decodeFileInMemory(bufferBytes, "");
    // add further process
    reader.recycle();
}
TextResult[] com.dynamsoft.dbr.BarcodeReader.decodeFileInMemory(InputStream fileStream, String templateName) throws BarcodeReaderException, IOException

Parameters
fileStream The image file bytes in memory.
templateName The template name.

Return Value
An array of TextResult

Exception
BarcodeReaderException, IOException

Code Snippet

BarcodeReader.initLicense("YOUR-LICENSE-KEY");
BarcodeReader reader = BarcodeReader.getInstance();
if(reader != null)
{
	//get FileInputStream fis from other component
	TextResult[] result = reader.decodeFileInMemory(fis, "");
    // add further process
    reader.recycle();
}

DecodeBuffer

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

TextResult[] com.dynamsoft.dbr.BarcodeReader.decodeBuffer(byte[] buffer, int width, int height, int stride, int enumImagePixelFormat, String templateName)	throws BarcodeReaderException

TextResult[] com.dynamsoft.dbr.BarcodeReader.decodeBuffer(byte[] buffer, int width, int height, int stride, int enumImagePixelFormat, int orientation, String templateName) throws BarcodeReaderException

Parameters
buffer The array of bytes which contain the image data.
width The width of the image in pixels.
height The height of the image in pixels.
stride The stride (or scan width) of the image.
enumImagePixelFormat The image pixel format used in the image byte array.
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.
templateName The template name.

Return Value
An array of TextResult

Exception
BarcodeReaderException

Code Snippet

BarcodeReader.initLicense("YOUR-LICENSE-KEY");
BarcodeReader reader = BarcodeReader.getInstance();
if(reader != null)
{
	byte[] bufferBytes;
	int iWidth = 0;
	int iHeight = 0;
	int iStride = 0;
	int format;
	GetBufferFromFile("your file path", bufferBytes, iWidth, iHeight, iStride, format);
	TextResult[] result = reader.decodeBuffer(bufferBytes, iWidth,  iHeight, iStride, format, "");
    // add further process
    reader.recycle();
}

DecodeBase64String

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

TextResult[] com.dynamsoft.dbr.BarcodeReader.decodeBase64String(String base64, String templateName)	throws BarcodeReaderException

Parameters
base64 A base64 encoded string that represents an image.
templateName The template name.

Return Value
An array of TextResult

Exception
BarcodeReaderException

Code Snippet

BarcodeReader.initLicense("YOUR-LICENSE-KEY");
BarcodeReader reader = BarcodeReader.getInstance();
if(reader != null)
{
	TextResult[] result = reader.decodeBase64String("file in base64 string", "");
    // add further process
    reader.recycle();
}

DecodeBufferedImage

Decodes barcode from a buffered imag (bitmap).

TextResult[] com.dynamsoft.dbr.BarcodeReader.decodeBufferedImage(BufferedImage image, String templateName)	throws IOException, BarcodeReaderException

Parameters
image The image to be decoded.
templateName The template name.

Return Value
An array of TextResult

Exception
BarcodeReaderException, IOException

Code Snippet

BarcodeReader.initLicense("YOUR-LICENSE-KEY");
BarcodeReader reader = BarcodeReader.getInstance();
if(reader != null)
{
	//get BufferedImage input from other component
	TextResult[] result = reader.decodeBufferedImage(input, "");
    // add further process
    reader.recycle();
}

initIntermediateResult

Initiates an intermediateResult struct with default values.

IntermediateResult com.dynamsoft.dbr.BarcodeReader.initIntermediateResult(int resultType)	throws BarcodeReaderException	

Parameters
resultType The type of the intermediate result to init.

Return Value
An IntermediateResult class with default values.

Exception
BarcodeReaderException

Code Snippet

BarcodeReader.initLicense("YOUR-LICENSE-KEY");
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[] com.dynamsoft.dbr.BarcodeReader.decodeIntermediateResults(IntermediateResults[] results, String templateName)	throws BarcodeReaderException	

Parameters
results The intermediate result array for decoding.
templateName The template name.

Return Value
An array of TextResult

Exception
BarcodeReaderException

Code Snippet

BarcodeReader.initLicense("YOUR-LICENSE-KEY");
BarcodeReader reader = BarcodeReader.getInstance();
if(reader != null)
{
	PublicRuntimeSettings settings = reader.getRuntimeSettings(); settings.intermediateResultTypes = EnumIntermediateResultType.IRT_ORIGINAL_IMAGE;
	reader.updateRuntimeSettings(settings);
	reader.decodeFile("your file path", "");
	IntermediateResult[] irtResult = reader.getIntermediateResults();
	TextResult[] result = reader.decodeIntermediateResults(irtResult, "");
    // 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.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 +