Imaging Control 4 C++ Library 1.0.0
Loading...
Searching...
No Matches
Display Class Reference

Represents a display that can be used to display images. More...

Public Types

using WindowClosedHandler = std::function< void(Display &display)>
 Function prototype for window-closed event handlers.
 
using NotificationToken = void *
 Represents a registered callback.
 

Public Member Functions

bool displayBuffer (const std::shared_ptr< ic4::ImageBuffer > &buffer, Error &err=Error::Default())
 Displays a specific image buffer.
 
bool setRenderPosition (DisplayRenderPosition pos, int left=-1, int top=-1, int width=-1, int height=-1, Error &err=Error::Default())
 Configure the image scaling and alignment options for a display.
 
DisplayStatistics statistics (Error &err=Error::Default())
 Queries display statistics.
 
NotificationToken eventAddWindowClosed (WindowClosedHandler cb, Error &err=Error::Default())
 Registers a new window-closed event handler.
 
bool eventRemoveWindowClosed (NotificationToken token, Error &err=Error::Default())
 Unregisters a window-closed event handler.
 

Static Public Member Functions

static std::shared_ptr< Displaycreate (DisplayType type, WindowHandle hParent, Error &err=Error::Default())
 Creates a new display.
 

Friends

class Grabber
 

Detailed Description

Represents a display that can be used to display images.

To create a display, call Display::create().

Display objects are generally used in two distinct ways:

Display objects are neither copyable nor movable, and are only handled via std::shared_ptr<Display>.

Note
Some functions, such as Grabber::streamSetup(), takes shared ownership of the display object. The display is kept alive by the Grabber instance even if no external reference to the display object exists.
See also
Display::create

Member Typedef Documentation

◆ NotificationToken

using NotificationToken = void*

Represents a registered callback.

When a callback function is registered using Display::eventAddWindowClosed, a token is returned.

The token can then be used to remove the callback using Display::eventRemoveWindowClosed at a later time.

◆ WindowClosedHandler

using WindowClosedHandler = std::function<void(Display& display)>

Function prototype for window-closed event handlers.

Parameters
[in]displayThe Display on which the event handler was registered.

Member Function Documentation

◆ create()

static std::shared_ptr< Display > create ( DisplayType  type,
WindowHandle  hParent,
Error err = Error::Default() 
)
inlinestatic

Creates a new display.

Parameters
[in]typeThe type of display to create
[in]hParentHandle to the parent window to embed the display into.
[out]errReference to an error handler. See Error Handling for details.
Returns
The new display, or nullptr if an error occurs.
Note
Some displays/platforms allow creating floating display windows when passing a null handle as parent.

◆ displayBuffer()

bool displayBuffer ( const std::shared_ptr< ic4::ImageBuffer > &  buffer,
Error err = Error::Default() 
)
inline

Displays a specific image buffer.

Parameters
[in]bufferThe buffer to display
[out]errReference to an error handler. See Error Handling for details.
Returns
true on success, otherwise false.
Remarks
When buffer is nullptr, the display is cleared and will no longer display the previous buffer.

◆ eventAddWindowClosed()

NotificationToken eventAddWindowClosed ( WindowClosedHandler  cb,
Error err = Error::Default() 
)
inline

Registers a new window-closed event handler.

Parameters
[in]cbCallback function to be called when the display window is closed.
[out]errReference to an error handler. See Error Handling for details.
Returns
A token that can be used to unregister the callback using .\n If an error occurrs, the function returns nullptr.
See also
Display::eventRemoveWindowClosed

◆ eventRemoveWindowClosed()

bool eventRemoveWindowClosed ( NotificationToken  token,
Error err = Error::Default() 
)
inline

Unregisters a window-closed event handler.

Parameters
[in]tokenA token that was returned when registering an event handler using Display::eventAddWindowClosed().
[out]errReference to an error handler. See Error Handling for details.
Returns
true on success, otherwise false.
See also
Display::eventAddWindowClosed

◆ setRenderPosition()

bool setRenderPosition ( DisplayRenderPosition  pos,
int  left = -1,
int  top = -1,
int  width = -1,
int  height = -1,
Error err = Error::Default() 
)
inline

Configure the image scaling and alignment options for a display.

Parameters
[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
[out]errReference to an error handler. See Error Handling for details.
Returns
true on success, otherwise false.
Remarks
The left, top, width and height parameters are ignored unless mode is DisplayRenderPosition::Custom.

◆ statistics()

DisplayStatistics statistics ( Error err = Error::Default())
inline

Queries display statistics.

Parameters
[out]errReference to an error handler. See Error Handling for details.
Returns
A DisplayStatistics structure containing the number of displayed and dropped frames.