List of utility methods to do Bitmap Create
Drawable | GetUrlDrawable(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, ... |
Bitmap | create2DBitmap(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); ... |
Bitmap | decodeFromBytes(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; ... |
Bitmap | decodeFromResource(Resources res, int resId) decode From Resource return BitmapFactory.decodeResource(res, resId);
|
Bitmap | decodeFromResource(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); |
Bitmap | decodeSampledBitmapFromFile(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); ... |
Bitmap | decodeSampledBitmapFromResource(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); |
Bitmap | decodeSampledBitmapFromResource(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); |
Bitmap | getBitmap(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(); ... |
Bitmap | getImage(String absPath) get Image Bitmap bitmap = BitmapFactory.decodeFile(absPath);
return bitmap;
|