get Assets Bitmap - Android Graphics

Android examples for Graphics:Bitmap Asset

Description

get Assets Bitmap

Demo Code


//package com.java2s;
import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

import java.io.IOException;
import java.io.InputStream;

public class Main {

    public static Bitmap getAssetsBitmap(Context context,
            String assetsfileName) {
        Bitmap mBitmap = null;//w  ww  . java  2s .co m
        AssetManager mAssetManager = context.getAssets();
        try {
            InputStream mInputStream = mAssetManager.open(assetsfileName);
            mBitmap = BitmapFactory.decodeStream(mInputStream);
        } catch (IOException e) {
        }

        return mBitmap;
    }
}

Related Tutorials