我想解碼一個位圖,但該函數返回null,我不知道爲什麼。解碼位圖返回null
代碼:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == SELECT_FOTO)
{
Uri imgselect = data.getData();
String imgpath = imgselect.getPath();
File f = new File (imgpath);
Bitmap bm = BitmapFactory.decodeFile(f.getAbsolutePath());
Toast.makeText(Insertarlugar.this, "Bitmap es" + bm, Toast.LENGTH_LONG).show();
}
的敬酒指示我,BM爲空。我爲f.getPath()更改了f.getAbsolutePath(),但結果相同。 Uri imgselect和String imgpath有值。我不使用SD卡,並從圖庫中獲取位圖。
如何調整位圖大小?
謝謝。
首先檢查imgpath的值 –
正如我在我的帖子中所說,我檢查了imgselect的值。是內容/媒體/外部/圖像/媒體/ 11295,所以它有價值。 – axmug