List of usage examples for android.widget ImageView getDrawingCache
@Deprecated
public Bitmap getDrawingCache()
Calling this method is equivalent to calling getDrawingCache(false)
.
From source file:Main.java
public static Bitmap imageView2Bitmap(ImageView view) { Bitmap bitmap = null;// www .j a va2 s . c om try { bitmap = Bitmap.createBitmap(view.getDrawingCache()); view.setDrawingCacheEnabled(false); } catch (Exception e) { e.printStackTrace(); } return bitmap; }
From source file:com.onlyapps.sample.DetailActivity.java
public static void startActivity(Activity activity, View view, String imageUrl, int position) { Intent intent = new Intent(activity, DetailActivity.class); intent.putExtra(DetailActivity.EXTRA_PARAM_IMAGEURL, imageUrl); intent.putExtra(DetailActivity.EXTRA_PARAM_POSITION, position); ImageView image = (ImageView) view.findViewById(R.id.image); image.setDrawingCacheEnabled(true);//from w ww .j a v a 2s.c o m Bitmap bitmap = image.getDrawingCache(); ActivityOptionsCompat options = ActivityOptionsCompat.makeThumbnailScaleUpAnimation(view, bitmap, 0, 0); ActivityCompat.startActivity(activity, intent, options.toBundle()); image.setDrawingCacheEnabled(false); }
From source file:mp.paschalis.LoginFragment.java
/** * Update the login View//from w w w. j a v a 2s. c om * * @param code the Library code */ public void updateLoginView(Library lib) { try { ((StartActivity) getSherlockActivity()).isLibrarySelected = true; // Invalidate the menu, so a new one will be created ((StartActivity) getSherlockActivity()).invalidateOptionsMenu(); TextView loginLibrary = (TextView) getSherlockActivity().findViewById(R.id.TextViewLoginLibraryName); loginLibrary.setText(lib.name); textViewLibraryLocation = (TextView) getSherlockActivity() .findViewById(R.id.textViewLoginLibraryLocation); textViewLibraryLocation.setText(lib.location); ImageView loginLogo = (ImageView) getSherlockActivity().findViewById(R.id.imageViewLoginLibraryLogo); // Show logo ImageLoader.DataClassDisplayBookCover bk = new ImageLoader.DataClassDisplayBookCover(); bk.iv = loginLogo; App.imageLoader.DisplayImage(lib.getImageURL(), bk); // Save bitmap in app loginLogo.buildDrawingCache(); // Save Library logo as drawable in app app.loginLogoDrawable = new BitmapDrawable(getResources(), loginLogo.getDrawingCache()); enableLoginForm(); tryToAutofillWithPrefs(); } catch (NullPointerException npe) { // noth } }
From source file:baizhuan.hangzhou.com.gankcopy.view.customview.photoview.PhotoViewAttacher.java
public Bitmap getVisibleRectangleBitmap() { ImageView imageView = getImageView(); return imageView == null ? null : imageView.getDrawingCache(); }
From source file:fm.jihua.weixinexplorer.cache.ImageWorker.java
/** * Load an image specified by the data parameter into an ImageView (override * {@link ImageWorker#processBitmap(Object)} to define the processing logic). A memory and disk * cache will be used if an {@link ImageCache} has been set using * {@link ImageWorker#setImageCache(ImageCache)}. If the image is found in the memory cache, it * is set immediately, otherwise an {@link AsyncTask} will be created to asynchronously load the * bitmap./*from w ww. jav a 2 s .c om*/ * * @param data The URL of the image to download. * @param imageView The ImageView to bind the downloaded image to. */ public void loadImage(Object data, ImageView imageView) { if (data == null) { return; } Bitmap bitmap = null; if (mImageCache != null) { bitmap = mImageCache.getBitmapFromMemCache(String.valueOf(data)); } if (bitmap != null) { // Bitmap found in memory cache if (mCornerBitmap) { imageView.setImageBitmap(ImageHlp.getRoundedCornerBitmap(bitmap, 28)); } else { imageView.setImageBitmap(bitmap); } } else if (cancelPotentialWork(data, imageView)) { final BitmapWorkerTask task = new BitmapWorkerTask(imageView); final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task); imageView.setImageDrawable(asyncDrawable); if (mCornerBitmap) { Bitmap bmp = imageView.getDrawingCache(); if (bmp != null) { imageView.setImageBitmap(ImageHlp.getRoundedCornerBitmap(bmp, 28)); } else { Log.w("ImageWorker", "bmp is null"); } } // NOTE: This uses a custom version of AsyncTask that has been pulled from the // framework and slightly modified. Refer to the docs at the top of the class // for more info on what was changed. task.executeOnExecutor(AsyncTask.DUAL_THREAD_EXECUTOR, data); } }