Skip to content


The library display_lib provides functions to display image data in a simple window. The library does not replace a GUI toolkit and is intended only for debugging purposes for applications without a GUI. In particular, the library does not implement features for scaling or transforming images and is limited to display image data up to the size of the screen.

To use the library, the include file SisoDisplay.h should be added to the source code.

#include <SisoDisplay.h>

Additionally, display_lib.lib should be added to your Microsoft Visual Studio Project, or to your Linux project. If you use CMake, the package name is SisoDisplayLib, the libraries are stored in the variable ${SISODISPLAYLIB_LIBRARIES} and the the include directory is stored in the variable ${SISODISPLAYLIB_INCLUDE_DIR}. See Prerequisites for more details on projects and how to use CMake.

Creating a Display Window#

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);

To create a display window, the function CreateDisplay() can be called. The function expects the bits per pixel and the window dimensions in the parameters. If the call succeeds, it will return a value equal or greater than zero, which is an identifier for the display window. In case of an error, a negative value is returned.

If the display window is no longer needed, the function CloseDisplay() should be called.

The image buffer dimensions for the display window are initially set to the same width and height as the window. If the image to be displayed is very large, the window size can be set to smaller dimensions and the function SetBufferWidth() can be called to set the buffer size for the image data.


The display library is limited to handle images up to 2 GB.

The following example shows how to create a display window matching the image dimensions and pixel format of the applet:

// get image dimensions and pixel format from applet
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 ...


Drawing to the Display Window#

void DrawBuffer(
    int id,
    const void * buffer,
    int frameNumber,
    const char * title);

To draw the image data in the display window, the function DrawBuffer() can be called. The function expects the display window id in the first parameter and a pointer to the buffer which contains the image data in the second parameter. The remaining two parameters can be used to display a frame number and some text in the title of the display window.

The following example shows how to display the image data in a simple acquisition loop:

frameindex_t nextFrame = 1;
while (true) {
    // wait for new image(s)
    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 ...
Back to top