Skip to main content

ImageRef API in React Native Barcode Scanner SDK

ImageRef is a lightweight image reference type used throughout the Scanbot SDK to represent image data in a unified and effective manner. Additionally, it acts as a universal interface for images that any component of the SDK captures, processes, or returns. It enables memory efficient Image processing across the SDK and also makes it cross accessible across the SDKs on supported platforms.

In order to manage memory effectively, the Scanbot SDK uses autorelease blocks to ensure that ImageRefs are released when they are no longer needed. This means that ImageRefs are automatically released at the end of the block in which they were created, so no manual memory management is required. However, if you need to use an ImageRef outside the current autorelease block, you can serialize it and later deserialize it.

ImageRef from Encoded Buffer

ImageRef can be created from an encoded image buffer, which is a base64 string containing the image data in a specific format (e.g., JPEG, PNG). This allows you to work with images that are already in memory without needing to save them to disk first.

Creating ImageRef from Encoded Buffer
loading...

ImageRef from File URI

ImageRef can also be created from a file URI, which is a string representing the location of an image file on the device's storage.

Creating ImageRef from File URI
loading...

Utilizing ImageRef

Once you have an ImageRef, you can use it with various SDK components that accept ImageRef as input. ImageRef can also be used to save images to disk or convert them to encoded buffers for further processing.

Using ImageRefs
loading...

Want to scan longer than one minute?

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

Get free trial license

If ImageRef usage is needed outside the current autorelease block, serialize it and later deserialize it within a new autorelease block. This ensures proper memory management and release when the ImageRef is no longer needed.

Buffer Serialization and Deserialization

The ImageRef can be serialized to a buffer and deserialized back to an ImageRef when needed.

Serializing and Deserializing ImageRef
loading...

Reference Serialization and Deserialization

The ImageRef can also be serialized to a reference uniqueId string and deserialized back to an ImageRef

Serializing and Deserializing ImageRef
loading...