1

I start following intent:

            Intent cropIntent = new Intent("com.android.camera.action.CROP");
            cropIntent.setDataAndType(data.getData(), "image/*");
            cropIntent.putExtra("crop", "true");
            cropIntent.putExtra("outputX", wallWidth);
            cropIntent.putExtra("outputY", wallHeight);
            cropIntent.putExtra("aspectX", wallWidth);
            cropIntent.putExtra("aspectY", wallHeight);
            cropIntent.putExtra("scale", true);
            cropIntent.putExtra("scaleUpIfNeeded", true);
            cropIntent.putExtra("return-data", true);
            cropIntent.putExtra("noFaceDetection", true);

In my case wallWidth and wallHeight are 960/800 and then this intent stucks at cropping (this loading circle rotates the whole time). If I enter there something around 400 or less for the output it works perfectly. How can I fix this? Because I want to have a bitmap with higher resolution as output.

L3n95
  • 1,505
  • 3
  • 25
  • 49
  • Android does not have a `CROP` `Intent`: http://commonsware.com/blog/2013/01/23/no-android-does-not-have-crop-intent.html – CommonsWare Sep 27 '14 at 12:39
  • I know but some smartphones have it – L3n95 Sep 27 '14 at 12:41
  • Yes, but "some" is not "all". If your goal is to have an app that is compatible across most Android devices, do not rely upon an undocumented, unsupported `Intent` action. Use a library or implement your own image cropping UI. – CommonsWare Sep 27 '14 at 12:43
  • Yes for that I created my own cropping UI but that only starts if the Intent above doesn't exist. So you don't know the answer for my question? – L3n95 Sep 27 '14 at 12:49
  • The answer to your question is to stop using that `Intent` action. Even if the device has an activity that supports it, that activity may not work all that well. Device manufacturers routinely screw up support for the documented and supported actions (e.g., `ACTION_IMAGE_CAPTURE`). The reliability of undocumented and unsupported actions will tend to be worse. And, since you already have a better alternative integrated into your app, use it. – CommonsWare Sep 27 '14 at 12:57
  • The problem is the alternative isn't better :D https://github.com/MMP-forTour/cropimage Is this library free and hasn't to be mentioned in my app that I use it? Then I would implement this. – L3n95 Sep 27 '14 at 13:04
  • Interpretation of open source licenses is off-topic for Stack Overflow. And there are [newer libraries than that one](https://android-arsenal.com/tag/45). – CommonsWare Sep 27 '14 at 13:06

1 Answers1

-1

Big picture to use Uri, small images using Bitmap.Here you need to use the Uri.

The key code is as follows:

private static final String IMAGE_FILE_LOCATION = "file:///sdcard/temp.jpg";//temp file
private Uri imageUri = Uri.parse(IMAGE_FILE_LOCATION);//The Uri to store the big bitmap

startPhotoZoom(data.getData());

public void startPhotoZoom(Uri uri) {
 Intent intent = new Intent("com.android.camera.action.CROP");
 intent.setDataAndType(uri, "image/*");
 intent.putExtra("crop", "true");
 intent.putExtra("aspectX", 1);
 intent.putExtra("aspectY", 1);
 intent.putExtra("scale", true);
 intent.putExtra("outputX", 500);
 intent.putExtra("outputY", 500);
 intent.putExtra("noFaceDetection", true);
 intent.putExtra("return-data", false);
 intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
 intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
 startActivityForResult(intent, Constant.CROP_IMAGE);
}

Bitmap bitmap = decodeUriAsBitmap(imageUri);

//decode bitmap
private Bitmap decodeUriAsBitmap(Uri uri){
 Bitmap bitmap = null;
 try {
  bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));
 } catch (FileNotFoundException e) {
  e.printStackTrace();
  return null;
 }
 return bitmap;
}
iOnesmile
  • 99
  • 4