Android Bitmap Load getBitmapFromAsset(String strName, Context context)

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

Description

get Bitmap From Asset

Declaration

public static Bitmap getBitmapFromAsset(String strName, Context context) 

Method Source Code

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

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

public class Main {
    public static Bitmap getBitmapFromAsset(String strName, Context context) {
        try {/*  w w  w  .  j  a v  a 2  s  . co  m*/
            AssetManager assetManager = context.getAssets();
            InputStream inputStream = assetManager.open(strName);
            return BitmapFactory.decodeStream(inputStream);
        } catch (IOException e) {
            Toast.makeText(context, "Error in filepath", Toast.LENGTH_SHORT)
                    .show();
            e.printStackTrace();
        }

        return null;
    }
}

Related

  1. downloadImageToSd(String urlSource, String pathDest, String referer)
  2. getResizedBitmap(Uri imageUri, Activity activity)
  3. downSampleBitmap(Uri uri, Activity act, Boolean needRotate)
  4. getBitmap(Context context, int resId)
  5. getBitmap(String photoId)
  6. getBitmapFromInternet(String strName)
  7. getBitmapFromUri(Context ctxt, Uri selectedImageURI)
  8. getBitmapFromUrl(String url)
  9. loadBitmapFromFile(String fileNameWithPath)