void IRenderWebBrowser.OnPaint(PaintElementType type, Rect dirtyRect, IntPtr buffer, int width, int height) { if (screenshotSource != null) { try { var bmp = new Bitmap(width, height); var data = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); NativeMethods.CopyMemory(data.Scan0, buffer, (uint)(width * height * 4)); bmp.UnlockBits(data); screenshotSource.SetResult(bmp); screenshotSource = null; } catch (Exception ex) { screenshotSource.SetException(ex); screenshotSource = null; } } else { target.RenderFrame(type, dirtyRect, buffer, width, height); } }
void IRenderWebBrowser.OnPaint(PaintElementType type, Rect dirtyRect, IntPtr buffer, int width, int height) { target.RenderFrame(type, dirtyRect, buffer, width, height); }