Android 加載本地圖片decodeStream()方法OOM

    public static Bitmap getLocalBitmap(String url) {
        try {
            FileInputStream fis = new FileInputStream(url);
            BitmapFactory.Options options=new BitmapFactory.Options();
            options.inJustDecodeBounds = false;
            options.inSampleSize = 10;
            Bitmap btp =BitmapFactory.decodeStream(fis,null,options);
            return btp;  ///把流轉化爲Bitmap圖片

        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return null;
        }

    }
這個方法用於加載本地圖片,Option的設定可以降低OOM的可能性
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章