Table of Contents

Class Buffer

네임스페이스
easyar

Buffer는 원시 바이트 배열을 저장하며 이미지 데이터에 접근하는 데 사용할 수 있습니다. Java API에서는 Image에서 buffer를 가져온 후 Java 바이트 배열로 데이터를 copy할 수 있습니다. EasyAR Sense의 모든 버전에서 이미지 데이터에 접근할 수 있습니다. Image를 참조하십시오.

Buffer

메서드

wrap

지정된 길이의 원시 메모리 블록을 래핑합니다. Buffer가 완전히 해제될 때, 사용자 정의 메모리 소멸 동작을 실행하는 deleter 콜백이 호출됩니다. deleter는 반드시 스레드 안전(thread-safe)해야 합니다.

void easyar_Buffer_wrap(void * ptr, int size, easyar_FunctorOfVoid deleter, easyar_Buffer * * Return)
static std::shared_ptr<Buffer> wrap(void * ptr, int size, std::function<void()> deleter)
public static @Nonnull Buffer wrap(long ptr, int size, @Nonnull FunctorOfVoid deleter)
companion object fun wrap(ptr: Long, size: Int, deleter: FunctorOfVoid): Buffer
+ (easyar_Buffer *)wrap:(void *)ptr size:(int)size deleter:(void (^)())deleter
public static func wrap(_ ptr: OpaquePointer?, _ size: Int32, _ deleter: @escaping () -> Void) -> Buffer
public static Buffer wrap(IntPtr ptr, int size, Action deleter)

매개 변수

이름 형식 설명
ptr IntPtr
size Int32
deleter Action

반환 값

형식 설명
Buffer

create

지정한 바이트 길이의 Buffer를 생성합니다.

void easyar_Buffer_create(int size, easyar_Buffer * * Return)
static std::shared_ptr<Buffer> create(int size)
public static @Nonnull Buffer create(int size)
companion object fun create(size: Int): Buffer
+ (easyar_Buffer *)create:(int)size
public static func create(_ size: Int32) -> Buffer
public static Buffer create(int size)

매개 변수

이름 형식 설명
size Int32

반환 값

형식 설명
Buffer

data

원시 메모리 주소를 반환합니다.

void * easyar_Buffer_data(const easyar_Buffer * This)
void * data()
public long data()
fun data(): Long
- (void *)data
public func data() -> OpaquePointer?
public virtual IntPtr data()

반환 값

형식 설명
IntPtr

size

Buffer 바이트 길이

int easyar_Buffer_size(const easyar_Buffer * This)
int size()
public int size()
fun size(): Int
- (int)size
public func size() -> Int32
public virtual int size()

반환 값

형식 설명
Int32

memoryCopy

원시 메모리를 복사합니다. 주로 메모리 조작이 제대로 지원되지 않는 언어나 환경에서 사용됩니다.

void easyar_Buffer_memoryCopy(void * src, void * dest, int length)
static void memoryCopy(void * src, void * dest, int length)
public static void memoryCopy(long src, long dest, int length)
companion object fun memoryCopy(src: Long, dest: Long, length: Int): Unit
+ (void)memoryCopy:(void *)src dest:(void *)dest length:(int)length
public static func memoryCopy(_ src: OpaquePointer?, _ dest: OpaquePointer?, _ length: Int32) -> Void
public static void memoryCopy(IntPtr src, IntPtr dest, int length)

매개 변수

이름 형식 설명
src IntPtr
dest IntPtr
length Int32

반환 값

형식 설명
Void

tryCopyFrom

원시 메모리 주소에서 데이터를 Buffer로 복사를 시도합니다. 복사가 성공하면 true를 반환하고, 그렇지 않으면 false를 반환합니다. 실패 원인은 다음과 같습니다: 소스 데이터 범위 또는 대상 데이터 범위가 가용 범위를 초과한 경우.

bool easyar_Buffer_tryCopyFrom(easyar_Buffer * This, void * src, int srcIndex, int index, int length)
bool tryCopyFrom(void * src, int srcIndex, int index, int length)
public boolean tryCopyFrom(long src, int srcIndex, int index, int length)
fun tryCopyFrom(src: Long, srcIndex: Int, index: Int, length: Int): Boolean
- (bool)tryCopyFrom:(void *)src srcIndex:(int)srcIndex index:(int)index length:(int)length
public func tryCopyFrom(_ src: OpaquePointer?, _ srcIndex: Int32, _ index: Int32, _ length: Int32) -> Bool
public virtual bool tryCopyFrom(IntPtr src, int srcIndex, int index, int length)

매개 변수

이름 형식 설명
src IntPtr
srcIndex Int32
index Int32
length Int32

반환 값

형식 설명
Boolean

tryCopyTo

Buffer에서 원시 메모리 주소로 데이터를 복사하려고 시도합니다. 복사가 성공하면 true를 반환하고, 그렇지 않으면 false를 반환합니다. 실패 원인은 소스 데이터 범위 또는 대상 데이터 범위가 사용 가능한 범위를 벗어난 경우입니다

bool easyar_Buffer_tryCopyTo(easyar_Buffer * This, int index, void * dest, int destIndex, int length)
bool tryCopyTo(int index, void * dest, int destIndex, int length)
public boolean tryCopyTo(int index, long dest, int destIndex, int length)
fun tryCopyTo(index: Int, dest: Long, destIndex: Int, length: Int): Boolean
- (bool)tryCopyTo:(int)index dest:(void *)dest destIndex:(int)destIndex length:(int)length
public func tryCopyTo(_ index: Int32, _ dest: OpaquePointer?, _ destIndex: Int32, _ length: Int32) -> Bool
public virtual bool tryCopyTo(int index, IntPtr dest, int destIndex, int length)

매개 변수

이름 형식 설명
index Int32
dest IntPtr
destIndex Int32
length Int32

반환 값

형식 설명
Boolean

partition

하위 버퍼를 생성하고 원본 버퍼를 참조합니다. 버퍼는 모든 서브-버퍼가 해제된 후에야 비로소 해제될 것입니다.

void easyar_Buffer_partition(easyar_Buffer * This, int index, int length, easyar_Buffer * * Return)
std::shared_ptr<Buffer> partition(int index, int length)
public @Nonnull Buffer partition(int index, int length)
fun partition(index: Int, length: Int): Buffer
- (easyar_Buffer *)partition:(int)index length:(int)length
public func partition(_ index: Int32, _ length: Int32) -> Buffer
public virtual Buffer partition(int index, int length)

매개 변수

이름 형식 설명
index Int32
length Int32

반환 값

형식 설명
Buffer

wrapByteArray

바이트 배열을 래핑합니다.

public static @Nonnull Buffer wrapByteArray(byte @Nonnull[] bytes)
companion object fun wrapByteArray(bytes: Array<Byte>): Buffer
public static Buffer wrapByteArray(byte[] bytes)

매개 변수

이름 형식 설명
bytes

반환 값

형식 설명
Buffer

wrapByteArray

바이트 배열을 래핑합니다. 시작 위치와 길이를 지정할 수 있으며, Buffer가 읽기 전용인지 읽기-쓰기가 가능한지 지정할 수 있습니다(읽기 전용 Buffer는 해제 속도가 더 빠를 수 있음). deleter 콜백을 지정할 수 있으며, Buffer가 완전히 해제될 때 deleter 콜백이 호출되어 사용자 정의 메모리 해제 동작을 수행합니다. deleter는 스레드 안전해야 합니다.

public static @Nonnull Buffer wrapByteArray(byte @Nonnull[] bytes, int index, int length, boolean readOnly, @Nonnull FunctorOfVoid deleter)
companion object fun wrapByteArray(bytes: Array<Byte>, index: Int, length: Int, readOnly: Boolean, deleter: FunctorOfVoid): Buffer

매개 변수

이름 형식 설명
bytes
index Int32
length Int32
readOnly Boolean
deleter Action

반환 값

형식 설명
Buffer

wrapByteArray

바이트 배열을 래핑합니다. 시작 위치와 길이를 지정할 수 있습니다.

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

매개 변수

이름 형식 설명
bytes
index Int32
length Int32

반환 값

형식 설명
Buffer

wrapByteArray

바이트 배열을 래핑합니다. 시작 위치와 길이를 지정할 수 있습니다. deleter 콜백을 지정할 수 있으며, Buffer가 완전히 해제될 때 deleter 콜백이 호출되어 사용자 정의 메모리 해제 동작을 수행합니다. deleter는 반드시 스레드 안전(thread-safe)해야 합니다.

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

매개 변수

이름 형식 설명
bytes
index Int32
length Int32
deleter Action

반환 값

형식 설명
Buffer

wrapBuffer

java.nio.Buffer를 래핑하다

public static @Nonnull Buffer wrapBuffer(java.nio.@Nonnull Buffer directBuffer)
companion object fun wrapBuffer(directBuffer: java.nio.Buffer): Buffer

매개 변수

이름 형식 설명
directBuffer

반환 값

형식 설명
Buffer

wrapBuffer

Java의 java.nio.Buffer를 래핑합니다. deleter 콜백을 지정할 수 있으며, Buffer가 완전히 해제될 때 사용자 정의 메모리 파기 동작을 수행하기 위해 deleter 콜백이 호출됩니다. deleter는 반드시 스레드-안전해야 합니다.

public static @Nonnull Buffer wrapBuffer(java.nio.@Nonnull Buffer directBuffer, @Nonnull FunctorOfVoid deleter)
companion object fun wrapBuffer(directBuffer: java.nio.Buffer, deleter: Action): Buffer

매개 변수

이름 형식 설명
directBuffer
deleter Action

반환 값

형식 설명
Buffer

copyFromByteArray

바이트 배열에서 Buffer로 데이터를 복사합니다. 복사에 실패하면 예외를 발생시킵니다. 실패 원인은 다음과 같습니다: 소스 데이터 범위 또는 대상 데이터 범위가 가용 범위를 초과한 경우.

public void copyFromByteArray(byte @Nonnull[] src)
fun copyFromByteArray(src: Array<Byte>): Unit
public void copyFromByteArray(byte[] src)

매개 변수

이름 형식 설명
src

copyFromByteArray

바이트 배열에서 Buffer로 데이터를 복사합니다. 복사에 실패하면 예외를 발생시킵니다. 실패 원인은 다음과 같습니다: 소스 데이터 범위 또는 대상 데이터 범위가 가용 범위를 초과한 경우.

public void copyFromByteArray(byte @Nonnull[] src, int srcIndex, int index, int length)
fun copyFromByteArray(src: Array<Byte>, srcIndex: Int, index: Int, length: Int): Unit
public void copyFromByteArray(byte[] src, int srcIndex, int index, int length)

매개 변수

이름 형식 설명
src
srcIndex Int32
index Int32
length Int32

copyToByteArray

버퍼에서 바이트 배열로 데이터를 복사합니다. 복사가 실패하면 예외를 발생시킵니다. 실패 원인으로는 소스 데이터 범위 또는 대상 데이터 범위가 사용 가능한 범위를 벗어난 경우가 있습니다.

public void copyToByteArray(byte @Nonnull[] dest)
fun copyToByteArray(dest: Array<Byte>): Unit
public void copyToByteArray(byte[] dest)

매개 변수

이름 형식 설명
dest

copyToByteArray

버퍼에서 바이트 배열로 데이터를 복사합니다. 복사가 실패하면 예외를 발생시킵니다. 실패 원인으로는 소스 데이터 범위 또는 대상 데이터 범위가 사용 가능한 범위를 벗어난 경우가 있습니다.

public void copyToByteArray(int index, byte @Nonnull[] dest, int destIndex, int length)
fun copyToByteArray(index: Int, dest: Array<Byte>, destIndex: Int, length: Int): Unit
public void copyToByteArray(int index, byte[] dest, int destIndex, int length)

매개 변수

이름 형식 설명
index Int32
dest
destIndex Int32
length Int32

tryCopyFromByteArray

바이트 배열에서 Buffer로 데이터를 복사합니다. 복사가 성공하면 true를 반환하고, 그렇지 않으면 false를 반환합니다. 실패하는 이유는 다음과 같습니다: 소스 데이터 범위 또는 대상 데이터 범위가 사용 가능한 범위를 벗어났습니다.

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

매개 변수

이름 형식 설명
src

반환 값

형식 설명
Boolean

tryCopyFromByteArray

바이트 배열에서 Buffer로 데이터를 복사합니다. 복사가 성공하면 true를 반환하고, 그렇지 않으면 false를 반환합니다. 실패하는 이유는 다음과 같습니다: 소스 데이터 범위 또는 대상 데이터 범위가 사용 가능한 범위를 벗어났습니다.

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

매개 변수

이름 형식 설명
src
srcIndex Int32
index Int32
length Int32

반환 값

형식 설명
Boolean

tryCopyToByteArray

버퍼에서 바이트 배열로 데이터를 복사합니다. 복사가 성공하면 true를 반환하고, 그렇지 않으면 false를 반환합니다. 실패 원인으로는 원본 데이터 범위 또는 대상 데이터 범위가 유효 범위를 벗어난 경우가 있습니다.

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

매개 변수

이름 형식 설명
dest

반환 값

형식 설명
Boolean

tryCopyToByteArray

버퍼에서 바이트 배열로 데이터를 복사합니다. 복사가 성공하면 true를 반환하고, 그렇지 않으면 false를 반환합니다. 실패 원인으로는 원본 데이터 범위 또는 대상 데이터 범위가 유효 범위를 벗어난 경우가 있습니다.

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

매개 변수

이름 형식 설명
index Int32
dest
destIndex Int32
length Int32

반환 값

형식 설명
Boolean