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

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); // ...
The possible codes are:
enum 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
};
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

Examples:
Graphics/test/example.cpp, Graphics/test/particles.cpp, Graphics/test/test.cpp, and Images/test/test.cpp.

◆ 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)
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'.

Examples:
Graphics/test/test.cpp.

◆ 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)

Examples:
Graphics/test/test.cpp.

◆ 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 ( 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)

Examples:
Graphics/test/test.cpp.

◆ capturePoint() [2/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)

◆ captureRectangle() [1/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)

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ captureRectangle() [2/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)

◆ captureRectangle() [3/6]

void Imagine::captureRectangle ( int  x,
int  y,
byte *  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)

◆ captureRectangle() [4/6]

void Imagine::captureRectangle ( const IntPoint2 p,
byte *  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() [5/6]

void Imagine::captureRectangle ( int  x,
int  y,
byte *  R,
byte *  G,
byte *  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 ( const IntPoint2 p,
byte *  R,
byte *  G,
byte *  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)

◆ 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)
captureWindow(C,w,h);
putColorImage(542,10,C,w,h,false,.25);
delete[]C; // ...

Examples:
Graphics/test/test.cpp.

◆ captureWindow() [2/3]

void Imagine::captureWindow ( byte *&  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)
captureWindow(RGB,w,h);
putColorImage(276,10,RGB,w,h,false,.25);
delete[]RGB; // ...

◆ captureWindow() [3/3]

void Imagine::captureWindow ( byte *&  R,
byte *&  G,
byte *&  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; // ...

◆ clearWindow()

void Imagine::clearWindow ( )

Clears a window.

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

Examples:
Graphics/test/example.cpp, Graphics/test/test.cpp, and Images/test/test.cpp.

◆ 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;

Examples:
Graphics/test/example.cpp, Graphics/test/test.cpp, and Images/test/test.cpp.

◆ 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
#ifdef IMAGINE_OPENGL
#endif
closeWindow(W4); // ...

Examples:
Graphics/test/example.cpp, Graphics/test/particles.cpp, Graphics/test/test.cpp, and Images/test/test.cpp.

◆ 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
// ...
Examples:
Graphics/test/test.cpp.

◆ drawArrow() [1/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

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ 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)

◆ 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)

◆ drawArrow() [4/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)

◆ drawCircle() [1/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

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ drawCircle() [2/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)

◆ drawEllipse() [1/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

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ drawEllipse() [2/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)

◆ drawLine() [1/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

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ drawLine() [2/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)

◆ drawPoint() [1/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

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ drawPoint() [2/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)

◆ 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

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ drawPoly() [2/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

◆ drawPoly() [3/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

◆ drawRect() [1/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

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ drawRect() [2/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)

◆ drawString() [1/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.); // ...

Examples:
Graphics/test/example.cpp, Graphics/test/particles.cpp, and Graphics/test/test.cpp.

◆ drawString() [2/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
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

Examples:
Graphics/test/test.cpp.

◆ endGraphics()

void Imagine::endGraphics ( )

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

Examples:
Graphics/test/example.cpp, Graphics/test/particles.cpp, Graphics/test/test.cpp, and Images/test/test.cpp.

◆ fillCircle() [1/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

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ fillCircle() [2/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)

◆ fillEllipse() [1/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

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ fillEllipse() [2/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)

◆ 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

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ fillPoly() [2/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

◆ fillPoly() [3/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

◆ fillRect() [1/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

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ fillRect() [2/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)

◆ flushEvents()

void Imagine::flushEvents ( )

Flush the event queue.

See this page for usage: Handling events

flushEvents(); // flush events

Examples:
Graphics/test/test.cpp.

◆ 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'); // ...
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'.

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ 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'.

Examples:
Graphics/test/test.cpp.

◆ 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

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ 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

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

Examples:
Graphics/test/example.cpp, Graphics/test/particles.cpp, and Graphics/test/test.cpp.

◆ 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
// ...

Examples:
Graphics/test/test.cpp.

◆ loadAlphaColorImage() [2/2]

bool Imagine::loadAlphaColorImage ( const std::string &  name,
byte *&  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)
byte* RGBA;
byte* RGBA1;
loadAlphaColorImage(srcPath("ryu.gif"), RGBA, w1, h1); //GIF
loadAlphaColorImage(srcPath("sup.png"), RGBA1,w,h); //PNG
// ...

◆ 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; // ...

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ loadColorImage() [2/4]

bool Imagine::loadColorImage ( const std::string &  name,
byte *&  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
byte *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; // ...

◆ loadColorImage() [3/4]

bool Imagine::loadColorImage ( const std::string &  name,
byte *&  r,
byte *&  g,
byte *&  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)
byte *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() [4/4]

bool Imagine::loadColorImage ( const std::string &  name,
byte *&  r,
byte *&  g,
byte *&  b,
byte *&  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;
byte *R,*G,*B, *A;
byte *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);
// ...

◆ loadGreyImage()

bool Imagine::loadGreyImage ( const std::string &  name,
byte *&  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
byte *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; // ...

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ milliSleep()

void Imagine::milliSleep ( int  msec)

Pause program for a certain period. 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
} // ...

Examples:
Graphics/test/example.cpp, Graphics/test/particles.cpp, and Graphics/test/test.cpp.

◆ noRefreshBegin()

void Imagine::noRefreshBegin ( )

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

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

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ 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(); // ...

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ noRefreshPop()

void Imagine::noRefreshPop ( )
inline

Ends a section started with noRefreshPush()

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

Examples:
Graphics/test/test.cpp.

◆ 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(); // ...

Examples:
Graphics/test/test.cpp.

◆ 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
#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); // ...

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ 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); // ...

Examples:
Graphics/test/example.cpp, Graphics/test/particles.cpp, Graphics/test/test.cpp, and Images/test/test.cpp.

◆ 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); // ...

Examples:
Graphics/test/example.cpp, Graphics/test/particles.cpp, and Graphics/test/test.cpp.

◆ putAlphaColorImage() [1/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
// ...

Examples:
Graphics/test/test.cpp.

◆ putAlphaColorImage() [2/3]

void Imagine::putAlphaColorImage ( int  x,
int  y,
byte *  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.)

◆ putAlphaColorImage() [3/3]

void Imagine::putAlphaColorImage ( const IntPoint2 p,
byte *  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.)

◆ putColorImage() [1/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

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ putColorImage() [2/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() [3/8]

void Imagine::putColorImage ( int  x,
int  y,
const byte *  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.)
byte* rgb=new byte[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() [4/8]

void Imagine::putColorImage ( const IntPoint2 p,
const byte *  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.)
byte* rgb=new byte[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 byte *  r,
const byte *  g,
const byte *  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.)
byte 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() [6/8]

void Imagine::putColorImage ( const IntPoint2 p,
const byte *  r,
const byte *  g,
const byte *  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.)
byte 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() [7/8]

void Imagine::putColorImage ( int  x,
int  y,
const byte *  r,
const byte *  g,
const byte *  b,
const byte *  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;
byte *R,*G,*B, *A;
byte *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() [8/8]

void Imagine::putColorImage ( const IntPoint2 p,
const byte *  r,
const byte *  g,
const byte *  b,
const byte *  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;
byte *R,*G,*B, *A;
byte *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);
// ...

◆ putGreyImage() [1/2]

void Imagine::putGreyImage ( int  x,
int  y,
const byte *  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.)
byte* grey=new byte[256*256]; // put grey bitmap
for (int j=0;j<256;j++)
for (int i=0;i<256;i++)
grey[i+256*j]=byte(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

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ putGreyImage() [2/2]

void Imagine::putGreyImage ( const IntPoint2 p,
const byte *  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.)
byte* grey=new byte[256*256]; // put grey bitmap
for (int j=0;j<256;j++)
for (int i=0;i<256;i++)
grey[i+256*j]=byte(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
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);
} // ...

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ saveAlphaColorImage() [1/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();
// ...

Examples:
Graphics/test/test.cpp.

◆ saveAlphaColorImage() [2/3]

bool Imagine::saveAlphaColorImage ( const std::string &  name,
byte *  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
// ...

◆ saveAlphaColorImage() [3/3]

bool Imagine::saveAlphaColorImage ( const std::string &  name,
const byte *  r,
const byte *  g,
const byte *  b,
const byte *  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;
// ...

◆ 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; // ...

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ saveColorImage() [2/3]

bool Imagine::saveColorImage ( const std::string &  name,
const byte *  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
byte *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; // ...

◆ saveColorImage() [3/3]

bool Imagine::saveColorImage ( const std::string &  name,
const byte *  r,
const byte *  g,
const byte *  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)
byte *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; // ...

◆ saveGreyImage()

bool Imagine::saveGreyImage ( const std::string &  name,
const byte *  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
byte *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; // ...

Examples:
Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ 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

Examples:
Graphics/test/example.cpp, Graphics/test/particles.cpp, Graphics/test/test.cpp, and Images/test/test.cpp.

◆ setBackGround()

void Imagine::setBackGround ( const Color col)

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

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

Examples:
Graphics/test/particles.cpp, and Graphics/test/test.cpp.

◆ 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
Examples:
Graphics/test/particles.cpp, and Graphics/test/test.cpp.

◆ setLight() [1/3]

void Imagine::setLight ( bool  b)

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

Examples:
Graphics/test/test.cpp.

◆ setLight() [2/3]

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;
}
// ...

◆ setLight() [3/3]

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.

◆ setMaskFromColor() [1/3]

void Imagine::setMaskFromColor ( byte *&  r,
byte *&  g,
byte *&  b,
byte *&  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();
// ...
Examples:
Graphics/test/test.cpp.

◆ setMaskFromColor() [2/3]

void Imagine::setMaskFromColor ( byte *&  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
// ...

◆ setMaskFromColor() [3/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();
// ...

◆ 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)

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

Examples:
Graphics/test/example.cpp, Graphics/test/particles.cpp, and Graphics/test/test.cpp.

◆ 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
showWindow(W4,2); // ...

Examples:
Graphics/test/test.cpp.

◆ 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

Examples:
Graphics/test/test.cpp.