4
갤러리의 이미지를 비트 맵 API를 통해로드하고 있지만 이미지의 방향이 저장된 것과 다릅니다. 어딘가에 stackoverflow에 난 그 oreintation 값을 얻으려면 다음 행렬을 회전 읽을 필요가 읽습니다. 나는 이것을 시도했지만 내 방향은 exif 인터페이스에서 0으로오고있다. 당신이 getAttributeInt
에서 다시 0
을 받고있는 경우갤러리에서 올바른 방향의 이미지를로드 할 수 없습니다.
int desiredImageWidth = 310; // pixels
int desiredImageHeight = 518; // pixels
Log.i("FA", "Image Loading "+strFileName);
BitmapFactory.Options o = new BitmapFactory.Options();
Bitmap newImage = Bitmap.createScaledBitmap(BitmapFactory.decodeFile(strFileName, o),
desiredImageWidth,
desiredImageHeight,
false);
Bitmap finalBmp = getCorrectOrientedBitmap(strFileName,newImage);
Bitmap myBitmap32 = finalBmp.copy(Bitmap.Config.ARGB_8888, true);
Mat matImg = Utils.bitmapToMat(myBitmap32);
내 주요 방향 함수는 그냥 이미지가 그 안에 저장된 모든 방향 정보를 가지고 있지 않습니다 "회전"을 의미한다고 생각,
private Bitmap getCorrectOrientedBitmap(String filename,Bitmap Source) throws IOException{
Bitmap rotatedBitmap = null;
ExifInterface exif = new ExifInterface(filename);
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
Matrix matrix = new Matrix();
Log.i("FA", "orientation "+orientation);
switch(orientation)
{
case 6:
matrix.postRotate(90);
break;
case 3:
matrix.postRotate(180);
break;
case 8:
matrix.postRotate(270);
break;
}
rotatedBitmap = Bitmap.createBitmap(Source, 0, 0, Source.getWidth(), Source.getHeight(), matrix, true);
return rotatedBitmap;
}
나는 또한 동일한 문제로 달리고있다. 그러나 제 경우에는 갤러리의 그림 중 일부가 다른 방향으로 나타납니다. 효과가있는 솔루션을 게시 할 수 있습니까? – user2376920