2012-05-21 30 views
0

我在android相機的Intent方法捕獲的imageview中顯示圖像。我已經通過三星Nexus測試了這個代碼,但是當我通過Nexus S進行測試時,圖像在270度時被旋轉了一圈。我一直在經歷這些鏈接如何在android中獲取設備的方向?

ACTION_IMAGE_CAPTURE orientation problem on Nexus S and Samsung Galaxy S I9000

Camera/picture orientation in Android

http://developer.android.com/reference/android/hardware/Camera.Parameters.html#setRotation%28int%29

Picture orientation from gallery/camera intent

但這個代碼

ExifInterface exif = new ExifInterface("filepath"); 
exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); 

總是給0在兩個設備中。請告訴我我會知道,圖像顯示在特定設備中的哪個角度顯示,以便它將應用於所有設備,一旦我將獲得它的角度,我將自行旋轉。提前致謝。

+0

或該[http://mobisocial.stanford.edu/news/2011/08/rotating-images-in-android/](http://mobisocial.stanford.edu/news/2011/08/rotating- images-in-android /) – sschrass

+0

這是我對這個問題的解決方案; http://stackoverflow.com/a/8864367/137404 –

回答

0

我不是100%肯定我明白你在找什麼,但如果你想在設備的方向,看看這個問題:

Check orientation on Android phone

+0

我試過getResources()。getConfiguration()。orientation。但兩臺設備上的結果仍然相同。 –

+0

你到底想做什麼?因爲如果你只想設置方向,而不是檢查當前的方向,那應該更容易一些。 – MNRSullivan

0

會發生什麼,如果你:

ExifInterface exif = new ExifInterface("filepath"); 
exif.getAttribute(ExifInterface.TAG_ORIENTATION); 

+0

它總是在兩個設備中都爲0。顯示精美的Nexus S和以橫向顯示圖像或旋轉圖像的Nexus S。 –

+0

有你讀通過此:http://stackoverflow.com/questions/8450539/images-taken-with-action-image-capture-always-returns-1-for-exifinterface-tag-or/8864367#8864367? – sschrass

+0

看來,有一個錯誤解釋您提到的exif標籤的行爲。 – sschrass