Class Image
- 네임스페이스
- easyar
Image는 이미지 데이터를 저장하며 메모리 내 이미지를 나타냅니다. Image는 원시 데이터에 대한 접근을 바이트 배열 형태로 제공하며, 너비/높이(width/height) 등의 정보에 접근하는 인터페이스도 제공합니다. EasyAR Sense의 모든 버전에서 이미지 데이터에 접근할 수 있습니다. iOS에서는 다음과 같이 접근합니다.
#import <easyar/buffer.oc.h>
#import <easyar/image.oc.h>
easyar_OutputFrame * outputFrame = [outputFrameBuffer peek];
if (outputFrame != nil) {
easyar_Image * i = [[outputFrame inputFrame] image];
easyar_Buffer * b = [i buffer];
char * bytes = calloc([b size], 1);
memcpy(bytes, [b data], [b size]);
// 여기서 bytes 사용
free(bytes);
}
Android에서는,
import cn.easyar.*;
OutputFrame outputFrame = outputFrameBuffer.peek();
if (outputFrame != null) {
InputFrame inputFrame = outputFrame.inputFrame();
Image i = inputFrame.image();
Buffer b = i.buffer();
byte[] bytes = new byte[b.size()];
b.copyToByteArray(0, bytes, 0, bytes.length);
// 여기서 bytes 사용
b.dispose();
i.dispose();
inputFrame.dispose();
outputFrame.dispose();
}
Image
생성자
Image
void easyar_Image__ctor(easyar_Buffer * buffer, easyar_PixelFormat format, int width, int height, easyar_Image * * Return)
Image(std::shared_ptr<Buffer> buffer, PixelFormat format, int width, int height)
public Image(@Nonnull Buffer buffer, int format, int width, int height)
constructor(buffer: Buffer, format: Int, width: Int, height: Int)
+ (easyar_Image *) create:(easyar_Buffer *)buffer format:(easyar_PixelFormat)format width:(int)width height:(int)height
public convenience init(_ buffer: Buffer, _ format: PixelFormat, _ width: Int32, _ height: Int32)
public Image(Buffer buffer, PixelFormat format, int width, int height)
매개 변수
| 이름 | 형식 | 설명 |
|---|---|---|
| buffer | Buffer | |
| format | PixelFormat | |
| width | Int32 | |
| height | Int32 |
메서드
buffer
이미지의 데이터 버퍼를 반환합니다. Buffer API를 사용하여 내부 데이터에 접근할 수 있습니다. 획득한 Buffer 데이터의 내용을 수정해서는 안됩니다. 이 내용은 다른 스레드에서 사용될 수 있기 때문입니다.
void easyar_Image_buffer(const easyar_Image * This, easyar_Buffer * * Return)
std::shared_ptr<Buffer> buffer()
public @Nonnull Buffer buffer()
fun buffer(): Buffer
- (easyar_Buffer *)buffer
public func buffer() -> Buffer
public virtual Buffer buffer()
반환 값
| 형식 | 설명 |
|---|---|
| Buffer |
format
이미지 형식 반환
easyar_PixelFormat easyar_Image_format(const easyar_Image * This)
PixelFormat format()
public int format()
fun format(): Int
- (easyar_PixelFormat)format
public func format() -> PixelFormat
public virtual PixelFormat format()
반환 값
| 형식 | 설명 |
|---|---|
| PixelFormat |
width
이미지 너비를 반환합니다. 이미지 데이터의 오른쪽에는 pixelWidth - width 픽셀의 패딩이 있습니다.
int easyar_Image_width(const easyar_Image * This)
int width()
public int width()
fun width(): Int
- (int)width
public func width() -> Int32
public virtual int width()
반환 값
| 형식 | 설명 |
|---|---|
| Int32 |
height
이미지 높이를 반환합니다. 이미지 데이터의 아래쪽에는 pixelHeight - height 픽셀의 패딩이 있을 것입니다.
int easyar_Image_height(const easyar_Image * This)
int height()
public int height()
fun height(): Int
- (int)height
public func height() -> Int32
public virtual int height()
반환 값
| 형식 | 설명 |
|---|---|
| Int32 |
pixelWidth
이미지 인코딩 시 사용된 픽셀 너비를 반환합니다
int easyar_Image_pixelWidth(const easyar_Image * This)
int pixelWidth()
public int pixelWidth()
fun pixelWidth(): Int
- (int)pixelWidth
public func pixelWidth() -> Int32
public virtual int pixelWidth()
반환 값
| 형식 | 설명 |
|---|---|
| Int32 |
pixelHeight
이미지 인코딩 시 사용되는 픽셀 높이를 반환합니다.
int easyar_Image_pixelHeight(const easyar_Image * This)
int pixelHeight()
public int pixelHeight()
fun pixelHeight(): Int
- (int)pixelHeight
public func pixelHeight() -> Int32
public virtual int pixelHeight()
반환 값
| 형식 | 설명 |
|---|---|
| Int32 |
create
void easyar_Image_create(easyar_Buffer * buffer, easyar_PixelFormat format, int width, int height, int pixelWidth, int pixelHeight, easyar_Image * * Return)
static std::shared_ptr<Image> create(std::shared_ptr<Buffer> buffer, PixelFormat format, int width, int height, int pixelWidth, int pixelHeight)
public static @Nonnull Image create(@Nonnull Buffer buffer, int format, int width, int height, int pixelWidth, int pixelHeight)
companion object fun create(buffer: Buffer, format: Int, width: Int, height: Int, pixelWidth: Int, pixelHeight: Int): Image
+ (easyar_Image *)create:(easyar_Buffer *)buffer format:(easyar_PixelFormat)format width:(int)width height:(int)height pixelWidth:(int)pixelWidth pixelHeight:(int)pixelHeight
public static func create(_ buffer: Buffer, _ format: PixelFormat, _ width: Int32, _ height: Int32, _ pixelWidth: Int32, _ pixelHeight: Int32) -> Image
public static Image create(Buffer buffer, PixelFormat format, int width, int height, int pixelWidth, int pixelHeight)
매개 변수
| 이름 | 형식 | 설명 |
|---|---|---|
| buffer | Buffer | |
| format | PixelFormat | |
| width | Int32 | |
| height | Int32 | |
| pixelWidth | Int32 | |
| pixelHeight | Int32 |
반환 값
| 형식 | 설명 |
|---|---|
| Image |