Android Bitmap Save saveBitmap(File saveToFile, Bitmap bitmapToSave)

Here you can find the source of saveBitmap(File saveToFile, Bitmap bitmapToSave)

Description

save Bitmap

Declaration

public static boolean saveBitmap(File saveToFile, Bitmap bitmapToSave) 

Method Source Code

//package com.java2s;
import android.graphics.Bitmap;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Main {
    public static boolean saveBitmap(File saveToFile, Bitmap bitmapToSave) {
        try {/*  w  w w .j a va2s.  co  m*/
            FileOutputStream fileOutputStream = new FileOutputStream(
                    saveToFile);
            bitmapToSave.compress(Bitmap.CompressFormat.JPEG, 100,
                    fileOutputStream);
            fileOutputStream.flush();
            fileOutputStream.close();
        } catch (FileNotFoundException fileNotFoundException) {
            fileNotFoundException.printStackTrace();
            return false;
        } catch (IOException IOException) {
            IOException.printStackTrace();
            return false;
        }
        return true;
    }
}

Related

  1. save(Bitmap bitmap, String fileName)
  2. saveBitmapToFile(Bitmap bitmap, String filename)
  3. saveBitmap(Bitmap bmp, String path, CompressFormat format)
  4. saveBitmap(Bitmap image)
  5. saveBitmap(File file, Bitmap bitmap)
  6. saveBitmapAsJpgAtSd(Bitmap mBitmap, String dirPath, String fileName)
  7. saveBitmapFromView(View view, String path)
  8. saveBitmapJPEGWithBackgroundColor( String strFileName, Bitmap bitmap, int nQuality, int nBackgroundColor)
  9. saveBitmapPNGWithBackgroundColor( String strFileName, Bitmap bitmap, int nBackgroundColor)