shenhb
V2EX  ›  Android

android x5webview,截长图有不模糊的写法吗,现在截图出来都很模糊

  •  
  •   shenhb · Jul 15, 2019 · 14046 views
    This topic created in 2537 days ago, the information mentioned may be changed or developed.
    2 replies    2019-07-15 14:58:54 +08:00
    shenhb
        1
    shenhb  
    OP
       Jul 15, 2019
    shenhb
        2
    shenhb  
    OP
       Jul 15, 2019
    java 代码
    `
    private Bitmap captureWebView(WebView webView) {

    int wholeWidth = webView.computeHorizontalScrollRange();
    int wholeHeight = webView.computeVerticalScrollRange();
    Bitmap x5bitmap = Bitmap.createBitmap(wholeWidth , wholeHeight, Bitmap.Config.ARGB_8888);

    Canvas x5canvas = new Canvas(x5bitmap);
    x5canvas.scale((float) wholeWidth / (float) webView.getContentWidth(), (float) wholeHeight / (float)webView.getContentHeight());
    if ( webView.getX5WebViewExtension() == null) {
    return null;
    }

    webView.getX5WebViewExtension().snapshotWholePage(x5canvas, false, false);
    return x5bitmap;
    }

    `
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5282 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 09:06 · PVG 17:06 · LAX 02:06 · JFK 05:06
    ♥ Do have faith in what you're doing.