내 모바일 카메라에서 사진을 클릭하고 ImageView에 표시하는 Android 애플리케이션을 구축 중입니다. 시계 반대 방향으로 90도 회전하면 자동으로 표시됩니다. 회전시키지 않고 모바일이 클릭하는 방향으로 이동합니다.카메라로 촬영할 때 이미지를 모바일 방향으로 회전 : Android
누구든지 관련 코드 조각이나 관련 문서에 대한 포인터를 제공 할 수 있습니까?
내 모바일 카메라에서 사진을 클릭하고 ImageView에 표시하는 Android 애플리케이션을 구축 중입니다. 시계 반대 방향으로 90도 회전하면 자동으로 표시됩니다. 회전시키지 않고 모바일이 클릭하는 방향으로 이동합니다.카메라로 촬영할 때 이미지를 모바일 방향으로 회전 : Android
누구든지 관련 코드 조각이나 관련 문서에 대한 포인터를 제공 할 수 있습니까?
ExifInterface exif = new ExifInterface(imageFilePath);
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
switch(orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
// rotate the image
break;
//....
}
사용이 그것은 당신을 도울 것입니다 methoh.
/*
* 1 = Horizontal (normal)
* 2 = Mirror horizontal
* 3 = Rotate 180
* 4 = Mirror vertical
* 5 = Mirror horizontal and rotate 270 CW
* 6 = Rotate 90 CW
* 7 = Mirror horizontal and rotate 90 CW
* 8 = Rotate 270 CW
*/
public static Bitmap getRotateBitmapImage(Bitmap bm, int newHeight,int newWidth, int exifOrientation) {
int width = bm.getWidth();
int height = bm.getHeight();
float scaleWidth = ((float) newWidth)/width;
float scaleHeight = ((float) newHeight)/height;
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
switch (exifOrientation) {
case ExifInterface.ORIENTATION_ROTATE_270:
rotate = 270;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_90:
rotate = 90;
break;
case ExifInterface.ORIENTATION_TRANSPOSE:
rotate = 45;
break;
case 0:
rotate = 360;
break;
default:
break;
}
matrix.postRotate(rotate);
// resizedBitmap = Bitmap.createScaledBitmap(bm, 65, 65, true);
Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);
return resizedBitmap;
}
나는 이미지를 캡처 중에도 인터넷을 XYZ = 새로운 의도 (Mediastore.ACTION_IMAGE_CAPTURE)를 사용하고 있습니다. 이 형식은 어떤 형식으로 저장되며 여기서 캡처 한 이미지의 객체를 여기에 설명 된 기능에 전달할 수 있습니까? 새 높이, 새 너비는 어때? – psbits
비트 맵의 크기를 조정하지 않으면 newHeight 및 newWitdh 부분을 무시하면됩니다. bitmap.getWidth() 및 bitmap.getHeight()를 사용하면됩니다. –
Bitmap.createBitmap을 실행할 때 새 높이/너비를 제거 할 수 있습니다. – samsad