load Bitmap From View - Android User Interface

Android examples for User Interface:View Bitmap

Description

load Bitmap From View

Demo Code


//package com.java2s;

import android.graphics.Bitmap;
import android.graphics.Canvas;

import android.view.View;

public class Main {
    public static Bitmap loadBitmapFromView(View v) {
        int w = v.getWidth(); // v.getLayoutParams().width
        int h = v.getHeight(); // v.getLayoutParams().height
        Bitmap b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_4444);
        Canvas c = new Canvas(b);
        v.layout(0, 0, w, h);/*w  ww.j  a va2  s  . co m*/
        v.draw(c);
        return b;
    }
}

Related Tutorials