Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.graphics.Bitmap;

import android.view.View;

public class Main {
    /**
     * Returns a bitmap from the views drawing cache. Warining: disables drawing
     * cache after usage.
     * 
     * @param view
     * @return
     */
    public static Bitmap getBitmapFromView(View view) {
        view.setDrawingCacheEnabled(true);
        view.layout(0, 0, view.getWidth(), view.getBottom());
        view.buildDrawingCache();
        Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache());
        view.setDrawingCacheEnabled(false);
        return bitmap;
    }
}