【发布时间】:2014-07-31 05:59:32
【问题描述】:
我收到一条错误消息,提示在运行时 Save() 行需要编码器参数。我不知道我应该为这个参数输入什么。有什么想法吗?
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);
MemoryStream ms = new MemoryStream();
bmpScreenCapture.Save(ms, bmpScreenCapture.RawFormat); // <---- ERROR
byte[] bytes = ms.GetBuffer();
ms.Close();
}
}
【问题讨论】:
-
当你说“错误”时,你是指编译器还是运行时?
-
这些都没有保存到“MemoryStream”对象,所以我认为它的处理方式不同。不知道为什么疯狂的反对票。有人教别人一些东西,我们否决了这个问题?这些链接与我的问题并不完全相同,因为它们将它们保存到磁盘。