0

It seems dublicate but it is not please look my question.

I ve searched many times on google and stackoverflow. I found many examples but none of it does not solve my issue.

What I need is :

I want to capture image and save it (I give the path) After that I want to crop it and save it same place(I mean replace the original file with cropped image)

What I did is:

I use this for take image:

 Intent cameraIntent = new Intent( MediaStore.ACTION_IMAGE_CAPTURE); 
 cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); // outputFileUri is my path
 startActivityForResult(cameraIntent, TAKE_PHOTO_CODE); 

For the crop the image I use this sample on stackoverflow :

this

What is done:

I capture the image and after capture I run the crop image method and it is fine as well.

After I done with crop the image I cant see the cropped image , it is just captured image.

What is the issue:

There is no error but I want to see captured image will be replaced with the original captured image.

thanks in advance!!

Community
  • 1
  • 1
CompEng
  • 7,161
  • 16
  • 68
  • 122
  • http://code.tutsplus.com/tutorials/capture-and-crop-an-image-with-the-device-camera--mobile-11458 see this link – Meenal May 14 '14 at 05:14
  • thanks for answer , I implement this to my project , after I capture image there are two options , crop photo and crop picture , crop photo is fine for me but crop picture is not work on my phone , how can I solve this? – CompEng May 14 '14 at 07:17

1 Answers1

1

Try this, onActivityResult you will Returned data

  @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {


    case Utils.CROP_IMAGE:
        if (resultCode == RESULT_OK) {
            // Create an instance of bundle and get the returned data
            try {
                Uri outputFileUri = data.getData();
                             String path = getRealPathFromURI(outputFileUri)

            } catch (Exception e) {
                // TODO: handle exception
            }
        }
        break;

    default:
        break;
    }
}

Get file path fome URI.

 public String getRealPathFromURI(Uri contentUri) 
 {
 String[] proj = { MediaStore.Audio.Media.DATA };
 Cursor cursor = managedQuery(contentUri, proj, null, null, null);
 int column_index = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA);
 cursor.moveToFirst();
 return cursor.getString(column_index);
}
Murali Ganesan
  • 2,925
  • 4
  • 20
  • 31