我有一個android應用程序,允許用戶拍照。在這種情況下,圖像並不總是正確顯示,這取決於圖像捕獲過程中手機的方向。我提供了一個可以在大多數手機上使用的旋轉圖像功能,但不是所有的手機。事實上,當它不起作用的應用程序崩潰。旋轉功能在下面提供。我很欣賞任何可以在所有手機上使用此功能的反饋。此外,該應用程序只是崩潰,錯誤陷阱不會被調用。android旋轉圖像只在某些手機上崩潰
private void rotateImage(float degrees){
try{
String imageFile = Environment.getExternalStorageDirectory()+"/"+Imagefile;
Bitmap bitmap = BitmapFactory.decodeFile(imageFile);
int width = bitmap.getWidth();
int height = bitmap.getHeight();
// resize the bit map
//matrix.postScale(scaleWidth, scaleHeight);
// rotate the Bitmap
Matrix matrix = new Matrix();
matrix.postRotate(degrees);
// create the new Bitmap
Bitmap rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
imageAsset.setImageBitmap(rotatedBitmap);
// clean up
bitmap = null;
rotatedBitmap = null;
matrix = null;
}catch(Exception e){
utility.logError(this,"{"+CLASS_NAME+"}[rotateImage] Error: "+e.getMessage());
}
}
什麼是錯誤?你應該發佈logcat的相關部分以及可能產生錯誤的代碼。 –
沒有錯誤信息。它只是崩潰。由於我無法購買每個手機型號,所以有時我只能依靠用戶反饋。 –
您是否在Android Market控制檯中有任何報告?告訴用戶抱怨發送報告! –