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 getWebViewShotshatByPicture(WebView webView) {
        Picture picture = webView.capturePicture();
        int width = picture.getWidth();
        int height = picture.getHeight();
        Bitmap bw = null;
        if (width > 0 && height > 0) {
            bw = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
            Canvas canvas = new Canvas(bw);
            //picture.draw(canvas);
            canvas.drawPicture(picture);
        }
        return bw;
    }
}