Skip to main content

Handling image results with the React Native Barcode Scanner SDK

When returnBarcodeImage is enabled in BarcodeScannerScreenConfiguration.scannerConfiguration, each barcode result includes a cropped image of the scanned frame. This image is represented by an ImageRef, which holds a reference to the image in memory.

An ImageRef can be used to save the cropped barcode image to the file system or retrieve it as a Base64-encoded string. Since it holds native resources, it's important to release the reference once it's no longer needed.

To ensure proper memory management, ImageRef instances should be used within an autorelease block that handles disposal automatically.

Handling Barcode Result with ImageRefs
loading...

If more flexibility is needed and the barcode results need to be evaluated at a later point or in another part of the app, the option to serialize the result is available.

Handling Barcode Result with ImageRefs
loading...

There is also an option to encode all results as Base64 strings.

Handling Barcode Result with ImageRefs
loading...

Want to scan longer than one minute?

Generate a free trial license to test the Scanbot SDK thoroughly.

Get free trial license