save Bitmap To PNG File - Android android.graphics

Android examples for android.graphics:PNG

Description

save Bitmap To PNG File

Demo Code

import java.io.FileOutputStream;

import android.graphics.Bitmap;

public class Main {

  public static void saveToFile(String filename, Bitmap bmp) {
    try {/*w  w  w. j a  va  2s . c  o  m*/
      FileOutputStream out = new FileOutputStream(filename);
      bmp.compress(Bitmap.CompressFormat.PNG, 100, out);
      out.flush();
      out.close();
    } catch (Exception e) {
    }
  }

}

Related Tutorials