Android View to Image Capture getBitmapFromView(View view)

Here you can find the source of getBitmapFromView(View view)

Description

get Bitmap From View

Declaration

public static Bitmap getBitmapFromView(View view) 

Method Source Code

//package com.java2s;

import android.graphics.Bitmap;

import android.graphics.Canvas;
import android.graphics.Color;

import android.graphics.drawable.Drawable;

import android.view.View;

public class Main {
    public static Bitmap getBitmapFromView(View view) {
        Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth(),
                view.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(returnedBitmap);
        Drawable bgDrawable = view.getBackground();
        if (bgDrawable != null)
            bgDrawable.draw(canvas);/*from ww w . j  a v  a  2  s.  c om*/
        else
            canvas.drawColor(Color.WHITE);
        view.draw(canvas);

        return returnedBitmap;
    }
}

Related

  1. captureWebView(WebView webView)
  2. captureWebViewVisibleSize(WebView webView)
  3. convertViewToBitmap(View view)
  4. printScreen(View v)
  5. printScreen(View v, int quality)
  6. shotScreen(View cv)
  7. view2Bitmap(View view)