【发布时间】:2014-03-08 18:18:30
【问题描述】:
我正在尝试进行全屏截屏并将其加载到图片框中,但它给了我这个错误: System.Drawing.dll 中发生了“System.ArgumentException”类型的第一次机会异常 附加信息:Ongeldige 参数。
代码:
using (Bitmap bmpScreenCapture = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height))
{
using (Graphics g = Graphics.FromImage(bmpScreenCapture))
{
g.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
Screen.PrimaryScreen.Bounds.Y,
0, 0,
bmpScreenCapture.Size,
CopyPixelOperation.SourceCopy);
}
pictureBox1.Image = bmpScreenCapture;
}
乔瑞。
【问题讨论】:
-
哪个调用给了你错误?
-
@JoachimIsaksson pictureBox1.Image = bmpScreenCapture;
-
第一次机会异常不一定是坏事,看看this blog post。你的这段代码真的会抛出异常或崩溃吗?
-
您可能需要重新考虑
using,它会在将位图设置为 PictureBox 图像时处理位图。
标签: c# graphics bitmap screenshot