save Bitmap From View - Android User Interface

Android examples for User Interface:View Bitmap

Description

save Bitmap From View

Demo Code


//package com.java2s;
import java.io.FileOutputStream;

import android.graphics.Bitmap;

import android.view.View;

public class Main {
    public static void saveBitmapFromView(View view, String path) {
        if (view != null) {
            Bitmap bitmap = view.getDrawingCache();

            try {
                FileOutputStream fos = new FileOutputStream(path);
                bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
            } catch (Exception e) {
                e.printStackTrace();//www  . j a v  a 2  s  . co  m
            }
        }
    }
}

Related Tutorials