Dies ist mein Code:Image setImageBitmap nach Crop nicht
File cropImage = new File(Environment.getExternalStorageDirectory(), "o_crop_image.jpg");
try {
if (cropImage.exists()) {
cropImage.delete();
}
cropImage.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
cropUri = Uri.fromFile(cropImage);
Intent i = new Intent("com.android.camera.action.CROP");
i.setDataAndType(imageUri, "image/*"); //imageUri is the original image
i.putExtra("scale", true);
i.putExtra(MediaStore.EXTRA_OUTPUT, cropUri);
startActivityForResult(i, CROP_PHOTO);
Und onActivityResult
:
case CROP_PHOTO:
if (resultCode == RESULT_OK) {
Bitmap bitmap = BitmapFactory.decodeFile(cropImage.getAbsoluteFile());
photo.setImageBitmap(bitmap); //photo is an ImageView
}
break;
Der Code photo.setImageBitmap(bitmap)
funktionieren soll, aber das Image keine Bilder zeigte. Die Bitmap, die ich bekomme, ist in Ordnung, was ich in der SD finden kann.
Auch andere Bitmaps können nicht in ImageView gesetzt werden, aber die Methode setImageResource
ist in Ordnung. Kann mir da jemand helfen?
[Android hat kein 'CROP'' Intent'] (https://commonsware.com/blog/2013/01/23/no-android-does-not-have-crop-intent.html). Es gibt viele [Bild beschneidende Bibliotheken für Android] (https://android-arsenal.com/tag/45). Bitte benutze eins. – CommonsWare