c# Take a screenshot of specific area [closed]

2019-06-04 00:26发布

I know there are many questions like this but none of their answers are working for me or just I can't do it correctly, anyway if it's possible please give me a simple code!

I know the location of the green dot and I want to construct a rectangle based on this location.

Example:

enter image description here

And most important how to take a screenshot of this area?

I don't know how to change this code to work for my case.

private Bitmap Screenshot()
    {
        Bitmap bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

        Graphics g = Graphics.FromImage(bmpScreenshot);

        g.CopyFromScreen(0, 0, 0, 0, Screen.PrimaryScreen.Bounds.Size);

        return bmpScreenshot;
    }

1条回答
疯言疯语
2楼-- · 2019-06-04 01:08

Merging the documentation on MSDN and your problem:

g.CopyFromScreen(center.X - 36, center.Y - 30, 0, 0, new Size(36 * 2, 30 * 2));
查看更多
登录 后发表回答