C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






How to capture Screenshots in C#.Net


Posted Date: 25 May 2008    Resource Type: Code Snippets    Category: Tools
Author: Raju.MMember Level: Gold    
Rating: Points: 10



This C# code for capturing screen shots. This code returns bitmap image save this image in computer.


private static Bitmap BitMapCreater()
{
Rectangle rect = Screen.PrimaryScreen.Bounds;
int color = Screen.PrimaryScreen.BitsPerPixel;
PixelFormat pFormat;
switch (color)
{
case 8:
case 16:
pFormat = PixelFormat.Format16bppRgb565;
break;

case 24:
pFormat = PixelFormat.Format24bppRgb;
break;

case 32:
pFormat = PixelFormat.Format32bppArgb;
break;

default:
pFormat = PixelFormat.Format32bppArgb;
break;
}
Bitmap bmp = new Bitmap(rect.Width, rect.Height, pFormat);
Graphics g = Graphics.FromImage(bmp);
g.CopyFromScreen(rect.Left, rect.Top, 0, 0, rect.Size);
return bmp;
}
call this method to SAVE file

on Button Click()
{
Bitmap b = BitMapCreater();
printScreen = string.Format("{0}{1}", Path.GetTempPath(), "screen" + i + ".jpg");
b.Save(printScreen, ImageFormat.Jpeg);

}




Responses

Author: vijetha    29 May 2008Member Level: Gold   Points : 2
U can Try this also

this.Hide();
Bitmap Bitmap;
Graphics Graps;
Bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
Graps = Graphics.FromImage(Bitmap);
Graps.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
Bitmap.Save(System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\YourShot.jpeg", ImageFormat.Jpeg);
MessageBox.Show("Your Screen Shot Save in Desktop");
this.Show();


Author: Raju.M    29 May 2008Member Level: Gold   Points : 2
Ok vijetha


Author: komaladevi    29 May 2008Member Level: Gold   Points : 2
good one


Author: Kumar Velu    30 May 2008Member Level: Diamond   Points : 2
nice...


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Capture windows screen using C#.Net  .  Capture Screenshots  .  

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: Porgrammatically retrieve properties of a PDF document
Previous Resource: Data in Repeater
Return to Discussion Resource Index
Post New Resource
Category: Tools


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use