【发布时间】:2016-07-14 20:41:58
【问题描述】:
我希望在 Visual Studio (C#) 中创建一个程序,该程序会在屏幕的确切位置扫描屏幕以获取准确的图像。我已经看到许多讨论涉及找到“接近”图像的算法,但我的将是 100% 准确的;位置、大小等等。
我使用以下代码从屏幕的一部分 [图 1] 获得了一个 png:
private void button1_Click(object sender, EventArgs e)
{
//Create a new bitmap.
var bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height);
// Create a graphics object from the bitmap.
var gfxScreenshot = Graphics.FromImage(bmpScreenshot);
// Take the screenshot from the upper left corner to the right bottom corner.
gfxScreenshot.CopyFromScreen(1555, 950,
1700, 1010,
Screen.PrimaryScreen.Bounds.Size,
CopyPixelOperation.SourceCopy);
// Save the screenshot to the specified path that the user has chosen.
bmpScreenshot.Save("Screenshot.png");
}
所以,基本上这是我的程序流程图,说明我想如何前进: 1)使用上面的代码创建主png 2)运行循环: 使用与主 png 相同的过程创建相同的屏幕截图 比较主 png 和新的截图 png 和 if:match 然后继续,否则重复循环。
我对编程很陌生,但我不相信这超出了我的能力范围,只要有一点指导。我编写了相当复杂的(在我看来)VBA 和 Matlab 程序。任何帮助是极大的赞赏。
谢谢你, 斯隆
【问题讨论】:
标签: image bitmap screen screenshot