get Bitmap From Asset - Android android.content.res

Android examples for android.content.res:AssetManager

Description

get Bitmap From Asset

Demo Code

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.lemon.assist.Check;
import android.lemon.config.BaseConfig;
import android.os.Environment;
import android.os.StatFs;

import java.io.InputStream;


public class Main{

    public static Bitmap getBitmapFromAsset(Context context, String fileName) {
        Bitmap bit = null;/*from w  w  w.jav  a 2  s  .c  om*/
        try {
            AssetManager assetManager = context.getAssets();
            InputStream is = assetManager.open(fileName);
            bit = BitmapFactory.decodeStream(is);
        } catch (Exception e) {

        }
        return bit;
    }

}

Related Tutorials