Dhava Mani

Dhava Mani

  • NA
  • 1
  • 0

Save the content as image file

Jan 6 2010 11:59 PM
Hi,
i'm having a user control. in that i draw some lines. now i want to save the lines as a image when i click the save button. but the lines are not saving in the image.here is my code. this is done in windows application.



uctest line = new uctest();

private void frmTest_Load(object sender, EventArgs e)
{
this.Controls.Add(line);
}
private void button1_Click(object sender, EventArgs e)
{
SaveAsBitmap(this.line , "D:\\f1.jpg");
}
public void SaveAsBitmap(Control control, string fileName)
{

Graphics g = control.CreateGraphics();
Bitmap bmp = new Bitmap(control.Width, control.Height);

Image MyImage = new Bitmap(control.Width, control.Height);


control.DrawToBitmap(bmp, new Rectangle(0, 0, control.Width, control.Height));
bmp.Save(fileName);
bmp.Dispose();
}


thanks

Answers (1)