【发布时间】:2018-03-05 10:23:01
【问题描述】:
我正在从事屏幕共享项目。我只通过套接字发送屏幕差异,比较以前的缓冲区和实际缓冲区。它工作
我使用 Format16bppRgb555 向客户端发送 8 到 9 FPS 以减少位图的总字节大小
byte[] wholescreensize= new byte[1360 * 768 * 2];// Its around 2 Mb
我的问题是当全屏更改时。
我使用下面的函数获得了大约 45-60 kb 的 PNG 图像
45kb * 10 (FPS) = 450kb
可以减少超过 45 kb。
我不想降低 FPS,因为它是实时屏幕共享应用程序。
JPEG 压缩或 LZ4/GZIP 也没有太大的区别,因为 PNG 图像已经压缩
private void SendImgDiffToClient(byte[] contents,Rectangle rectangle)
{
//Converting Small Portion to Bitmap.Bcoz Image.FromStrem not working here error Parameter is not Valid
byte[] byteArrayout = new byte[contents.Length];
var bitmap = new Bitmap(rectangle.Width, rectangle.Height, PixelFormat.Format16bppRgb555);
var bitmap_data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.WriteOnly, PixelFormat.Format16bppRgb555);
Marshal.Copy(contents, 0, bitmap_data.Scan0, byteArrayout.Length);
bitmap.UnlockBits(bitmap_data);
//Converting Small Bitmap to Png Byte Array and Sending to Client
using (MemoryStream ms = new MemoryStream())
{
Image msImage = (Image)bitmap;
msImage.Save(ms, ImageFormat.Png);
msImage.Dispose();
byteArrayout = ms.ToArray();
}
SendtoClient(byteArrayout);
}
My Questing 是在这种情况下减少字节的最佳方法。
【问题讨论】:
-
PNG 是无损压缩。如果您想进一步降低它,请使用有损 (JPG) 压缩、帧间压缩 (mpg) 和/或降低帧速率。
-
没有很好的方法来做到这一点,对于现代显示器尺寸来说总是太慢。使用内置的操作系统支持,谷歌“c#远程桌面服务”来查找命中。它通过编码视频驱动程序命令而不是像素来获得速度。
-
@HansPassant 我已经在为此进行研究。我没有得到任何合适的解决方案。试过这个但没有运气stackoverflow.com/questions/31543940/…
-
好吧,我告诉过你。使用 RDP。
-
那么,github.com/T1T4N/NVNC 可以激励你:)
标签: c# screensharing