码迷,mamicode.com
首页 > 其他好文 > 详细

c#实现截取电脑全屏

时间:2014-09-04 23:40:12      阅读:282      评论:0      收藏:0      [点我收藏+]

标签:blog   http   io   ar   for   文件   art   cti   sp   

转载自http://blog.csdn.net/lijgame/article/details/1447921

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Drawing.Imaging;

namespace first

{    

  public partial class Form2 : Form    

   {        

     public Form2()        

    {            

      InitializeComponent();        

    }        

    private void button1_Click(object sender, EventArgs e)        

    {            

      //获得当前屏幕的分辨率            

      Screen scr = Screen.PrimaryScreen;            

      Rectangle rc = scr.Bounds;            

      int iWidth = rc.Width;            

      int iHeight = rc.Height;            

      //创建一个和屏幕一样大的Bitmap            

      Image myImage = new Bitmap(iWidth, iHeight);            

      //从一个继承自Image类的对象中创建Graphics对象            

      Graphics g = Graphics.FromImage(myImage);            

      //抓屏并拷贝到myimage里            

      g.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(iWidth, iHeight));            

      //保存为文件            

      myImage.Save("1.jpg");        

    }    

  }

}

c#实现截取电脑全屏

标签:blog   http   io   ar   for   文件   art   cti   sp   

原文地址:http://www.cnblogs.com/liyanzhui/p/3957052.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!