How do I capture the current screen as an image?

2019-02-03 19:50发布

I want to add the ability for the users to capture the current screen in my app and email it. I have a very non-technical user base so I need this to be as simple as possible. I plan to let them click a menu item called Help Me! which will then capture the current Application Screen, hopefully as a jpg or png, and then open Outlook and add the image as an attachment.

I was reading through this post ScreenCapture on Code Project but it is a little old and isn't exactly what I was looking for so I thought I would check if there is a better way of doing this.

How do I get started on this? Is there a library or are the built in capabilities enough?

Thanks!

2条回答
Luminary・发光体
2楼-- · 2019-02-03 19:54

That post you linked is the right approach, they just made it very complex. You would want to use Graphics.CopyFromScreen.

Rectangle bounds = this.Bounds;

using(Bitmap ss = new Bitmap(bounds.Width, bounds.Height))
using(Graphics g = Graphics.FromImage(ss))
{
  g.CopyFromScreen(this.Location, Point.Empty, bounds.Size);
  ss.Save("test.jpg", ImageFormat.Jpeg);
}
查看更多
神经病院院长
3楼-- · 2019-02-03 19:59
登录 后发表回答