1

如何在屏幕外渲染模式下禁用浏览器 Awesomium 中的图像加载?

4

2 回答 2

1

您可以在创建 WebSession 时关闭图像加载:

WebView.WebSession = WebCore.CreateWebSession(new WebPreferences(){LoadImagesAutomatically = false});

于 2013-09-24T07:45:57.113 回答
1

您也可以使用 ResourceInterceptor。优点:无需重新创建WebSession + WebControl/WebView即可切换。

public class ResourceInterceptor : IResourceInterceptor
{
    public bool NoImages { get; set; }

    private static string[] _imagesFileTypes = { ".png", ".jpg", ".jpeg", ".gif", ".bmp" };

    public ResourceResponse OnRequest(ResourceRequest request)
    {
        string ext = System.IO.Path.GetExtension(request.Url.ToString()).ToLower();

        if (NoImages && _imagesFileTypes.Contains(ext))
        {
            request.Cancel();
        }

        return null;
    }

    public bool OnFilterNavigation(NavigationRequest request)
    {
        return false;
    }
}


...

ResourceInterceptor ResInt = new ResourceInterceptor();
WebCore.ResourceInterceptor = ResInt;
于 2013-10-09T05:51:17.023 回答