C#: how to take a screenshot of a portion of screen
Use the following:
Rectangle rect = new Rectangle(0, 0, 100, 100);
Bitmap bmp = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(bmp);
g.CopyFromScreen(rect.Left, rect.Top, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy);
bmp.Save(fileName, ImageFormat.Jpeg);
c# Take a screenshot of specific area
Merging the documentation on MSDN and your problem:
g.CopyFromScreen(center.X - 36, center.Y - 30, 0, 0, new Size(36 * 2, 30 * 2));
How to do a screenshot area selection by drawing on desktop to take screenshot?
Create form with semi-transparent (or fully transparent) background, which is always-on-top, borderless and in the size of the desktop. Do any screenshot rectangle selection graphics (e.g. selected rectangle + guides + magnifier, fully opaque) on that form. When selection is made by user, hide the form and take the screenshot.
Capture screenshot of only a section of a form?
The Control
class from which Panel
derives has a method DrawToBitmap()
. You can use that.
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.drawtobitmap.aspx
Related Topics
Questions About Entity Framework Context Lifetime
Publish a Project with Local Database
How to Set Chrome Preferences Using Selenium Webdriver .Net Binding
Outofmemoryexception on Declaration of Large Array
Applying % Number Format to a Cell Value Using Openxml
Linq to Xml - Update/Alter the Nodes of an Xml Document
Panel for Drawing Graphics and Scrolling
How to Terminate a Thread in C#
How to Get Current Regional Settings in C#
Server.Mappath - Physical Path Given, Virtual Path Expected
How to Get the Icon from the Executable File Only Having an Instance of It's Process in C#
Cannot Deserialize the Current JSON Array (E.G. [1,2,3])
Encoding Trouble with Httpwebresponse
Authentication with Old Password No Longer Supported, Use 4.1 Style Passwords