Imagine++
Graphics Library

Classes

struct  Imagine::Event
 Event info. More...
 
class  Imagine::Mesh
 A mesh representing a 3D object. More...
 
class  Imagine::NativeBitmap
 Native bitmap: image stored in graphics card format, fast to display. More...
 

Typedefs

typedef FVector< double, 3 > Imagine::DoublePoint3
 Double space point.
 
typedef DoublePoint3 Imagine::DoubleVector3
 Double space vector.
 
typedef FVector< float, 3 > Imagine::FloatPoint3
 Float space point.
 
typedef FloatPoint3 Imagine::FloatVector3
 Float space vector.
 
typedef Coords< 2 > Imagine::IntPoint2
 Plane point with integral coordinates.
 
typedef FArray< int, 4 > Imagine::Quad
 Quadrilateral to insert in a mesh, built from four space point indices.
 
typedef FArray< int, 3 > Imagine::Triangle
 Triangle to insert in a mesh, built from three space point indices.
 
typedef WindowInternal * Imagine::Window
 Handle to a display window.
 

Enumerations

enum  Imagine::EventState { EVS_NONE =0 , EVS_SHIFT =(1<<0) , EVS_CONTROL =(1<<1) , EVS_ALT =(1<<2) }
 Event State. More...
 
enum  Imagine::EventType {
  EVT_NONE = 0 , EVT_BUT_ON = 2 , EVT_BUT_OFF = 3 , EVT_MOTION = 5 ,
  EVT_KEY_ON , EVT_KEY_OFF
}
 Event type (keyboard or mouse event). More...
 
enum  Imagine::KeyCode {
  KEY_BACK =16777219 , KEY_TAB =16777217 , KEY_RETURN =16777220 , KEY_NUMPAD_ENTER =16777221 ,
  KEY_ESCAPE =16777216 , KEY_INSERT =16777222 , KEY_DELETE =16777223 , KEY_HOME =16777232 ,
  KEY_END =16777233 , KEY_PAGEUP =16777238 , KEY_PAGEDOWN , KEY_LEFT =16777234 ,
  KEY_UP , KEY_RIGHT , KEY_DOWN , KEY_SHIFT =16777248 ,
  KEY_CONTROL =16777249 , KEY_CMD =16777299 , KEY_ALT =16777251 , KEY_PRINT =16777225 ,
  KEY_SCROLL =16777254 , KEY_PAUSE =16777224 , KEY_MENU =16777301 , KEY_F1 =16777264 ,
  KEY_F2 , KEY_F3 , KEY_F4 , KEY_F5 ,
  KEY_F6 , KEY_F7 , KEY_F8 , KEY_F9 ,
  KEY_F10 , KEY_F11 , KEY_F12 , KEY_NUMLOCK =16777253
}
 Keyboard codes for characterless keys. More...
 
enum  Imagine::MeshColorMode {
  CONSTANT_COLOR , FACE_COLOR , VERTEX_COLOR , FACE_VALUE ,
  VERTEX_VALUE
}
 Mesh lighting mode.
 
enum  Imagine::MeshData { VERTEX , TRIANGLE , QUAD }
 Type of mesh data that holds values.
 
enum  Imagine::MeshFaceMode { POINT , LINE , FILL }
 Mesh display mode.
 
enum  Imagine::MeshShadingMode { FLAT_SHADING , SMOOTH_SHADING }
 Mesh shading mode.
 
enum  Imagine::WindowType { WINDOW_2D , WINDOW_3D }
 Type of Window. More...
 

Functions

int Imagine::anyClick ()
 Wait for mouse click in any window.
 
int Imagine::anyClick (Window &win, int &subWin)
 Wait for mouse click in any window (returning window).
 
int Imagine::anyGetKey (Window &win, int &subWin, bool ignoreModifier=true)
 Wait for key press in any window.
 
int Imagine::anyGetMouse (int &x, int &y, Window &win, int &subWin)
 Wait for mouse click in any window (returning window and position).
 
int Imagine::anyGetMouse (IntPoint2 &p, Window &win, int &subWin)
 Wait for mouse click in any window (returning window and position).
 
Color Imagine::capturePoint (const IntPoint2 &p)
 Capture (point).
 
Color Imagine::capturePoint (int x, int y)
 Capture (point).
 
void Imagine::captureRectangle (const IntPoint2 &p, Color *c, int w, int h)
 Capture (sub window).
 
void Imagine::captureRectangle (const IntPoint2 &p, octet *R, octet *G, octet *B, int w, int h)
 Capture (sub window).
 
void Imagine::captureRectangle (const IntPoint2 &p, octet *RGB, int w, int h)
 Capture (sub window).
 
void Imagine::captureRectangle (int x, int y, Color *c, int w, int h)
 Capture (sub window).
 
void Imagine::captureRectangle (int x, int y, octet *R, octet *G, octet *B, int w, int h)
 Capture (sub window).
 
void Imagine::captureRectangle (int x, int y, octet *RGB, int w, int h)
 Capture (sub window).
 
void Imagine::captureWindow (Color *&cols, int &w, int &h)
 Window capture.
 
void Imagine::captureWindow (octet *&R, octet *&G, octet *&B, int &w, int &h)
 Window capture.
 
void Imagine::captureWindow (octet *&RGB, int &w, int &h)
 Window capture.
 
void Imagine::clearWindow ()
 clearWindow.
 
int Imagine::click ()
 Wait for mouse click in active window.
 
void Imagine::closeWindow (Window w)
 Close window.
 
AlphaColorImagine::convertColorToAlphaColor (const Imagine::Color *cols, int w, int h)
 Convert a Color Image to a AlphaColor Image.
 
void Imagine::drawArrow (const IntPoint2 &p1, const IntPoint2 &p2, const AlphaColor &col, double ta, double tl, int style=0, int width=1, bool xorMode=false)
 Arrow.
 
void Imagine::drawArrow (const IntPoint2 &p1, const IntPoint2 &p2, const AlphaColor &col, int arrowWidth=8, int arrowHeight=5, int style=0, int width=1, bool xorMode=false)
 Arrow (IntPoint2).
 
void Imagine::drawArrow (int x1, int y1, int x2, int y2, const AlphaColor &col, double ta, double tl, int style=0, int width=1, bool xorMode=false)
 Arrow.
 
void Imagine::drawArrow (int x1, int y1, int x2, int y2, const AlphaColor &col, int arrowWidth=8, int arrowHeight=5, int style=0, int width=1, bool xorMode=false)
 Arrow.
 
void Imagine::drawCircle (const IntPoint2 &c, int r, const Color &col, int penWidth=1, bool xorMode=false)
 Circle (IntPoint2).
 
void Imagine::drawCircle (int xc, int yc, int r, const Color &col, int penWidth=1, bool xorMode=false)
 Circle.
 
void Imagine::drawEllipse (const IntPoint2 &p, int w, int h, const Color &col, int penWidth=1, bool xorMode=false)
 Ellipse (IntPoint2).
 
void Imagine::drawEllipse (int x, int y, int w, int h, const Color &col, int penWidth=1, bool xorMode=false)
 Ellipse.
 
void Imagine::drawLine (const IntPoint2 &p1, const IntPoint2 &p2, const Color &col, int penWidth=1, bool xorMode=false)
 Line (IntPoint2).
 
void Imagine::drawLine (int x1, int y1, int x2, int y2, const Color &col, int penWidth=1, bool xorMode=false)
 Line.
 
void Imagine::drawPoint (const IntPoint2 &p, const Color &col, bool xorMode=false)
 Point (IntPoint2).
 
void Imagine::drawPoint (int x, int y, const Color &col, bool xorMode=false)
 Point.
 
void Imagine::drawPoly (const int x[], const int y[], int n, const Color &col, int width=1, bool xorMode=false)
 Draw a polygon.
 
void Imagine::drawPoly (const int xy[], int n, const Color &col, int width=1, bool xorMode=false)
 Polygon (one array).
 
void Imagine::drawPoly (const IntPoint2 *p, int n, const Color &col, int width=1, bool xorMode=false)
 Polygon (IntPoint2).
 
void Imagine::drawRect (const IntPoint2 &p, int w, int h, const Color &col, int penWidth=1, bool xorMode=false)
 Rectangle (IntPoint2).
 
void Imagine::drawRect (int x, int y, int w, int h, const Color &col, int penWidth=1, bool xorMode=false)
 Rectangle.
 
void Imagine::drawString (const IntPoint2 &p, const std::string &s, const AlphaColor &col, int fontSize=12, double alpha=0, bool italic=false, bool bold=false, bool underlined=false, bool xorMode=false)
 String (IntPoint2).
 
void Imagine::drawString (int x, int y, const std::string &s, const AlphaColor &col, int fontSize=12, double alpha=0, bool italic=false, bool bold=false, bool underlined=false, bool xorMode=false)
 String.
 
void Imagine::enableMouseTracking (bool en)
 Mouse tracking, controlling whether pointer motion triggers an event.
 
void Imagine::endGraphics ()
 Terminate graphics application.
 
void Imagine::fillCircle (const IntPoint2 &c, int r, const AlphaColor &col, bool xorMode=false)
 Filled Circle (IntPoint2).
 
void Imagine::fillCircle (int xc, int yc, int r, const AlphaColor &col, bool xorMode=false)
 Filled Circle.
 
void Imagine::fillEllipse (const IntPoint2 &p, int w, int h, const AlphaColor &col, bool xorMode=false)
 Filled Ellipse (IntPoint2).
 
void Imagine::fillEllipse (int x, int y, int w, int h, const AlphaColor &col, bool xorMode=false)
 Filled Ellipse.
 
void Imagine::fillPoly (const int x[], const int y[], int n, const AlphaColor &col, bool xorMode=false)
 Filled Polygon.
 
void Imagine::fillPoly (const int xy[], int n, const AlphaColor &col, bool xorMode=false)
 Filled Polygon.
 
void Imagine::fillPoly (const IntPoint2 *p, int n, const AlphaColor &col, bool xorMode=false)
 Filled Polygon (IntPoint2).
 
void Imagine::fillRect (const IntPoint2 &p, int w, int h, const AlphaColor &col, bool xorMode=false)
 Filled rectangle (IntPoint2).
 
void Imagine::fillRect (int x, int y, int w, int h, const AlphaColor &col, bool xorMode=false)
 Filled rectangle.
 
void Imagine::flushEvents ()
 Flush event queue, discarding unhandled events.
 
void Imagine::getEvent (int ms, Event &ev)
 Get keyboard and mouse events.
 
int Imagine::getKey (bool ignoreModifier=true)
 Wait for key press in active window.
 
int Imagine::getMouse (int &x, int &y)
 Wait for mouse click in active window (returning position).
 
int Imagine::getMouse (IntPoint2 &p)
 Wait for mouse click in active window (returning position).
 
void Imagine::hideMesh (const Mesh &M, bool reinitCam=true)
 Hide mesh.
 
bool Imagine::loadAlphaColorImage (const std::string &name, AlphaColor *&acols, int &w, int &h)
 Load color image with alpha channel.
 
bool Imagine::loadAlphaColorImage (const std::string &name, octet *&rgba, int &w, int &h)
 Load color image with alpha channel.
 
bool Imagine::loadColorImage (const std::string &name, Color *&cols, int &w, int &h)
 Load color image.
 
bool Imagine::loadColorImage (const std::string &name, octet *&r, octet *&g, octet *&b, int &w, int &h)
 Load color image.
 
bool Imagine::loadColorImage (const std::string &name, octet *&r, octet *&g, octet *&b, octet *&a, int &w, int &h)
 Load color image with alpha channel.
 
bool Imagine::loadColorImage (const std::string &name, octet *&rgb, int &w, int &h)
 Load color image.
 
bool Imagine::loadGreyImage (const std::string &name, octet *&g, int &w, int &h)
 Load grey image.
 
void Imagine::milliSleep (int msec)
 ... Pause program for a certain period.
 
void Imagine::noRefreshBegin ()
 Norefresh begin.
 
void Imagine::noRefreshEnd ()
 Norefresh end.
 
void Imagine::noRefreshPop ()
 Norefresh pop.
 
void Imagine::noRefreshPush ()
 Norefresh push.
 
Window Imagine::openComplexWindow (int w, int h, const std::string &name="Imagine++", int tabsNb=1, const std::string *tabsNames=0, const WindowType *tabsTypes=0, int x=-1, int y=-1)
 New complex window.
 
Window Imagine::openWindow (int w, int h, const std::string &windowTitle="Imagine++", int x=-1, int y=-1)
 New window for 2D graphics.
 
Window Imagine::openWindow3D (int w, int h, const std::string &windowTitle="Imagine++", int x=-1, int y=-1)
 New window for 3D graphics.
 
void Imagine::putAlphaColorImage (const IntPoint2 &p, octet *rgba, int w, int h, bool xorMode=false, double fact=1.)
 Display color bitmap with alpha channel.
 
void Imagine::putAlphaColorImage (int x, int y, Imagine::AlphaColor *cols, int w, int h, bool xorMode=false, double fact=1.)
 Display color bitmap with alpha channel.
 
void Imagine::putAlphaColorImage (int x, int y, octet *rgba, int w, int h, bool xorMode=false, double fact=1.)
 Display color bitmap with alpha channel.
 
void Imagine::putColorImage (const IntPoint2 &p, const Color *cols, int w, int h, bool xorMode=false, double fact=1.)
 Display color bitmap.
 
void Imagine::putColorImage (const IntPoint2 &p, const octet *r, const octet *g, const octet *b, const octet *a, int w, int h, bool xorMode=false, double fact=1.)
 Display color bitmap with alpha channel.
 
void Imagine::putColorImage (const IntPoint2 &p, const octet *r, const octet *g, const octet *b, int w, int h, bool xorMode=false, double fact=1.)
 Display color bitmap.
 
void Imagine::putColorImage (const IntPoint2 &p, const octet *rgb, int w, int h, bool xorMode=false, double fact=1.)
 Display color bitmap.
 
void Imagine::putColorImage (int x, int y, const Color *cols, int w, int h, bool xorMode=false, double fact=1.)
 Display color bitmap.
 
void Imagine::putColorImage (int x, int y, const octet *r, const octet *g, const octet *b, const octet *a, int w, int h, bool xorMode=false, double fact=1.)
 Display color bitmap with alpha channel.
 
void Imagine::putColorImage (int x, int y, const octet *r, const octet *g, const octet *b, int w, int h, bool xorMode=false, double fact=1.)
 Display color bitmap.
 
void Imagine::putColorImage (int x, int y, const octet *rgb, int w, int h, bool xorMode=false, double fact=1.)
 Display color bitmap.
 
void Imagine::putGreyImage (const IntPoint2 &p, const octet *g, int w, int h, bool xorMode=false, double fact=1.)
 Display grey bitmap.
 
void Imagine::putGreyImage (int x, int y, const octet *g, int w, int h, bool xorMode=false, double fact=1.)
 Display grey bitmap.
 
void Imagine::putNativeBitmap (int x, int y, const NativeBitmap &bm, bool xorMode=false, double fact=1.)
 Display native bitmap.
 
bool Imagine::saveAlphaColorImage (const std::string &name, const octet *r, const octet *g, const octet *b, const octet *a, int w, int h, int quality=85)
 Save color image with alpha channel.
 
bool Imagine::saveAlphaColorImage (const std::string &name, Imagine::AlphaColor *cols, int w, int h, int quality=85)
 Save color image with alpha channel.
 
bool Imagine::saveAlphaColorImage (const std::string &name, octet *rgba, int w, int h, int quality=85)
 Save color image with alpha channel.
 
bool Imagine::saveColorImage (const std::string &name, const Color *cols, int w, int h, int quality=85)
 Save color image.
 
bool Imagine::saveColorImage (const std::string &name, const octet *r, const octet *g, const octet *b, int w, int h, int quality=85)
 Save color image.
 
bool Imagine::saveColorImage (const std::string &name, const octet *rgb, int w, int h, int quality=85)
 Save color image.
 
bool Imagine::saveGreyImage (const std::string &name, const octet *g, int w, int h, int quality=85)
 Save grey image.
 
void Imagine::setActiveWindow (Window w, int subWin=0)
 Set active window.
 
void Imagine::setBackGround (const Color &col)
 Set ackground color of window.
 
void Imagine::setCamera (const DoublePoint3 &pos, const DoublePoint3 &dir, const DoubleVector3 &up)
 Sets the camera pose.
 
void Imagine::setLight (bool b)
 Set/unset lighting in 3D rendering.
 
void Imagine::setLight (const FloatVector3 &dir, float ambient=0.2f)
 Set direction for diffuse lighting and ambient lighting in 3D rendering.
 
void Imagine::setLight (float dirx, float diry, float dirz, float ambient=0.2f)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void Imagine::setMaskFromColor (AlphaColor *&acols, int w, int h, AlphaColor col)
 Create a transparency mask from a specified color-key.
 
void Imagine::setMaskFromColor (octet *&r, octet *&g, octet *&b, octet *&a, int w, int h, const Color &col)
 Create a transparency mask from a specified color-key.
 
void Imagine::setMaskFromColor (octet *&rgba, int w, int h, const Color &col)
 Create a transparency mask from a specified color-key.
 
void Imagine::showMesh (const Mesh &M, bool reinitCam=true)
 Show mesh.
 
void Imagine::showWindow (Window w, int subWin=0)
 Show window.
 
void Imagine::unGetEvent (const Event &ev)
 Unget event.
 

Detailed Description

Enumeration Type Documentation

◆ EventState

Keyboard state when the event occured (independently on what caused the event). These are binary masks (e.g. if (state&EVS_SHIFT) {} ...)

  • EVS_NONE : None
  • EVS_SHIFT : Shift was down
  • EVS_CONTROL : Control was down
  • EVS_ALT : Alt was down

◆ EventType

Possible values for for Event::type. What triggered the event:

  • EVT_NONE : No event (thus, a timeout)
  • EVT_BUT_ON : A mouse button has been pressed
  • EVT_BUT_OFF : A mouse button has been released
  • EVT_MOTION : The mouse has moved
  • EVT_KEY_ON : A key has been pressed
  • EVT_KEY_OFF : A key has been released

◆ KeyCode

Codes assigned to most non alpha-numeric keys (alpha-numeric keys are represented by their ASCII code: 'A', '0'...)

Functions getKey() and anyGetKey() may return one of those. The field Event::key stores such a value.

do { // get key
cout << "Please press UP arrow in first tab" << endl;
} while (getKey() != KEY_UP); // ...
int getKey(bool ignoreModifier=true)
Wait for key press in active window.

The possible codes are:

enum KeyCode {
KeyCode
Keyboard codes for characterless keys.
Definition Events.h:17
KEY_BACK=16777219, KEY_TAB=16777217,
KEY_RETURN=16777220, KEY_NUMPAD_ENTER=16777221,
KEY_ESCAPE=16777216,
KEY_INSERT=16777222, KEY_DELETE=16777223,
KEY_HOME=16777232, KEY_END=16777233,
KEY_PAGEUP=16777238, KEY_PAGEDOWN,
KEY_LEFT=16777234, KEY_UP, KEY_RIGHT, KEY_DOWN,
KEY_SHIFT=16777248, KEY_CONTROL=16777249,
KEY_CMD=16777299, KEY_ALT=16777251,
KEY_PRINT=16777225, KEY_SCROLL=16777254,
KEY_PAUSE=16777224, KEY_MENU=16777301,
KEY_F1=16777264, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6,
KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12,
KEY_NUMLOCK=16777253
};

Use the names defined above, not their numerical values: your code will be clearer and more portable.

The direction arrow keys are KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT.

Modifier keys are KEY_SHIFT, KEY_ALT, KEY_CONTROL, KEY_CMD (Command key under MacOS, Windows key otherwise).

◆ WindowType

Type of Window

  • WINDOW_2D: 2D display
  • WINDOW_3D: 3D display (meshes using OpenGL), with navigation:
    • SHIFT+Button 1: rotate
    • SHIFT+Button 3: translate
    • Mouse wheel: zoom
    • SHIFT+a: zoom in
    • SHIFT+z: zoom out
    • SHIFT+r: recenter camera
    • SHIFT+m: toggle solid/wire/points mode

Function Documentation

◆ anyClick() [1/2]

int Imagine::anyClick ( )

Waits for a mouse click in any window (see also click()).

Returns
mouse button (1=left, 2=middle, 3=right)
button=anyClick(); // click any
int anyClick()
Wait for mouse click in any window.

◆ anyClick() [2/2]

int Imagine::anyClick ( Window & win,
int & subWin )

Waits for a mouse click in any window (see also click()).

Parameters
winthe Window that is clicked
subWinsubwindow index (if any)
Returns
mouse button (1=left, 2=middle, 3=right)
button=anyClick(W1,sw); // click any (returning window)

◆ anyGetKey()

int Imagine::anyGetKey ( Window & win,
int & subWin,
bool ignoreModifier = true )

Waits for a key pressed in any window (see also getKey()).

Parameters
winthe Window that is clicked
subWinsubwindow index (if any)
ignoreModifierwhether to ignore modifier keys (shift, ctrl, alt)
Returns
Returns ASCII code (uppercase) or KeyCode
int key=anyGetKey(W1,sw); // get key (any window)
int anyGetKey(Window &win, int &subWin, bool ignoreModifier=true)
Wait for key press in any window.

Warning: Imagine++ up to version 4.2.0 used to return uppercase letters even when the SHIFT key was not pressed. This is no longer the case, so that if only a letter key is pressed, the lowercase ASCII code is returned, such as 'a' instead of 'A'.

◆ anyGetMouse() [1/2]

int Imagine::anyGetMouse ( int & x,
int & y,
Window & win,
int & subWin )

Waits for a mouse click in any window (see also getMouse()).

Parameters
x,yCoordinates of the cliked point
winthe Window that is clicked
subWinsubwindow index (if any)
Returns
mouse button (1=left, 2=middle, 3=right)
button=anyGetMouse(x,y,W1,sw); // get mouse (any window)
int anyGetMouse(int &x, int &y, Window &win, int &subWin)
Wait for mouse click in any window (returning window and position).

◆ anyGetMouse() [2/2]

int Imagine::anyGetMouse ( IntPoint2 & p,
Window & win,
int & subWin )
inline

Waits for a mouse click in any window (see also getMouse()).

Parameters
pCoordinates of the cliked point
winthe Window that is clicked
subWinsubwindow index (if any)
Returns
mouse button (1=left, 2=middle, 3=right)
button=anyGetMouse(p,W1,sw); // get mouse (any window, IntPoint2)

◆ capturePoint() [1/2]

Color Imagine::capturePoint ( const IntPoint2 & p)
inline

Captures one pixel of the active window. Do not call for all pixels!

Parameters
ppoint to capture
Returns
color of pixel
Color c2=capturePoint(IntPoint2(10,10)); // 2D capture (point) (IntPoint2)
RGB< octet > Color
RGB<octet> alias.
Definition Color.h:283
Color capturePoint(int x, int y)
Capture (point).
Coords< 2 > IntPoint2
Plane point with integral coordinates.
Definition Types.h:17

◆ capturePoint() [2/2]

Color Imagine::capturePoint ( int x,
int y )

Captures one pixel of the active window. Do not call for all pixels!

Parameters
x,ypoint to capture
Returns
color of pixel
Color c1=capturePoint(10,10); // 2D capture (point)

◆ captureRectangle() [1/6]

void Imagine::captureRectangle ( const IntPoint2 & p,
Color * c,
int w,
int h )
inline

Captures part of the active window.

Parameters
ptop left
cColor array (have to be already allocated)
w,hdimensions
captureRectangle(IntPoint2(50,10),cols1,100,50); // 2D capture (subwindow Color array) (IntPoint2)
void captureRectangle(int x, int y, Color *c, int w, int h)
Capture (sub window).

◆ captureRectangle() [2/6]

void Imagine::captureRectangle ( const IntPoint2 & p,
octet * R,
octet * G,
octet * B,
int w,
int h )
inline

Captures part of the active window.

Parameters
ptop left
R,G,BRGB arrays (have to be already allocated)
w,hdimensions
captureRectangle(IntPoint2(50,10),r1,g1,b1,100,50); // 2D capture (subwindow 3 arrays) (IntPoint2)

◆ captureRectangle() [3/6]

void Imagine::captureRectangle ( const IntPoint2 & p,
octet * RGB,
int w,
int h )
inline

Captures part of the active window.

Parameters
ptop left
RGB1 RGB array (have to be already allocated)
w,hdimensions
captureRectangle(IntPoint2(50,10),rgb1,100,50); // 2D capture (subwindow 1 array) (IntPoint2)

◆ captureRectangle() [4/6]

void Imagine::captureRectangle ( int x,
int y,
Color * c,
int w,
int h )

Captures part of the active window.

Parameters
x,ytop left
cColor array (have to be already allocated)
w,hdimensions
captureRectangle(IntPoint2(50,10),cols1,100,50); // 2D capture (subwindow Color array) (IntPoint2)

◆ captureRectangle() [5/6]

void Imagine::captureRectangle ( int x,
int y,
octet * R,
octet * G,
octet * B,
int w,
int h )

Captures part of the active window.

Parameters
x,ytop left
R,G,BRGB arrays (have to be already allocated)
w,hdimensions
captureRectangle(IntPoint2(50,10),r1,g1,b1,100,50); // 2D capture (subwindow 3 arrays) (IntPoint2)

◆ captureRectangle() [6/6]

void Imagine::captureRectangle ( int x,
int y,
octet * RGB,
int w,
int h )

Captures part of the active window.

Parameters
x,ytop left
RGB1 RGB array (have to be already allocated)
w,hdimensions
captureRectangle(IntPoint2(50,10),rgb1,100,50); // 2D capture (subwindow 1 array) (IntPoint2)

◆ captureWindow() [1/3]

void Imagine::captureWindow ( Color *& cols,
int & w,
int & h )

Captures the active window. Allocates buffers.

Parameters
colscaptured array
w,hdimensions (note: might have changed since openWindow!)
setActiveWindow(W2); // 2D capture (Color array)
void setActiveWindow(Window w, int subWin=0)
Set active window.
captureWindow(C,w,h);
putColorImage(542,10,C,w,h,false,.25);
delete[]C; // ...
void captureWindow(Color *&cols, int &w, int &h)
Window capture.
void putColorImage(int x, int y, const Color *cols, int w, int h, bool xorMode=false, double fact=1.)
Display color bitmap.

◆ captureWindow() [2/3]

void Imagine::captureWindow ( octet *& R,
octet *& G,
octet *& B,
int & w,
int & h )

Captures the active window. Allocates buffers.

Parameters
R,G,Bcaptured RGB arrays
w,hdimensions (note: might have changed since openWindow!)
setActiveWindow(W2); // 2D capture (3 arrays)
captureWindow(R,G,B,w,h);
putColorImage(10,10,R,G,B,w,h,false,.25);
delete[]R;
delete[]G;
delete[]B; // ...

◆ captureWindow() [3/3]

void Imagine::captureWindow ( octet *& RGB,
int & w,
int & h )

Captures the active window. Allocates buffers.

Parameters
RGBcaptured array
w,hdimensions (note: might have changed since openWindow!)
setActiveWindow(W2); // 2D capture (1 array)
putColorImage(276,10,RGB,w,h,false,.25);
delete[]RGB; // ...
RED GREEN BLUE color.
Definition Color.h:28

◆ clearWindow()

void Imagine::clearWindow ( )

Clears a window.

  • 2D: erase all (becomes WHITE)
  • 3D: hide all meshes
clearWindow(); // clear (3D)
void clearWindow()
clearWindow.
clearWindow(); // clear (2D)

◆ click()

int Imagine::click ( )

Waits for a mouse click in active window (see also anyClick()).

Returns
mouse button (1=left, 2=middle, 3=right)
cout << "Please click in first tab" << endl;

◆ closeWindow()

void Imagine::closeWindow ( Window w)

Closes a window. You must have stored the window handle returned by openWindow and variants.

Parameters
wthe window to close
closeWindow(W1); // close
void closeWindow(Window w)
Close window.
#ifdef IMAGINE_OPENGL
#endif
closeWindow(W4); // ...

◆ convertColorToAlphaColor()

AlphaColor * Imagine::convertColorToAlphaColor ( const Imagine::Color * cols,
int w,
int h )

It puts 255 to the alpha-channel for all pixels Use this funtion if you want to use setMaskFromColor on a Color Image

Parameters
colsarray of Color, line after line, from top left to bottom right
w,hdimensions of (h lines of w pixels)
// convert Color image to Color image with alpha channel
Color* C1;
loadColorImage(srcPath("test.jpg"),C1,w,h); // Load JPEG IMAGE
aC = convertColorToAlphaColor(C1,w,h); // Add alpha Channel
setMaskFromColor(aC,w,h,Color(255,255,255)); // Hide the white color
putAlphaColorImage(0,0,aC,w,h); // Display Image with alpha channel
// ...
#define srcPath(s)
Transform relative file path to absolute path.
Definition Base.h:43
RGBA< octet > AlphaColor
RGBA<byte> alias.
Definition Color.h:356
void setMaskFromColor(octet *&r, octet *&g, octet *&b, octet *&a, int w, int h, const Color &col)
Create a transparency mask from a specified color-key.
bool loadColorImage(const std::string &name, Color *&cols, int &w, int &h)
Load color image.
void putAlphaColorImage(int x, int y, Imagine::AlphaColor *cols, int w, int h, bool xorMode=false, double fact=1.)
Display color bitmap with alpha channel.
AlphaColor * convertColorToAlphaColor(const Imagine::Color *cols, int w, int h)
Convert a Color Image to a AlphaColor Image.

◆ drawArrow() [1/4]

void Imagine::drawArrow ( const IntPoint2 & p1,
const IntPoint2 & p2,
const AlphaColor & col,
double ta,
double tl,
int style = 0,
int width = 1,
bool xorMode = false )
inline

Draws an arrow.

Parameters
p1beginning point
p2end point
colAlphaColor or Color
ta,tlTip box angle and length
style(0,1 or 2, default=0)
widthLine width (default=1)
xorModeXOR drawing (default=off). Used twice, recovers the original content
drawArrow(IntPoint2(300,300),IntPoint2(250,350),BLACK,60.,17.,0); // arrow (angle IntPoint2)
const Color BLACK(0, 0, 0)
Predefined color.
void drawArrow(int x1, int y1, int x2, int y2, const AlphaColor &col, int arrowWidth=8, int arrowHeight=5, int style=0, int width=1, bool xorMode=false)
Arrow.

◆ drawArrow() [2/4]

void Imagine::drawArrow ( const IntPoint2 & p1,
const IntPoint2 & p2,
const AlphaColor & col,
int arrowWidth = 8,
int arrowHeight = 5,
int style = 0,
int width = 1,
bool xorMode = false )
inline

Draws an arrow.

Parameters
p1beginning point
p2end point
colAlphaColor or Color
arrowWidth,arrowHeightTip box dimension (default 8x5)
style(0,1 or 2, default=0)
widthLine width (default=1)
xorModeXOR drawing (default=off). Used twice, recovers the original content
drawArrow(IntPoint2(300,300),IntPoint2(350,350),BLUE,14,6,2,2); // arrow (IntPoint2)
const Color BLUE(0, 0, 255)
Predefined color.

◆ drawArrow() [3/4]

void Imagine::drawArrow ( int x1,
int y1,
int x2,
int y2,
const AlphaColor & col,
double ta,
double tl,
int style = 0,
int width = 1,
bool xorMode = false )
inline

Draws an arrow.

Parameters
x1,y1beginning point
x2,y2end point
colAlphaColor or Color
ta,tlTip box angle and length
style(0,1 or 2, default=0)
widthLine width (default=1)
xorModeXOR drawing (default=off). Used twice, recovers the original content
drawArrow(300,300,300,400,GREEN,40.,10.,1); // arrow (angle)
const Color GREEN(0, 255, 0)
Predefined color.

◆ drawArrow() [4/4]

void Imagine::drawArrow ( int x1,
int y1,
int x2,
int y2,
const AlphaColor & col,
int arrowWidth = 8,
int arrowHeight = 5,
int style = 0,
int width = 1,
bool xorMode = false )

Draws an arrow.

Parameters
x1,y1beginning point
x2,y2end point
colAlphaColor or Color
arrowWidth,arrowHeightTip box dimension (default 8x5)
style(0,1 or 2, default=0)
widthLine width (default=1)
xorModeXOR drawing (default=off). Used twice, recovers the original content
drawArrow(300,300,400,300,RED); // arrow
const Color RED(255, 0, 0)
Predefined color.

◆ drawCircle() [1/2]

void Imagine::drawCircle ( const IntPoint2 & c,
int r,
const Color & col,
int penWidth = 1,
bool xorMode = false )
inline

Draws a circle.

Parameters
ccenter
rradius
colColor
penWidthline width (default=1)
xorModeXOR drawing (default=off). Used twice, recovers the original content
drawCircle(IntPoint2(200,400),80,Color(55,250,30),3,true); // circle (IntPoint2)
void drawCircle(int xc, int yc, int r, const Color &col, int penWidth=1, bool xorMode=false)
Circle.

◆ drawCircle() [2/2]

void Imagine::drawCircle ( int xc,
int yc,
int r,
const Color & col,
int penWidth = 1,
bool xorMode = false )

Draws a circle.

Parameters
xc,yccenter
rradius
colColor
penWidthline width (default=1)
xorModeXOR drawing (default=off). Used twice, recovers the original content
drawCircle(30,430,50,BLACK); // circle

◆ drawEllipse() [1/2]

void Imagine::drawEllipse ( const IntPoint2 & p,
int w,
int h,
const Color & col,
int penWidth = 1,
bool xorMode = false )
inline

Draws an ellipse.

Parameters
pTop Left
w,hDimensions
colColor
penWidthline width (default=1)
xorModeXOR drawing (default=off). Used twice, recovers the original content
drawEllipse(IntPoint2(200,100),100,200,Color(255,120,0),4,true); // ellipse (IntPoint2)
void drawEllipse(int x, int y, int w, int h, const Color &col, int penWidth=1, bool xorMode=false)
Ellipse.

◆ drawEllipse() [2/2]

void Imagine::drawEllipse ( int x,
int y,
int w,
int h,
const Color & col,
int penWidth = 1,
bool xorMode = false )

Draws an ellipse.

Parameters
x,yTop Left
w,hDimensions
colColor
penWidthline width (default=1)
xorModeXOR drawing (default=off). Used twice, recovers the original content
drawEllipse(30,30,200,100,BLUE); // ellipse

◆ drawLine() [1/2]

void Imagine::drawLine ( const IntPoint2 & p1,
const IntPoint2 & p2,
const Color & col,
int penWidth = 1,
bool xorMode = false )
inline

Draws a line.

Parameters
p1First point
p2Second point
colColor
penWidthline width (default=1)
xorModeXOR drawing (default=off). Used twice, recovers the original content
drawLine(IntPoint2(0,200),IntPoint2(300,0),Color(120,120,255),2,true); // line (IntPoint2)
void drawLine(int x1, int y1, int x2, int y2, const Color &col, int penWidth=1, bool xorMode=false)
Line.

◆ drawLine() [2/2]

void Imagine::drawLine ( int x1,
int y1,
int x2,
int y2,
const Color & col,
int penWidth = 1,
bool xorMode = false )

Draws a line.

Parameters
x1,y1First point
x2,y2Second point
colColor
penWidthline width (default=1)
xorModeXOR drawing (default=off). Used twice, recovers the original content
drawLine(0,0,300,200,RED); // line

◆ drawPoint() [1/2]

void Imagine::drawPoint ( const IntPoint2 & p,
const Color & col,
bool xorMode = false )
inline

Draws a point.

Parameters
ppoint
colColor
xorModeXOR drawing (default=off). Used twice, recovers the original content
drawPoint(IntPoint2(230,120),BLUE,true); // point (IntPoint2)
void drawPoint(int x, int y, const Color &col, bool xorMode=false)
Point.

◆ drawPoint() [2/2]

void Imagine::drawPoint ( int x,
int y,
const Color & col,
bool xorMode = false )

Draws a point.

Parameters
x,ypoint
colColor
xorModeXOR drawing (default=off). Used twice, recovers the original content
drawPoint(200,300,RED); // point

◆ drawPoly() [1/3]

void Imagine::drawPoly ( const int x[],
const int y[],
int n,
const Color & col,
int width = 1,
bool xorMode = false )

Close it, drawing a line from last point to first one.

Parameters
x,yPoints positions (x[0],y[0]), ..., (x[n-1],y[n-1])
nNumber of points
colColor
widthLine width (default=1)
xorModeXOR drawing (default=off). Used twice, recovers the original content
int x[]={100,200,170},y[]={200,250,220}; // polygon
fillPoly(x,y,3,YELLOW); // inside
drawPoly(x,y,3,RED); // contour
const Color YELLOW(255, 255, 0)
Predefined color.
void drawPoly(const int x[], const int y[], int n, const Color &col, int width=1, bool xorMode=false)
Draw a polygon.
void fillPoly(const int x[], const int y[], int n, const AlphaColor &col, bool xorMode=false)
Filled Polygon.

◆ drawPoly() [2/3]

void Imagine::drawPoly ( const int xy[],
int n,
const Color & col,
int width = 1,
bool xorMode = false )
inline

Draws a polygon. Close it, drawing a line from last point to first one.

Parameters
xyPoints positions (one array points are (xy[0],xy[1]), (xy[2],xy[3]) ...
nNumber of points
colColor
widthLine width (default=1)
xorModeXOR drawing (default=off). Used twice, recovers the original content
int xy[]={120,30,200,60,160,80}; // polygon (one array)
fillPoly(xy,3,BLACK); // inside
drawPoly(xy,3,GREEN,5); // contour

◆ drawPoly() [3/3]

void Imagine::drawPoly ( const IntPoint2 * p,
int n,
const Color & col,
int width = 1,
bool xorMode = false )

Draws a polygon. Close it, drawing a line from last point to first one.

Parameters
pPoints positions
nNumber of points
colColor
widthLine width (default=1)
xorModeXOR drawing (default=off). Used twice, recovers the original content
IntPoint2 p[]={IntPoint2(400,400),IntPoint2(300,450),IntPoint2(350,480)}; // polygon (IntPoint2)
fillPoly(p,3,YELLOW); // inside
drawPoly(p,3,BLUE,3); // contour

◆ drawRect() [1/2]

void Imagine::drawRect ( const IntPoint2 & p,
int w,
int h,
const Color & col,
int penWidth = 1,
bool xorMode = false )
inline

Draws a rectangle.

Parameters
pTop Left
w,hDimensions
colColor
penWidthline width (default=1)
xorModeXOR drawing (default=off). Used twice, recovers the original content
drawRect(IntPoint2(200,400),30,20,Color(55,120,200),2,true); // rectangle (IntPoint2)
void drawRect(int x, int y, int w, int h, const Color &col, int penWidth=1, bool xorMode=false)
Rectangle.

◆ drawRect() [2/2]

void Imagine::drawRect ( int x,
int y,
int w,
int h,
const Color & col,
int penWidth = 1,
bool xorMode = false )

Draws a rectangle.

Parameters
x,yTop Left
w,hDimensions
colColor
penWidthline width (default=1)
xorModeXOR drawing (default=off). Used twice, recovers the original content
drawRect(310,130,100,40,BLUE); // rectangle

◆ drawString() [1/2]

void Imagine::drawString ( const IntPoint2 & p,
const std::string & s,
const AlphaColor & col,
int fontSize = 12,
double alpha = 0,
bool italic = false,
bool bold = false,
bool underlined = false,
bool xorMode = false )
inline

Draws a string. NB: xorMode does not work!

Parameters
pPosition (first char)
sString
colAlphaColor or Color
fontSizesize (default=12) (NB: cannot choose font yet)
alphaAngle (default=0=horizontal)
italic,bold,underlinedstyle (default=no)
xorModeXOR drawing (default=off). Used twice, recovers the original content
drawString(400,10,"Hello",BLACK); // strings
void drawString(int x, int y, const std::string &s, const AlphaColor &col, int fontSize=12, double alpha=0, bool italic=false, bool bold=false, bool underlined=false, bool xorMode=false)
String.
drawString(400,210,"Hello !",RED,15,35.,true);
drawString(IntPoint2(400,200),"Hello !!",BLUE,14,270.); // ...

◆ drawString() [2/2]

void Imagine::drawString ( int x,
int y,
const std::string & s,
const AlphaColor & col,
int fontSize = 12,
double alpha = 0,
bool italic = false,
bool bold = false,
bool underlined = false,
bool xorMode = false )

Draws a string. NB: xorMode does not work!

Parameters
x,yPosition (first char)
sString
colAlphaColor or Color
fontSizesize (default=12) (NB: cannot choose font yet)
alphaAngle (default=0=horizontal)
italic,bold,underlinedstyle (default=no)
xorModeXOR drawing (default=off). Used twice, recovers the original content
drawString(400,10,"Hello",BLACK); // strings
drawString(400,210,"Hello !",RED,15,35.,true);
drawString(IntPoint2(400,200),"Hello !!",BLUE,14,270.); // ...

◆ enableMouseTracking()

void Imagine::enableMouseTracking ( bool en)

If mouse tracking is disabled (the default), the active window only receives mouse move events when at least one mouse button is pressed while the mouse is being moved. If mouse tracking is enabled, the widget receives mouse move events even if no buttons are pressed.

// receiving mouse move events even if no button is pressed

◆ endGraphics()

void Imagine::endGraphics ( )

If there is an open window, it waits for a mouse click before exiting.

◆ fillCircle() [1/2]

void Imagine::fillCircle ( const IntPoint2 & c,
int r,
const AlphaColor & col,
bool xorMode = false )
inline

Fills a circle.

Parameters
ccenter
rradius
colAlphaColor or Color
xorModeXOR drawing (default=off). Used twice, recovers the original content
fillCircle(IntPoint2(200,200),20,Color(255,250,230),true); // filled circle (IntPoint2)
void fillCircle(int xc, int yc, int r, const AlphaColor &col, bool xorMode=false)
Filled Circle.

◆ fillCircle() [2/2]

void Imagine::fillCircle ( int xc,
int yc,
int r,
const AlphaColor & col,
bool xorMode = false )

Fills a circle.

Parameters
xc,yccenter
rradius
colAlphaColor or Color
xorModeXOR drawing (default=off). Used twice, recovers the original content
fillCircle(330,43,30,YELLOW); // filled circle

◆ fillEllipse() [1/2]

void Imagine::fillEllipse ( const IntPoint2 & p,
int w,
int h,
const AlphaColor & col,
bool xorMode = false )
inline

Fills an ellipse.

Parameters
pTop Left
w,hDimensions
colAlphaColor or Color
xorModeXOR drawing (default=off). Used twice, recovers the original content
fillEllipse(IntPoint2(100,300),200,30,Color(55,220,200),true); // filled ellipse (IntPoint2)
void fillEllipse(int x, int y, int w, int h, const AlphaColor &col, bool xorMode=false)
Filled Ellipse.

◆ fillEllipse() [2/2]

void Imagine::fillEllipse ( int x,
int y,
int w,
int h,
const AlphaColor & col,
bool xorMode = false )

Fills an ellipse.

Parameters
x,yTop Left
w,hDimensions
colAlphaColor or Color
xorModeXOR drawing (default=off). Used twice, recovers the original content
fillEllipse(330,30,30,100,CYAN); // filled ellipse
const Color CYAN(0, 255, 255)
Predefined color.

◆ fillPoly() [1/3]

void Imagine::fillPoly ( const int x[],
const int y[],
int n,
const AlphaColor & col,
bool xorMode = false )

Draws a filled polygon. Close it, from last point to first one.

Parameters
x,yPoints positions (x[0],y[0]), ..., (x[n-1],y[n-1])
nNumber of points
colAlphaColor or Color
xorModeXOR drawing (default=off). Used twice, recovers the original content
int x[]={100,200,170},y[]={200,250,220}; // polygon
fillPoly(x,y,3,YELLOW); // inside

◆ fillPoly() [2/3]

void Imagine::fillPoly ( const int xy[],
int n,
const AlphaColor & col,
bool xorMode = false )

Draws a filled polygon. Close it, from last point to first one.

Parameters
xyPoints positions (one array points are (xy[0],xy[1]), (xy[2],xy[3]) ...
nNumber of points
colAlphaColor or Color
xorModeXOR drawing (default=off). Used twice, recovers the original content
int xy[]={120,30,200,60,160,80}; // polygon (one array)
fillPoly(xy,3,BLACK); // inside

◆ fillPoly() [3/3]

void Imagine::fillPoly ( const IntPoint2 * p,
int n,
const AlphaColor & col,
bool xorMode = false )

Draws a filled polygon. Close it, from last point to first one.

Parameters
pPoints positions
nNumber of points
colAlphaColor or Color
xorModeXOR drawing (default=off). Used twice, recovers the original content
IntPoint2 p[]={IntPoint2(400,400),IntPoint2(300,450),IntPoint2(350,480)}; // polygon (IntPoint2)
fillPoly(p,3,YELLOW); // inside

◆ fillRect() [1/2]

void Imagine::fillRect ( const IntPoint2 & p,
int w,
int h,
const AlphaColor & col,
bool xorMode = false )
inline

Fills a rectangle.

Parameters
pTop Left
w,hDimensions
colAlphaColor or Color
xorModeXOR drawing (default=off). Used twice, recovers the original content
fillRect(IntPoint2(300,200),30,20,Color(55,120,200),true); // filled rectangle (IntPoint2)
void fillRect(int x, int y, int w, int h, const AlphaColor &col, bool xorMode=false)
Filled rectangle.

◆ fillRect() [2/2]

void Imagine::fillRect ( int x,
int y,
int w,
int h,
const AlphaColor & col,
bool xorMode = false )

Fills a rectangle.

Parameters
x,yTop Left
w,hDimensions
colAlphaColor or Color
xorModeXOR drawing (default=off). Used twice, recovers the original content
fillRect(110,130,100,40,BLUE); // filled rectangle

◆ flushEvents()

void Imagine::flushEvents ( )

Flush the event queue.

See this page for usage: Handling events

flushEvents(); // flush events
void flushEvents()
Flush event queue, discarding unhandled events.

◆ getEvent()

void Imagine::getEvent ( int ms,
Event & ev )

Get next event in queue. Wait for around ms milliseconds before timeout.

Parameters
msNumber of milliseconds before timeout. ms=-1: no wait limit.
evThe event. If timeout, ev.type is EVT_NONE.

See this page for usage: Handling events

cout << "Generate events, press 'q' key done" << endl; // manually process events
Event ev;
do {
getEvent(500,ev);
switch (ev.type) {
case EVT_NONE:
cout << "No event for 500ms" << endl;
break;
case EVT_MOTION:
cout << "Motion" << endl;
break;
case EVT_KEY_ON:
cout << "Key " << ev.key << " pressed"<< endl;
break;
case EVT_KEY_OFF:
cout << "Key " << ev.key << " released"<< endl;
break;
case EVT_BUT_ON:
cout << "Button " << ev.button << " pressed"<< endl;
break;
case EVT_BUT_OFF:
cout << "Button " << ev.button << " released"<< endl;
break;
}
if (ev.type!=EVT_NONE)
cout << " Mouse=[" << ev.pix.x() <<','<<ev.pix.y() << "] ,State="<< ev.state
<< ",Win=" << ev.win << ",SubWin=" << ev.subWin << endl;
} while (ev.type!=EVT_KEY_ON || ev.key!='q'); // ...
const T & y() const
Read alias.
Definition FVector.h:118
const T & x() const
Read alias.
Definition FVector.h:104
void getEvent(int ms, Event &ev)
Get keyboard and mouse events.
Event info.
Definition Events.h:69
int key
Key code that triggered the event, if any (only for types EVT_KEY_ON and EVT_KEY_OFF).
Definition Events.h:78
int subWin
SubWindow where the event occurred.
Definition Events.h:84
EventType type
Event type.
Definition Events.h:71
int button
Mouse button (1,2,3) that triggered the event, if any.
Definition Events.h:75
Window win
Window where the event occurred.
Definition Events.h:82
EventState state
Keyboard state (bitfield) just before the event occured.
Definition Events.h:80
IntPoint2 pix
Mouse position (only for EVT_BUT_ON, EVT_BUT_OFF and EVT_MOTION).
Definition Events.h:73

Warning: Imagine++ up to version 4.2.0 used to return uppercase letters for key press even when the SHIFT key was not pressed. This is no longer the case, so that if only a letter key is pressed, the lowercase ASCII code is returned in ev.key, such as 'a' instead of 'A'.

◆ getKey()

int Imagine::getKey ( bool ignoreModifier = true)

Waits for a key pressed in active window (see also anyGetKey()).

Parameters
ignoreModifierwhether to ignore modifier keys (shift, ctrl, alt)
Returns
ASCII code or KeyCode
do { // get key
cout << "Please press UP arrow in first tab" << endl;
} while (getKey() != KEY_UP); // ...

Warning: Imagine++ up to version 4.2.0 used to return uppercase letters even when the SHIFT key was not pressed. This is no longer the case, so that if only a letter key is pressed, the lowercase ASCII code is returned, such as 'a' instead of 'A'.

◆ getMouse() [1/2]

int Imagine::getMouse ( int & x,
int & y )

Waits for a mouse click in active window (see setActiveWindow()).

Parameters
x,yCoordinates of the cliked point
Returns
mouse button (1=left, 2=middle, 3=right)
button=getMouse(x,y); // get mouse
int getMouse(int &x, int &y)
Wait for mouse click in active window (returning position).

◆ getMouse() [2/2]

int Imagine::getMouse ( IntPoint2 & p)
inline

Waits for a mouse click in active window (see setActiveWindow()).

Parameters
pThe cliked point
Returns
mouse button (1=left, 2=middle, 3=right)
button=getMouse(p); // get mouse (IntPoint2)

◆ hideMesh()

void Imagine::hideMesh ( const Mesh & M,
bool reinitCam = true )

Removes a mesh from active window (must be a 3D window).

Parameters
MMesh to hide
reinitCamReset camera to fit all the meshes being viewed
hideMesh(fM); // hide mesh
void hideMesh(const Mesh &M, bool reinitCam=true)
Hide mesh.

Function only available if your version of Imagine++ was built with OpenGL support. The preprocessor macro IMAGINE_OPENGL indicates that, see file Imagine/Graphics/ConfigGraphics.h

◆ loadAlphaColorImage() [1/2]

bool Imagine::loadAlphaColorImage ( const std::string & name,
AlphaColor *& acols,
int & w,
int & h )

Loads and allocates a color image from a file.

Parameters
namefile name
acolsAlphaColor array (see putAlphaColorImage())
w,hdimensions
Returns
false if error
// Load Image with AlphaColor
int Aw, Ah;
if(loadAlphaColorImage("out.png", AC, Aw, Ah)) // Load PNG Image with a transparent background
cout << "out.png loaded" << endl;
cout << "Transparent image saved and reloaded on black background" << endl;
putAlphaColorImage(0,0,AC,Aw,Ah); // Display Image with Alpha channel
// ...
void setBackGround(const Color &col)
Set ackground color of window.
bool loadAlphaColorImage(const std::string &name, AlphaColor *&acols, int &w, int &h)
Load color image with alpha channel.

◆ loadAlphaColorImage() [2/2]

bool Imagine::loadAlphaColorImage ( const std::string & name,
octet *& rgba,
int & w,
int & h )

Loads and allocates a color image from a file.

Parameters
namefile name
rgbaarray (see putAlphaColorImage())
w,hdimensions
Returns
false if error
// load color image (1 rgba array)
octet* RGBA1;
loadAlphaColorImage(srcPath("ryu.gif"), RGBA, w1, h1); //GIF
loadAlphaColorImage(srcPath("sup.png"), RGBA1,w,h); //PNG
// ...
RED GREEN BLUE Alpha color.
Definition Color.h:140
unsigned char octet
0 to 255 integer type.
Definition Color.h:18

◆ loadColorImage() [1/4]

bool Imagine::loadColorImage ( const std::string & name,
Color *& cols,
int & w,
int & h )

Loads and allocates a color image from a file.

Parameters
namefile name
colsColor array (see putColorImage())
w,hdimensions
Returns
false if error
Color *C; // load color image (Color array)
loadColorImage(srcPath("ksmall.jpg"),C,w,h);
putColorImage(40,40,C,w,h);
saveColorImage("out2.tif",C,w,h);
delete[]C; // ...
bool saveColorImage(const std::string &name, const Color *cols, int w, int h, int quality=85)
Save color image.

◆ loadColorImage() [2/4]

bool Imagine::loadColorImage ( const std::string & name,
octet *& r,
octet *& g,
octet *& b,
int & w,
int & h )

Loads and allocates a color image from a file.

Parameters
namefile name
r,g,barrays (see putColorImage())
w,hdimensions
Returns
false if error
int w,h; // load color image (3 arrays)
octet *R,*G,*B;
loadColorImage(srcPath("ksmall.jpg"),R,G,B,w,h);
putColorImage(10,10,R,G,B,w,h);
saveColorImage("out1.png",R,G,B,w,h);
delete[]R;
delete[]G;
delete[]B; // ...

◆ loadColorImage() [3/4]

bool Imagine::loadColorImage ( const std::string & name,
octet *& r,
octet *& g,
octet *& b,
octet *& a,
int & w,
int & h )

Loads and allocates a color image from a file.

Parameters
namefile name
r,g,b,aarrays (see putAlphaColorImage())
w,hdimensions
Returns
false if error
// Load Image with Alpha channel
int w,h,w1,h1;
octet *R,*G,*B, *A;
octet *r,*g,*b, *a;
loadColorImage(srcPath("sup.png"),R,G,B,A,w,h); // Load PNG Image
loadColorImage(srcPath("test.jpg"), r,g,b,a,w1,h1); // Load JPEG Image
cout << "Transparent image (R,G,B,A) from PNG" << endl;
putColorImage(0,0,R,G,B,A,w,h);
click();// Display image with alpha channel
cout << "Two opaque images" << endl;
putColorImage(IntPoint2(100,100),r,g,b,a,w1,h1);
// ...
int click()
Wait for mouse click in active window.

◆ loadColorImage() [4/4]

bool Imagine::loadColorImage ( const std::string & name,
octet *& rgb,
int & w,
int & h )

Loads and allocates a color image from a file.

Parameters
namefile name
rgbarray (see putColorImage())
w,hdimensions
Returns
false if error
octet *RGB; // load color image (1 rgb array)
loadColorImage(srcPath("ksmall.jpg"),RGB,w,h);
putColorImage(70,70,RGB,w,h);
saveColorImage("out3.jpg",RGB,w,h);
saveColorImage("out4.jpg",RGB,w,h,95);
delete[]RGB; // ...

◆ loadGreyImage()

bool Imagine::loadGreyImage ( const std::string & name,
octet *& g,
int & w,
int & h )

Loads and allocates a grey image from a file.

Parameters
namefile name
garray (see putGreyImage())
w,hdimensions
Returns
false if error
octet *I; // load grey image
loadGreyImage(srcPath("ksmall.jpg"),I,w,h);
putGreyImage(100,100,I,w,h);
saveGreyImage("out5.png",I,w,h);
delete[]I; // ...
void putGreyImage(int x, int y, const octet *g, int w, int h, bool xorMode=false, double fact=1.)
Display grey bitmap.
bool loadGreyImage(const std::string &name, octet *&g, int &w, int &h)
Load grey image.
bool saveGreyImage(const std::string &name, const octet *g, int w, int h, int quality=85)
Save grey image.

◆ milliSleep()

void Imagine::milliSleep ( int msec)

Waits for (approximately!) msec milliseconds, then return.

Parameters
msecnumber of milliseconds
for (int i=0;i<4;i++) { // sleep
cout << i << endl;
milliSleep(300); // 300ms
} // ...
void milliSleep(int msec)
... Pause program for a certain period.

◆ noRefreshBegin()

void Imagine::noRefreshBegin ( )

To draw faster, stop refreshing 2D drawings. They are buffered until noRefreshEnd() is called.

noRefreshBegin(); // No refresh section
void noRefreshBegin()
Norefresh begin.
for (int i=0;i<200;i+=5)
drawPoint(i+10,250-i,RED);
noRefreshEnd(); // ...
void noRefreshEnd()
Norefresh end.

◆ noRefreshEnd()

void Imagine::noRefreshEnd ( )

Ends a section started with noRefreshBegin().

noRefreshBegin(); // No refresh section
for (int i=0;i<200;i+=5)
drawPoint(i+10,250-i,RED);
noRefreshEnd(); // ...

◆ noRefreshPop()

void Imagine::noRefreshPop ( )
inline

Ends a section started with noRefreshPush()

noRefreshPush(); // No refresh section (push/pop)
void noRefreshPush()
Norefresh push.
Definition Draw.h:405
for (int i=0;i<200;i+=5)
drawCircle(i+10,i+10,3,BLUE);
noRefreshPop(); // ...
void noRefreshPop()
Norefresh pop.
Definition Draw.h:413

◆ noRefreshPush()

void Imagine::noRefreshPush ( )
inline

To draw faster, stop refreshing 2D drawings. They are buffered until corresponding noRefreshPop() is called. Push and pop might be recursively included.

noRefreshPush(); // No refresh section (push/pop)
for (int i=0;i<200;i+=5)
drawCircle(i+10,i+10,3,BLUE);
noRefreshPop(); // ...

◆ openComplexWindow()

Window Imagine::openComplexWindow ( int w,
int h,
const std::string & name = "Imagine++",
int tabsNb = 1,
const std::string * tabsNames = 0,
const WindowType * tabsTypes = 0,
int x = -1,
int y = -1 )

Creates and opens a complex window with tabsNb tabs. If no other window or complex window is opened, first tab becomes the active window

Parameters
w,hsize
namewindowTitle title (default="Imagine++")
tabsNbnumber of tabs
tabsNamestitles of tabs (can be null array)
tabsTypestypes of tabs (WINDOW_2D or WINDOW_3D). This can be the null array, in which case all windows are 2D.
x,yscreen position (default=let OS choose)
Returns
a window handle
Window W1=openWindow(300,200); // Open
Window openWindow(int w, int h, const std::string &windowTitle="Imagine++", int x=-1, int y=-1)
New window for 2D graphics.
WindowInternal * Window
Handle to a display window.
Definition Types.h:48
#ifdef IMAGINE_OPENGL
Window W2=openWindow3D(200,300, "3D");
#endif
Window W3=openComplexWindow(300,200,"3 tabs",3); // Complex Open
#ifdef IMAGINE_OPENGL
string names[]={"2D a","2D b","3D"};
WindowType types[]={WINDOW_2D,WINDOW_2D,WINDOW_3D};
Window W4=openComplexWindow(512,360,"2D/2D/3D",3,names, types);
#else
string names[]={"2D a","2D b"};
WindowType types[]={WINDOW_2D,WINDOW_2D};
Window W4=openComplexWindow(512,360,"2D/2D",2,names, types);
#endif
setActiveWindow(W3,1); // ...
Window openWindow3D(int w, int h, const std::string &windowTitle="Imagine++", int x=-1, int y=-1)
New window for 3D graphics.
Window openComplexWindow(int w, int h, const std::string &name="Imagine++", int tabsNb=1, const std::string *tabsNames=0, const WindowType *tabsTypes=0, int x=-1, int y=-1)
New complex window.
WindowType
Type of Window.
Definition Types.h:42

◆ openWindow()

Window Imagine::openWindow ( int w,
int h,
const std::string & windowTitle = "Imagine++",
int x = -1,
int y = -1 )

Creates and opens a window. If another window is already open, the new one does not get the painting orders yet, call setActiveWindow for that. If no other window is opened, no need to call setActiveWindow. If you are interested in a single window, you do not need to store the result in a variable.

Parameters
w,hsize
windowTitletitle (default="Imagine++")
x,yscreen position (default=let OS choose)
Returns
a window handle
Window W1=openWindow(300,200); // Open
#ifdef IMAGINE_OPENGL
Window W2=openWindow3D(200,300, "3D");
#endif
Window W3=openComplexWindow(300,200,"3 tabs",3); // Complex Open
#ifdef IMAGINE_OPENGL
string names[]={"2D a","2D b","3D"};
WindowType types[]={WINDOW_2D,WINDOW_2D,WINDOW_3D};
Window W4=openComplexWindow(512,360,"2D/2D/3D",3,names, types);
#else
string names[]={"2D a","2D b"};
WindowType types[]={WINDOW_2D,WINDOW_2D};
Window W4=openComplexWindow(512,360,"2D/2D",2,names, types);
#endif
setActiveWindow(W3,1); // ...

◆ openWindow3D()

Window Imagine::openWindow3D ( int w,
int h,
const std::string & windowTitle = "Imagine++",
int x = -1,
int y = -1 )

Creates and opens a window. If no other window is opened, becomes the active window

Parameters
w,hsize
windowTitletitle (default="Imagine++")
x,yscreen position (default=let OS choose)
Returns
a window handle
Window W1=openWindow(300,200); // Open
#ifdef IMAGINE_OPENGL
Window W2=openWindow3D(200,300, "3D");
#endif
Window W3=openComplexWindow(300,200,"3 tabs",3); // Complex Open
#ifdef IMAGINE_OPENGL
string names[]={"2D a","2D b","3D"};
WindowType types[]={WINDOW_2D,WINDOW_2D,WINDOW_3D};
Window W4=openComplexWindow(512,360,"2D/2D/3D",3,names, types);
#else
string names[]={"2D a","2D b"};
WindowType types[]={WINDOW_2D,WINDOW_2D};
Window W4=openComplexWindow(512,360,"2D/2D",2,names, types);
#endif
setActiveWindow(W3,1); // ...

◆ putAlphaColorImage() [1/3]

void Imagine::putAlphaColorImage ( const IntPoint2 & p,
octet * rgba,
int w,
int h,
bool xorMode = false,
double fact = 1. )

Displays a color bitmap. 1 rgba array.

Parameters
ptop left position of bitmap in window
rgbaarray of values, line after line, from top left to bottom right: {r(0,0),g(0,0),b(0,0),a(0,0),r(1,0),g(1,0),b(1,0),b(1,0),...}
w,hdimensions (h lines of w pixels)
xorModeXOR drawing (default=off). Used twice, recovers the original content
factscaling factor (default=1.)
// put alphacolor bitmap (1 rgba (RGBA) array)
cout << "Tranparent image (RGBA) from PNG" << endl;
octet *rgba;
loadAlphaColorImage(srcPath("sup.png"),rgba,w,h); // Load PNG Image
putAlphaColorImage(0,0,rgba,w,h);
putAlphaColorImage(IntPoint2(100,100),rgba,w,h);
// ...

◆ putAlphaColorImage() [2/3]

void Imagine::putAlphaColorImage ( int x,
int y,
Imagine::AlphaColor * cols,
int w,
int h,
bool xorMode = false,
double fact = 1. )

Displays a color bitmap. AlphaColor array.

Parameters
x,ytop left position of bitmap in window
colsarray of AlphaColor, line after line, from top left to bottom right
w,hdimensions (h lines of w pixels)
xorModeXOR drawing (default=off). Used twice, recovers the original content
factscaling factor (default=1.)
// Load Image with AlphaColor
int Aw, Ah;
if(loadAlphaColorImage("out.png", AC, Aw, Ah)) // Load PNG Image with a transparent background
cout << "out.png loaded" << endl;
cout << "Transparent image saved and reloaded on black background" << endl;
putAlphaColorImage(0,0,AC,Aw,Ah); // Display Image with Alpha channel
// ...

◆ putAlphaColorImage() [3/3]

void Imagine::putAlphaColorImage ( int x,
int y,
octet * rgba,
int w,
int h,
bool xorMode = false,
double fact = 1. )

Displays a color bitmap. 1 rgba array.

Parameters
x,ytop left position of bitmap in window
rgbaarray of values, line after line, from top left to bottom right: {r(0,0),g(0,0),b(0,0),a(0,0),r(1,0),g(1,0),b(1,0),b(1,0),...}
w,hdimensions (h lines of w pixels)
xorModeXOR drawing (default=off). Used twice, recovers the original content
factscaling factor (default=1.)
// put alphacolor bitmap (1 rgba (RGBA) array)
cout << "Tranparent image (RGBA) from PNG" << endl;
octet *rgba;
loadAlphaColorImage(srcPath("sup.png"),rgba,w,h); // Load PNG Image
putAlphaColorImage(0,0,rgba,w,h);
putAlphaColorImage(IntPoint2(100,100),rgba,w,h);
// ...

◆ putColorImage() [1/8]

void Imagine::putColorImage ( const IntPoint2 & p,
const Color * cols,
int w,
int h,
bool xorMode = false,
double fact = 1. )
inline

Displays a color bitmap. Color array.

Parameters
ptop left position of bitmap in window
colsarray of Color, line after line, from top left to bottom right
w,hdimensions (h lines of w pixels)
xorModeXOR drawing (default=off). Used twice, recovers the original content
factscaling factor (default=1.)
Color* cols=new Color[256*256]; // put color bitmap (Color array)
for (int j=0;j<256;j++)
for (int i=0;i<256;i++)
cols[i+256*j]=Color(i,(2*j)%256,(i+j)%256); // Colors, functions of (i,j)
putColorImage(384,0,cols,256,256); // Draw this 256x256 color bitmap in (384,0)
putColorImage(IntPoint2(640,0),cols,256,256,false,.75); // ... and in (640,0), shrinked

◆ putColorImage() [2/8]

void Imagine::putColorImage ( const IntPoint2 & p,
const octet * r,
const octet * g,
const octet * b,
const octet * a,
int w,
int h,
bool xorMode = false,
double fact = 1. )
inline

Displays a color bitmap. 4 arrays.

Parameters
ptop left position of bitmap in window
r,g,b,aarrays of RED/GREEN/BLUE/ALPHA values (0-255), line after line, from top left to bottom right
w,hdimensions (h lines of w pixels)
xorModeXOR drawing (default=off). Used twice, recovers the original content
factscaling factor (default=1.)
// Load Image with Alpha channel
int w,h,w1,h1;
octet *R,*G,*B, *A;
octet *r,*g,*b, *a;
loadColorImage(srcPath("sup.png"),R,G,B,A,w,h); // Load PNG Image
loadColorImage(srcPath("test.jpg"), r,g,b,a,w1,h1); // Load JPEG Image
cout << "Transparent image (R,G,B,A) from PNG" << endl;
putColorImage(0,0,R,G,B,A,w,h);
click();// Display image with alpha channel
cout << "Two opaque images" << endl;
putColorImage(IntPoint2(100,100),r,g,b,a,w1,h1);
// ...

◆ putColorImage() [3/8]

void Imagine::putColorImage ( const IntPoint2 & p,
const octet * r,
const octet * g,
const octet * b,
int w,
int h,
bool xorMode = false,
double fact = 1. )
inline

Displays a color bitmap. 3 arrays.

Parameters
ptop left position of bitmap in window
r,g,barrays of RED/GREEN/BLUE values (0-255), line after line, from top left to bottom right
w,hdimensions (h lines of w pixels)
xorModeXOR drawing (default=off). Used twice, recovers the original content
factscaling factor (default=1.)
octet r[256*256],g[256*256],b[256*256]; // put color bitmap (3 arrays)
for (int j=0;j<256;j++) {
for (int i=0;i<256;i++) {
r[i+256*j]=i; // Some (RED,GREEN,BLUE) functions of (i,j)
g[i+256*j]=255-i;
b[i+256*j]=(j<128)?255:0;
}
}
putColorImage(0,0,r,g,b,256,256); // Draw this 256x256 (r,g,b) bitmap in (0,0)
putColorImage(IntPoint2(256,0),r,g,b,256,256,false,.5); // ... and in (256,0), shrinked

◆ putColorImage() [4/8]

void Imagine::putColorImage ( const IntPoint2 & p,
const octet * rgb,
int w,
int h,
bool xorMode = false,
double fact = 1. )
inline

Displays a color bitmap. 1 rgb array.

Parameters
ptop left position of bitmap in window
rgbarray of values, line after line, from top left to bottom right: {r(0,0),g(0,0),b(0,0),r(1,0),g(1,0),b(1,0),...}
w,hdimensions (h lines of w pixels)
xorModeXOR drawing (default=off). Used twice, recovers the original content
factscaling factor (default=1.)
octet* rgb=new octet[3*256*256]; // put color bitmap (1 rgb array)
for (int j=0;j<256;j++)
for (int i=0;i<256;i++) {
rgb[3*(i+256*j)]=i/2; // RED
rgb[3*(i+256*j)+1]=255-j/2; // GREEN
rgb[3*(i+256*j)+2]=128; // BLUE
}
putColorImage(0,256,rgb,256,256); // Draw this 256x256 rgb bitmap in (0,256)
putColorImage(IntPoint2(256,256),rgb,256,256,false,.25); // ... and in (256,256), shrinked

◆ putColorImage() [5/8]

void Imagine::putColorImage ( int x,
int y,
const Color * cols,
int w,
int h,
bool xorMode = false,
double fact = 1. )

Displays a color bitmap. Color array.

Parameters
x,ytop left position of bitmap in window
colsarray of Color, line after line, from top left to bottom right
w,hdimensions (h lines of w pixels)
xorModeXOR drawing (default=off). Used twice, recovers the original content
factscaling factor (default=1.)
Color* cols=new Color[256*256]; // put color bitmap (Color array)
for (int j=0;j<256;j++)
for (int i=0;i<256;i++)
cols[i+256*j]=Color(i,(2*j)%256,(i+j)%256); // Colors, functions of (i,j)
putColorImage(384,0,cols,256,256); // Draw this 256x256 color bitmap in (384,0)
putColorImage(IntPoint2(640,0),cols,256,256,false,.75); // ... and in (640,0), shrinked

◆ putColorImage() [6/8]

void Imagine::putColorImage ( int x,
int y,
const octet * r,
const octet * g,
const octet * b,
const octet * a,
int w,
int h,
bool xorMode = false,
double fact = 1. )

Displays a color bitmap. 4 arrays.

Parameters
x,ytop left position of bitmap in window
r,g,b,aarrays of RED/GREEN/BLUE/ALPHA values (0-255), line after line, from top left to bottom right
w,hdimensions (h lines of w pixels)
xorModeXOR drawing (default=off). Used twice, recovers the original content
factscaling factor (default=1.)
// Load Image with Alpha channel
int w,h,w1,h1;
octet *R,*G,*B, *A;
octet *r,*g,*b, *a;
loadColorImage(srcPath("sup.png"),R,G,B,A,w,h); // Load PNG Image
loadColorImage(srcPath("test.jpg"), r,g,b,a,w1,h1); // Load JPEG Image
cout << "Transparent image (R,G,B,A) from PNG" << endl;
putColorImage(0,0,R,G,B,A,w,h);
click();// Display image with alpha channel
cout << "Two opaque images" << endl;
putColorImage(IntPoint2(100,100),r,g,b,a,w1,h1);
// ...

◆ putColorImage() [7/8]

void Imagine::putColorImage ( int x,
int y,
const octet * r,
const octet * g,
const octet * b,
int w,
int h,
bool xorMode = false,
double fact = 1. )

Displays a color bitmap. 3 arrays.

Parameters
x,ytop left position of bitmap in window
r,g,barrays of RED/GREEN/BLUE values (0-255), line after line, from top left to bottom right
w,hdimensions (h lines of w pixels)
xorModeXOR drawing (default=off). Used twice, recovers the original content
factscaling factor (default=1.)
octet r[256*256],g[256*256],b[256*256]; // put color bitmap (3 arrays)
for (int j=0;j<256;j++) {
for (int i=0;i<256;i++) {
r[i+256*j]=i; // Some (RED,GREEN,BLUE) functions of (i,j)
g[i+256*j]=255-i;
b[i+256*j]=(j<128)?255:0;
}
}
putColorImage(0,0,r,g,b,256,256); // Draw this 256x256 (r,g,b) bitmap in (0,0)
putColorImage(IntPoint2(256,0),r,g,b,256,256,false,.5); // ... and in (256,0), shrinked

◆ putColorImage() [8/8]

void Imagine::putColorImage ( int x,
int y,
const octet * rgb,
int w,
int h,
bool xorMode = false,
double fact = 1. )

Displays a color bitmap. 1 rgb array.

Parameters
x,ytop left position of bitmap in window
rgbarray of values, line after line, from top left to bottom right: {r(0,0),g(0,0),b(0,0),r(1,0),g(1,0),b(1,0),...}
w,hdimensions (h lines of w pixels)
xorModeXOR drawing (default=off). Used twice, recovers the original content
factscaling factor (default=1.)
octet* rgb=new octet[3*256*256]; // put color bitmap (1 rgb array)
for (int j=0;j<256;j++)
for (int i=0;i<256;i++) {
rgb[3*(i+256*j)]=i/2; // RED
rgb[3*(i+256*j)+1]=255-j/2; // GREEN
rgb[3*(i+256*j)+2]=128; // BLUE
}
putColorImage(0,256,rgb,256,256); // Draw this 256x256 rgb bitmap in (0,256)
putColorImage(IntPoint2(256,256),rgb,256,256,false,.25); // ... and in (256,256), shrinked

◆ putGreyImage() [1/2]

void Imagine::putGreyImage ( const IntPoint2 & p,
const octet * g,
int w,
int h,
bool xorMode = false,
double fact = 1. )
inline

Displays a grey bitmap.

Parameters
ptop left position of bitmap in window
garray of grey values between 0 and 255, line after line, from top left to bottom right
w,hdimensions (h lines of w pixels)
xorModeXOR drawing (default=off). Used twice, recovers the original content
factscaling factor (default=1.)
octet* grey=new octet[256*256]; // put grey bitmap
Image< octet, dim > grey(const Image< T, dim > &I, T m, T M)
Grey level representation.
Definition IO.h:289
for (int j=0;j<256;j++)
for (int i=0;i<256;i++)
grey[i+256*j]=octet(128+127*sin((i+j)/10.)); // Some pattern
putGreyImage(384,256,grey,256,256); // Draw at point (384,256);
putGreyImage(IntPoint2(640,256),grey,256,256,false,1.5); // ... and (640,256), expanded

◆ putGreyImage() [2/2]

void Imagine::putGreyImage ( int x,
int y,
const octet * g,
int w,
int h,
bool xorMode = false,
double fact = 1. )

Displays a grey bitmap.

Parameters
x,ytop left position of bitmap in window
garray of grey values between 0 and 255, line after line, from top left to bottom right
w,hdimensions (h lines of w pixels)
xorModeXOR drawing (default=off). Used twice, recovers the original content
factscaling factor (default=1.)
octet* grey=new octet[256*256]; // put grey bitmap
for (int j=0;j<256;j++)
for (int i=0;i<256;i++)
grey[i+256*j]=octet(128+127*sin((i+j)/10.)); // Some pattern
putGreyImage(384,256,grey,256,256); // Draw at point (384,256);
putGreyImage(IntPoint2(640,256),grey,256,256,false,1.5); // ... and (640,256), expanded

◆ putNativeBitmap()

void Imagine::putNativeBitmap ( int x,
int y,
const NativeBitmap & bm,
bool xorMode = false,
double fact = 1. )

Displays native bitmap into active window

Parameters
x,ydrawing position (top left in window)
bmthe native bitmap to display
xorModeXOR drawing (default=off). Used twice, recovers the original content
factscaling factor (default=1.)
putNativeBitmap(0,0,bm); // Put native bitmap
void putNativeBitmap(int x, int y, const NativeBitmap &bm, bool xorMode=false, double fact=1.)
Display native bitmap.
putNativeBitmap(IntPoint2(300,0),bm,false,1.5);
putNativeBitmap(0,300,bm,false,0.75);
for (int i=0;i<1024;i+=8) {
putNativeBitmap(i,200,bm,true,0.5); // use XOR to display/undisplay
milliSleep(100);
putNativeBitmap(i,200,bm,true,0.5);
} // ...

◆ saveAlphaColorImage() [1/3]

bool Imagine::saveAlphaColorImage ( const std::string & name,
const octet * r,
const octet * g,
const octet * b,
const octet * a,
int w,
int h,
int quality = 85 )

Saves a color image into a file.

Parameters
namefile name
r,g,b,aarrays (see putColorImage())
w,hdimensions
qualityJpeg quality (between 0 and 100)
Returns
false if error
// Save Image with an alpha channel
if(saveAlphaColorImage("out.png",r,g,b,a,w1,h1))
cout << "Image saved" << endl;
else
cout << "Image is *not* saved -> something is wrong" << endl;
// ...
bool saveAlphaColorImage(const std::string &name, Imagine::AlphaColor *cols, int w, int h, int quality=85)
Save color image with alpha channel.

◆ saveAlphaColorImage() [2/3]

bool Imagine::saveAlphaColorImage ( const std::string & name,
Imagine::AlphaColor * cols,
int w,
int h,
int quality = 85 )

Saves a color image into a file.

Parameters
namefile name
colsarray (see putAlphaColorImage())
w,hdimensions
qualityJpeg quality (between 0 and 100)
Returns
false if error
// create a mask from a color (AlphaColor array)
loadAlphaColorImage(srcPath("ryu.gif"),C,w,h); // Load a GIF image
setMaskFromColor(C, w, h, Color(112,136,136)); // Hide the background color
cout << "2nd Mask for AlphaColor" << endl;
saveAlphaColorImage("ryu2.png", C, w, h); // Save image to PNG with transparency
putAlphaColorImage(0,0,C,w,h); // Display Image with an alpha channel
click();
// ...

◆ saveAlphaColorImage() [3/3]

bool Imagine::saveAlphaColorImage ( const std::string & name,
octet * rgba,
int w,
int h,
int quality = 85 )

Saves a color image into a file.

Parameters
namefile name
rgbaarray (see putAlphaColorImage())
w,hdimensions
qualityJpeg quality (between 0 and 100)
Returns
false if error
// create a mask from a color (rgba array)
loadAlphaColorImage(srcPath("ryu.gif"), RGBA, w1, h1); // Load a GIF Image (prefer PNG)
setMaskFromColor(RGBA, w1, h1, Color(112,136,136)); // Hide the background color
saveAlphaColorImage("ruy.png", RGBA, w1, h1); // Save Image to PNG without background color (ie. with transparency)
putAlphaColorImage(0,0,RGBA1,w,h); // Display Image with an alpha channel
// ...

◆ saveColorImage() [1/3]

bool Imagine::saveColorImage ( const std::string & name,
const Color * cols,
int w,
int h,
int quality = 85 )

Saves a color image into a file.

Parameters
namefile name
colsarray (see putColorImage())
w,hdimensions
qualityJpeg quality (between 0 and 100)
Returns
false if error
Color *C; // load color image (Color array)
loadColorImage(srcPath("ksmall.jpg"),C,w,h);
putColorImage(40,40,C,w,h);
saveColorImage("out2.tif",C,w,h);
delete[]C; // ...

◆ saveColorImage() [2/3]

bool Imagine::saveColorImage ( const std::string & name,
const octet * r,
const octet * g,
const octet * b,
int w,
int h,
int quality = 85 )

Saves a color image into a file.

Parameters
namefile name
r,g,barrays (see putColorImage())
w,hdimensions
qualityJpeg quality (between 0 and 100)
Returns
false if error
int w,h; // load color image (3 arrays)
octet *R,*G,*B;
loadColorImage(srcPath("ksmall.jpg"),R,G,B,w,h);
putColorImage(10,10,R,G,B,w,h);
saveColorImage("out1.png",R,G,B,w,h);
delete[]R;
delete[]G;
delete[]B; // ...

◆ saveColorImage() [3/3]

bool Imagine::saveColorImage ( const std::string & name,
const octet * rgb,
int w,
int h,
int quality = 85 )

Saves a color image into a file.

Parameters
namefile name
rgbarray (see putColorImage())
w,hdimensions
qualityJpeg quality (between 0 and 100)
Returns
false if error
octet *RGB; // load color image (1 rgb array)
loadColorImage(srcPath("ksmall.jpg"),RGB,w,h);
putColorImage(70,70,RGB,w,h);
saveColorImage("out3.jpg",RGB,w,h);
saveColorImage("out4.jpg",RGB,w,h,95);
delete[]RGB; // ...

◆ saveGreyImage()

bool Imagine::saveGreyImage ( const std::string & name,
const octet * g,
int w,
int h,
int quality = 85 )

Saves a grey image into a file.

Parameters
namefile name
garray (see putGreyImage())
w,hdimensions
qualityJpeg quality (between 0 and 100)
Returns
false if error
octet *I; // load grey image
loadGreyImage(srcPath("ksmall.jpg"),I,w,h);
putGreyImage(100,100,I,w,h);
saveGreyImage("out5.png",I,w,h);
delete[]I; // ...

◆ setActiveWindow()

void Imagine::setActiveWindow ( Window w,
int subWin = 0 )

Sets the active tab into given ComplexWindow, i.e. the one that will get the next drawing commands.

Parameters
wWindow handle
subWintab index
Window W1=openWindow(300,200); // Open
#ifdef IMAGINE_OPENGL
Window W2=openWindow3D(200,300, "3D");
#endif
Window W3=openComplexWindow(300,200,"3 tabs",3); // Complex Open
#ifdef IMAGINE_OPENGL
string names[]={"2D a","2D b","3D"};
WindowType types[]={WINDOW_2D,WINDOW_2D,WINDOW_3D};
Window W4=openComplexWindow(512,360,"2D/2D/3D",3,names, types);
#else
string names[]={"2D a","2D b"};
WindowType types[]={WINDOW_2D,WINDOW_2D};
Window W4=openComplexWindow(512,360,"2D/2D",2,names, types);
#endif
setActiveWindow(W3,1); // ...

◆ setBackGround()

void Imagine::setBackGround ( const Color & col)

Sets window background (for 2D and 3D graphics).

Parameters
colBackground Color
setActiveWindow(W4,2); // background (2D only)

◆ setCamera()

void Imagine::setCamera ( const DoublePoint3 & pos,
const DoublePoint3 & dir,
const DoubleVector3 & up )
Parameters
poswhere the camera is
dirwhere the camera is looking at, relative to pos
upthe up direction

◆ setLight() [1/2]

void Imagine::setLight ( bool b)

The default diffuse light has direction z, the viewing direction.

◆ setLight() [2/2]

void Imagine::setLight ( const FloatVector3 & dir,
float ambient = 0.2f )

The direction vector is automatically normalized, but putting a null vector indicates no lighting (and ambient is indifferent).

// 3D lighting
FloatVector3 dir(0.0f, sqrt(0.5), sqrt(0.5));
const float theta=0.05f;
const float rot[3*3] = { // Rotation matrix
cos(theta), sin(theta), 0,
-sin(theta), cos(theta), 0,
0, 0, 1};
FMatrix<float,3,3> rotz(rot);
cout << "Change light direction" << endl;
while(true) {
// hideMesh(S,false);
setLight(dir);
// showMesh(S, false);
Event e; // Wait for mouse click without blocking
getEvent(100,e);
if(e.type == EVT_BUT_ON)
break;
dir = rotz*dir;
}
// ...
void setLight(bool b)
Set/unset lighting in 3D rendering.
FloatPoint3 FloatVector3
Float space vector.
Definition Types.h:25

◆ setMaskFromColor() [1/3]

void Imagine::setMaskFromColor ( AlphaColor *& acols,
int w,
int h,
AlphaColor col )

It puts the value 0 to the alpha-channel for all pixels which contain the color you want to hide. In other words, the Color col becomes invisible

Parameters
acolsarray of AlphaColor, line after line, from top left to bottom right
w,hdimensions (h lines of w pixels)
colcolor that is about to be hidden
// create a mask from a color (AlphaColor array)
loadAlphaColorImage(srcPath("ryu.gif"),C,w,h); // Load a GIF image
setMaskFromColor(C, w, h, Color(112,136,136)); // Hide the background color
cout << "2nd Mask for AlphaColor" << endl;
saveAlphaColorImage("ryu2.png", C, w, h); // Save image to PNG with transparency
putAlphaColorImage(0,0,C,w,h); // Display Image with an alpha channel
click();
// ...

◆ setMaskFromColor() [2/3]

void Imagine::setMaskFromColor ( octet *& r,
octet *& g,
octet *& b,
octet *& a,
int w,
int h,
const Color & col )

It puts the value 0 to the alpha-channel for all pixels which contain the color you want to hide. In other words, the Color col becomes invisible

Parameters
r,g,b,aarrays of RED/GREEN/BLUE/ALPHA values (0-255), line after line, from top left to bottom right
w,hdimensions (h lines of w pixels)
colcolor that is about to be hidden ///
// create mask from a color
loadColorImage(srcPath("ryu.gif"), r, g, b, a, w1, h1); // Load color with alpha channel (for transparency, using PNG or GIF is better)
setMaskFromColor(r,g,b,a,w1,h1,Color(112,136,136)); // Hide the background color
cout << "First Mask" << endl;
putColorImage(0,0,r,g,b,a,w1,h1); // Display Image with alpha channel
click();
// ...

◆ setMaskFromColor() [3/3]

void Imagine::setMaskFromColor ( octet *& rgba,
int w,
int h,
const Color & col )

It puts the value 0 to the alpha-channel for all pixels which contain the color you want to hide. In other words, the Color col becomes invisible

Parameters
rgbaarray of values, line after line, from top left to bottom right: {r(0,0),g(0,0),b(0,0),a(0,0),r(1,0),g(1,0),b(1,0),a(1,0),...}
w,hdimensions (h lines of w pixels)
colcolor that is about to be hidden
// create a mask from a color (rgba array)
loadAlphaColorImage(srcPath("ryu.gif"), RGBA, w1, h1); // Load a GIF Image (prefer PNG)
setMaskFromColor(RGBA, w1, h1, Color(112,136,136)); // Hide the background color
saveAlphaColorImage("ruy.png", RGBA, w1, h1); // Save Image to PNG without background color (ie. with transparency)
putAlphaColorImage(0,0,RGBA1,w,h); // Display Image with an alpha channel
// ...

◆ showMesh()

void Imagine::showMesh ( const Mesh & M,
bool reinitCam = true )

Shows a mesh in active window (must be a 3D window).

Parameters
MMesh to show
reinitCamReset camera to view all meshes (same as SHIFT-r)
Mesh cone=Mesh::Cone(DoublePoint3(0,0,0),DoubleVector3(0,1,0),0.25); // show mesh
A mesh representing a 3D object.
Definition Mesh.h:151
static Mesh Cone(const DoublePoint3 &base, const DoubleVector3 &axis, double r, int resolution=32)
Cone.
DoublePoint3 DoubleVector3
Double space vector.
Definition Types.h:21
FVector< double, 3 > DoublePoint3
Double space point.
Definition Types.h:19
cone.setColor(CYAN);
showMesh(cone); // ...
void setColor(Color col)
Set color.
void showMesh(const Mesh &M, bool reinitCam=true)
Show mesh.

IMPORTANT NOTE:

  • A mesh does not live in a window! It can be viewed in more than one window (showMesh/hideMesh functions).
  • Closing a window does not delete the meshes viewed in it
  • To hide the mesh later, you must keep the mesh variable.
    • For instance:
      showMesh(Mesh(...)); // Displayed, but cannot be hidden later
      This is the right thing to do:
      Mesh S(...);
    • Inside a function:
      Mesh f() {
      Mesh S(...);
      return S;
      }
      void g() {
      Mesh S=f();
      ... // We can hide it later with hideMesh(S);
      }
  • However, it is possible to hide all meshes in active window with clearWindow function

Function only available if your version of Imagine++ was built with OpenGL support. The preprocessor macro IMAGINE_OPENGL indicates that, see file Imagine/Graphics/ConfigGraphics.h

◆ showWindow()

void Imagine::showWindow ( Window w,
int subWin = 0 )

Brings a window to front and sets it active.

Parameters
wWindow handle
subWinsubwindow number (optional)
showWindow(W1); // show
void showWindow(Window w, int subWin=0)
Show window.
showWindow(W4,2); // ...

◆ unGetEvent()

void Imagine::unGetEvent ( const Event & ev)

Push back event at end of queue.

Parameters
evThe event.

See this page for usage: Handling events

unGetEvent(ev); // unget event
void unGetEvent(const Event &ev)
Unget event.