截图仅包含黑色像素

时间:2010-08-30 21:11:38

标签: c# .net networking screenshot p2p

为什么在使用以下代码每20毫秒截取一次屏幕截图并通过加密连接将其传输给对等方时,会收到黑屏? (我知道20毫秒的刷新速度有点快,但似乎不是问题。处理器和网络可以很好地跟上刷新率,问题是位图看起来完全是黑色的编辑:我现在知道这是一个奇怪的网络问题,但现在图像显示模糊,好像这是一个糟糕的模拟信号。我已经附上了该帖子的截图。 {{3} }

 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);
        }

1 个答案:

答案 0 :(得分:1)

这恰好是路由器的网络错误(XSF支持错误),现在已修复。