是否可以对窗口而不是整个屏幕进行屏幕截图. [英] Is it possible to take a screenshot of the window rather than the whole screen.

查看:90
本文介绍了是否可以对窗口而不是整个屏幕进行屏幕截图.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

using System.Drawing;
using System.Drawing.Imaging; 



^进口



^ Imports

private void button8_Click(object sender, EventArgs e)
   {

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




^截屏的代码.

是否可以截取窗口而不是整个屏幕的屏幕截图?


-谢谢.




^ Code to take screenshot.

Is it possible to take a screenshot of the window rather than the whole screen?


-Thanks.

推荐答案

假定它是完全可见的,则只需使用表单属性:
Assuming it is fully visible, then just use the form properties:
Bitmap printscreen = new Bitmap(Width,Height);
Graphics graphics = Graphics.FromImage(printscreen as Image);
graphics.CopyFromScreen(Left, Top, 0, 0, Size);
printscreen.Save(@"F:\Temp\screen.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

将仅捕获按钮所在形式所需的区域.

Will capture just the area you want of the form your button is in.


^ ]

只需将其转换为C#
Screen Capture Class[^]

Just convert it to C#


希望 [<一个href ="http://www.geekpedia.com/tutorial181_Capturing-screenshots-using-Csharp.html" target ="_ blank" title ="New Window"> ^ ]可能会对您有所帮助.
Hope this[^] might help you.


这篇关于是否可以对窗口而不是整个屏幕进行屏幕截图.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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