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

BitmapGetBitmap(String imageUrl)
Get Bitmap
Bitmap mBitmap = null;
try {
    URL url = new URL(imageUrl);
    URLConnection conn = url.openConnection();
    InputStream is = conn.getInputStream();
    mBitmap = BitmapFactory.decodeStream(is);
} catch (MalformedURLException e) {
    e.printStackTrace();
...
Bitmapbase642Bitmap(String string)
base Bitmap
Bitmap bitmap = null;
try {
    byte[] bitmapArray;
    bitmapArray = Base64.decode(string, Base64.DEFAULT);
    bitmap = BitmapFactory.decodeByteArray(bitmapArray, 0,
            bitmapArray.length);
} catch (Exception e) {
    e.printStackTrace();
...
BitmapdecodeBitmap(Resources res, int resId)
decode Bitmap
return BitmapFactory.decodeResource(res, resId);
BitmapdecodeBitmap(Resources res, int resId, int reqWidth, int reqHeight)
decode Bitmap
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(res, resId, options);
options.inSampleSize = calculateInSampleSize(options, reqWidth,
        reqHeight);
options.inJustDecodeBounds = false;
return BitmapFactory.decodeResource(res, resId, options);
BitmapdecodeFromFile(String path)
decode From File
return decodeFromFile(path, 0, 0);
BitmapdecodeFromFile(String path, int reqWidth, int reqHeight)
decode From File
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, options);
options.inSampleSize = inSampleSize(options, reqWidth, reqHeight);
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(path, options);
BitmapdecodeSampledBitmapFileForSize(File f, int reqWidth, int reqHeight)
decode Sampled Bitmap File For Size
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(f.getPath(), options);
options.inSampleSize = calculateInSampleSize(options, reqWidth,
        reqHeight);
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(f.getPath(), options);
BitmapdecodeSampledBitmapFromBytes(byte[] res, int reqWidth, int reqHeight)
decode Sampled Bitmap From Bytes
if (reqWidth > MAX_WIDTH)
    reqWidth = MAX_WIDTH;
if (reqHeight > MAX_HEIGHT)
    reqHeight = MAX_HEIGHT;
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
options.inPurgeable = true;
options.inInputShareable = true;
...
BitmapdecodeSampledBitmapFromBytesForCurrentScreen( byte[] res, Context ctxt)
decode Sampled Bitmap From Bytes For Current Screen
Display display = DisplayUtils.getScreenDisplay(ctxt);
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
return decodeSampledBitmapFromBytes(res, width, height);
BitmapdecodeSampledBitmapFromResource(Resources res, int resId, int reqWidth, int reqHeight)
decode Sampled Bitmap From Resource
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(res, resId, options);
options.inSampleSize = calculateInSampleSize(options, reqWidth,
        reqHeight);
options.inJustDecodeBounds = false;
return BitmapFactory.decodeResource(res, resId, options);