display_lib#
라이브러리를 사용하려면 include 파일인 SisoDisplay.h 을(를) 소스 코드에 추가해야 합니다.
#include <SisoDisplay.h>
추가로, display_lib.lib 을(를) Microsoft Visual Studio 프로젝트에 추가해야 하며, Linux 프로젝트의 경우 libdisplay_lib.so 을(를) Linux 프로젝트에 추가합니다. CMake를 사용하는 경우 패키지 이름은 SisoDisplayLib이며 라이브러리는 다음 변수에 저장됩니다. ${SISODISPLAYLIB_LIBRARIES} 그리고 include 디렉토리는 다음 변수에 저장됩니다. ${SISODISPLAYLIB_INCLUDE_DIR}. 프로젝트 및 CMake 사용 방법에 대한 자세한 내용은 전제 조건 을(를) 참조하십시오.
디스플레이 창 생성#
int CreateDisplay(
unsigned int bitsPerPixel,
unsigned int width,
unsigned int height);
void CloseDisplay(
int id);
void SetBufferWidth(
int id,
unsigned int width,
unsigned int height);
디스플레이 창을 생성하려면 다음 함수를 호출할 수 있습니다. CreateDisplay() 이 함수는 매개변수로 픽셀당 비트 수와 창 크기를 요구합니다. 호출에 성공하면 디스플레이 창의 식별자인 0 이상의 값이 반환됩니다. 오류가 발생하면 음수 값이 반환됩니다.
디스플레이 창이 더 이상 필요하지 않으면 다음 함수를 호출해야 합니다. CloseDisplay() should be called.
디스플레이 창의 이미지 버퍼 크기는 초기화 시 창과 동일한 너비 및 높이로 설정됩니다. 표시할 이미지가 매우 큰 경우 창 크기를 더 작게 설정하고 다음 함수를 호출하여 이미지 데이터의 버퍼 크기를 설정할 수 있습니다. SetBufferWidth() can be called to set the buffer size for the image data.
정보
디스플레이 라이브러리는 최대 2GB의 이미지만 처리하도록 제한됩니다.
다음 예시는 앱들의 이미지 크기 및 Pixel Format에 맞는 디스플레이 창을 생성하는 방법을 보여줍니다.
// get image dimensions and pixel format from applet
int result = FG_INVALID_PARAMETER;
int width = 0, height = 0, fgFormat = 0;
int widthId = Fg_getParameterIdByName(fg, "FG_WIDTH");
int heightId = Fg_getParameterIdByName(fg, "FG_HEIGHT");
int fgFormatId = Fg_getParameterIdByName(fg, "FG_FORMAT");
if (widthId > 0 && heightId > 0 && fgFormatId > 0) {
result = Fg_getParameterWithType(fg, widthId, &width, dma);
if (result == FG_OK) {
result = Fg_getParameterWithType(fg, heightId, &height, dma);
}
if (result == FG_OK) {
result = Fg_getParameterWithType(fg, fgFormatId, &fgFormat, dma);
}
}
// get number of bits per pixel for the format
int bitsPerPixel = FG_INVALID_VALUE;
if (result == FG_OK) {
bitsPerPixel = Fg_getBitsPerPixel(fgFormat);
}
if (bitsPerPixel <= 0) {
result = FG_INVALID_VALUE;
}
// create a display
int display = FG_INVALID_HANDLE;
if (result == FG_OK) {
display = CreateDisplay(bitsPerPixel, width, height);
}
if (display >= 0) {
// use display ...
CloseDisplay(display);
}
디스플레이 창에 그리기#
void DrawBuffer(
int id,
const void * buffer,
int frameNumber,
const char * title);
디스플레이 창에 이미지 데이터를 그리려면 다음 함수를 DrawBuffer() 호출할 수 있습니다. 이 함수는 첫 번째 매개변수에서 디스플레이 창 ID를, 두 번째 매개변수에서 이미지 데이터가 포함된 버퍼에 대한 포인터를 요구합니다. 나머지 두 매개변수는 디스플레이 창의 제목에 프레임 번호와 일부 텍스트를 표시하는 데 사용할 수 있습니다.
다음 예시는 간단한 취득 루프에서 이미지 데이터를 표시하는 방법을 보여줍니다.
frameindex_t nextFrame = 1;
while (true) {
// wait for new images
frameindex_t newestFrame =
Fg_getLastPicNumberBlockingEx(fg, nextFrame, dma,
timeoutInSeconds, mem);
if (newestFrame > 0) {
// get pointer to current frame buffer
void * ptr = Fg_getImagePtrEx(fg, newestFrame, dma, mem);
// draw current frame buffer
DrawBuffer(display, ptr, newestFrame & 0x7fffffff,
"A Sample Image Display");
// calculate next frame
nextFrame = (newestFrame < FRAMEINDEX_MAX) ? newestFrame + 1 : 1;
} else {
// handle error ...
}
}