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

作者: linlin76 (linlin76)   2017-02-15 21:38:10
目前使用這個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)
這樣我可以怎麼處理@@?
作者: givemepass (λ)   2017-02-21 22:09:00
你可能要先解URI 轉換成路徑在做副檔名判斷即可請參考 https://goo.gl/7bwTlX 裡面有一段getPath

Links booklink

Contact Us: admin [ a t ] ucptt.com