110,533
社区成员
发帖
与我相关
我的任务
分享
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.Threading;//
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Bitmap bmp;
public Form1()
{
InitializeComponent();
}
/// <summary>
/// 加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form1_Load(object sender, EventArgs e)
{
Thread thread = new Thread(new ThreadStart(GetImg));
thread.IsBackground = true;
thread.Start();
}
/// <summary>
/// 循环读取桌面图像
/// </summary>
public void GetImg()
{
while (true)
{
Thread.Sleep(100);
//获取全屏图像
this.bmp = new Bitmap(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height);
Graphics g = Graphics.FromImage(this.bmp);
//
g.CopyFromScreen(0, 0, 0, 0, new Size(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height));
this.pictureBox1.Image = this.bmp;
}
}
}
}