当使用以下代码每 20 毫秒截取一次屏幕截图并通过加密连接将其传输到对等点时,为什么我会收到黑屏? (我知道 20 毫秒的刷新率有点快,但似乎这不是问题。处理器和网络可以很好地跟上刷新率,问题是位图显示为全黑. 编辑:我现在知道这是一个有点奇怪的网络问题,但现在图像显示模糊,好像它是一个糟糕的模拟信号。我在这篇文章中附上了该程序的屏幕截图。 http://imgur.com/y9rWb.png
P2PStream thestream = (P2PStream)sender;
Bitmap mymap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics screenshotGFX = Graphics.FromImage(mymap);
screenshotGFX.CopyFromScreen(new Point(),new Point(),new Size(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height));
Stream encryptedStream = networkLogic.getCryptoStream(thestream, true);
while (true)
{
try
{
screenshotGFX.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
mymap.Save(encryptedStream,System.Drawing.Imaging.ImageFormat.Png);
}
catch (Exception)
{
MessageBox.Show("A client has disconnected");
break;
}
System.Threading.Thread.Sleep(20);
}
最佳答案
这恰好是路由器的网络错误(错误的 XSF 支持),现在已修复。
关于c# - 截取的屏幕截图仅包含黑色像素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3604264/