Save Bitmap to JPEG - Android Graphics

Android examples for Graphics:JPEG Image

Description

Save Bitmap to JPEG

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 saveJPGE_After(Bitmap bitmap, String path) {
        File file = new File(path);
        try {/*from w  w  w.  j a v  a 2 s  .c  om*/
            FileOutputStream out = new FileOutputStream(file);
            if (bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out)) {
                out.flush();
                out.close();
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Related Tutorials