List of utility methods to do Bitmap Load
Bitmap | downSampleBitmap(Uri uri, Activity act, Boolean needRotate) down Sample Bitmap DisplayMetrics displaymetrics = new DisplayMetrics(); act.getWindowManager().getDefaultDisplay() .getMetrics(displaymetrics); Resources r = act.getResources(); int px = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 50, r.getDisplayMetrics()); int targetWidth = displaymetrics.heightPixels; int targetHeight = displaymetrics.widthPixels - px; ... |
Bitmap | getBitmap(Context context, int resId) get Bitmap BitmapDrawable drawable = (BitmapDrawable) context.getResources()
.getDrawable(resId);
return drawable.getBitmap();
|
Bitmap | getBitmap(String photoId) This method used to get Bitmap From photo id. final Cursor photo = mSmartAndroidActivity.managedQuery( Data.CONTENT_URI, new String[] { Photo.PHOTO }, Data._ID + "=?", new String[] { photoId }, null); final Bitmap photoBitmap; if (photo.moveToFirst()) { byte[] photoBlob = photo.getBlob(photo .getColumnIndex(Photo.PHOTO)); photoBitmap = BitmapFactory.decodeByteArray(photoBlob, 0, ... |
Bitmap | getBitmapFromAsset(String strName, Context context) get Bitmap From Asset try { 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(); ... |
Bitmap | getBitmapFromInternet(String strName) get Bitmap From Internet try { URL url = new URL(strName); HttpURLConnection connection = (HttpURLConnection) url .openConnection(); connection.setDoInput(true); connection.connect(); InputStream input = connection.getInputStream(); Bitmap myBitmap = BitmapFactory.decodeStream(input); ... |
Bitmap | getBitmapFromUri(Context ctxt, Uri selectedImageURI) get Bitmap From Uri try { InputStream is = ctxt.getContentResolver().openInputStream( selectedImageURI); is = ctxt.getContentResolver() .openInputStream(selectedImageURI); Bitmap bitmap = BitmapFactory.decodeStream(is); return bitmap; } catch (FileNotFoundException e) { ... |
Bitmap | getBitmapFromUrl(String url) get Bitmap From Url byte[] bytes = getBytesFromUrl(url); return byteToBitmap(bytes); |
Bitmap | loadBitmapFromFile(String fileNameWithPath) load Bitmap From File Bitmap bitmap = BitmapFactory.decodeFile(fileNameWithPath);
return bitmap;
|
Bitmap | downloadBitmap(URI uri) download Bitmap try { URLConnection connection = uri.toURL().openConnection(); connection.connect(); InputStream is = connection.getInputStream(); BufferedInputStream bis = new BufferedInputStream(is, 8 * 1024); Bitmap bmp = BitmapFactory.decodeStream(bis); bis.close(); is.close(); ... |
Bitmap | returnBitMap(String path) return Bit Map URL url = null;
Bitmap bitmap = null;
url = new URL(path);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitmap = BitmapFactory.decodeStream(is);
...
|