Example usage for android.view TextureView getBitmap

List of usage examples for android.view TextureView getBitmap

Introduction

In this page you can find the example usage for android.view TextureView getBitmap.

Prototype

public Bitmap getBitmap() 

Source Link

Document

Returns a android.graphics.Bitmap representation of the content of the associated surface texture.

Usage

From source file:com.darktalker.cordova.screenshot.Screenshot.java

private Bitmap getBitmap() {
    Bitmap bitmap = null;//from w ww.  j av  a 2  s  .  c  o  m

    boolean isCrosswalk = false;
    try {
        Class.forName("org.crosswalk.engine.XWalkWebViewEngine");
        isCrosswalk = true;
    } catch (Exception e) {
    }

    if (isCrosswalk) {
        try {

            TextureView textureView = findXWalkTextureView((ViewGroup) webView.getView());
            if (textureView != null) {
                bitmap = textureView.getBitmap();
                return bitmap;
            }
        } catch (Exception e) {
        }
    }

    View view = webView.getView().getRootView();
    view.setDrawingCacheEnabled(true);
    bitmap = Bitmap.createBitmap(view.getDrawingCache());
    view.setDrawingCacheEnabled(false);

    return bitmap;
}