此方法可当工具类直接使用:
- * 读取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;
- }