| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
2.1.3 Drawing in memory
The last way of MathGL using is the drawing in memory. Class mglGraphZB allows one to create a bitmap picture in memory. Further this picture can be displayed in window by some window libraries (like wxWidgets, FLTK, Windows GDI and so on). For example, the code for drawing in wxWidget library looks like:
void MyForm::OnPaint(wxPaintEvent& event)
{
int w,h,x,y;
GetClientSize(&w,&h); // size of the picture
mglGraphZB gr(w,h);
gr.Alpha(true); // draws something using MathGL
gr.Light(true); gr.Light(0,mglPoint(1,0,-1));
sample(&gr,NULL);
wxImage img(w,h,gr.GetBits(),true);
ToolBar->GetSize(&x,&y); // gets a height of the toolbar if any
wxPaintDC dc(this); // and draws it
dc.DrawBitmap(wxBitmap(img),0,y);
}
The drawing in other libraries is most the same. Moreover, I excluded the support of TIFF and JPEG files from MathGL by default for compatibility with wxWidgets library.
