Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Picture;
import android.webkit.WebView;

public class Main {

    public static Bitmap getWebViewShopshat(WebView webView) {
        webView.setDrawingCacheEnabled(true);
        webView.buildDrawingCache();
        Picture snapShot = webView.capturePicture();
        Bitmap bitmap = Bitmap.createBitmap(snapShot.getWidth(), snapShot.getHeight(), Bitmap.Config.ARGB_8888);
        //bitmap.eraseColor(Color.WHITE);

        Canvas c = new Canvas(bitmap);
        int state = c.save();
        webView.draw(c);
        //c.restoreToCount(state);
        c.restore();
        webView.destroyDrawingCache();

        return bitmap;
    }
}