当前,我正在拍摄整个屏幕的屏幕截图,但我只在整个屏幕的1/4中寻找一些像素块。
因此,我想知道哪种方法可以更快地截取屏幕截图,可以是整个屏幕还是屏幕的一部分? 哪个使用较少的内存或CPU使用率?
答案 0 :(得分:0)
您是否看过this问题?
建议的CopyFromScreen()方法可让您从屏幕上复制像素的任何部分,例如像这样:
// The x and y position of the portion on the screen that should be captured.
int x = 0, y = 0;
// The width and height of the screenshot.
int width = 200;
int height = 200;
var screenBmp = new Bitmap(width, height);
var g = Graphics.FromImage(screenBmp);
// Copy pixels from the screen.
g.CopyFromScreen(x, y, 0, 0, screenBmp.Size);
screenBmp.Save("screenshot.png", System.Drawing.Imaging.ImageFormat.Png);