首页 新闻 赞助 找找看

桌面图像绘制

0
悬赏园豆:80 [待解决问题]

我在用WPF开发一个远程桌面,用InteropBitmap来绘制桌面图像,代码如下:
IntPtr  m_hSharedMemoryFile = Win32Api.CreateFileMapping(new IntPtr(-1), IntPtr.Zero, PageAccess.READWRITE, 0, size, null);
IntPtr  m_pwData = Win32Api.MapViewOfFile(m_hSharedMemoryFile, FileMapAccess.ALLACCESS, 0, 0, (uint)size);
BitmapDesktop = Imaging.CreateBitmapSourceFromMemorySection(m_hSharedMemoryFile, width, height, pixelFormat, vnc.Framebuffer.Width * 4, 0) as InteropBitmap;
 imgDesktop.Source=BitmapDesktop;
 public unsafe virtual void Draw(InteropBitmap bitmapDesktop, IntPtr m_pwData)
        {
            if (rectangle != null && rectangle.Width > 0 && rectangle.Height > 0)
            {
                int width = bitmapDesktop.PixelWidth;
                int offset = width - rectangle.Width;
                int row;
                int* ptr = (int*)m_pwData;
                ptr += rectangle.Y * width + rectangle.X;
                try
                {
                    for (int y = 0; y < rectangle.Height; ++y)
                    {
                        row = y * rectangle.Width;
                        for (int x = 0; x < rectangle.Width; ++x)
                        {
                                *ptr++ = framebuffer[row + x];
                        }
                        ptr += offset;
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Write("Encoded Drawing ", ex);
                }
                finally
                {
                    bitmapDesktop.Invalidate();
                }
            }
        }

这么做,在移动窗口的时候会出现花屏现象,而且很严重,求各位大神们帮忙解决一下,很急

明耀的主页 明耀 | 初学一级 | 园豆:122
提问于:2016-05-17 09:58
< >
分享
所有回答(1)
0

可以在移动过程中只绘制一个虚框,在移动后绘制窗口,另外,做mstc记得microsoft好像有个com组件

jello chen | 园豆:7306 (大侠五级) | 2016-05-18 08:49

能说的详细一些吗,最好有代码,非常感谢

支持(0) 反对(0) 明耀 | 园豆:122 (初学一级) | 2016-05-18 09:21
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册