星空网 > 软件开发 > ASP.net

C#截屏

本实例代码实现了WinForm截屏保存为图片,亲测可行。

界面截图:
C#截屏

下载:http://hovertree.com/h/bjaf/scjyuanma.htm


以下代码可以实际运行,在项目HoverTreeCSJ中运行成功。

/* 何问起 http://hovertree.com/hovertreescj/ */using System;using System.Drawing;using System.Drawing.Imaging;using System.IO;using System.Windows.Forms;namespace HoverTreeSCJ.SCJForms.ToolForms{  public partial class Form_GetScreen : Form  {    public Form_GetScreen()    {      InitializeComponent();    }    private void button_getScreen_Click(object sender, EventArgs e)    {      FormWindowState h_currentState = MdiParent.WindowState;      if (checkBox_isHide.Checked)      {        //MdiParent.Hide();        //http://hovertree.com/h/bjaf/de7qg5wd.htm        this.MdiParent.WindowState = FormWindowState.Minimized;      }      //创建图象,保存将来截取的图象      Bitmap image = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);      Graphics imgGraphics = Graphics.FromImage(image);      //设置截屏区域 柯乐义      imgGraphics.CopyFromScreen(0, 0, 0, 0, new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height));      //保存      SaveImage(image);      if (checkBox_isHide.Checked)      {        this.MdiParent.WindowState = h_currentState;        // this.MdiParent.Show();      }    }    //保存图象文件    private void SaveImage(Image image)    {      //http://hovertree.com/h/bjaf/ruwwcg2p.htm      saveFileDialog_getScreen.FileName = "何问起截图" + DateTime.Now.ToFileTime();      if (saveFileDialog_getScreen.ShowDialog(this) == DialogResult.OK)      {                string fileName = saveFileDialog_getScreen.FileName;        string extension = Path.GetExtension(fileName);        if (extension == ".jpg")        {          image.Save(fileName, ImageFormat.Jpeg);        }        else        {          image.Save(fileName, ImageFormat.Bmp);        }      }    }  }}

转自:http://hovertree.com/h/bjaf/76q5yeli.htm

推荐:http://www.cnblogs.com/roucheng/p/DataGridView.html

http://hovertree.top




原标题:C#截屏

关键词:C#

C#
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

国际货运价钱:https://www.goluckyvip.com/tag/99576.html
国际快递哪个快递公司好:https://www.goluckyvip.com/tag/99577.html
国际快递公司电话:https://www.goluckyvip.com/tag/99578.html
邮政寄国际快递怎么寄:https://www.goluckyvip.com/tag/99579.html
Joom新政:https://www.goluckyvip.com/tag/9958.html
国际快递sf是什么快递:https://www.goluckyvip.com/tag/99580.html
建水县住宿推荐:https://www.vstour.cn/a/410233.html
豪华游轮上海到深圳 游轮豪华游深圳出发:https://www.vstour.cn/a/410234.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流