0

When I store captured image from camera after cropping, cropped jpg image file is

stored in my specified folder.

I want to store "that" cropped image file with bmp filename extension.

iehrlich
  • 3,572
  • 4
  • 34
  • 43
Na Jun Yeop
  • 55
  • 1
  • 7
  • If a post solves your problem, Please mark it as answer, That's the way of showing courtesy. – Rahul Jul 12 '17 at 02:19

2 Answers2

0

I suggest the steps are:

  1. After cropped jpg you convert it to Bitmap with this code

    Bitmap bMap = BitmapFactory.decodeFile(imgPath);
    
  2. Save bMap with bmp extention you can follow suggest function over HERE

  3. Delete cropped jpg file to free memory

    File dir = getFilesDir();
    
    File file = new File(dir, "filename");
    
    if (file.exists()) {
    
     boolean deleted = file.delete();
    
    }
    
Khang Tran
  • 467
  • 5
  • 16
0

Try below code -

            FileOutputStream out = null;
            try {
                out = new FileOutputStream(AbsoluteFilePath);
                bmp.compress(Bitmap.CompressFormat.PNG, 100, out); // bmp is your Bitmap instance
                // PNG is a lossless format, the compression factor (100) is ignored
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                try {
                    if (out != null) {
                        out.close();
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

SOURCE : Save bitmap to location

Rahul
  • 675
  • 6
  • 18