///截取电脑全屏
Code
private void button2_Click(object sender, EventArgs e)
{
Bitmap myImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics g = Graphics.FromImage(myImage);
g.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height));
IntPtr dc1 = g.GetHdc();
g.ReleaseHdc(dc1);
myImage.Save(@"c:\screen0.jpg");
}
///截取窗体屏幕
窗体截图
private void button3_Click(object sender, EventArgs e)
{
Bitmap myImage = new Bitmap(this.Width, this.Height);
Graphics g = Graphics.FromImage(myImage);
g.CopyFromScreen(new Point(this.Location.X, this.Location.Y), new Point(0, 0), new Size(this.Width, this.Height));
IntPtr dc1 = g.GetHdc();
g.ReleaseHdc(dc1);
myImage.Save(@"c:\screen1.jpg");
}
阅读(828) | 评论(0) | 转发(0) |