Android Bitmap Load getBitmapFromAsset(Context context, String strName)

Here you can find the source of getBitmapFromAsset(Context context, String strName)

Description

get Bitmap From Asset

License

Open Source License

Declaration

public static Bitmap getBitmapFromAsset(Context context, String strName) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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 getBitmapFromAsset(Context context, String strName) {
        AssetManager assetManager = context.getAssets();

        InputStream istr;//from  w  ww . ja va  2 s . co  m
        Bitmap bitmap = null;
        try {
            istr = assetManager.open(strName);
            bitmap = BitmapFactory.decodeStream(istr);
        } catch (IOException e) {
            return null;
        }

        return bitmap;
    }
}

Related

  1. download(String url, String fileName)
  2. fetchImage(final Context context, final String url, final BitmapFactory.Options decodeOptions, final Object cookie, final OnFetchCompleteListener callback)
  3. fetchImage(final Context context, final String url, final OnFetchCompleteListener callback)
  4. getBitmap(Resources resources, int resourceId)
  5. getBitmap(String url, Context context, String newPicName)
  6. getBitmapFromFile(File file)
  7. getBitmapFromFile(String filePath)
  8. getBitmapFromFileInputStream(FileInputStream is)
  9. getBitmapFromRes(Context context, int resId)