Imaging Control 4 C Library  1.3.0
Display

The display functions provide an easy and fast way to display images. More...

Data Structures

struct  IC4_DISPLAY_STATS
 A structure containing display statistics. More...
 
struct  IC4_DISPLAY
 Represents a display that can be used to display images. More...
 

Macros

#define IC4_WINDOW_HANDLE_NULL   platform_specific
 An invalid window handle value. More...
 

Typedefs

typedef platform_specific IC4_WINDOW_HANDLE
 A window handle to be used as parent. More...
 
typedef void(* ic4_display_window_closed_handler) (struct IC4_DISPLAY *pDisplay, void *user_ptr)
 Function pointer for the window-closed handler. More...
 
typedef void(* ic4_display_window_closed_deleter) (void *user_ptr)
 Function pointer for cleanup of the device-lost user data. More...
 

Enumerations

enum  IC4_DISPLAY_TYPE { IC4_DISPLAY_DEFAULT, IC4_DISPLAY_WIN32_OPENGL }
 Defines the possible display types. More...
 
enum  IC4_DISPLAY_RENDER_POSITION {
  IC4_DISPLAY_RENDER_POSITION_TOPLEFT, IC4_DISPLAY_RENDER_POSITION_CENTER, IC4_DISPLAY_RENDER_POSITION_STRETCH_TOPLEFT, IC4_DISPLAY_RENDER_POSITION_STRETCH_CENTER,
  IC4_DISPLAY_RENDER_POSITION_CUSTOM
}
 Contains the possible display alignment and stretch modes. More...
 

Functions

bool ic4_display_create (enum IC4_DISPLAY_TYPE type, IC4_WINDOW_HANDLE parent, struct IC4_DISPLAY **ppDisplay)
 Creates a new display. More...
 
bool ic4_display_create_external_opengl (struct IC4_DISPLAY **ppDisplay)
 Creates a new external OpenGL display. More...
 
struct IC4_DISPLAYic4_display_ref (struct IC4_DISPLAY *pDisplay)
 Increases the display's internal reference count by one. More...
 
void ic4_display_unref (struct IC4_DISPLAY *pDisplay)
 Decreases the display's internal reference count by one. More...
 
bool ic4_display_display_buffer (struct IC4_DISPLAY *pDisplay, const struct IC4_IMAGE_BUFFER *buffer)
 Displays a specific image buffer. More...
 
bool ic4_display_get_stats (struct IC4_DISPLAY *pDisplay, struct IC4_DISPLAY_STATS *stats)
 Queries statistics about a display. More...
 
bool ic4_display_set_render_position (struct IC4_DISPLAY *pDisplay, enum IC4_DISPLAY_RENDER_POSITION pos, int left, int top, int width, int height)
 Configure the image scaling and alignment options for a display. More...
 
bool ic4_display_event_add_window_closed (struct IC4_DISPLAY *pDisplay, ic4_display_window_closed_handler handler, void *user_ptr, ic4_display_window_closed_deleter deleter)
 Registers a callback to be called when the display is closed. More...
 
bool ic4_display_event_remove_window_closed (struct IC4_DISPLAY *pDisplay, ic4_display_window_closed_handler handler, void *user_ptr)
 Unregisters a display-closed handler that was previously registered using ic4_display_event_add_window_closed(). More...
 
bool ic4_display_external_opengl_initialize (struct IC4_DISPLAY *pDisplay)
 Initialize the external OpenGL display. More...
 
bool ic4_display_external_opengl_render (struct IC4_DISPLAY *pDisplay, int width, int height)
 Updates the external OpenGL display with the latest image available. More...
 
bool ic4_display_external_opengl_notify_window_closed (struct IC4_DISPLAY *pDisplay)
 Notifies the external OpenGL display component that the window has been closed. More...
 

Detailed Description

The display functions provide an easy and fast way to display images.

To create a display, call ic4_display_create() or ic4_display_create_external_opengl().

Macro Definition Documentation

◆ IC4_WINDOW_HANDLE_NULL

#define IC4_WINDOW_HANDLE_NULL   platform_specific

An invalid window handle value.

When passed to a function, this value specifies that no parent window is set.

The value of IC4_WINDOW_HANDLE_NULL is platform-specific.

Typedef Documentation

◆ ic4_display_window_closed_deleter

typedef void(* ic4_display_window_closed_deleter) (void *user_ptr)

Function pointer for cleanup of the device-lost user data.

Parameters
[in]user_ptrUser data that was specified when calling ic4_grabber_event_add_device_lost()

◆ ic4_display_window_closed_handler

typedef void(* ic4_display_window_closed_handler) (struct IC4_DISPLAY *pDisplay, void *user_ptr)

Function pointer for the window-closed handler.

Parameters
[in]pDisplayPointer to the display whose window was closed
[in]user_ptrUser data that was specified when calling ic4_display_event_add_window_closed()

◆ IC4_WINDOW_HANDLE

typedef platform_specific IC4_WINDOW_HANDLE

A window handle to be used as parent.

The type of IC4_WINDOW_HANDLE is platform-specific.

Enumeration Type Documentation

◆ IC4_DISPLAY_RENDER_POSITION

Contains the possible display alignment and stretch modes.

Enumerator
IC4_DISPLAY_RENDER_POSITION_TOPLEFT 

Display images unscaled at the top left corner of the window.

IC4_DISPLAY_RENDER_POSITION_CENTER 

Display images unscaled an the center of the window.

IC4_DISPLAY_RENDER_POSITION_STRETCH_TOPLEFT 

Display images stretched at the top left corner of the window.

IC4_DISPLAY_RENDER_POSITION_STRETCH_CENTER 

Display images stretched at the center of the window.

IC4_DISPLAY_RENDER_POSITION_CUSTOM 

Display images at custom coordinates.

◆ IC4_DISPLAY_TYPE

Defines the possible display types.

Enumerator
IC4_DISPLAY_DEFAULT 

Selects the platform's default display type.

For Windows, this is IC4_DISPLAY_WIN32_OPENGL.

IC4_DISPLAY_WIN32_OPENGL 

Optimized OpenGL display for Windows platform.

Function Documentation

◆ ic4_display_create()

bool ic4_display_create ( enum IC4_DISPLAY_TYPE  type,
IC4_WINDOW_HANDLE  parent,
struct IC4_DISPLAY **  ppDisplay 
)

Creates a new display.

Parameters
[in]typeThe type of display to create
[in]parentHandle to the parent window to embed the display into.
[out]ppDisplayPointer to receive the handle to the new display object.
When the display is no longer required, release the object reference using ic4_display_unref().
Returns
true on success, otherwise false.
Use ic4_get_last_error() to query error information.
Warning
This function only works in Windows platforms. For other platforms, use ic4_display_create_external_opengl().
See also
ic4_display_unref

◆ ic4_display_create_external_opengl()

bool ic4_display_create_external_opengl ( struct IC4_DISPLAY **  ppDisplay)

Creates a new external OpenGL display.

Parameters
[out]ppDisplayPointer to receive the handle to the new display object.
When the display is no longer required, release the object reference using ic4_display_unref().
Returns
true on success, otherwise false.
Use ic4_get_last_error() to query error information.
Remarks
To use the external renderer, the application has to follow these steps:
See also
ic4_display_unref

◆ ic4_display_display_buffer()

bool ic4_display_display_buffer ( struct IC4_DISPLAY pDisplay,
const struct IC4_IMAGE_BUFFER buffer 
)

Displays a specific image buffer.

Parameters
[in]pDisplayA display
[in]bufferThe buffer to display
Remarks
It is not always necessary to call this function.
When a display is registered with a IC4_GRABBER using ic4_grabber_set_display(), images are displayed automatically.
Returns
true on success, otherwise false.
Use ic4_get_last_error() to query error information.
Remarks
When buffer is NULL, the display is cleared and will no longer display the previous buffer.

◆ ic4_display_event_add_window_closed()

bool ic4_display_event_add_window_closed ( struct IC4_DISPLAY pDisplay,
ic4_display_window_closed_handler  handler,
void *  user_ptr,
ic4_display_window_closed_deleter  deleter 
)

Registers a callback to be called when the display is closed.

Parameters
[in]pDisplayA display
[in]handlerThe function to be called when the display is closed
[in]user_ptrUser data to be passed in calls to handler.
[in]deleterA function to be called when the handler was unregistered and the user_ptr will no longer be required.
The deleter function can be used to release data associated with user_ptr.
The deleter function will be called when the display-closed handler is unregistered, or the display object itself is destroyed.
Note
To unregister a display-closed handler, call ic4_display_event_remove_window_closed().
Returns
true on success, otherwise false.
Use ic4_get_last_error() to query error information.

◆ ic4_display_event_remove_window_closed()

bool ic4_display_event_remove_window_closed ( struct IC4_DISPLAY pDisplay,
ic4_display_window_closed_handler  handler,
void *  user_ptr 
)

Unregisters a display-closed handler that was previously registered using ic4_display_event_add_window_closed().

Parameters
[in]pDisplayThe display on which the callback is currently registered
[in]handlerPointer to the function to be unregistered
[in]user_ptrUser data that the function was previously registered with
Note
The pair of handler and user_ptr has to be an exact match to the parameters used in the call to ic4_display_event_add_window_closed().
Returns
true on success, otherwise false.
Use ic4_get_last_error() to query error information.

◆ ic4_display_external_opengl_initialize()

bool ic4_display_external_opengl_initialize ( struct IC4_DISPLAY pDisplay)

Initialize the external OpenGL display.

Parameters
[in]pDisplayThe external OpenGL display
Returns
true on success, otherwise false.
Use ic4_get_last_error() to query error information.
Remarks
This function must be called with the OpenGL context activated for the executing thread (e.g. makeCurrent).

◆ ic4_display_external_opengl_notify_window_closed()

bool ic4_display_external_opengl_notify_window_closed ( struct IC4_DISPLAY pDisplay)

Notifies the external OpenGL display component that the window has been closed.

Parameters
[in]pDisplayThe external OpenGL display
Returns
true on success, otherwise false.
Use ic4_get_last_error() to query error information.

◆ ic4_display_external_opengl_render()

bool ic4_display_external_opengl_render ( struct IC4_DISPLAY pDisplay,
int  width,
int  height 
)

Updates the external OpenGL display with the latest image available.

Parameters
[in]pDisplayThe external OpenGL display
[in]widthWidth of the display window in physical pixels
[in]heightHeight of the display window in physical pixels
Returns
true on success, otherwise false.
Use ic4_get_last_error() to query error information.
Remarks
This function must be called with the OpenGL context activated for the executing thread (e.g. makeCurrent).

◆ ic4_display_get_stats()

bool ic4_display_get_stats ( struct IC4_DISPLAY pDisplay,
struct IC4_DISPLAY_STATS stats 
)

Queries statistics about a display.

Parameters
[in]pDisplayA display
[out]statsPointer to a IC4_DISPLAY_STATS structure receiving statistics about the display
Returns
true on success, otherwise false.
Use ic4_get_last_error() to query error information.

◆ ic4_display_ref()

struct IC4_DISPLAY* ic4_display_ref ( struct IC4_DISPLAY pDisplay)

Increases the display's internal reference count by one.

Parameters
[in]pDisplayA pointer to a display
Returns
The pointer passed via pDisplay
Remarks
If pDisplay is NULL, the function returns NULL. An error value is not set.
See also
ic4_display_unref

◆ ic4_display_set_render_position()

bool ic4_display_set_render_position ( struct IC4_DISPLAY pDisplay,
enum IC4_DISPLAY_RENDER_POSITION  pos,
int  left,
int  top,
int  width,
int  height 
)

Configure the image scaling and alignment options for a display.

Parameters
[in]pDisplayA display
[in]posThe scaling and alignment mode to use
[in]leftThe left coordinate of the target rectangle inside the display window
[in]topThe top coordinate of the target rectangle inside the display window
[in]widthThe width of the target rectangle inside the display window
[in]heightThe height of the target rectangle inside the display window
Remarks
The left, top, width and height parameters are ignored unless pos is IC4_DISPLAY_RENDER_POSITION_CUSTOM.
A zoom effect can be created by setting width and height to a multiple of the width and height of the image buffer(s) to be displayed. Set left and top to negative values to specifiy the top left corner of the visible image.
Returns
true on success, otherwise false.
Use ic4_get_last_error() to query error information.

◆ ic4_display_unref()

void ic4_display_unref ( struct IC4_DISPLAY pDisplay)

Decreases the display's internal reference count by one.

If the reference count reaches zero, the object is destroyed.

Parameters
[in]pDisplayA pointer to a display
Remarks
If pDisplay is NULL, the function does nothing. An error value is not set.
See also
ic4_display_ref