Here you can find the source of getImageFromAssetFile(Context context, String fileName)
Parameter | Description |
---|---|
context | a parameter |
fileName | a parameter |
public static Bitmap getImageFromAssetFile(Context context, String fileName)
//package com.java2s; import java.io.InputStream; import android.content.Context; import android.content.res.AssetManager; import android.graphics.Bitmap; import android.graphics.BitmapFactory; public class Main { /**/*from w ww.ja va 2s . c o m*/ * get image from assert * * @param context * @param fileName * @return */ public static Bitmap getImageFromAssetFile(Context context, String fileName) { Bitmap image = null; try { AssetManager am = context.getAssets(); InputStream is = am.open(fileName); BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inPreferredConfig = Bitmap.Config.RGB_565; opt.inPurgeable = true; opt.inInputShareable = true; image = BitmapFactory.decodeStream(is, null, opt); is.close(); } catch (Exception e) { e.printStackTrace(); } return image; } }