This c# code will help to make a screen shot and save it accordingly.
//namespace to be included using System.Drawing.Imaging;
//Define Image & graphics variable. private static Bitmap bmpScreenShot; private static Graphics graphicScreenShot;
//The button click event. private void button_Capture_Click(object sender, EventArgs e) { //To hide the form, otherwise it will be there in screen shot. this.Hide();
//setting the bitmap object to the size of the screen. bmpScreenShot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
//creating a graphic object from that bitmap. graphicScreenShot = Graphics.FromImage(bmpScreenShot);
//Taking the screen shot from the top left corner to bottom right corner. graphicScreenShot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
//Saving the screenshot in the defined format at the specified location. bmpScreenShot.Save("C:\\test.bmp", ImageFormat.Bmp);
//Again showing the form. this.Show(); }
|
No responses found. Be the first to respond and make money from revenue sharing program.
|