I have reads many question about this, but I still failed using this code... maybe anyone can corect my code... I want to crop an image from file that i know the location us
try {
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(mPhotoUri, "image/*");
intent.putExtra("crop", "true");
Integer altura = documento.getAltura();
Integer largura = documento.getLargura();
if (altura != null && largura != null) {
intent.putExtra("aspectY", altura);
intent.putExtra("aspectX", largura);
}
File file = imagemProcessor.getNewFile();
mCropUri = Uri.fromFile(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, mCropUri);
intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
startActivityForResult(intent, REQUEST_IMAGE_CROP);
} catch (ActivityNotFoundException e) {
Context context = getBaseContext();
Toast toast = Toast.makeText(context, "Your device doesn't support the crop action!", Toast.LENGTH_SHORT);
toast.show();
} catch (IOException e) {
Context context = getBaseContext();
Toast toast = Toast.makeText(context, "Fail to create file!", Toast.LENGTH_SHORT);
toast.show();
}