C#中以特定区域的截图 [英] c# Take a screenshot of specific area

查看:1382
本文介绍了C#中以特定区域的截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有很多这样的问题,但没有他们的答案都为我工作
或者只是我不能这样做正确,反正如果可能的话,请给我一个简单的code!

我知道绿点的位置,我想构建基于此位置的矩形。

例如:

和最重要的是如何利用这个区域的屏幕截图?

我不知道如何改变这种code为我的情况下工作。

 私人位图截图()
    {
        位图bmpScreenshot =新位图(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height);        图形G = Graphics.FromImage(bmpScreenshot);        g.CopyFromScreen(0,0,0,0,Screen.PrimaryScreen.Bounds.Size);        返回bmpScreenshot;
    }


解决方案

合并在MSDN上并您的问题文档:

  g.CopyFromScreen(center.X  -  36 center.Y  -  30,0,0,新的大小(36 * 2,30 * 2));

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;
    }

解决方案

Merging the documentation on MSDN and your problem:

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

这篇关于C#中以特定区域的截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆