Bitmap theScreenShot = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
theScreenShot.Save(stream_or_filename, ImageFormat.Jpeg);
theScreenShot.Dispose();
Another way to save the panel as a jpg format and you can take a print of your control using below method.
Use this event on your form :-
_document.PrintPage += new PrintPageEventHandler(document_PrintPage);
/// Prepare the page to be print for the area of the control to be printed.
private void document_PrintPage(object sender, PrintPageEventArgs e)
{
this.Dock = System.Windows.Forms.DockStyle.None;
this.Size = Temp_Image.Size;
//Takes away focus from any printed controls to make sure output is what we want.
this.Focus();
this.Refresh();
this.DrawToBitmap(Temp_Image, New System.Drawing.Rectangle(0, 0, Temp_Image.Width, Temp_Image.Height));
this.Dock = System.Windows.Forms.DockStyle.Fill;
e.Graphics.DrawImage(Temp_Image, e.MarginBounds);
e.Graphics.Clip = new Region(e.MarginBounds);
}
By this method you can print your control you just pass the object of your control (control will be panel,treeView,listView)and this will calculate the height ,width and then call the print method ,print preview or save as jpg file.
0 comments:
Post a Comment