The CImg Library - C++ Template Image Processing Toolkit





[ Main ] [ News] [ Download ] [ Screenshots ] [ FAQ ] [ Tutorial ] [ Documentation ] [ Forum ] [ Chat ] [ Links ]

CImgDisplay Struct Reference

This class represents a window which can display CImg images and handles mouse and keyboard events. More...

List of all members.

Constructors / Destructor / Instance Management

 ~CImgDisplay ()
 Destructor.
 CImgDisplay ()
 Create an empty display window.
 CImgDisplay (const unsigned int width, const unsigned int height, const char *title=0, const unsigned int normalization=3, const bool is_fullscreen=false, const bool is_closed=false)
 Create a display window with a specified size pwidth x height.
template<typename T >
 CImgDisplay (const CImg< T > &img, const char *title=0, const unsigned int normalization=3, const bool is_fullscreen=false, const bool is_closed=false)
 Create a display window from an image.
template<typename T >
 CImgDisplay (const CImgList< T > &list, const char *title=0, const unsigned int normalization=3, const bool is_fullscreen=false, const bool is_closed=false)
 Create a display window from an image list.
 CImgDisplay (const CImgDisplay &disp)
 Create a display window by copying another one.
CImgDisplayassign ()
 In-place version of the destructor.
CImgDisplayassign (const unsigned int width, const unsigned int height, const char *title=0, const unsigned int normalization=3, const bool is_fullscreen=false, const bool is_closed=false)
 In-place version of the constructor.
template<typename T >
CImgDisplayassign (const CImg< T > &img, const char *title=0, const unsigned int normalization=3, const bool is_fullscreen=false, const bool is_closed=false)
 In-place version of the constructor.
template<typename T >
CImgDisplayassign (const CImgList< T > &list, const char *title=0, const unsigned int normalization=3, const bool is_fullscreen=false, const bool is_closed=false)
 In-place version of the constructor.
CImgDisplayassign (const CImgDisplay &disp)
 In-place version of the constructor.
static CImgDisplayempty ()
 Return a reference to an empty display.

Overloaded Operators

template<typename t >
CImgDisplayoperator= (const CImg< t > &img)
template<typename t >
CImgDisplayoperator= (const CImgList< t > &list)
CImgDisplayoperator= (const CImgDisplay &disp)
 Operator=().
 operator bool () const
 Return true if display is not empty.

Instance Checking

bool is_empty () const
 Return true is display is empty.
bool is_closed () const
bool is_resized () const
bool is_moved () const
bool is_event () const
bool is_fullscreen () const
bool is_keyESC () const
bool is_keyF1 () const
bool is_keyF2 () const
bool is_keyF3 () const
bool is_keyF4 () const
bool is_keyF5 () const
bool is_keyF6 () const
bool is_keyF7 () const
bool is_keyF8 () const
bool is_keyF9 () const
bool is_keyF10 () const
bool is_keyF11 () const
bool is_keyF12 () const
bool is_keyPAUSE () const
bool is_key1 () const
bool is_key2 () const
bool is_key3 () const
bool is_key4 () const
bool is_key5 () const
bool is_key6 () const
bool is_key7 () const
bool is_key8 () const
bool is_key9 () const
bool is_key0 () const
bool is_keyBACKSPACE () const
bool is_keyINSERT () const
bool is_keyHOME () const
bool is_keyPAGEUP () const
bool is_keyTAB () const
bool is_keyQ () const
bool is_keyW () const
bool is_keyE () const
bool is_keyR () const
bool is_keyT () const
bool is_keyY () const
bool is_keyU () const
bool is_keyI () const
bool is_keyO () const
bool is_keyP () const
bool is_keyDELETE () const
bool is_keyEND () const
bool is_keyPAGEDOWN () const
bool is_keyCAPSLOCK () const
bool is_keyA () const
bool is_keyS () const
bool is_keyD () const
bool is_keyF () const
bool is_keyG () const
bool is_keyH () const
bool is_keyJ () const
bool is_keyK () const
bool is_keyL () const
bool is_keyENTER () const
bool is_keySHIFTLEFT () const
bool is_keyZ () const
bool is_keyX () const
bool is_keyC () const
bool is_keyV () const
bool is_keyB () const
bool is_keyN () const
bool is_keyM () const
bool is_keySHIFTRIGHT () const
bool is_keyARROWUP () const
bool is_keyCTRLLEFT () const
bool is_keyAPPLEFT () const
bool is_keyALT () const
bool is_keySPACE () const
bool is_keyALTGR () const
bool is_keyAPPRIGHT () const
bool is_keyMENU () const
bool is_keyCTRLRIGHT () const
bool is_keyARROWLEFT () const
bool is_keyARROWDOWN () const
bool is_keyARROWRIGHT () const
bool is_keyPAD0 () const
bool is_keyPAD1 () const
bool is_keyPAD2 () const
bool is_keyPAD3 () const
bool is_keyPAD4 () const
bool is_keyPAD5 () const
bool is_keyPAD6 () const
bool is_keyPAD7 () const
bool is_keyPAD8 () const
bool is_keyPAD9 () const
bool is_keyPADADD () const
bool is_keyPADSUB () const
bool is_keyPADMUL () const
bool is_keyPADDIV () const
bool is_key (const unsigned int key) const
bool is_key (const char *const textcode) const
 Get keycode corresponding to given input string.
bool is_key_sequence (const unsigned int *const key_sequence, const unsigned int length, const bool remove_sequence=false)
 Test if a key sequence has been typed.

Instance Characteristics

int width () const
 Return display width.
int height () const
 Return display height.
int mouse_x () const
 Return X-coordinate of the mouse pointer.
int mouse_y () const
 Return Y-coordinate of the mouse pointer.
unsigned int button () const
 Return current or previous state of the mouse buttons.
int wheel () const
 Return current state of the mouse wheel.
unsigned int key (const unsigned int pos=0) const
 Return current or previous state of the keyboard.
unsigned int released_key (const unsigned int pos=0) const
unsigned int normalization () const
 Return normalization type of the display.
const char * title () const
 Return title of the display.
int window_width () const
 Return display window width.
int window_height () const
 Return display window height.
int window_x () const
 Return X-coordinate of the window.
int window_y () const
 Return Y-coordinate of the window.
float frames_per_second ()
 Return the frame per second rate.
static unsigned int keycode (const char *const textcode)
 Get keycode corresponding to given input string.
static int screen_width ()
 Return the width of the screen resolution.
static int screen_height ()
 Return the height of the screen resolution.

Display Manipulation

template<typename T >
CImgDisplaydisplay (const CImg< T > &img)
 Display an image in a window.
template<typename T >
CImgDisplaydisplay (const CImgList< T > &list, const char axis='x', const char align='p')
 Display an image list CImgList<T> into a display window.
CImgDisplayresize (const bool redraw=true)
 Resize a display window in its current size.
template<typename T >
CImgDisplayresize (const CImg< T > &img, const bool redraw=true)
 Resize a display window with the size of an image.
CImgDisplayresize (const CImgDisplay &disp, const bool redraw=true)
 Resize a display window using the size of the given display disp.
CImgDisplayresize (const int width, const int height, const bool redraw=true)
 Resize window.
CImgDisplayset_fullscreen (const bool is_fullscreen, const bool redraw=true)
 Set fullscreen mode.
CImgDisplaytoggle_fullscreen (const bool redraw=true)
 Toggle fullscreen mode.
CImgDisplayshow ()
 Show a closed display.
CImgDisplayclose ()
 Close a visible display.
CImgDisplaymove (const int pos_x, const int pos_y)
 Move window.
CImgDisplayshow_mouse ()
 Show mouse pointer.
CImgDisplayhide_mouse ()
 Hide mouse pointer.
CImgDisplayset_mouse (const int pos_x, const int pos_y)
 Move mouse pointer to a specific location.
CImgDisplayset_title (const char *format,...)
 Set the window title.
template<typename T >
CImgDisplayrender (const CImg< T > &img)
 Render image buffer into GDI native image format.
CImgDisplaypaint ()
 Re-paint image content in window.
template<typename T >
const CImgDisplaysnapshot (CImg< T > &img) const
 Take a snapshot of the display in the specified image.
CImgDisplayset_button ()
 Simulate a mouse button event.
CImgDisplayset_button (const unsigned int button, const bool is_pressed=true)
CImgDisplayset_wheel ()
 Simulate a mouse wheel event, or flush wheel events.
CImgDisplayset_wheel (const int amplitude)
CImgDisplayset_key ()
 Simulate a keyboard press/release event, or flush all key events.
CImgDisplayset_key (const unsigned int keycode, const bool pressed=true)
CImgDisplayflush ()
 Flush all display events.
CImgDisplaywait (const unsigned int milliseconds)
 Synchronized waiting function. Same as cimg::wait().
CImgDisplaywait ()
 Wait for an event occuring on the current display.
static void wait (CImgDisplay &disp1)
 Wait for any event occuring on the display disp1.
static void wait (CImgDisplay &disp1, CImgDisplay &disp2)
 Wait for any event occuring either on the display disp1 or disp2.
static void wait (CImgDisplay &disp1, CImgDisplay &disp2, CImgDisplay &disp3)
 Wait for any event occuring either on the display disp1, disp2 or disp3.
static void wait (CImgDisplay &disp1, CImgDisplay &disp2, CImgDisplay &disp3, CImgDisplay &disp4)
 Wait for any event occuring either on the display disp1, disp2, disp3 or disp4.
static void wait (CImgDisplay &disp1, CImgDisplay &disp2, CImgDisplay &disp3, CImgDisplay &disp4, CImgDisplay &disp5)
 Wait for any event occuring either on the display disp1, disp2, disp3, disp4 or disp5.
static void wait (CImgDisplay &disp1, CImgDisplay &disp2, CImgDisplay &disp3, CImgDisplay &disp4, CImgDisplay &disp5, CImgDisplay &disp6)
 Wait for any event occuring either on the display disp1, disp2, disp3, disp4, ... disp6.
static void wait (CImgDisplay &disp1, CImgDisplay &disp2, CImgDisplay &disp3, CImgDisplay &disp4, CImgDisplay &disp5, CImgDisplay &disp6, CImgDisplay &disp7)
 Wait for any event occuring either on the display disp1, disp2, disp3, disp4, ... disp7.
static void wait (CImgDisplay &disp1, CImgDisplay &disp2, CImgDisplay &disp3, CImgDisplay &disp4, CImgDisplay &disp5, CImgDisplay &disp6, CImgDisplay &disp7, CImgDisplay &disp8)
 Wait for any event occuring either on the display disp1, disp2, disp3, disp4, ... disp8.
static void wait (CImgDisplay &disp1, CImgDisplay &disp2, CImgDisplay &disp3, CImgDisplay &disp4, CImgDisplay &disp5, CImgDisplay &disp6, CImgDisplay &disp7, CImgDisplay &disp8, CImgDisplay &disp9)
 Wait for any event occuring either on the display disp1, disp2, disp3, disp4, ... disp9.
static void wait (CImgDisplay &disp1, CImgDisplay &disp2, CImgDisplay &disp3, CImgDisplay &disp4, CImgDisplay &disp5, CImgDisplay &disp6, CImgDisplay &disp7, CImgDisplay &disp8, CImgDisplay &disp9, CImgDisplay &disp10)
 Wait for any event occuring either on the display disp1, disp2, disp3, disp4, ... disp10.
static void wait_all ()
 Wait for a window event in any CImg window.


Detailed Description

This class represents a window which can display CImg images and handles mouse and keyboard events.

Creating a CImgDisplay instance opens a window that can be used to display a CImg<T> image of a CImgList<T> image list inside. When a display is created, associated window events (such as mouse motion, keyboard and window size changes) are handled and can be easily detected by testing specific CImgDisplay data fields. See Using Display Windows. for a complete tutorial on using the CImgDisplay class.


Constructor & Destructor Documentation

CImgDisplay ( const unsigned int  width,
const unsigned int  height,
const char *  title = 0,
const unsigned int  normalization = 3,
const bool  is_fullscreen = false,
const bool  is_closed = false 
)

Create a display window with a specified size pwidth x height.

Parameters:
width Width of the display window.
height Height of the display window.
title Title of the display window.
normalization Normalization type of the display window (0=none, 1=always, 2=once).
is_fullscreen : Fullscreen mode.
is_closed : Initially visible mode. A black image will be initially displayed in the display window.

CImgDisplay ( const CImg< T > &  img,
const char *  title = 0,
const unsigned int  normalization = 3,
const bool  is_fullscreen = false,
const bool  is_closed = false 
) [explicit]

Create a display window from an image.

Parameters:
img : Image that will be used to create the display window.
title : Title of the display window
normalization : Normalization type of the display window.
is_fullscreen : Fullscreen mode.
is_closed : Initially visible mode.

CImgDisplay ( const CImgList< T > &  list,
const char *  title = 0,
const unsigned int  normalization = 3,
const bool  is_fullscreen = false,
const bool  is_closed = false 
) [explicit]

Create a display window from an image list.

Parameters:
list : The list of images to display.
title : Title of the display window
normalization : Normalization type of the display window.
is_fullscreen : Fullscreen mode.
is_closed : Initially visible mode.

CImgDisplay ( const CImgDisplay disp  ) 

Create a display window by copying another one.

Parameters:
disp : Display window to copy.


Member Function Documentation

CImgDisplay& display ( const CImgList< T > &  list,
const char  axis = 'x',
const char  align = 'p' 
)

Display an image list CImgList<T> into a display window.

First, all images of the list are appended into a single image used for visualization, then this image is displayed in the current display window.

Parameters:
list : The list of images to display.
axis : The axis used to append the image for visualization. Can be 'x' (default),'y','z' or 'c'.
align : Defines the relative alignment of images when displaying images of different sizes. Can be 'c' (centered, which is the default), 'p' (top alignment) and 'n' (bottom aligment).

CImgDisplay& resize ( const CImg< T > &  img,
const bool  redraw = true 
)

Resize a display window with the size of an image.

Parameters:
img : Input image. image.width and image.height give the new dimensions of the display window.
redraw : If true (default), the current displayed image in the display window will be bloc-interpolated to fit the new dimensions. If false, a black image will be drawn in the resized window.