Android Bitmap Save saveBitmap(final Bitmap bitmap, final String savePath)

Here you can find the source of saveBitmap(final Bitmap bitmap, final String savePath)

Description

save Bitmap

Declaration

public static void saveBitmap(final Bitmap bitmap, final String savePath) 

Method Source Code

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Locale;
import android.annotation.SuppressLint;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.text.TextUtils;
import android.widget.ImageView;

public class Main{
    private static final int DEAFULT_QUALITY = 100;
    public static void saveBitmap(final Bitmap bitmap, final String savePath) {
        FileOutputStream fileOutputStream = null;
        try {/* www .j a  v a  2s  .  c  om*/
            fileOutputStream = new FileOutputStream(savePath);
            bitmap.compress(Bitmap.CompressFormat.JPEG, DEAFULT_QUALITY,
                    fileOutputStream);
            fileOutputStream.flush();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                fileOutputStream.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}

Related

  1. bitmap2File(Bitmap bitmap, File file)
  2. bitmap2Stream(Bitmap bitmap)
  3. getImagePath(Context context, Bitmap inImage)
  4. saveBitmap(Bitmap bitmap, File file)
  5. saveBitmap(String bitName, Bitmap bitmap)
  6. saveBitmapFromScrollView(ScrollView scrollView, String path)
  7. saveBitmaptoFile(Bitmap bmp, String path, CompressFormat format, int quality)
  8. saveImage(String filename, Bitmap bm)
  9. saveImage(String filename, Bitmap bm, boolean landscape)