CefSharp WpfControl并渲染到图像 [英] CefSharp WpfControl and rendering to image

查看:121
本文介绍了CefSharp WpfControl并渲染到图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们想在wpf应用程序的基于铬的浏览器中显示一个网页。
浏览器中显示的网站也应该显示在另一个屏幕上,但不能交互。
我想结合使用cefsharp wpf浏览器控件和cefsharp屏幕外渲染。

We want to show a webpage in a chromium based browser within a wpf application. The website that is displayed within the browser should also be shown on another screen but without interaction. I want to combine the cefsharp wpf browser control and the cefsharp offscreen rendering.

我可以使用一个Chrome实例来显示页面并在wpf中进行交互并导出吗?当前的可见网站是否是图片?

Can I use one chromium instance for displaying the page with interactions in wpf and export the current visible website as an image?

谢谢您,最好的问候,

Simon

推荐答案

谢谢,这确实适用于OnPaint方法或事件。

Thank you amatiland, it indeed works with the OnPaint Method or Event.

    public MainWindow()
    {
        InitializeComponent();

        Browser.Paint += Browser_Paint;
    }

    void Browser_Paint(object sender, CefSharp.Wpf.PaintEventArgs e)
    {
        Bitmap newBitmap = new Bitmap(e.Width, e.Height, 4 * e.Width, System.Drawing.Imaging.PixelFormat.Format32bppRgb, e.Buffer);

        var aPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "TestImageCefSharpQuant.png");
        newBitmap.Save(aPath);
    }

XAML

    <wpf:ChromiumWebBrowser x:Name="Browser" Address="www.google.com"></wpf:ChromiumWebBrowser>

这篇关于CefSharp WpfControl并渲染到图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆