且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

截屏代码

更新时间:2022-09-13 20:24:53

命名空间:

截屏代码using System.Drawing; 
截屏代码using System.Drawing.Imaging; 
截屏代码using System.Windows.Forms;

相关代码

   //获得当前屏幕的分辨率 
截屏代码            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(@"c:/1.jpeg");


本文转自today4king博客园博客,原文链接:http://www.cnblogs.com/jinzhao/archive/2009/10/12/1581752.html,如需转载请自行联系原作者