C#: How to Take a Screenshot of a Portion of Screen

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



Leave a reply



Submit