Save Bitmap to PNG - Android Graphics

Android examples for Graphics:PNG Image

Description

Save Bitmap to PNG

Demo Code


//package com.java2s;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import android.graphics.Bitmap;

public class Main {

    public static void savePNG_After(Bitmap bitmap, String name) {
        File file = new File(name);
        try {//from   www.  j ava 2  s .  c  o m
            FileOutputStream out = new FileOutputStream(file);
            if (bitmap.compress(Bitmap.CompressFormat.PNG, 100, out)) {
                out.flush();
                out.close();
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Related Tutorials