C#实现截屏
要求窗体button实现Prtscr截取全屏的功能还有一个button实现截取窗口功能然后显示另存为哪里的窗口...
要求窗体button实现Prtscr截取全屏的功能还有一个button实现截取窗口功能
然后显示另存为哪里的窗口 展开
然后显示另存为哪里的窗口 展开
1个回答
展开全部
下面是截屏和另存的的方法
截屏
private void button1_Click(object sender, EventArgs e)
{
this.Visible = false;
System.Threading.Thread.Sleep(200);
Bitmap bit = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics g = Graphics.FromImage(bit);
g.CopyFromScreen(new Point(0,0),new Point(0,0),bit.Size);
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "bmp|*.bmp|jpg|*.jpg|gif|*.gif";
if (saveFileDialog.ShowDialog() != DialogResult.Cancel)
{
bit.Save(saveFileDialog.FileName);
}
g.Dispose();
this.Visible = true;
}
截取窗体
private void button2_Click(object sender, EventArgs e)
{
Bitmap bit = new Bitmap(this.Width,this.Height);
Graphics g = Graphics.FromImage(bit);
g.CopyFromScreen(this.Location, new Point(0, 0), bit.Size);
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "bmp|*.bmp|jpg|*.jpg|gif|*.gif";
if (saveFileDialog.ShowDialog() != DialogResult.Cancel)
{
bit.Save(saveFileDialog.FileName);
}
g.Dispose();
}
截屏
private void button1_Click(object sender, EventArgs e)
{
this.Visible = false;
System.Threading.Thread.Sleep(200);
Bitmap bit = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics g = Graphics.FromImage(bit);
g.CopyFromScreen(new Point(0,0),new Point(0,0),bit.Size);
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "bmp|*.bmp|jpg|*.jpg|gif|*.gif";
if (saveFileDialog.ShowDialog() != DialogResult.Cancel)
{
bit.Save(saveFileDialog.FileName);
}
g.Dispose();
this.Visible = true;
}
截取窗体
private void button2_Click(object sender, EventArgs e)
{
Bitmap bit = new Bitmap(this.Width,this.Height);
Graphics g = Graphics.FromImage(bit);
g.CopyFromScreen(this.Location, new Point(0, 0), bit.Size);
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "bmp|*.bmp|jpg|*.jpg|gif|*.gif";
if (saveFileDialog.ShowDialog() != DialogResult.Cancel)
{
bit.Save(saveFileDialog.FileName);
}
g.Dispose();
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询