Buffer Class

Description

Buffer stores a raw byte array, which can be used to access image data.

To access image data in Java API, get buffer from Image and copy to a Java byte array.

You can always access image data since the first version of EasyAR Sense. Refer to Image .

wrap

Wraps a raw memory block. When Buffer is released by all holders, deleter callback will be invoked to execute user-defined memory destruction. deleter must be thread-safe.

C

void easyar_Buffer_wrap(void * ptr, int size, easyar_FunctorOfVoid deleter, easyar_Buffer * * Return)

C++17

static std::shared_ptr<Buffer> wrap(void * ptr, int size, std::function<void()> deleter)

C++03

static void wrap(void * ptr, int size, FunctorOfVoid deleter, Buffer * * Return)

Java

public static @Nonnull Buffer wrap(long ptr, int size, @Nonnull FunctorOfVoid deleter)

Kotlin

companion object fun wrap(ptr: Long, size: Int, deleter: FunctorOfVoid): Buffer

Objective-C

+ (easyar_Buffer *)wrap:(void *)ptr size:(int)size deleter:(void (^)())deleter

Swift

public static func wrap(_ ptr: OpaquePointer?, _ size: Int32, _ deleter: @escaping () -> Void) -> Buffer

C#

public static Buffer wrap(IntPtr ptr, int size, Action deleter)

create

Creates a Buffer of specified byte size.

C

void easyar_Buffer_create(int size, easyar_Buffer * * Return)

C++17

static std::shared_ptr<Buffer> create(int size)

C++03

static void create(int size, Buffer * * Return)

Java

public static @Nonnull Buffer create(int size)

Kotlin

companion object fun create(size: Int): Buffer

Objective-C

+ (easyar_Buffer *)create:(int)size

Swift

public static func create(_ size: Int32) -> Buffer

C#

public static Buffer create(int size)

data

Returns raw data address.

C

void * easyar_Buffer_data(const easyar_Buffer * This)

C++17

void * data()

C++03

void * data()

Java

public long data()

Kotlin

fun data(): Long

Objective-C

- (void *)data

Swift

public func data() -> OpaquePointer?

C#

public virtual IntPtr data()

size

Byte size of raw data.

C

int easyar_Buffer_size(const easyar_Buffer * This)

C++17

int size()

C++03

int size()

Java

public int size()

Kotlin

fun size(): Int

Objective-C

- (int)size

Swift

public func size() -> Int32

C#

public virtual int size()

memoryCopy

Copies raw memory. It can be used in languages or platforms without complete support for memory operations.

C

void easyar_Buffer_memoryCopy(void * src, void * dest, int length)

C++17

static void memoryCopy(void * src, void * dest, int length)

C++03

static void memoryCopy(void * src, void * dest, int length)

Java

public static void memoryCopy(long src, long dest, int length)

Kotlin

companion object fun memoryCopy(src: Long, dest: Long, length: Int): Unit

Objective-C

+ (void)memoryCopy:(void *)src dest:(void *)dest length:(int)length

Swift

public static func memoryCopy(_ src: OpaquePointer?, _ dest: OpaquePointer?, _ length: Int32) -> Void

C#

public static void memoryCopy(IntPtr src, IntPtr dest, int length)

tryCopyFrom

Tries to copy data from a raw memory address into Buffer. If copy succeeds, it returns true, or else it returns false. Possible failure causes includes: source or destination data range overflow.

C

bool easyar_Buffer_tryCopyFrom(easyar_Buffer * This, void * src, int srcIndex, int index, int length)

C++17

bool tryCopyFrom(void * src, int srcIndex, int index, int length)

C++03

bool tryCopyFrom(void * src, int srcIndex, int index, int length)

Java

public boolean tryCopyFrom(long src, int srcIndex, int index, int length)

Kotlin

fun tryCopyFrom(src: Long, srcIndex: Int, index: Int, length: Int): Boolean

Objective-C

- (bool)tryCopyFrom:(void *)src srcIndex:(int)srcIndex index:(int)index length:(int)length

Swift

public func tryCopyFrom(_ src: OpaquePointer?, _ srcIndex: Int32, _ index: Int32, _ length: Int32) -> Bool

C#

public virtual bool tryCopyFrom(IntPtr src, int srcIndex, int index, int length)

tryCopyTo

Copies buffer data to user array.

C

bool easyar_Buffer_tryCopyTo(easyar_Buffer * This, int index, void * dest, int destIndex, int length)

C++17

bool tryCopyTo(int index, void * dest, int destIndex, int length)

C++03

bool tryCopyTo(int index, void * dest, int destIndex, int length)

Java

public boolean tryCopyTo(int index, long dest, int destIndex, int length)

Kotlin

fun tryCopyTo(index: Int, dest: Long, destIndex: Int, length: Int): Boolean

Objective-C

- (bool)tryCopyTo:(int)index dest:(void *)dest destIndex:(int)destIndex length:(int)length

Swift

public func tryCopyTo(_ index: Int32, _ dest: OpaquePointer?, _ destIndex: Int32, _ length: Int32) -> Bool

C#

public virtual bool tryCopyTo(int index, IntPtr dest, int destIndex, int length)

partition

Creates a sub-buffer with a reference to the original Buffer. A Buffer will only be released after all its sub-buffers are released.

C

void easyar_Buffer_partition(easyar_Buffer * This, int index, int length, easyar_Buffer * * Return)

C++17

std::shared_ptr<Buffer> partition(int index, int length)

C++03

void partition(int index, int length, Buffer * * Return)

Java

public @Nonnull Buffer partition(int index, int length)

Kotlin

fun partition(index: Int, length: Int): Buffer

Objective-C

- (easyar_Buffer *)partition:(int)index length:(int)length

Swift

public func partition(_ index: Int32, _ length: Int32) -> Buffer

C#

public virtual Buffer partition(int index, int length)

wrapByteArray

Wraps a byte array. The start position and length can be specified. Read-only or read-write can be specified. (Read-only Buffer may be faster on release.) A deleter callback can be specified. When Buffer is released by all holders, deleter callback will be invoked to execute user-defined memory destruction. deleter must be thread-safe.

Java

public static @Nonnull Buffer wrapByteArray(byte @Nonnull[] bytes)

public static @Nonnull Buffer wrapByteArray(byte @Nonnull[] bytes, int index, int length, boolean readOnly, @Nonnull FunctorOfVoid deleter)

Kotlin

companion object fun wrapByteArray(bytes: Array<Byte>): Buffer

companion object fun wrapByteArray(bytes: Array<Byte>, index: Int, length: Int, readOnly: Boolean, deleter: FunctorOfVoid): Buffer

C#

public static Buffer wrapByteArray(byte[] bytes)

public static Buffer wrapByteArray(byte[] bytes, int index, int length)

public static Buffer wrapByteArray(byte[] bytes, int index, int length, Action deleter)

wrapBuffer

Wraps a java.nio.Buffer. A deleter callback can be specified. When Buffer is released by all holders, deleter callback will be invoked to execute user-defined memory destruction. deleter must be thread-safe.

Java

public static @Nonnull Buffer wrapBuffer(java.nio.@Nonnull Buffer directBuffer)

public static @Nonnull Buffer wrapBuffer(java.nio.@Nonnull Buffer directBuffer, @Nonnull FunctorOfVoid deleter)

Kotlin

companion object fun wrapBuffer(directBuffer: java.nio.Buffer): Buffer

companion object fun wrapBuffer(directBuffer: java.nio.Buffer, deleter: FunctorOfVoid): Buffer

copyFromByteArray

Copies data from a byte array into Buffer. If copy failed, an exception will be thrown. Possible failure causes includes: source or destination data range overflow.

Java

public void copyFromByteArray(byte @Nonnull[] src)

public void copyFromByteArray(byte @Nonnull[] src, int srcIndex, int index, int length)

Kotlin

fun copyFromByteArray(src: Array<Byte>): Unit

fun copyFromByteArray(src: Array<Byte>, srcIndex: Int, index: Int, length: Int): Unit

C#

public void copyFromByteArray(byte[] src)

public void copyFromByteArray(byte[] src, int srcIndex, int index, int length)

copyToByteArray

Copies data from Buffer to a byte array. If copy failed, an exception will be thrown. Possible failure causes includes: source or destination data range overflow.

Java

public void copyToByteArray(byte @Nonnull[] dest)

public void copyToByteArray(int index, byte @Nonnull[] dest, int destIndex, int length)

Kotlin

fun copyToByteArray(dest: Array<Byte>): Unit

fun copyToByteArray(index: Int, dest: Array<Byte>, destIndex: Int, length: Int): Unit

C#

public void copyToByteArray(byte[] dest)

public void copyToByteArray(int index, byte[] dest, int destIndex, int length)

tryCopyFromByteArray

Tries to copy data from a byte array into Buffer. If copy succeeds, it returns true, or else it returns false. Possible failure causes includes: source or destination data range overflow.

Swift

public func tryCopyFromByteArray(_ src: [UInt8]) -> Bool

public func tryCopyFromByteArray(_ src: [UInt8], _ srcIndex: Int32, _ index: Int32, _ length: Int32) -> Bool

tryCopyToByteArray

Tries to copy data from Buffer to a byte array. If copy succeeds, it returns true, or else it returns false. Possible failure causes includes: source or destination data range overflow.

Swift

public func tryCopyToByteArray(_ dest: [UInt8]) -> Bool

public func tryCopyToByteArray(_ index: Int32, _ dest: [UInt8], _ destIndex: Int32, _ length: Int32) -> Bool