我在用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();
}
}
}
这么做,在移动窗口的时候会出现花屏现象,而且很严重,求各位大神们帮忙解决一下,很急
可以在移动过程中只绘制一个虚框,在移动后绘制窗口,另外,做mstc记得microsoft好像有个com组件
能说的详细一些吗,最好有代码,非常感谢