Android examples for Graphics:PNG Image
save Bitmap to PNG file
//package com.java2s; import android.graphics.Bitmap; import android.os.Environment; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static void saveBitmap(String path, String bitName, Bitmap mBitmap) {// ww w.j a va 2s.c o m File f = new File(Environment.getExternalStorageDirectory() .toString() + "/" + bitName + ".png"); try { f.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block } FileOutputStream fOut = null; try { fOut = new FileOutputStream(f); } catch (FileNotFoundException e) { e.printStackTrace(); } mBitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut); try { fOut.flush(); } catch (IOException e) { e.printStackTrace(); } try { fOut.close(); } catch (IOException e) { e.printStackTrace(); } } }