2014-12-18 3 views
0

이제는 ExifInterface를 구현했지만 카메라 의도로 찍은 이미지를 회전시키지 않았습니다. 이미지가 세로 대신 가로 방향으로 표시됩니다. 여기 ExifInterface가 이미지를 회전시키지 않습니다.

내 코드입니다 :

Intent imageIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); 
    File imagesFolder = new File(Environment.getExternalStorageDirectory(), "My Fodler"); 
    imagesFolder.mkdirs(); 
    File image = new File(imagesFolder, "My_" + timeStamp + ".jpg"); 
    fileUri = Uri.fromFile(image); 
    ExifInterface exif = null; 
    try { 
     exif = new ExifInterface(image.getAbsolutePath()); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
     int orientation = exif.getAttributeInt(
       ExifInterface.TAG_ORIENTATION, 
       ExifInterface.ORIENTATION_NORMAL); 

     switch (orientation) { 
     case ExifInterface.ORIENTATION_ROTATE_270: 
      rotate = 270; 
      break; 
     case ExifInterface.ORIENTATION_ROTATE_180: 
      rotate = 180; 
      break; 
     case ExifInterface.ORIENTATION_ROTATE_90: 
      rotate = 90; 
      break; 
     } 
imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); 
startActivityForResult(imageIntent, TAKE_PICTURE); 
} 

은 내가 잘못 여기서 뭐하는 거지? 도와주세요.

+0

이번이 오리엔테이션에 대해 두 번째 묻는 질문은 두 번째입니까? – jenuine

+0

http://stackoverflow.com/questions/27542693/how-to-change-the-orientation-of-image-taken-by-camera-intent/27542902#27542902 – jenuine

답변

0

먼저, 아직 존재하지 않는 파일을 검사하려면 ExifInterface을 사용하고 있습니다. 카메라 앱이 사진을 촬영할 때까지 기다려 파일이 존재하므로 다음을 사용하십시오. ExifInterface.

둘째, EXIF ​​헤더를 읽고 rotate을 설정하면 ... rotate 값으로 아무 작업도 수행하지 않습니다. 이미지를 회전 시키려면 their previous SO question의 답변에있는 지침을 따르고 Matrix을 사용하십시오. 가급적이면 전체 카메라 이미지를 회전시킬 수있는 힙 공간이 충분하지 않을 수도 있습니다 (가능하면 다운 샘플 된 이미지를 회전 시키십시오).

+0

안녕하세요 고맙습니다. 제안대로 해 봤지만 행복합니다. 100 % 감사를드립니다. 한 가지 더 문제는 카메라의 의도 이후 맵에 배치 된 특정 마커에 이미지를 저장하는 것입니다 (실제로 그 작업을 실제로 도왔습니다). 나는 그것에 대한 질문을했습니다. 당신이보기를 원한다면 질문이 여기에 있습니다 (그리고 어쩌면 도움이 될 수 있습니다 :-)? (http://stackoverflow.com/questions/27427152/hashmap-not-returning-image-to-marker-by-onmarkerclick) 감사합니다. 정말로 감사드립니다. – Allrounder

관련 문제