2013-02-15 96 views
0

我對此代碼有問題。我想從路徑加載圖像到imageview。當使用此代碼一切正常BitmapFactory.decodeFile僅在手機中返回null,不在仿真器中

image.setImageBitmap(BitmapFactory.decodeFile(imagePath)); 

但是當我用這一個,在模擬器是好的,但應用程序停止在電話工作,讓我的錯誤,無效的位圖

Bitmap bitmap = BitmapFactory.decodeFile(imagePath); 

image.setImageBitmap(bitmap);

我需要這段代碼。

Matrix mat = new Matrix(); 
mat.postRotate(90); 
bitmap = BitmapFactory.decodeFile(imagePath); 
bitmap_final = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), mat, true); 
image.setImageBitmap(bitmap_final); 

再次,在模擬器,一切都很好,在手機沒有:/感謝您的幫助和抱歉不好英語

+1

也許'imagePath'在仿真器上有效,但不在設備上,路徑是什麼?你是否也在說使用* same *方法調用,而是分配給一個變量失敗? – 2013-02-15 23:36:25

回答

0

所以,我解決了這個問題。這可能是內存,我從文檔setPic使用方法,現在應用程序沒有問題。但奇怪的是,它在模擬器中沒有問題。

相關問題