Here you can find the source of savePNGBitmap(Bitmap bmp, String path)
public static boolean savePNGBitmap(Bitmap bmp, String path)
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; public class Main { public static boolean savePNGBitmap(Bitmap bmp, String path) { return saveBitmap(bmp, path, Bitmap.CompressFormat.PNG); }//from w w w .j ava 2s . c o m private static boolean saveBitmap(Bitmap bmp, String path, CompressFormat format) { if (bmp == null || path == null) { return false; } try { File file = new File(path); if (!file.exists()) { file.createNewFile(); } FileOutputStream fos = new FileOutputStream(file); ByteArrayOutputStream baos = new ByteArrayOutputStream(); bmp.compress(format, 100, baos); fos.write(baos.toByteArray()); baos.flush(); fos.flush(); baos.close(); fos.close(); return true; } catch (Exception e) { e.printStackTrace(); return false; } } }