C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » C# Syntax »

Create ScreenShot using C#


Posted Date: 08 Jul 2009    Resource Type: Code Snippets    Category: C# Syntax
Author: Harish ShankerMember Level: Gold    
Rating: 1 out of 5Points: 10



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();
}



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Screen shot  .  Print screen  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: To shutdown the system
Previous Resource: How to Run Our Windows/Console Application during Windows Startup?
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use