IT Community - Software Programming, Web Development and Technical Support

Can we capture the desktop background image programatically using c#?

This is a discussion on Can we capture the desktop background image programatically using c#? within the C# Programming forums, part of the Software Development category; Can we capture the desktop background image programatically using c#?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C# Programming

Register FAQ Members List Calendar Mark Forums Read
  3 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 07-19-2007, 10:38 PM
mobilegeek mobilegeek is offline
D-Web Analyst
 
Join Date: Jun 2007
Posts: 205
mobilegeek is on a distinguished road
Default Can we capture the desktop background image programatically using c#?

Can we capture the desktop background image programatically using c#?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-20-2007, 01:10 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 633
oxygen is on a distinguished road
Default Re: Can we capture the desktop background image programatically using c#?

Yes, we can

private static Bitmap bmpScreenshot;
private static Graphics gfxScreenshot;

// If the user has chosen a path where to save the screenshot
if (saveScreenshot.ShowDialog() == DialogResult.OK)
{
// Hide the form so that it does not appear in the screenshot
this.Hide();

// Set the bitmap object to the size of the screen
bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width,Screen.Pr imaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);

// Create a graphics object from the bitmap
gfxScreenshot = Graphics.FromImage(bmpScreenshot);

// Take the screenshot from the upper left corner to the right bottom corner
gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen. Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);

// Save the screenshot to the specified path that the user has chosen
bmpScreenshot.Save(saveScreenshot.FileName, ImageFormat.Png);

// Show the form again
this.Show();
}
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/c-programming/2249-can-we-capture-desktop-background-image-programatically-using-c.html
Posted By For Type Date
Digg / Programming / Upcoming This thread Refback 07-20-2007 04:30 AM
Digg / Programming / Upcoming This thread Refback 07-20-2007 01:48 AM
Digg / News / Upcoming This thread Refback 07-20-2007 01:46 AM

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set background image for <td> using style property? poornima HTML, CSS and Javascript Coding Techniques 6 01-31-2008 12:24 AM
Desktop Background Problem it.wily Operating Systems 13 01-10-2008 09:34 PM
What is a function to capture dynamic values in the web Vuser script? Shanthi Testing Tools 2 11-16-2007 04:45 AM
How to create an image from panel background Image S.Vinothkumar C# Programming 1 10-22-2007 03:52 AM
How can we capture the todays screen image programmatically in windows mobile 5.0 poc mobilegeek C# Programming 1 07-21-2007 01:46 AM


All times are GMT -7. The time now is 04:49 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0