繁体   English   中英

在指定的坐标处截屏

[英]Take screenshot at specified coordinates

在Windows Forms应用程序中,如何拍摄某些坐标的“屏幕快照”?

在下面的图片中,您看到一个窗口,并且该窗口内部是一个灰色的小方框,位于中心附近。

在此处输入图片说明

如何在每个可能放置该框的位置上,如何以编程方式对其进行“截屏”(包括其中的任何内容)?

简单的方法

简单,使用Graphics.CopyFromScreen

private Bitmap bitmap;
private Graphics graph;

graph.CopyFromScreen(X, Y, 0, 0, Size, CopyPixelOperation.SourceCopy);

现在,您可以使用bitmap ,其中包含该区域的源副本。

暴躁的方式

SendKeys.Send("%{PRTSC}"); //Alt + PrtSc to screenshot just the active window.
Bitmap clipboardImage = Clipboard.GetImage(); //Get image from the clipboard
//Here you crop the image using Bitmap.Clone();
//Be happy and question yourself why you are doing this way.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM