xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 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.

Public Member Functions

 CImgDisplay ()
 Create an empty display window.
 CImgDisplay (const unsigned int dimw, const unsigned int dimh, const char *title=0, const unsigned int normalization_type=3, const bool fullscreen_flag=false, const bool closed_flag=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_type=3, const bool fullscreen_flag=false, const bool closed_flag=false)
 Create a display window from an image.
template<typename T >
 CImgDisplay (const CImgList< T > &list, const char *title=0, const unsigned int normalization_type=3, const bool fullscreen_flag=false, const bool closed_flag=false)
 Create a display window from an image list.
 CImgDisplay (const CImgDisplay &disp)
 Create a display window by copying another one.
 ~CImgDisplay ()
 Destructor.
CImgDisplayoperator= (const CImgDisplay &disp)
 Assignment operator.
bool is_empty () const
 Return true is display is empty.
 operator bool () const
 Return true if display is not empty.
int dimx () const
 Return display width.
int dimy () const
 Return display height.
int window_dimx () const
 Return display window width.
int window_dimy () const
 Return display window height.
int window_posx () const
 Return X-coordinate of the window.
int window_posy () const
 Return Y-coordinate of the window.
CImgDisplaywait (const unsigned int milliseconds)
 Synchronized waiting function. Same as cimg::wait().
CImgDisplaywait ()
 Wait for an event occuring on the current display.
float frames_per_second ()
 Return the frame per second rate.
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.
template<typename T >
CImgDisplayoperator<< (const CImg< T > &img)
 Display an image CImg<T> into a display window.
template<typename T >
CImgDisplayoperator<< (const CImgList< T > &list)
 Display an image CImg<T> into a display window.
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 bool redraw=true)
 Resize a display window in its current size.
CImgDisplayfullscreen (const bool redraw=true)
 Set fullscreen mode.
CImgDisplaynormalscreen (const bool redraw=true)
 Set normal screen mode.
CImgDisplayflush ()
 Clear all events of the current display.
bool is_key (const bool remove=false)
 Test if any key has been pressed.
bool is_key (const unsigned int key1, const bool remove)
 Test if a key has been pressed.
bool is_key (const unsigned int key1, const unsigned int key2, const bool remove)
 Test if a key sequence has been typed.
bool is_key (const unsigned int key1, const unsigned int key2, const unsigned int key3, const bool remove)
 Test if a key sequence has been typed.
bool is_key (const unsigned int key1, const unsigned int key2, const unsigned int key3, const unsigned int key4, const bool remove)
 Test if a key sequence has been typed.
bool is_key (const unsigned int key1, const unsigned int key2, const unsigned int key3, const unsigned int key4, const unsigned int key5, const bool remove)
 Test if a key sequence has been typed.
bool is_key (const unsigned int key1, const unsigned int key2, const unsigned int key3, const unsigned int key4, const unsigned int key5, const unsigned int key6, const bool remove)
 Test if a key sequence has been typed.
bool is_key (const unsigned int key1, const unsigned int key2, const unsigned int key3, const unsigned int key4, const unsigned int key5, const unsigned int key6, const unsigned int key7, const bool remove)
 Test if a key sequence has been typed.
bool is_key (const unsigned int key1, const unsigned int key2, const unsigned int key3, const unsigned int key4, const unsigned int key5, const unsigned int key6, const unsigned int key7, const unsigned int key8, const bool remove)
 Test if a key sequence has been typed.
bool is_key (const unsigned int key1, const unsigned int key2, const unsigned int key3, const unsigned int key4, const unsigned int key5, const unsigned int key6, const unsigned int key7, const unsigned int key8, const unsigned int key9, const bool remove)
 Test if a key sequence has been typed.
bool is_key (const unsigned int *const keyseq, const unsigned int N, const bool remove=true)
 Test if a key sequence has been typed.
CImgDisplayassign ()
 In-place version of the destructor.
CImgDisplayassign (const unsigned int dimw, const unsigned int dimh, const char *title=0, const unsigned int normalization_type=3, const bool fullscreen_flag=false, const bool closed_flag=false)
 In-place version of the previous constructor.
template<typename T >
CImgDisplayassign (const CImg< T > &img, const char *title=0, const unsigned int normalization_type=3, const bool fullscreen_flag=false, const bool closed_flag=false)
 In-place version of the previous constructor.
template<typename T >
CImgDisplayassign (const CImgList< T > &list, const char *title=0, const unsigned int normalization_type=3, const bool fullscreen_flag=false, const bool closed_flag=false)
 In-place version of the previous constructor.
CImgDisplayassign (const CImgDisplay &disp)
 In-place version of the previous constructor.
CImgDisplayresize (const int width, const int height, const bool redraw=true)
 Resize window.
CImgDisplaytoggle_fullscreen (const bool redraw=true)
 Toggle fullscreen mode.
CImgDisplayshow ()
 Show a closed display.
CImgDisplayclose ()
 Close a visible display.
CImgDisplaymove (const int posx, const int posy)
 Move window.
CImgDisplayshow_mouse ()
 Show mouse pointer.
CImgDisplayhide_mouse ()
 Hide mouse pointer.
CImgDisplayset_mouse (const int posx, const int posy)
 Move mouse pointer to a specific location.
CImgDisplayset_title (const char *format,...)
 Set the window title.
template<typename T >
CImgDisplaydisplay (const CImg< T > &img)
 Display an image in a window.
CImgDisplaypaint ()
 Re-paint image content in window.
template<typename T >
CImgDisplayrender (const CImg< T > &img)
 Render image buffer into GDI native image format.
template<typename T >
const CImgDisplaysnapshot (CImg< T > &img) const
 Take a snapshot of the display in the specified image.

Static Public Member Functions

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 int screen_dimx ()
 Return the width of the screen resolution.
static int screen_dimy ()
 Return the height of the screen resolution.
static void wait_all ()
 Wait for a window event in any CImg window.

Public Attributes

unsigned int width
 Width of the display.
unsigned int height
 Height of the display.
unsigned int normalization
 Normalization type used for the display.
char * title
 Display title.
volatile int window_x
 X-pos of the display on the screen.
volatile int window_y
 Y-pos of the display on the screen.
volatile unsigned int window_width
 Width of the underlying window.
volatile unsigned int window_height
 Height of the underlying window.
volatile int mouse_x
 X-coordinate of the mouse pointer on the display.
volatile int mouse_y
 Y-coordinate of the mouse pointer on the display.
volatile unsigned int buttons [512]
 Button state of the mouse.
volatile int wheel
 Wheel state of the mouse.
volatile unsigned int & key
 Key value if pressed.
volatile unsigned int & released_key
 Key value if released.
volatile bool is_closed
 Closed state of the window.
volatile bool is_resized
 Resized state of the window.
volatile bool is_moved
 Moved state of the window.
volatile bool is_event
 Event state of the window.
volatile bool is_keyESC
 Current state of the corresponding key (exists for all referenced keys).
bool is_fullscreen
 Fullscreen state of the display.


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  dimw,
const unsigned int  dimh,
const char *  title = 0,
const unsigned int  normalization_type = 3,
const bool  fullscreen_flag = false,
const bool  closed_flag = false 
) [inline]

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

Parameters:
dimw Width of the display window.
dimh Height of the display window.
title Title of the display window.
normalization_type Normalization type of the display window (0=none, 1=always, 2=once).
fullscreen_flag : Fullscreen mode.
closed_flag : 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_type = 3,
const bool  fullscreen_flag = false,
const bool  closed_flag = false 
) [inline]

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_type : Normalization type of the display window.
fullscreen_flag : Fullscreen mode.
closed_flag : Initially visible mode.

CImgDisplay ( const CImgList< T > &  list,
const char *  title = 0,
const unsigned int  normalization_type = 3,
const bool  fullscreen_flag = false,
const bool  closed_flag = false 
) [inline]

Create a display window from an image list.

Parameters:
list : The list of images to display.
title : Title of the display window
normalization_type : Normalization type of the display window.
fullscreen_flag : Fullscreen mode.
closed_flag : Initially visible mode.

CImgDisplay ( const CImgDisplay disp  )  [inline]

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' 
) [inline]

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 'v'.
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 
) [inline]

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.