公告
财富商城
积分规则
提问
发文
2019-01-14 07:33发布
劫难
like
TakeScreenshot(new Rectangle(0,0,100,100), "output.jpg");
Use the following:
Rectangle rect = new Rectangle(0, 0, 100, 100); Bitmap bmp = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb); Graphics g = Graphics.FromImage(bmp); g.CopyFromScreen(rect.Left, rect.Top, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy); bmp.Save(fileName, ImageFormat.Jpeg);
Have you checked the Graphics.CopyFromScreen method?
Here is the code to capture the screen. Change the values to the size you need.
Bitmap printscreen = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); Graphics graphics = Graphics.FromImage(printscreen as Image); graphics.CopyFromScreen(0, 0, 0, 0, printscreen.Size); printscreen.Save(@"C:\printscreen.jpg", ImageFormat.Jpeg);
Or make method which will return you captured image like this :
Image CaptureScreen(int sourceX, int sourceY, int destX, int destY, Size regionSize) { Bitmap bmp = new Bitmap(regionSize.Width, regionSize.Height); Graphics g = Graphics.FromImage(bmp); g.CopyFromScreen(sourceX, sourceY, destX, destY, regionSize); return bmp; } ...... // call Image image = CaptureScreen(sourceX, sourceY, destX, destY, regionSize); image.Save(@"C:\Somewhere\screen.jpg);
Use the Graphics.CopyFromScreen method. Google turns up this tutorial.
Graphics.CopyFromScreen
最多设置5个标签!
Use the following:
Have you checked the Graphics.CopyFromScreen method?
Here is the code to capture the screen. Change the values to the size you need.
Or make method which will return you captured image like this :
Use the
Graphics.CopyFromScreen
method. Google turns up this tutorial.