Android Bitmap Load loadBitmapAsset(Context context, String asset)

Here you can find the source of loadBitmapAsset(Context context, String asset)

Description

load Bitmap Asset

License

Open Source License

Declaration

public static Bitmap loadBitmapAsset(Context context, String asset) 

Method Source Code

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

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import java.io.IOException;
import java.io.InputStream;

public class Main {
    private static final String TAG = "FeedMe";

    public static Bitmap loadBitmapAsset(Context context, String asset) {
        InputStream is = null;/*  ww  w.  j av a  2s .co  m*/
        Bitmap bitmap = null;
        try {
            is = context.getAssets().open(asset);
            if (is != null) {
                bitmap = BitmapFactory.decodeStream(is);
            }
        } catch (IOException e) {
            Log.e(TAG, e.toString());
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (IOException e) {
                    Log.e(TAG, "Cannot close InputStream: ", e);
                }
            }
        }
        return bitmap;
    }
}

Related

  1. loadBitmap(InputStream is)
  2. loadBitmap(String bitmapUrl, ImageView imageView, int reqWidth, int reqHeight)
  3. loadBitmap(String url)
  4. loadBitmap(String url)
  5. loadBitmap(String url)
  6. loadBitmapFromAssets(Context context, String name)
  7. loadBitmapFromStorage(String path)
  8. loadImage(String filename)
  9. loadImage(String urlStr)