此方法可當工具類直接使用:
- * 讀取Assets文件夾中的圖片資源
- * @param context
- * @param fileName 圖片名稱
- * @return
- */
- public static Bitmap getImageFromAssetsFile(Context context, String fileName) {
- Bitmap p_w_picpath = null;
- AssetManager am = context.getResources().getAssets();
- try {
- InputStream is = am.open(fileName);
- p_w_picpath = BitmapFactory.decodeStream(is);
- is.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return p_w_picpath;
- }