C#实现屏幕拷贝的方法
2017-09-19 15:00
381 查看
本文实例讲述了C#实现屏幕拷贝的方法。分享给大家供大家参考。具体如下:
方法一:
方法二:
方法一:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; namespace WindowsApplication2 { public partial class Form21 : Form { public Form21() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Rectangle screenRect = Screen.PrimaryScreen.WorkingArea; Bitmap dumpBitmap = new Bitmap(screenRect.Width, screenRect.Height); Graphics tg = Graphics.FromImage(dumpBitmap); tg.CopyFromScreen(0, 0, 0, 0, new Size(dumpBitmap.Width, dumpBitmap.Height)); this.pictureBox1.BackgroundImage = dumpBitmap; this.pictureBox1.BackgroundImageLayout = ImageLayout.Stretch; dumpBitmap.Save(@"c:/image1.bmp"); } } }
方法二:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication2 { public partial class Form22 : Form { public Form22() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Rectangle rect = new Rectangle(0, 0, this.Size.Width, this.Size.Height); Bitmap dumpBitmap = new Bitmap(this.Size.Width, this.Size.Height); this.DrawToBitmap(dumpBitmap, rect); this.pictureBox1.BackgroundImage = dumpBitmap; this.pictureBox1.BackgroundImageLayout = ImageLayout.Stretch; dumpBitmap.Save(@"c:/image2.bmp"); } } }
相关文章推荐
- C#实现屏幕拷贝的方法
- C#通过指针实现快速拷贝的方法
- C#实现简单屏幕监控的方法
- C#拷贝文件简单实现方法
- C#实现截取当前屏幕的方法
- C#运用FileInfo类实现拷贝文件的方法
- 解决C#全屏幕截图的实现方法
- C#实现windows form拷贝内容到剪贴板的方法
- C#中序列化实现深拷贝,实现DataGridView初始化刷新的方法
- 使用C#实现阿拉伯数字到大写中文的转换-第二种方法
- C#下实现主从DropDownList互动的方法(转)
- javascript 实现类似C#中字符串的Trim()方法
- 用 C# 做组件设计时的事件实现方法讨论
- 在WIN95中实现文件拷贝的编程方法
- asp.net能实现身份认证的EMAIL发送方法(c#版本)
- 解决用序列化方式实现对象拷贝时出的异常解决方法
- C#下实现主从DropDownList互动的方法
- 用序列化方法实现的Prototype的深拷贝
- 在C#中使用异步Socket编程实现TCP网络服务的C/S的通讯构架(二)----使用方法
- 在C#中使用异步Socket编程实现TCP网络服务的C/S的通讯构架(二)----使用方法