Android Bitmap Save saveBitmap(Bitmap bitmap, File file)

Here you can find the source of saveBitmap(Bitmap bitmap, File file)

Description

save Bitmap

Declaration

public static File saveBitmap(Bitmap bitmap, File file)
            throws IOException 

Method Source Code

//package com.java2s;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import android.graphics.Bitmap;

public class Main {
    public static File saveBitmap(Bitmap bitmap, File file)
            throws IOException {

        ByteArrayOutputStream bytes = new ByteArrayOutputStream();

        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytes);

        //write the bytes in file
        FileOutputStream fo = new FileOutputStream(file);
        fo.write(bytes.toByteArray());//from  w ww.j  av a  2s . c  om

        // remember close de FileOutput
        fo.close();

        return file;
    }
}

Related

  1. addBitmapToMemoryCache(String key, Bitmap bitmap)
  2. base64Bitmap(Bitmap bitmap)
  3. bitmap2File(Bitmap bitmap, File file)
  4. bitmap2Stream(Bitmap bitmap)
  5. getImagePath(Context context, Bitmap inImage)
  6. saveBitmap(String bitName, Bitmap bitmap)
  7. saveBitmap(final Bitmap bitmap, final String savePath)
  8. saveBitmapFromScrollView(ScrollView scrollView, String path)
  9. saveBitmaptoFile(Bitmap bmp, String path, CompressFormat format, int quality)