- 使用ExifInterface類別及可辦到
ExifInterface exifInterface = new ExifInterface(picturePath);
Matrix matrix = new Matrix();
int orientation = exifInterface.getAttributeInt(
ExifInterface.TAG_ORIENTATION, 0);
if (orientation == ExifInterface.ORIENTATION_ROTATE_90) {
matrix.postRotate(90);
} else if (orientation == ExifInterface.ORIENTATION_ROTATE_180) {
matrix.postRotate(180);
} else if (orientation == ExifInterface.ORIENTATION_ROTATE_270) {
matrix.postRotate(270);
}
Bitmap pictureBitmap = Bitmap.createScaledBitmap(
BitmapFactory.decodeFile(picturePath), 300, 300, true);
Bitmap pictureBitmap2 = Bitmap.createBitmap(pictureBitmap, 0, 0,
pictureBitmap.getWidth(), pictureBitmap.getHeight(), matrix,
true);
picture_IV.setImageBitmap(pictureBitmap2);
picturePath : 為字串型態(此字串為圖片存在於SD卡上的路徑)
picture_IV : 為ImageView的參考
沒有留言:
張貼留言