我在保存图像时遇到了一些麻烦,它在我尝试保存图像的行上显示“参数错误”。
我不确定这是我创建图像的方式还是只是保存这就是问题所在。
public static void Fullscreen()
{
string fileName = Helper.RandomStr(10) + ".png";
try
{
var image = ScreenCapture.CaptureFullscreen();
image.Save(fileName, ImageFormat.Png);
System.Diagnostics.Process.Start(fileName);
}
catch (Exception ex)
{
MessageBox.Show("Unable to capture fullscreen because: " + ex.ToString() + "\r\n\r\nFile: " + fileName);
}
}
编辑:
这是获取位图的方法
public static Bitmap CaptureFullscreen()
{
using (Bitmap bmp = new Bitmap(ScreenDimensions.Width, ScreenDimensions.Height))
{
using (Graphics g = Graphics.FromImage(bmp))
{
g.CopyFromScreen(Point.Empty, Point.Empty, bmp.Size);
}
return bmp;
}
}