[問題] 讀取圖片GIF錯誤Image failed to decode

看板AndroidDev作者 (linlin76)時間8年前 (2017/02/15 21:38), 8年前編輯推噓1(101)
留言2則, 1人參與, 最新討論串1/1
目前使用這個lib處理照片裁切 https://github.com/oginotihiro/cropview 可是選取照片時,如果選到GIF就會閃退 看一下程式碼 主要是死在 InputStream is = context.getContentResolver().openInputStream(sourceUri); BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(is, false); 以上程式碼sourceUri如果抓到圖檔是GIF就會跳 Image failed to decode using JPEG decoder 原本想說去判斷Uri看是不是GIF再另外處理 可是我看Uri是亂碼 (sourceUri = content://com.android.providers.media.documents/document/image%3A22486) 這樣我可以怎麼處理@@? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.160.166.6 ※ 文章網址: https://www.ptt.cc/bbs/AndroidDev/M.1487165894.A.49C.html ※ 編輯: linlin76 (1.160.166.6), 02/15/2017 21:46:59

02/21 22:09, , 1F
你可能要先解URI 轉換成路徑在做副檔名判斷即可
02/21 22:09, 1F

02/21 22:09, , 2F
請參考 https://goo.gl/7bwTlX 裡面有一段getPath
02/21 22:09, 2F
文章代碼(AID): #1Of5d6IS (AndroidDev)