c# Take a screenshot of specific area [closed]

[亡魂溺海] 提交于 2020-01-14 05:02:48

问题


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:

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:


Merging the documentation on MSDN and your problem:

g.CopyFromScreen(center.X - 36, center.Y - 30, 0, 0, new Size(36 * 2, 30 * 2));


来源:https://stackoverflow.com/questions/13388922/c-sharp-take-a-screenshot-of-specific-area

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!