how to get uri from Bitmap after cropping image was selected from gallery
i tried this
public Uri getImageUri(Context inContext, Bitmap inImage) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); inImage.compress(Bitmap.CompressFormat.PNG, 100, bytes); String path = MediaStore.Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null); return Uri.parse(path); } but uri = null
i want to get uri from this
if (resultCode == Activity.RESULT_OK && requestCode == PICK_IMAGE_REQUEST) { Uri imageUri = data.getData(); performCrop(imageUri); Log.e(TAG, "image before crop:" + imageUri); }else if(resultCode == Activity.RESULT_OK && requestCode == PIC_CROP ){ // get the returned data Bundle extras = data.getExtras(); // get the cropped bitmap Bitmap selectedBitmap = extras.getParcelable("data"); getImageUri(this,selectedBitmap); Uri ImageUri = data.getData(); Log.e(TAG, "image before crop:" + ImageUri); log image before crop=null
---- UPDATE CROPPING----
private void performCrop(Uri picUri) { try { Intent cropIntent = new Intent("com.android.camera.action.CROP"); // indicate image type and Uri cropIntent.setDataAndType(picUri, "image/*"); // set crop properties here cropIntent.putExtra("crop", true); // indicate aspect of desired crop cropIntent.putExtra("aspectX", 1); cropIntent.putExtra("aspectY", 1); // indicate output X and Y cropIntent.putExtra("outputX", 128); cropIntent.putExtra("outputY", 128); // retrieve data on return cropIntent.putExtra("return-data", true); // start the activity - we handle returning in onActivityResult startActivityForResult(cropIntent, PIC_CROP); } // respond to users whose devices do not support the crop action catch (ActivityNotFoundException anfe) { // display an error message String errorMessage = "Whoops - your device doesn't support the crop action!"; Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT); toast.show(); }