Hi all

I am wanting to write a collection of GDI+ objects (rectangles, lines etc) and save the resulting diagram to a graphics file (JPG or PNG). I can easily draw what I want to screen by doing the following:
Code:
void CCanvas::DrawModelToScreen() 
{
  CClientDC dc(this);
  Graphics graphics(dc.m_hDC);
  SolidBrush whiteBrush(Color(255, 255, 255, 255));
  Pen blackPen(Color(255, 0,0,0));

  int x = 10;
  int y = 10;
  int width = 100;
  int height = 100;

  graphics.FillRectangle(&whiteBrush, x, y, width, height);
  graphics.DrawRectangle(&blackPen, x, y, width, height);
  ....
}
However I have absolutely no idea how write to a JPEG or PNG instead. Please can someone help!!