Android Bitmap Save saveBitmap(Bitmap image)

Here you can find the source of saveBitmap(Bitmap image)

Description

save Bitmap

Declaration

public static String saveBitmap(Bitmap image) 

Method Source Code

//package com.java2s;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;

import java.util.Date;
import android.content.Context;
import android.graphics.Bitmap;

import android.util.Log;

public class Main {
    static Context cntxt;

    public static String saveBitmap(Bitmap image) {

        String timeStamp = new SimpleDateFormat("ddMMyyyy_HHmm")
                .format(new Date());
        String mImageName = "IP_" + timeStamp + ".jpg";

        try {/*w w  w  . j a  v  a  2  s .c om*/
            FileOutputStream fos = cntxt.openFileOutput(mImageName,
                    Context.MODE_PRIVATE);
            image.compress(Bitmap.CompressFormat.PNG, 90, fos);
            fos.close();
        } catch (FileNotFoundException e) {
            Log.d("image", "File not found: " + e.getMessage());
        } catch (IOException e) {
            Log.d("image", "Error accessing file: " + e.getMessage());
        }

        return mImageName;
    }
}

Related

  1. addImageAsApplication(ContentResolver cr, String name, long dateTaken, String directory, String filename, Bitmap source, byte[] jpegData)
  2. saveBitmapToFile(Bitmap bitmap, String path)
  3. save(Bitmap bitmap, String fileName)
  4. saveBitmapToFile(Bitmap bitmap, String filename)
  5. saveBitmap(Bitmap bmp, String path, CompressFormat format)
  6. saveBitmap(File file, Bitmap bitmap)
  7. saveBitmap(File saveToFile, Bitmap bitmapToSave)
  8. saveBitmapAsJpgAtSd(Bitmap mBitmap, String dirPath, String fileName)
  9. saveBitmapFromView(View view, String path)