c# - 截取的屏幕截图仅包含黑色像素

标签 c# .net networking screenshot p2p

当使用以下代码每 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/

相关文章:

c# - 尝试使用 char * 数据编码结构,但数据为空

c# - 优化 nHibernate 中的最小和最大查询

c# - 如何检查实体是否是 foreach 循环的第一个元素

android - 如何首先将数据包从一部安卓手机发送到wifi路由器,然后再从路由器发送到另一部安卓手机??

node.js - nodejs - 为什么 Node.js 可以处理大量并发持久连接?

c# - .NET 3.5 中的 URL 重写

c# - Spin 在 Portable Class Library 中等待多次自旋

.net - 就 Web 服务而言,何时使用 SOAP 而不是 REST?

linux - nf_ct_get(skb,&ctinfo) 函数获取 IPv6 udp 数据包的 netfiter conntrack 'struct conn'

c# - Entity Framework 数据库优先 如何更改实体以使其从基类派生