ich dieses Beispiel hoffen, dass Sie helfen können:
// onActivityResult Methode
Uri selectedImage = data.getData();
if (selectedImage == null) {
imagePath = data.getStringExtra(GOTOConstants.IntentExtras.IMAGE_PATH);
Bitmap my_bitmap_camera = BitmapFactory.decodeFile(imagePath);
ExifInterface exif = new ExifInterface(imagePath);
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
switch (orientation){
case ExifInterface.ORIENTATION_ROTATE_90:
Matrix matrix = new Matrix();
matrix.postRotate(90);
my_bitmap_camera = Bitmap.createBitmap(my_bitmap_camera, 0, 0, my_bitmap_camera.getWidth(), my_bitmap_camera.getHeight(), matrix, true);
break;
}
ivScreenshot1.setImageBitmap(my_bitmap_camera);
}
// XML
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/ivScreenshot1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
// Sie können auch diesen Beitrag überprüfen: How to get the Correct orientation of the image selected from the Default Image gallery
ImageView.ScaleType.CENTER_INSIDE: https://developer.android.com/reference/android/widget/ImageView. ScaleType.html – yongsunCN
@youngsunCN, es funktioniert perfekt mit dem Landschaftsbild, aber Bilder, die in der vertikalen Ausrichtung aufgenommen wurden, zeigt die gleiche wie Landschaft (aber mit der falschen Rotation). Warum das? –
könnten Sie bitte ein Beispielbild hochladen – yongsunCN