List of usage examples for android.view View getDrawingCache
@Deprecated
public Bitmap getDrawingCache()
Calling this method is equivalent to calling getDrawingCache(false)
.
From source file:Main.java
public static Bitmap getViewBitmap(View view) { view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); view.buildDrawingCache();/*from ww w . j a v a 2s.c om*/ Bitmap bitmap = view.getDrawingCache(); return bitmap; }
From source file:com.hellofyc.base.util.ViewUtils.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) static void blur(Context context, View view) { view.buildDrawingCache();// ww w . ja va2 s. c o m Bitmap srcBitmap = view.getDrawingCache(); float radius = 20f; Bitmap overlay = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(overlay); canvas.translate(-view.getLeft(), -view.getTop()); canvas.drawBitmap(srcBitmap, 0, 0, null); RenderScript script = RenderScript.create(context); Allocation allocation = Allocation.createFromBitmap(script, overlay); ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.create(script, allocation.getElement()); blur.setInput(allocation); blur.setRadius(radius); blur.forEach(allocation); allocation.copyTo(overlay); view.setBackground(new BitmapDrawable(context.getResources(), overlay)); script.destroy(); }
From source file:Main.java
public static Bitmap convertViewToBitmap(View view) { view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); view.buildDrawingCache();/*from ww w . jav a2s . c o m*/ return view.getDrawingCache(); }
From source file:Main.java
public static Bitmap convertViewToBitmap(View view) { view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); // view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); view.buildDrawingCache();//from www. j a v a 2 s . co m Bitmap bitmap = view.getDrawingCache(); return bitmap; }
From source file:Main.java
public static Bitmap CreateBitmap(View v) { if (v == null) { Log.e(TAG, "View is null. Cannot create bitmap"); return null; }//www. ja v a 2 s.c o m v.setDrawingCacheEnabled(true); v.buildDrawingCache(); Bitmap bitmap = null; try { bitmap = Bitmap.createBitmap(v.getDrawingCache()); } catch (Exception e) { Log.e(TAG, "Unable to create bitmap"); } v.destroyDrawingCache(); v.setDrawingCacheEnabled(false); return bitmap; }
From source file:Main.java
public static Bitmap convertViewToBitmap(View v) { v.setDrawingCacheEnabled(true);//from w w w .ja v a 2 s . c om v.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight()); v.buildDrawingCache(true); Bitmap b = Bitmap.createBitmap(v.getDrawingCache()); v.setDrawingCacheEnabled(false); // clear drawing cache return b; }
From source file:fr.free.nrw.commons.Utils.java
/** * To take screenshot of the screen and return it in Bitmap format * * @param view//w w w .ja va2 s . co m * @return */ public static Bitmap getScreenShot(View view) { View screenView = view.getRootView(); screenView.setDrawingCacheEnabled(true); Bitmap bitmap = Bitmap.createBitmap(screenView.getDrawingCache()); screenView.setDrawingCacheEnabled(false); return bitmap; }
From source file:Main.java
public static Bitmap getViewBitmap(View view) { view.setDrawingCacheEnabled(true);/* ww w.j ava 2s .c o m*/ view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); view.buildDrawingCache(true); Bitmap bm = Bitmap.createBitmap(view.getDrawingCache()); view.setDrawingCacheEnabled(false); return bm; }
From source file:Main.java
public static Bitmap takeScreenshot(Activity activity, View view) { view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); view.setDrawingCacheEnabled(true);/*from w w w. ja v a 2 s. c o m*/ final Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache()); view.setDrawingCacheEnabled(false); return saveBitmapToFile(activity, bitmap); }
From source file:com.bobomee.android.common.util.ScreenUtil.java
/** * shot the current screen ,with the status but the status is trans * * * @param ctx current activity//from w ww . j a va 2 s.c o m */ public static Bitmap shotActivity(Activity ctx) { View view = ctx.getWindow().getDecorView(); view.setDrawingCacheEnabled(true); view.buildDrawingCache(); Bitmap bp = Bitmap.createBitmap(view.getDrawingCache(), 0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); view.setDrawingCacheEnabled(false); view.destroyDrawingCache(); return bp; }