Android Utililty Methods Bitmap Create

List of utility methods to do Bitmap Create

Description

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

Method

DrawableGetUrlDrawable(String url)
Get Url Drawable
try {
    URL aryURI = new URL(url);
    URLConnection conn = aryURI.openConnection();
    InputStream is = conn.getInputStream();
    Bitmap bmp = BitmapFactory.decodeStream(is);
    return new BitmapDrawable(bmp);
} catch (Exception e) {
    Log.e("ERROR", "urlImage2Drawable????????????imageUrl??" + url,
...
Bitmapcreate2DBitmap(Bitmap bitmap)
create D Bitmap
int width = bitmap.getWidth();
int height = bitmap.getHeight();
float scaleWidth = 2f;
float scaleHeight = 1f;
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
Bitmap leftBitmap = Bitmap.createBitmap(bitmap, 0, 0, width / 2,
        height, matrix, true);
...
BitmapdecodeFromBytes(byte[] bs, int reqWidth, int reqHeight)
decode From Bytes
if (null == bs) {
    return null;
BitmapFactory.Options decodeOptions = new BitmapFactory.Options();
Bitmap bitmap = null;
decodeOptions.inJustDecodeBounds = true;
BitmapFactory.decodeByteArray(bs, 0, bs.length, decodeOptions);
int actualWidth = decodeOptions.outWidth;
...
BitmapdecodeFromResource(Resources res, int resId)
decode From Resource
return BitmapFactory.decodeResource(res, resId);
BitmapdecodeFromResource(Resources res, int resId, int reqWidth, int reqHeight)
decode From Resource
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(res, resId, options);
options.inSampleSize = inSampleSize(options, reqWidth, reqHeight);
options.inJustDecodeBounds = false;
return BitmapFactory.decodeResource(res, resId, options);
BitmapdecodeSampledBitmapFromFile(String filePath, int reqWidth, int reqHeight)
decode Sampled Bitmap From File
if (TextUtils.isEmpty(filePath)) {
    return null;
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
options.inPurgeable = true;
options.inInputShareable = true;
BitmapFactory.decodeFile(filePath, options);
...
BitmapdecodeSampledBitmapFromResource(Resources res, int id, int reqWidth, int reqHeight)
decode Sampled Bitmap From Resource
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(res, id, options);
options.inSampleSize = calculateInSampleSize(options, reqWidth,
        reqHeight);
options.inJustDecodeBounds = false;
return BitmapFactory.decodeResource(res, id, options);
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);
BitmapgetBitmap(Context context, InputStream inputStream)
Gets the bitmap.
File cacheDir;
if (android.os.Environment.getExternalStorageState().equals(
        android.os.Environment.MEDIA_MOUNTED))
    cacheDir = new File(
            android.os.Environment.getExternalStorageDirectory(),
            "Zoolook");
else
    cacheDir = context.getCacheDir();
...
BitmapgetImage(String absPath)
get Image
Bitmap bitmap = BitmapFactory.decodeFile(absPath);
return bitmap;