Android Utililty Methods Bitmap Load

List of utility methods to do Bitmap Load

Description

The list of methods to do Bitmap Load are organized into topic(s).

Method

BitmapgetBitmapFromFileInputStream(FileInputStream is)
get Bitmap From File Input Stream
if (is == null)
    return null;
Bitmap bitmap = null;
try {
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inPreferredConfig = Config.RGB_565;
    options.inPurgeable = true;
    options.inInputShareable = true;
...
BitmapgetBitmapFromRes(Context context, int resId)
get Bitmap From Res
Bitmap bitmap = null;
try {
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inPreferredConfig = Config.RGB_565;
    options.inPurgeable = true;
    options.inInputShareable = true;
    bitmap = BitmapFactory.decodeResource(context.getResources(),
            resId, options);
...
BitmapgetFromUrl(String url)
Gets the from url.
URL myFileUrl = null;
try {
    myFileUrl = new URL(url);
} catch (MalformedURLException e) {
    e.printStackTrace();
HttpURLConnection conn = (HttpURLConnection) myFileUrl
        .openConnection();
...
BitmapgetImageFromUri(Context ctx, Uri uri, int reqWidth, int reqHeight)
get Image From Uri
InputStream iStream = ctx.getContentResolver().openInputStream(uri);
byte[] inputData = getBytes(iStream);
return decodeSampledBitmapFromBytes(inputData, reqWidth, reqHeight);
booleangetNetBitmap(String strUrl, File file, Context context, File file2)
get Net Bitmap
Log.e(TAG, "getBitmap from net");
Bitmap bitmap = null;
InputStream in = null;
FileOutputStream out = null;
try {
    URL url = new URL(strUrl);
    HttpURLConnection con = (HttpURLConnection) url
            .openConnection();
...
voidloadBitmap(Activity activity, int resId, ImageView imageView, int reqWidth, int reqHeight)
load Bitmap
BitmapFromResourcesTask task = new BitmapFromResourcesTask(
        activity, imageView, reqWidth, reqHeight);
task.execute(resId);
BitmaploadBitmap(Context c, String fileName)
load Bitmap
ParcelFileDescriptor pfd;
try {
    pfd = c.getContentResolver().openFileDescriptor(
            Uri.parse("file://" + fileName), "r");
} catch (IOException ex) {
    return null;
java.io.FileDescriptor fd = pfd.getFileDescriptor();
...
BitmaploadBitmap(Context c, String fileName, int width)
load Bitmap
ParcelFileDescriptor pfd;
try {
    pfd = c.getContentResolver().openFileDescriptor(
            Uri.parse("file://" + fileName), "r");
} catch (IOException ex) {
    return null;
java.io.FileDescriptor fd = pfd.getFileDescriptor();
...
BitmaploadBitmap(Context c, String fileName, int width, boolean sample)
load Bitmap
ParcelFileDescriptor pfd;
try {
    pfd = c.getContentResolver().openFileDescriptor(
            Uri.parse("file://" + fileName), "r");
} catch (IOException ex) {
    return null;
java.io.FileDescriptor fd = pfd.getFileDescriptor();
...
BitmaploadBitmap(InputStream is)
load Bitmap
try {
    if (is != null && is.available() > 0) {
        return BitmapFactory.decodeStream(is);
    } else {
        return null;
} catch (IOException e) {
    return null;
...