save Bitmap as Jpeg file - Android Graphics

Android examples for Graphics:Bitmap Save

Description

save Bitmap as Jpeg file

Demo Code


//package com.java2s;
import java.io.FileOutputStream;
import java.io.OutputStream;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;

public class Main {

    public static boolean saveBitmap(Bitmap bitmap, String filename) {
        if (bitmap == null)
            return false;
        try {//from  w ww  .j ava2s.  c o m
            OutputStream out = new FileOutputStream(filename);
            bitmap.compress(CompressFormat.JPEG, 100, out);

            out.close();
            return true;
        } catch (Exception e) {
            return false;
        }
    }
}

Related Tutorials