public static CopyFromFramebuffer ( |
||
source | The framebuffer to read. | |
sourceRectangle | VncRectangle | The framebuffer region to copy. |
target | The bitmap to copy into. | |
targetX | int | The leftmost X coordinate of the bitmap to draw to. |
targetY | int | The topmost Y coordinate of the bitmap to draw to. |
리턴 | void |
void UpdateFramebuffer(bool force, VncFramebuffer framebuffer) { if (framebuffer == null) { return; } int w = framebuffer.Width, h = framebuffer.Height; if (_bitmap == null || _bitmap.Width != w || _bitmap.Height != h || force) { _bitmap = new Bitmap(w, h, PixelFormat.Format32bppRgb); VncBitmap.CopyFromFramebuffer(framebuffer, new VncRectangle(0, 0, w, h), _bitmap, 0, 0); ClientSize = new Size(w, h); Invalidate(); } }
private void UpdateFramebuffer(bool force, VncFramebuffer framebuffer) { if (framebuffer == null) { return; } int w = framebuffer.Width, h = framebuffer.Height; if (this.bitmap == null || this.bitmap.Width != w || this.bitmap.Height != h || force) { this.bitmap = new Bitmap(w, h, PixelFormat.Format32bppRgb); VncBitmap.CopyFromFramebuffer(framebuffer, new VncRectangle(0, 0, w, h), this.bitmap, 0, 0); this.ScaleFactor = this.GetScaleFactor(framebuffer); this.Invalidate(); } }
private void HandleFramebufferChanged(object sender, FramebufferChangedEventArgs e) { this.BeginInvoke(new Action(() => { if (this.DesignMode) { return; } if (this.client == null) { return; } var framebuffer = this.client.Framebuffer; if (framebuffer == null) { return; } lock (framebuffer.SyncRoot) { this.UpdateFramebuffer(false, framebuffer); if (this.bitmap != null) { for (int i = 0; i < e.RectangleCount; i++) { var rect = e.GetRectangle(i); VncBitmap.CopyFromFramebuffer(framebuffer, rect, this.bitmap, rect.X, rect.Y); } } } for (int i = 0; i < e.RectangleCount; i++) { var rect = e.GetRectangle(i); var transformedRect = this.Transform( new Rectangle(rect.X, rect.Y, rect.Width, rect.Height), TransformDirection.FromDevice); this.Invalidate(transformedRect); } })); }
void HandleFramebufferChanged(object sender, FramebufferChangedEventArgs e) { BeginInvoke(new Action(() => { if (DesignMode) { return; } if (_client == null) { return; } var framebuffer = _client.Framebuffer; if (framebuffer == null) { return; } lock (framebuffer.SyncRoot) { UpdateFramebuffer(false, framebuffer); if (_bitmap != null) { for (int i = 0; i < e.RectangleCount; i++) { var rect = e.GetRectangle(i); VncBitmap.CopyFromFramebuffer(framebuffer, rect, _bitmap, rect.X, rect.Y); } } } for (int i = 0; i < e.RectangleCount; i++) { var rect = e.GetRectangle(i); //设置要更新的区域 //Invalidate(new Rectangle(rect.X, rect.Y, rect.Width, rect.Height)); Invalidate(new Rectangle(0, 0, this.Width, this.Height)); } })); }