load Bitmap From Assets - Android Graphics

Android examples for Graphics:Bitmap Asset

Description

load Bitmap From Assets

Demo Code


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

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

public class Main {
    public static Bitmap loadBitmapFromAssets(Context context, String name) {
        try {//from w w  w  . ja  v a 2 s . c  om
            InputStream is = context.getAssets().open(name);
            Bitmap bitmap = BitmapFactory.decodeStream(is);
            return bitmap;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related Tutorials