public static Bitmap getBitmapFromAsset(Context context, String filePath) {
AssetManager assetManager = context.getAssets();
InputStream istr;
Bitmap bitmap = null;
try {
istr = assetManager.open(filePath);
bitmap = BitmapFactory.decodeStream(istr);
} catch (IOException e) {
// handle exception
}
return bitmap;
}
the path is simply your file name fx bitmap.png. if you use subfolder bitmap/ then its bitmap/bitmap.png
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…