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
Save the content as image file
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Santhosh NRank #4,788 · 325 reputationPosted Jan 6, 2010, 7:12 PM EST
you can check here for a sample
http://www.homeandlearn.co.uk/csharp/csharp_s15p2.html