<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Farooq Azam &#187; screen capture</title>
	<atom:link href="http://www.farooqazam.net/tag/screen-capture/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.farooqazam.net</link>
	<description>C# &#38; .NET Programming Blog</description>
	<lastBuildDate>Fri, 23 Jul 2010 20:15:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Screen Capture Class For C#</title>
		<link>http://www.farooqazam.net/screen-capture-class-for-c-sharp/</link>
		<comments>http://www.farooqazam.net/screen-capture-class-for-c-sharp/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 16:30:46 +0000</pubDate>
		<dc:creator>Farooq Azam</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[c sharp]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[screen capture]]></category>

		<guid isPermaLink="false">http://www.farooqazam.net/?p=106</guid>
		<description><![CDATA[A class that will help you take screenshots quickly and easily. Following are the features of this class: Take screenshot of the whole screen Take screenshot of a particular area using a Rectangle Copy the screenshot to Clipboard. Save the screenshot straight after it is captured. All popular image formats are supported. How to use? [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.farooqazam.net%2Fscreen-capture-class-for-c-sharp%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.farooqazam.net%2Fscreen-capture-class-for-c-sharp%2F&amp;source=farooqaaa&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><img class="alignnone size-full wp-image-108" title="ScreenCapture" src="http://www.farooqazam.net/wp-content/uploads/2009/09/ScreenCapture.gif" alt="ScreenCapture" width="495" height="291" /></p>
<p>A class that will help you take screenshots quickly and easily.</p>
<p>Following are the features of this class:<span id="more-106"></span></p>
<ul>
<li>Take screenshot of the whole screen</li>
<li>Take screenshot of a particular area using a Rectangle</li>
<li>Copy the screenshot to Clipboard.</li>
<li>Save the screenshot straight after it is captured.</li>
<li>All popular image formats are supported.</li>
</ul>
<p><span id="more-103"> </span></p>
<h3>How to use?</h3>
<p>To import this class into your C# project all you have to do is to drag and drop the “ScreenCapture.cs” file into your project.</p>
<p>It is very simple to use this class. Here’s an overview of all the features:</p>
<pre class="brush: csharp;">// Add this code to the top of your code
// i.e: add it above &quot;public Form1() { ......&quot;

SC.ScreenCapture SC = new SC.ScreenCapture();

// To take a screenshot of the whole screen
// Use this code:

SC.CaptureScreen();

// If you want to save the screenshot straight after it is taken
// Use this code:
// Replace &quot;C:\\screenshot.jpg&quot; with your own path

SC.CaptureScreen(@&quot;C:\screenshot.jpg&quot;);

// To take screenshot of a particular area
// Use this code:
// Replace &quot;Rect&quot; with a Rectangle

SC.CaptureRectangle(Rect);

// To save the screenshot straight after it is taken
// Use this code:
// Replace &quot;C:\screenshot-rect.jpg&quot; with your own path and &quot;Rect&quot; with a rectangle.

SC.CaptureRectangle(Rect, &quot;C:\\screenshot-rect.jpg&quot;);

// Note: Use the code below after you've taken a screenshot.
// To copy the screenshot to Clipboard
// Use this code

SC.CopyToClipboard();
</pre>
<p>The above instructions showed you all the features this class offers. However, if you want to see this class in acton. Then I’ve made a simple application for you, which uses this class. Download the class alone or the sample application below:</p>
<h3>Dowload the ScreenCapture class and a sample application</h3>
<blockquote><p>ScreenCapture Class – <a title="Download ScreenCapture class" href="../source/ScreenCapture-class.zip"><strong>Download Now</strong></a> (1 Kb)</p>
<p>Sample Application – <a title="Download Sample Application" href="../source/ScreenCapture-sample.zip"><strong>Download Now</strong></a> (46 Kb)</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.farooqazam.net/screen-capture-class-for-c-sharp/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Screen Capture Application using C#</title>
		<link>http://www.farooqazam.net/screen-capture-application-using-c-sharp/</link>
		<comments>http://www.farooqazam.net/screen-capture-application-using-c-sharp/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 16:51:31 +0000</pubDate>
		<dc:creator>Farooq Azam</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[c sharp]]></category>
		<category><![CDATA[screen capture]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.farooqazam.net/?p=77</guid>
		<description><![CDATA[This is a detailed tutorial about making a simple Screen Capture (Screenshot Capture) application in C#. The features are: Take screenshot, view it and save it. We will be making a simple application but if you are little bit good with C# then you can enhance it and make it much better. Setting up the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.farooqazam.net%2Fscreen-capture-application-using-c-sharp%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.farooqazam.net%2Fscreen-capture-application-using-c-sharp%2F&amp;source=farooqaaa&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><a title="Click to enlarge" href="../wp-content/uploads/2009/09/form1.gif"><img title="Screen Capture Application" src="../wp-content/uploads/2009/09/form1.gif" alt="Screen Capture Application" width="411" height="380" /></a></p>
<p>This is a detailed tutorial about making a simple Screen Capture (Screenshot Capture) application in C#. The features are: Take screenshot, view it and save it. We will be making a simple application but if you are little bit good with C# then you can enhance it and make it much better.</p>
<h3>Setting up the Form</h3>
<p>For this tutorial we will need 2 buttons, a timer, SaveFileDialog and a PictureBox. Here&#8217;s the info:<span id="more-77"></span></p>
<ol>
<li>Add a button first and set its &#8220;Text&#8221; property to &#8220;Take Screenshot&#8221; and &#8220;Name&#8221; property to &#8220;button1&#8243;.</li>
<li>Add another button and set &#8220;Text&#8221; property to &#8220;Save Screenshot&#8221;, set its &#8220;Enabled&#8221; property to &#8220;False&#8221; and &#8220;Name&#8221; property to &#8220;button2&#8243;.</li>
<li>Add a timer and set it &#8220;Interval&#8221; to &#8220;500&#8243; and make sure its &#8220;Enabled&#8221; property is set to &#8220;False&#8221;..</li>
<li>Now add SaveFileDialog and set &#8220;Filter&#8221; to &#8221; JPEG Files|*.jpg|GIF Files|*.gif|PNG Files|*.png &#8220;.</li>
<li>Finally, add a Picturebox.</li>
</ol>
<p>That&#8217;s it. The form is now set-up. Lets get on with the coding.</p>
<h3>The Coding</h3>
<p>First of all, declare these variables at the top of the form; i.e: just above &#8220;public form1() { &#8230;&#8230; &#8220;.</p>
<pre class="brush: csharp;">Graphics g;

// This will get the Size (width &amp;amp; height) of the screen.
Size screenBounds = Screen.PrimaryScreen.Bounds.Size;

public Form1()
 {
 InitializeComponent();
 }
</pre>
<p>Okay. Now double-click &#8220;Take Screenshot&#8221; button which will automatically add the &#8220;Click&#8221; event for it. Use this code:</p>
<pre class="brush: csharp;">private void button1_Click(object sender, EventArgs e)
{
   // We need to hide the form so that we can
   // capture the area behind it.
   this.Hide();
   timer1.Start();
}
</pre>
<p>We started the Timer in the above code. Now lets put it to some use.</p>
<p>Double-click the timer which will automatically add the &#8220;Tick&#8221; event for it. Use this code:</p>
<pre class="brush: csharp;">private void timer1_Tick(object sender, EventArgs e)
{
   // The screenshot will be stored in this bitmap.
   Bitmap capture = new Bitmap(screenBounds.Width, screenBounds.Height);

   // The code below takes the screenshot and
   // saves it in &quot;capture&quot; bitmap.
   g = Graphics.FromImage(capture);
   g.CopyFromScreen(Point.Empty, Point.Empty, screenBounds);

   // This code assigns the screenshot
   // to the Picturebox so that we can view it
   pictureBox1.Image = capture;

   // The code below make the form visible again, enables the &quot;Save&quot; button and stops the timer.
   this.Show();
   button2.Enabled = true;
   timer1.Stop();
}</pre>
<p>The Screenshot capturing and showing it on the picturebox part is done now. Now let&#8217;s add the code for the &#8220;Save Screenshot&#8221; button.</p>
<p>Double-click the Save Screenshot button which adds the &#8220;Click&#8221; event. Use this code:</p>
<pre class="brush: csharp;">private void button2_Click(object sender, EventArgs e)
{
// Show the SaveFileDialog
DialogResult res = saveFileDialog1.ShowDialog();

// Saves the screenshot if the OK button is clicked.
if (res == DialogResult.OK)
{
// This will get the extension of the saved file
string ext = System.IO.Path.GetExtension(saveFileDialog1.FileName);

if(ext == &quot;.jpg&quot;)
pictureBox1.Image.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
else if(ext == &quot;.gif&quot;)
pictureBox1.Image.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Gif);
else if(ext == &quot;.png&quot;)
pictureBox1.Image.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Png);
}
}</pre>
<p>That&#8217;s it! We are done.</p>
<h3>Source Code</h3>
<p><a title="Download Source Code" href="/source/ScreenCapture.rar"><strong>Download Now</strong></a> (36 Kb)</p>
<p>Feedback and comments are warmly welcome <img src='http://www.farooqazam.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.farooqazam.net/screen-capture-application-using-c-sharp/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
